<div dir="ltr"><div><div>Also Joel,<br><br></div>If you'd like some documentation on testing for LLVM, you can refer to <a href="http://llvm.org/docs/TestingGuide.html">http://llvm.org/docs/TestingGuide.html</a>.<br><br></div>But of course, David's summary gives you an excellent overview.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 18, 2018 at 5:48 PM, David Chisnall via cfe-dev <span dir="ltr"><<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On 18 Jan 2018, at 15:46, Joel Jacobson via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br>
><br>
> Dear Clang hackers,<br>
><br>
> I'm trying to understand how Clang is tested,<br>
> I've looked at lots of .c and .cpp files in ./test/,<br>
> and I see a lot of "// expected-warning" and "// expected-error" annotations,<br>
> but I don't see any positive tests checking for expected values?<br>
<br>
</span>These are the expected values.  You are looking at Sema checks, which check that the semantic analyser is correctly diagnosing errors in programs.<br>
<span class=""><br>
><br>
> Other compilers such as rustc uses macros such as assert_eq, e.g.:<br>
> #[test]<br>
> fn test_extend_specialization() {<br>
>    let mut a = BinaryHeap::from(vec![-10, 1, 2, 3, 3]);<br>
>    let b = BinaryHeap::from(vec![-20, 5, 43]);<br>
><br>
>    a.extend(b);<br>
><br>
>    assert_eq!(a.into_sorted_vec()<wbr>, [-20, -10, 1, 2, 3, 3, 5, 43]);<br>
> }<br>
<br>
</span>This looks like an executable test (i.e. one where the output of the compiler must be run).  The clang test suite does not contain these, all of the CodeGen tests check that the correct IR is generated, but it’s then up to LLVM to correctly generate code from this.  In LLVM’s test suite, you will find tests that check that the expected assembly is generated from IR and that the expected binary sequences are generated from assembly.<br>
<br>
The advantage of a test suite of this structure is that it can run on any platform (there is no requirement, for example, that the platform that is currently running clang can run code using Windows or DWARF exceptions to test both of those).  The tests are all unit tests and so you can quickly (typically in under 30 seconds) run just the relevant part of the test suite while debugging a new feature.<br>
<br>
The down side is that they are not integration tests and so don’t check that the code is correct, only that it is the same as last time.  The LLVM Nightly Test suite contains a number of executable tests, but these typically take much longer to run and so are run by the CI infrastructure on a variety of different platforms.<br>
<br>
David<br>
<div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-dev</a><br>
</div></div></blockquote></div><br></div>