[PATCH] D29515: [lit] Don't use bash on Windows. Pipeing stdout to Filecheck doesn't work.

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 3 13:50:23 PST 2017


mpividori created this revision.
Herald added a reviewer: modocache.

Hi,
I disable usage of bash for tests on Windows. Instead, lets use the cmd prompt.
When working on tests for libFuzzer on Windows, I found some problems when pipeing stdout to Filecheck. So, there is a problem between bash and Filecheck.

For example, this lit test fails when using bash on Windows:

  CHECK: COVERAGE
  RUN: not LLVMFuzzer-NullDerefTest -print_coverage=1 2>&1 | FileCheck %s

But it works fine when using the command prompt.

If we redirect the stdout to a file and then read that file, it works fine, for example:

  CHECK: COVERAGE
  RUN: not LLVMFuzzer-NullDerefTest -print_coverage=1 2>&1 > sometmpfile
  RUN: cat sometmpfile | FileCheck %s

If we try with tee, like:

  CHECK: COVERAGE
  RUN: not LLVMFuzzer-NullDerefTest -print_coverage=1 2>&1 | tee sometmpfile
  RUN: cat sometmpfile | FileCheck %s

It works fine.

So the problem is when pipeing to Filecheck on bash on Windows.

I can see that FileCheck is using a MemoryBuffer to read stdin.
If I modify the function `getMemoryBufferForStream` in `lib/Support/MemoryBuffer.cpp`  to add a `sleep(1)` before reading, the tests works fine.
So, I guess there is some problem with `read()` returning 0 in an unexpected situation, before reading all the stdin.

Unfortunately I don't have the time to continue debugging to see what is the reason for the problem. So, I disable bash for tests on Windows.

I think this commit makes sense, since bash is not installed by default on Windows, and is not required for lit tests on: http://llvm.org/docs/GettingStartedVS.html#requirements 
We only require Python and GnuWin32. So, I think is preferable to use the same terminal for all tests in all Windows machines, instead of having different situations depending on having bash installed or not.


https://reviews.llvm.org/D29515

Files:
  utils/lit/lit/TestRunner.py


Index: utils/lit/lit/TestRunner.py
===================================================================
--- utils/lit/lit/TestRunner.py
+++ utils/lit/lit/TestRunner.py
@@ -572,7 +572,7 @@
 
 def executeScript(test, litConfig, tmpBase, commands, cwd):
     bashPath = litConfig.getBashPath()
-    isWin32CMDEXE = (litConfig.isWindows and not bashPath)
+    isWin32CMDEXE = litConfig.isWindows
     script = tmpBase + '.script'
     if isWin32CMDEXE:
         script += '.bat'


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29515.87010.patch
Type: text/x-patch
Size: 474 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170203/bde068ca/attachment.bin>


More information about the llvm-commits mailing list