<div dir="ltr">Hi,<div><br></div><div>I'm currently enabling ASan lit tests on Windows.</div><div><br></div><div>One problem I have is that some tests use multiple RUN lines, some of which are cross-platform and others are platform- or compiler-specific.</div>
<div>Is there any magic method to make some of the RUN lines conditional for a specific OS?</div><div><br></div><div>I think one of the goals here is to have as many tests that are actually shared on all the platforms and thus I don't think it's a very good idea to e.g. duplicate tests and have platform-specific RUN lines in them.</div>
<div><br></div><div>Examples to consider are:</div><div>[all located in projects/compiler/rt/test/asan/TestCases/]<br></div><div><div><br></div><div>1) sanity_check_pure_c.c has the following run lines:<br></div><div><div>
// RUN: %clang_asan -O2 %s -o %t</div><div>// RUN: not %run %t 2>&1 | FileCheck %s</div><div>// RUN: %clang_asan -O2 %s -pie -fPIE -o %t<br></div><div>// RUN: not %run %t 2>&1 | FileCheck %s</div></div><div>
<br></div><div>The first two lines are ok to run on any OS.</div><div>The third run line uses "-pie -fPIE" which doesn't apply on Windows.</div><div>Is there any way to disable the third and fourth RUN lines on Windows only?</div>
<div><br></div><div>2) print-stack-trace.cc has the following run lines:</div><div><div>// RUN: %clangxx_asan -O0 %s -o %t && %run %t 2>&1 | FileCheck %s</div><div>// RUN: %clangxx_asan -O3 %s -o %t && %run %t 2>&1 | FileCheck %s</div>
</div><div><br></div><div>The test expectations assume a particular stack trace being printed.</div><div>However, on Windows -O3 enables tail call / inlining optimizations that do not allow us to completely restore the stack trace from debug information (yet?).</div>
<div><br></div><div>3) interface_test.cc has the following run lines:</div><div><div>// RUN: %clang_asan %s -o %t && %run %t</div><div>// RUN: %clang_asan -x c %s -o %t && %run %t</div><div>// RUN: %clang %s -o %t && %run %t</div>
<div>// RUN: %clang -x c %s -o %t && %run %t</div></div><div><br></div><div>the first and third are ok, the second and the fourth assume clang has "-x c" available, which is not true on Windows where we use the clang-cl driver. The equivalent CL/clang-cl option is "/TC".</div>
<div>Options are:</div><div>- Copy the test to interface_test.c</div><div>- Use a macro for "-x c" / "/TC" (sounds like an overkill for just one test?)</div><div>- Conditional RUN line</div><div>...</div>
<div><br></div><div>4) no_asan_gen_globals.c</div><div><div>// RUN: %clang_asan %s -o %t.exe</div><div>// RUN: nm %t.exe | FileCheck %s</div></div><div>-> Could probably use llvm-something.exe instead.</div><div><br></div>
<div>-----</div><div><br></div><div>Given that there's just a handful of problematic lit tests, I kinda think we can actually duplicate the tests a little, but I'd like to avoid that if possible.</div><div><br></div>
<div>Any tips?</div></div><div><br></div><div>--</div><div>Tim</div></div>