1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

619 Commits

Author SHA1 Message Date
Brian Gesiak
da7a577d96 [lit] Fix type error for parallelism groups
Summary:
Whereas rL299560 and rL309071 call `parallelism_groups.items()`, under the
assumption that `parallelism_groups` is a `dict` type, the default
parameter for that attribute is a `list`. Change the default to a
`dict` for type correctness.

This regression in the unit tests would have been caught if the
unit tests were being run continously. It also would have been caught
if the lit project used a Python type checker such as `mypy`.

Test Plan:
As per the instructions in `utils/lit/README.txt`, run the lit unit
test suite:

```
utils/lit/lit.py \
    --path /path/to/your/llvm/build/bin \
    utils/lit/tests
```

Verify that the test `lit :: unit/TestRunner.py` fails before applying this
patch, but passes once this patch is applied.

Reviewers: mgorny, rnk, rafael

Reviewed By: mgorny

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35878

llvm-svn: 309122
2017-07-26 15:02:05 +00:00
Brian Gesiak
a5ba4551fd Revert "[lit] Remove dead code not referenced in the LLVM SVN repo."
Summary:
This reverts rL306623, which removed `FileBasedTest`, an abstract base class,
but did not also remove the usages of that class in the lit unit tests.
The revert fixes four test failures in the lit unit test suite.

Test plan:
As per the instructions in `utils/lit/README.txt`, run the lit unit
test suite:

```
utils/lit/lit.py \
    --path /path/to/your/llvm/build/bin \
    utils/lit/tests
```

Verify that the following tests fail before applying this patch, and
pass once the patch is applied:

```
lit :: test-data.py
lit :: test-output.py
lit :: xunit-output.py
```

In addition, run `check-llvm` to make sure the existing LLVM test suite
executes normally.

Reviewers: george.karpenkov, mgorny, dlj

Reviewed By: mgorny

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35877

llvm-svn: 309120
2017-07-26 14:59:36 +00:00
Reid Kleckner
71abc9a263 [lit] Attempt to fix Python unittest adaptor logic
llvm-svn: 309071
2017-07-26 01:27:18 +00:00
Michal Gorny
7d7ceddd5e [lit] Fix UnboundLocalError for invalid shtest redirects
Replace the incorrect variable reference when invalid redirect is used.
This fixes the following issue:

  File "/usr/src/llvm/utils/lit/lit/TestRunner.py", line 316, in processRedirects
    raise InternalShellError(cmd, "Unsupported redirect: %r" % (r,))
UnboundLocalError: local variable 'r' referenced before assignment

which in turn broke shtest-shell.py and max-failures.py lit tests.

The breakage was introduced during refactoring in rL307310.

Differential Revision: https://reviews.llvm.org/D35857

llvm-svn: 309044
2017-07-25 22:38:31 +00:00
George Karpenkov
800a42cc58 [lit] add a -vv option to echo all executed commands.
Debugging LIT scripts can be rather painful, as LIT directly does not
specify which line has failed.
Rather, FileCheck is expected to report the failing location, but it can
be often ambiguous if multiple commands are tested against the same
prefix.  This change adds a -vv option, which echoes all output.
Then detecting the error becomes straightforward: last printed line is
the failing one.

Of course, it could be desired to try to get failing line number
directly from bash, but it involves excessive hacks on older bash
versions (cf.
https://stackoverflow.com/questions/24398691/how-to-get-the-real-line-number-of-a-failing-bash-command)

Differential Revision: https://reviews.llvm.org/D35330

llvm-svn: 307938
2017-07-13 19:26:27 +00:00
Reid Kleckner
fc7c2b00b4 [lit] Fix import StringIO errors in Python 3
Remove the cStringIO micro-optimization, as it isn't portable to Python
3.

llvm-svn: 307669
2017-07-11 16:12:53 +00:00
Reid Kleckner
188612c241 [lit] Implement non-pipelined echo commands internally
Summary:
This speeds up the LLD test suite on Windows by 3x. Most of the time is
spent on lld/test/ELF/linkerscript/diagnostics.s, which repeatedly
constructs linker scripts with appending echo commands.

Reviewers: dlj, zturner, modocache

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35093

llvm-svn: 307668
2017-07-11 16:05:50 +00:00
George Karpenkov
e55b0ad210 [lit] Modify LIT to accept environment variable LIT_FILTER to select tests.
This is especially useful when lit is invoked indirectly by the build
system, and additional arguments can not be easily specified.

Differential Revision: https://reviews.llvm.org/D35091

llvm-svn: 307339
2017-07-07 00:22:11 +00:00
Reid Kleckner
8b4beffcce [lit] Factor out some shell input/output redirection logic, NFC
This is a very light refactoring aimed at improving readability. There
is definitely still room for improvement here.

llvm-svn: 307310
2017-07-06 20:40:27 +00:00
David L. Jones
19be4da6f7 [lit] Fix unit test discovery for Visual Studio builds.
Fix by Andrew Ng!

The Visual Studio build can contain output for multiple configuration types (
e.g. Debug, Release & RelWithDebInfo) within the same build output
directory. Therefore when discovering unit tests, the "build mode" sub directory
containing the appropriate configuration is included in the search. This sub
directory may not always be present, so a test for its existence is required.

Reviewers: zturner, modocache, dlj

Reviewed By: zturner, dlj

Subscribers: grimar, bd1976llvm, gbreynoo, edd, jhenderson, llvm-commits

Differential Revision: https://reviews.llvm.org/D34976

llvm-svn: 307235
2017-07-06 03:23:18 +00:00
David L. Jones
58f30176a9 [lit] Factor out listdir logic shared by different test formats.
Summary:
The lit test formats use largely the same logic for discovering tests. There are
some superficial differences in the logic, which seem reasonable enough to
handle in a single routine.

At a high level, the common goal is "look for files that end with one of these
suffixes, and skip anything starting with a dot." The balance of the logic
specific to ShTest and GoogleTest collapses quite a bit, so that
getTestsInDirectory is only a couple of lines around a call to the new function.

Reviewers: zturner, MatzeB, modocache

Subscribers: sanjoy, llvm-commits

Differential Revision: https://reviews.llvm.org/D34855

llvm-svn: 306895
2017-06-30 21:58:55 +00:00
Zachary Turner
427bb9febc Revert "[lit] Clean output directories before running tests."
This reverts commit da6318a92fba793e4f2447ec478b001392d57d43.

This is causing failures on some build bots due to what appears
to be some kind of lit ordering dependency.

llvm-svn: 306833
2017-06-30 16:05:03 +00:00
Zachary Turner
8e4d247b07 [lit] Clean output directories before running tests.
Presently lit leaks files in the tests' output directories.
Specifically, if a test creates output files, lit makes no
effort to remove them prior to the next test run.  This is
problematic because it leads to false positives whenever a
test passes because stale  files were present.  In general
it is a source of flakiness that should be removed.

This patch addresses this by building the list of all test
directories that are part of the current run set, and then
deleting those directories and recreating them anew.  This
gives each test a clean baseline to start from.

Differential Revision: https://reviews.llvm.org/D34732

llvm-svn: 306832
2017-06-30 16:01:30 +00:00
David L. Jones
76e6f0f057 [lit] Re-apply: Fix some convoluted logic around Unicode encoding, and de-duplicate across modules that used it.
(Take 2: this patch re-applies r306625, which was reverted in r306629. This
patch includes only trivial fixes.)

In Python2 and Python3, the various (non-)?Unicode string types are sort of
spaghetti. Python2 has unicode support tacked on via the 'unicode' type, which
is distinct from 'str' (which are bytes). Python3 takes the "unicode-everywhere"
approach, with 'str' representing a Unicode string.

Both have a 'bytes' type. In Python3, it is the only way to represent raw bytes.
However, in Python2, 'bytes' is an alias for 'str'. This leads to interesting
problems when an interface requires a precise type, but has to run under both
Python2 and Python3.

The previous logic appeared to be correct in all cases, but went through more
layers of indirection than necessary. This change does the necessary conversions
in one shot, with documentation about which paths might be taken in Python2 or
Python3.

Changes from r306625: some tests just print binary outputs, so in those cases,
fall back to str() in Python3. For googletests, add one missing call to
to_string().

(Tested by verifying the visible breakage with Python3. Verified that everything
works in py2 and py3.)

llvm-svn: 306643
2017-06-29 04:37:35 +00:00
David L. Jones
e3510c2c73 Revert "[lit] Fix some convoluted logic around Unicode encoding, and de-duplicate across modules that used it."
This reverts r306625.

llvm-svn: 306629
2017-06-29 02:22:49 +00:00
David L. Jones
c68b57af3c Fix spelling: uncode -> unicode.
Remember kids: there is no 'I' in str or bytes, but there is ALWAYS an
'I' in unicode.

llvm-svn: 306626
2017-06-29 01:03:56 +00:00
David L. Jones
2147bbfdc6 [lit] Fix some convoluted logic around Unicode encoding, and de-duplicate across modules that used it.
Summary:
In Python2 and Python3, the various (non-)?Unicode string types are sort of
spaghetti. Python2 has unicode support tacked on via the 'unicode' type, which
is distinct from 'str' (which are bytes). Python3 takes the "unicode-everywhere"
approach, with 'str' representing a Unicode string.

Both have a 'bytes' type. In Python3, it is the only way to represent raw bytes.
However, in Python2, 'bytes' is an alias for 'str'. This leads to interesting
problems when an interface requires a precise type, but has to run under both
Python2 and Python3.

The previous logic appeared to be correct in all cases, but went through more
layers of indirection than necessary. This change does the necessary conversions
in one shot, with documentation about which paths might be taken in Python2 or
Python3.

Reviewers: zturner, modocache

Subscribers: llvm-commits, sanjoy

Differential Revision: https://reviews.llvm.org/D34793

llvm-svn: 306625
2017-06-29 01:03:55 +00:00
David L. Jones
56cf7e2d17 [lit] Remove dead code not referenced in the LLVM SVN repo.
Summary:
This change removes the intermediate 'FileBasedTest' format from lit. This
format is only ever used by the ShTest format, so the logic can be moved into
ShTest directly.

In order to better clarify what the TestFormat subclasses do, I fleshed out the
TestFormat base class with Python's notion of abstract methods, using
@abc.abstractmethod. This gives a convenient way to document the expected
interface, without the risk of instantiating an abstract class (that's what
ABCMeta does -- it raises an exception if you try to instantiate a class which
has abstract methods, but not if you instantiate a subclass that implements
them).

Reviewers: zturner, modocache

Subscribers: sanjoy, llvm-commits

Differential Revision: https://reviews.llvm.org/D34792

llvm-svn: 306623
2017-06-29 01:01:03 +00:00
David L. Jones
b366d853fe [lit] Remove dead code (not referenced anywhere), and clarify some function names.
Summary:
The dead code seems to be unreferenced, according to textual search across the
LLVM SVN repo.

The clarification part of this change alters the name of a module-level function
so that it is different from the name of the class-methods that call it.
Currently, there are no erroneous references, but stylistically (c.f. PEP-8),
internal "helper" functions should generally be named accordingly by prepending
an underscore. (I also chose to add '_impl', which isn't necessary, but helps me
at least to mentally disambiguate the interface and implementation functions.)

Reviewers: zturner, modocache

Subscribers: sanjoy, llvm-commits

Differential Revision: https://reviews.llvm.org/D34775

llvm-svn: 306600
2017-06-28 21:14:13 +00:00
Alex Lorenz
9f2c1b5601 [lit][macOS] Add a utility function to find the platform SDK version
on macOS

This function will be used to tie Clang's Integeration tests to a particular
SDK version. See https://reviews.llvm.org/D32178 for more context.

llvm-svn: 304541
2017-06-02 11:21:37 +00:00
Dimitry Andric
a48f1cdc08 Return a lit.Test.Result object from TestRunner's executeShTest()
Summary:
For various clang analyzer tests, which were unsupported, I got lit
exceptions, similar to the following:

    Exception during script execution:
    Traceback (most recent call last):
      File "utils/lit/lit/run.py", line 190, in execute_test
        result = test.config.test_format.execute(test, lit_config)
      File "tools/clang/test/Analysis/analyzer_test.py", line 11, in execute
        if result.code == lit.Test.FAIL:
    AttributeError: 'tuple' object has no attribute 'code'

This is because executeShTest() in utils/lit/lit/TestRunner.py is
supposed to return a lit.Test.Result object, but in case of unsupported
tests, it returns a plain tuple.

Fix this by returning a properly initialized lit.Test.Result object
instead.

Reviewers: rnk, rafael, modocache

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D33579

llvm-svn: 303943
2017-05-25 23:56:44 +00:00
Zachary Turner
59ae1d0687 [lit] Take the last error when executing pipelines.
This seems to have been present since the beginning of time,
which is quite surprising.  The symptom was this: Suppose you
have a test with a run line that looks like this:

  RUN: foo | FileCheck %s

foo prints some output and then due to a bug in the program it
asserts.  On Windows this results in the program returning a
negative exit code.  But if enough output had been printed
already by the tool so that the FileCheck match would succeed
then FileCheck would return 0, and because of bad logic in
lit this 0 return value would overwrite the failed return
value from previous items in the pipeline.  This only happened
with negative exit codes.

The most sensible behavior is to just take whatever the first
exit code is.  There is no logical ordering defined on exit
codes, so comparing with < and > does not make a lot of sense.
Instead, as soon as we find the first non-successful return
value, that should be the result of the entire expression.

This fixes the issue, as now tests which fail on non-Windows
platforms also fail for me on Windows as well.

llvm-svn: 303440
2017-05-19 18:12:07 +00:00
Rafael Espindola
a043b0052c Add back a dummy --use-processes.
Some bots are using it.

llvm-svn: 303282
2017-05-17 18:55:01 +00:00
Rafael Espindola
97629e873b Always use the multiprocess module.
This seems to work on freebsd and openbsd these days.

llvm-svn: 303280
2017-05-17 18:20:01 +00:00
Reid Kleckner
8f7e341867 [lit] Try to exit more cleanly
If all jobs complete successfully, use pool.close() instead of
pool.terminate() before waiting for the workers. Zach Turner reported
that he was getting "access denied" exceptions from pool.terminate().

Make the workers abort immediately without printing to stderr when they
are interrupted.

Finally, catch exceptions when attempting to remove our temporary
testing directory. On abnormal exit, there can often be open handles
that haven't been cleaned up yet.

llvm-svn: 301941
2017-05-02 17:45:16 +00:00
Reid Kleckner
25a9da5485 [lit] Try using process pools by default again
Both pickling errors encountered on clang bots and Darwin compiler-rt
should now be fixed.

This has no impact on testing time on Linux, and on Windows goes from
88s to 63s for 'check'. The tests pass on Mac, but I haven't compared
execution time.

llvm-svn: 299775
2017-04-07 15:28:32 +00:00
Reid Kleckner
5972ba002c [lit] Implement timeouts and max_time for process pool testing
This is necessary to pass the lit test suite at llvm/utils/lit/tests.

There are some pre-existing failures here, but now switching to pools
doesn't regress any tests.

I had to change test-data/lit.cfg to import DummyConfig from a module to
fix pickling problems, but I think it'll be OK if we require test
formats to be written in real .py modules outside lit.cfg files.

I also discovered that in some circumstances AsyncResult.wait() will not
raise KeyboardInterrupt in a timely manner, but you can pass a non-zero
timeout to work around this. This makes threading.Condition.wait use a
polling loop that runs through the interpreter, so it's capable of
asynchronously raising KeyboardInterrupt.

llvm-svn: 299605
2017-04-06 00:38:28 +00:00
Reid Kleckner
75978a9b78 [lit] Revert to old execution strategy while I debug these pickling errors
llvm-svn: 299565
2017-04-05 17:16:37 +00:00
Reid Kleckner
a301eb1973 [lit] Use Python 3 style print to satisfy some bots
llvm-svn: 299564
2017-04-05 17:05:31 +00:00
Reid Kleckner
ffe34e060c [lit] Use process pools for test execution by default
Summary:
This drastically reduces lit test execution startup time on Windows. Our
previous strategy was to manually create one Process per job and manage
the worker pool ourselves. Instead, let's use the worker pool provided
by multiprocessing.  multiprocessing.Pool(jobs) returns almost
immediately, and initializes the appropriate number of workers, so they
can all start executing tests immediately. This avoids the ramp-up
period that the old implementation suffers from.  This appears to speed
up small test runs.

Here are some timings of the llvm-readobj tests on Windows using the
various execution strategies:

 # multiprocessing.Pool:
$ for i in `seq 1 3`; do tim python ./bin/llvm-lit.py -sv ../llvm/test/tools/llvm-readobj/ --use-process-pool |& grep real: ; done
real: 0m1.156s
real: 0m1.078s
real: 0m1.094s

 # multiprocessing.Process:
$ for i in `seq 1 3`; do tim python ./bin/llvm-lit.py -sv ../llvm/test/tools/llvm-readobj/ --use-processes |& grep real: ; done
real: 0m6.062s
real: 0m5.860s
real: 0m5.984s

 # threading.Thread:
$ for i in `seq 1 3`; do tim python ./bin/llvm-lit.py -sv ../llvm/test/tools/llvm-readobj/ --use-threads |& grep real: ; done
real: 0m9.438s
real: 0m10.765s
real: 0m11.079s

I kept the old code to launch processes in case this change doesn't work
on all platforms that LLVM supports, but at some point I would like to
remove both the threading and old multiprocessing execution strategies.

Reviewers: modocache, rafael

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31677

llvm-svn: 299560
2017-04-05 16:44:56 +00:00
Rafael Espindola
7287f2f247 [lit] Add a minimum export implementation.
llvm-svn: 299475
2017-04-04 22:20:18 +00:00
Rafael Espindola
4c46bce1b0 Rename variable.
Requested on post commit code review.

llvm-svn: 299232
2017-03-31 17:11:51 +00:00
Rafael Espindola
8faf0df49e Add a %basename substitution.
This will be used to avoid various call to basename in the asan tests.

llvm-svn: 299216
2017-03-31 13:41:10 +00:00
Rafael Espindola
455a6e04ae Use the current working directory in the glob expansion
This fixes tests that do things like

mkdir <dir>
cd <dir>
..
<cmd> *.foo

llvm-svn: 299209
2017-03-31 12:46:39 +00:00
Rafael Espindola
5e9a87e6cb Use os.path.realpath when tracking the cwd.
This is needed by TestCases/Posix/coverage-direct.cc

The problem is that the test does:

mkdir <dir>
cd <dir>
cd ..
rm -rf <dir>
<more commands>

the current directory currently looks like "/.../<dir>/../" which
doesn't exist when dir is deleted.

at some point we should probably switch to using the os current
directory (specially if we want to add subshell), but this is a small
incremental improvement.

llvm-svn: 299113
2017-03-30 21:05:31 +00:00
Rafael Espindola
ef7588f5bf lit: support redirect from globs
This adds support for commands like

FileCheck < foobar*

which is used by some asan tests because the file they want to read
has a pid in the name.

llvm-svn: 299111
2017-03-30 20:48:58 +00:00
Rafael Espindola
21bf5a962f Remove unused argument.
llvm-svn: 298994
2017-03-29 14:20:38 +00:00
Brian Gesiak
11423548eb lit: remove python2-isms
Summary:
`assert.assertItemEqual` went away in Python 3. Seeing how lists
are ordered, comparing a list against each other should work just
as well.

Patch by @jbergstroem (Johan Bergström).

Reviewers: modocache, gparker42

Reviewed By: modocache

Differential Revision: https://reviews.llvm.org/D31229

llvm-svn: 298479
2017-03-22 04:23:01 +00:00
Zachary Turner
394896e64a Teach lit to expand glob expressions.
This will enable removing hacks throughout the codebase
in clang and compiler-rt that feed multiple inputs to a
testing utility by globbing, all of which are either disabled
on Windows currently or using xargs / find hacks.

Differential Revision: https://reviews.llvm.org/D30380

llvm-svn: 296904
2017-03-03 18:55:24 +00:00
Greg Parker
efc0b2cc29 Reinstate "r292904 - [lit] Allow boolean expressions in REQUIRES and XFAIL
and UNSUPPORTED"

This reverts the revert in r292942.

llvm-svn: 293007
2017-01-25 02:26:03 +00:00
Alex Lorenz
f5445306bb Revert "r292904 - [lit] Allow boolean expressions in REQUIRES and XFAIL
and UNSUPPORTED"

After r292904 llvm-lit fails to emit the test results in the XML format for
Apple's internal buildbots.

rdar://30164800

llvm-svn: 292942
2017-01-24 16:17:04 +00:00
Greg Parker
fb425c96fe [lit] Allow boolean expressions in REQUIRES and XFAIL and UNSUPPORTED
A `lit` condition line is now a comma-separated list of boolean expressions. 
Comma-separated expressions act as if each expression were on its own 
condition line:
For REQUIRES, if every expression is true then the test will run. 
For UNSUPPORTED, if every expression is false then the test will run. 
For XFAIL, if every expression is false then the test is expected to succeed. 
As a special case "XFAIL: *" expects the test to fail.

Examples:
# Test is expected fail on 64-bit Apple simulators and pass everywhere else
XFAIL: x86_64 && apple && !macosx
# Test is unsupported on Windows and on non-Ubuntu Linux 
# and supported everywhere else
UNSUPPORTED: linux && !ubuntu, system-windows

Syntax: 
* '&&', '||', '!', '(', ')'. 'true' is true. 'false' is false.
* Each test feature is a true identifier. 
* Substrings of the target triple are true identifiers for UNSUPPORTED 
 and XFAIL, but not for REQUIRES. (This matches the current behavior.)
* All other identifiers are false.
* Identifiers are [-+=._a-zA-Z0-9]+

Differential Revision: https://reviews.llvm.org/D18185

llvm-svn: 292904
2017-01-24 09:58:02 +00:00
Greg Parker
49f3eceba0 Revert "[lit] Allow boolean expressions in REQUIRES and XFAIL and UNSUPPORTED"
This change needs to be better-coordinated with libc++.

llvm-svn: 292900
2017-01-24 08:58:20 +00:00
Greg Parker
1af70d3db9 [lit] Allow boolean expressions in REQUIRES and XFAIL and UNSUPPORTED
A `lit` condition line is now a comma-separated list of boolean expressions. 
Comma-separated expressions act as if each expression were on its own 
condition line:
For REQUIRES, if every expression is true then the test will run. 
For UNSUPPORTED, if every expression is false then the test will run. 
For XFAIL, if every expression is false then the test is expected to succeed. 
As a special case "XFAIL: *" expects the test to fail.

Examples:
# Test is expected fail on 64-bit Apple simulators and pass everywhere else
XFAIL: x86_64 && apple && !macosx
# Test is unsupported on Windows and on non-Ubuntu Linux 
# and supported everywhere else
UNSUPPORTED: linux && !ubuntu, system-windows

Syntax: 
* '&&', '||', '!', '(', ')'. 'true' is true. 'false' is false.
* Each test feature is a true identifier. 
* Substrings of the target triple are true identifiers for UNSUPPORTED 
  and XFAIL, but not for REQUIRES. (This matches the current behavior.)
* All other identifiers are false.
* Identifiers are [-+=._a-zA-Z0-9]+

Differential Revision: https://reviews.llvm.org/D18185

llvm-svn: 292896
2017-01-24 08:45:50 +00:00
Kuba Mracek
8d57ff60d8 [lit] Limit parallelism of sanitizer tests on Darwin [llvm part, take 2]
Running lit tests and unit tests of ASan and TSan on macOS has very bad performance when running with a high number of threads. This is caused by xnu (the macOS kernel), which currently doesn't handle mapping and unmapping of sanitizer shadow regions (reserved VM which are several terabytes large) very well. The situation is so bad that increasing the number of threads actually makes the total testing time larger. The macOS buildbots are affected by this. Note that we can't easily limit the number of sanitizer testing threads without affecting the rest of the tests.

This patch adds a special "group" into lit, and limits the number of concurrently running tests in this group. This helps solve the contention problem, while still allowing other tests to run in full, that means running lit with -j8 will still with 8 threads, and parallelism is only limited in sanitizer tests.

Differential Revision: https://reviews.llvm.org/D28420

llvm-svn: 292548
2017-01-20 00:24:32 +00:00
Graydon Hoare
88cd0769ca [lit] Support sharding testsuites, for parallel execution.
Summary:
This change equips lit.py with two new options, --num-shards=M and
--run-shard=N (set by default from env vars LIT_NUM_SHARDS and LIT_RUN_SHARD).

The options must be used together, and N must be in 1..M.

Together these options effect only test selection: they partition the testsuite
into M equal-sized "shards", then select only the Nth shard. They can be used
in a cluster of test machines to achieve a very crude (static) form of
parallelism, with minimal configuration work.

Reviewers: modocache, ddunbar

Reviewed By: ddunbar

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D28789

llvm-svn: 292417
2017-01-18 18:12:20 +00:00
Eric Fiselier
0501333e13 [LIT] Make util.executeCommand python3 friendly
Summary: The parameter `input` to `subprocess.Popen.communicate(...)` must be an object of type `bytes` . This is strictly enforced in python3. This patch (1) allows `to_bytes` to be safely called redundantly. (2) Explicitly convert `input` within `executeCommand`. This allows for usages like `executeCommand(['clang++', '-'], input='int main() {}\n')`.

Reviewers: ddunbar, BinaryKhaos, modocache, dim, EricWF

Reviewed By: EricWF

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D28736

llvm-svn: 292308
2017-01-18 00:12:41 +00:00
Kuba Mracek
61d1462f99 Revert r292231.
llvm-svn: 292237
2017-01-17 18:06:38 +00:00
Kuba Mracek
dc0f3e6b67 [lit] Limit parallelism of sanitizer tests on Darwin [llvm part]
Running lit tests and unit tests of ASan and TSan on macOS has very bad performance when running with a high number of threads. This is caused by xnu (the macOS kernel), which currently doesn't handle mapping and unmapping of sanitizer shadow regions (reserved VM which are several terabytes large) very well. The situation is so bad that increasing the number of threads actually makes the total testing time larger. The macOS buildbots are affected by this. Note that we can't easily limit the number of sanitizer testing threads without affecting the rest of the tests.

This patch adds a special "group" into lit, and limits the number of concurrently running tests in this group. This helps solve the contention problem, while still allowing other tests to run in full, that means running lit with -j8 will still with 8 threads, and parallelism is only limited in sanitizer tests.

Differential Revision: https://reviews.llvm.org/D28420

llvm-svn: 292231
2017-01-17 17:15:02 +00:00
Chandler Carruth
43eb155cf2 [gtest] Upgrade googletest to version 1.8.0, minimizing local changes.
This required re-working the streaming support and lit's support for
'--gtest_list_tests' but otherwise seems to be a clean upgrade.

Differential Revision: https://reviews.llvm.org/D28154

llvm-svn: 291029
2017-01-04 23:06:03 +00:00
Dylan McKay
03951f17f5 [AVR] Whitelist the avrlit config environment variables
This allows us to use `lit` to run on-target execution tests.

llvm-svn: 289769
2016-12-15 06:04:53 +00:00
Renato Golin
8d9c51307d Revert "[AVR] Add the very first on-target test"
This reverts commit r289648, as it's an execution test and relies on the
emulator/dispatcher being available on all builders.

llvm-svn: 289651
2016-12-14 13:24:20 +00:00
Dylan McKay
ebd67f8b91 [AVR] Add the very first on-target test
This test runs on actual AVR hardware.

llvm-svn: 289648
2016-12-14 12:03:39 +00:00
Eric Fiselier
9d535a8342 [lit] Support custom parsers in parseIntegratedTestScript
Summary:
Libc++ frequently has the need to parse more than just the builtin *test keywords* (`RUN`, `REQUIRES`, `XFAIL`, ect). For example libc++ currently needs a new keyword `MODULES-DEFINES: macro list...`. Instead of re-implementing the script parsing in libc++ this patch allows `parseIntegratedTestScript` to take custom parsers.

This patch introduces a new class `IntegratedTestKeywordParser` which implements the logic to parse/process a test keyword. Parsing of various keyword "kinds" are supported out of the box, including 'TAG', 'COMMAND', and 'LIST', which parse keywords such as `END.`, `RUN:` and `XFAIL:` respectively.

As an example after this change libc++ can implement the `MODULES-DEFINES` simply using: 
```
mparser = IntegratedTestKeywordParser('MODULES-DEFINES:', ParserKind.LIST)
parseIntegratedTestScript(test, additional_parsers=[mparser])
macro_list = mparser.getValue()
```


Reviewers: ddunbar, modocache, rnk, danalbert, jroelofs

Subscribers: mgrang, llvm-commits, cfe-commits

Differential Revision: https://reviews.llvm.org/D27005

llvm-svn: 288694
2016-12-05 20:21:21 +00:00
Kuba Mracek
57a1014fb2 Recommit r287403 (reverted in r287804): [lit] When setting SDKROOT on Darwin, use '--sdk macosx' to find the right SDK path.
This shouls now be safe and not break any more bots.  It's strictly better to use '--sdk macosx', otherwise xcrun can return weird things for example when you have Command Line Tools or the SDK installed into '/'.

llvm-svn: 288385
2016-12-01 17:45:22 +00:00
Vedant Kumar
8cd1c5209c Revert "[lit] When setting SDKROOT on Darwin, use '--sdk macosx' to find the right SDK path."
This reverts commit r287403. It breaks an internal asan bot. According
to Kuba, a fix is up for review here: https://reviews.llvm.org/D26929

llvm-svn: 287804
2016-11-23 20:51:09 +00:00
Kuba Mracek
d9a5ffbbe0 [lit] When setting SDKROOT on Darwin, use '--sdk macosx' to find the right SDK path.
This will make sure that we find an actual path in case you have Command Line Tools installed.

llvm-svn: 287403
2016-11-18 23:25:57 +00:00
Reid Kleckner
24254f0cd7 [lit] Print negative exit codes on Windows in hex
Negative exit codes are usually exceptions. They're easier to recognize
in hex. Compare -1073741502 to 0xc0000142.

llvm-svn: 286150
2016-11-07 21:06:20 +00:00
Brian Gesiak
fd11f97abb [lit] Remove TODO
Summary:
Instead of keeping track of TODOs for lit in a file checked into source
control, use LLVM's bug tracker. The TODOs have been migrated to the
following bugs:

* https://llvm.org/bugs/show_bug.cgi?id=30666
* https://llvm.org/bugs/show_bug.cgi?id=30667
* https://llvm.org/bugs/show_bug.cgi?id=30668
* https://llvm.org/bugs/show_bug.cgi?id=30669
* https://llvm.org/bugs/show_bug.cgi?id=30670
* https://llvm.org/bugs/show_bug.cgi?id=30671

Reviewers: ddunbar, beanz, echristo, delcypher

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25496

llvm-svn: 285973
2016-11-03 23:41:49 +00:00
Reid Kleckner
7dfe7f827f [lit] Work around Windows MSys command line tokenization bug
Summary:
This will allow us to revert LLD r284768, which added spaces to get MSys
echo to print what we want.

Reviewers: ruiu, inglorion, rafael

Subscribers: modocache, llvm-commits

Differential Revision: https://reviews.llvm.org/D26009

llvm-svn: 285237
2016-10-26 20:29:27 +00:00
Brian Gesiak
e8d7fa30fe [lit] Add more testing instructions to README
Summary:
r283710 introduced two regressions, one to llvm-lit, and the other to
lit executables that were installed via setuptools. Add instructions on
how to test for these regressions in the future.

Reviewers: ddunbar, delcypher, beanz, chapuni, cmatthews, echristo

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25459

llvm-svn: 284919
2016-10-22 17:27:31 +00:00
Michal Gorny
7a8aed281b [lit] Fix test shtest-timeout.py for modern output
Update the CHECK lines in the shtest-timeout.py lit test to account for
the current output. The output has been changed in r271610 without
adjusting the tests.

Differential Revision: https://reviews.llvm.org/D25236

llvm-svn: 284057
2016-10-12 21:40:08 +00:00
Michal Gorny
6a0d340d17 [lit] Fix FormatError on individual test timeout
Differential Revision: https://reviews.llvm.org/D25195

llvm-svn: 284056
2016-10-12 21:40:04 +00:00
Brian Gesiak
eab338b7d5 [lit] Run unit tests as part of lit test suite
Summary:
The Python file `utils/lit/lit/ShUtil.py` contains:

1. Logic used by lit itself
2. A set of unit tests for that logic, which can be run by invoking
  `python utils/lit/lit/ShUtil.py`

Move these unit tests to a `tests/unit` subdirectory of lit, and run
the tests as part of lit's test suite. This ensures that, should the
lit test suite be included in LLVM's own regression test suite, these
unit tests will also be run.

(Instructions on how to run lit's test suite can be found in
`utils/lit/README.txt`.)

Reviewers: ddunbar, echristo, delcypher, beanz

Subscribers: mehdi_amini, llvm-commits

Differential Revision: https://reviews.llvm.org/D25411

llvm-svn: 283968
2016-10-12 03:35:04 +00:00
Chris Matthews
2fa8e84ed6 Fix issue which cases lit installed with setup.py to not resolve main
llvm-svn: 283818
2016-10-10 23:22:11 +00:00
Brian Gesiak
c06864a754 [lit] Remove (or allow specific) unused imports
Summary:
Using Python linter flake8 on the utils/lit reveals several linter
warnings designated "F401: Unused import". Fix or silence these
warnings.

Some of these unused imports are legitimate, while some are part of lit's API.
For example, users of lit expect to be able to access `lit.formats.ShTest` in
their `lit.cfg`, despite the module hierarchy for that symbol actually being
`lit.formats.shtest.ShTest`. To silence linter errors for these lines,
include a "noqa" directive.

Reviewers: echristo, delcypher, beanz, ddunbar

Subscribers: mehdi_amini, llvm-commits

Differential Revision: https://reviews.llvm.org/D25407

llvm-svn: 283710
2016-10-10 01:22:06 +00:00
Brian Gesiak
beb38d584e [lit] Remove unused TestingProgressDisplay attr
Summary:
`TestingProgressDisplay` initializes its `current` attribute to `None`, but
never reads or writes the value again. Remove it.

Reviewers: echristo, delcypher, beanz, ddunbar

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25415

llvm-svn: 283709
2016-10-10 01:20:43 +00:00
Brian Gesiak
8421c838ab [lit] Fix undefined symbol ArgumentError
Summary:
`ArgumentError` is not defined by the Python standard library.
Executing this line of code would throw a exception, but not the
intended one. It would throw a `NameError` exception, since `ArgumentError`
is undefined.

Use `ValueError` instead, which is defined by the Python standard
library.

Reviewers: echristo, delcypher, beanz, ddunbar

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25410

llvm-svn: 283708
2016-10-10 01:19:27 +00:00
Brian Gesiak
eb592dbc2b [lit] Remove semicolons in Python code
Summary:
Semicolons aren't necessary as statement terminators in Python, and
each of these uses are superfluous as they appear at the end of a line.
The convention is to not use semicolons where not needed, so remove them.

Reviewers: echristo, delcypher, beanz, ddunbar

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25409

llvm-svn: 283707
2016-10-10 01:18:14 +00:00
Brian Gesiak
d7ea6205eb [lit] Remove unused variable in googletest format
Summary: `prefix` is written to but never read.

Reviewers: echristo, delcypher, beanz, ddunbar

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25408

llvm-svn: 283706
2016-10-10 01:15:33 +00:00
Brian Gesiak
8f43f1be6f [lit] Remove Python 2.6 and below exec workaround
Summary:
The minimum version of Python required to run LLVM's test suite is 2.7.
Remove a workaround for older Python versions.

Reviewers: echristo, delcypher, beanz, ddunbar

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25400

llvm-svn: 283705
2016-10-10 01:11:52 +00:00
Brian Gesiak
7b8f593578 [lit] Remove workaround for Python 2.5
Summary:
The minimum version of Python necessary to run the LLVM test suite is
2.7. Code to work around Python 2.5 and lower isn't necessary.

Reviewers: ddunbar, echristo, delcypher, beanz

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25209

llvm-svn: 283169
2016-10-04 00:15:37 +00:00
Chris Bieneman
b448adb807 [lit] Use argparse instead of optparse
Summary:
optparse is deprecated in Python 2.7, which is the minimum version of
Python required to run the LLVM test suite. Replace its usage in lit
with argparse, optparse's 2.7 replacement module.

argparse has several benefits over optparse, but this commit does not
make use of those benefits yet. Instead, it simply uses the new API,
and attempts to keep the number of changes to a minimum.

Confirmed that lit's test suite, as well as LLVM's regression test suite,
still pass with these changes.

Patch By Brian Gesiak!

Reviewers: ddunbar, echristo, beanz, delcypher

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25173

llvm-svn: 283152
2016-10-03 22:12:42 +00:00
Chris Bieneman
54624e7eed [lit] Throw in unimplemented method (NFC)
Summary:
lit's `OneCommandFileTest` class implements an abstract method that
raises if called. However, it raises by referencing an undefined
symbol. Instead, raise explicitly by throwing a `NotImplementedError`.
This is clearer, and appeases Python linters.

Patch By Brian Gesiak!

Reviewers: ddunbar, echristo, beanz

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25170

llvm-svn: 283090
2016-10-03 04:48:22 +00:00
Chris Bieneman
eccb1ef284 [lit] Remove unused imports (NFC)
Reviewers: ddunbar, echristo, beanz

Patch by Brian Gesiak!

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25169

llvm-svn: 283089
2016-10-03 04:48:18 +00:00
Chris Bieneman
e4053503bf [lit] Compare to None using identity, not equality
Summary:
In Python, `None` is a singleton, so checking whether a variable is
`None` may be done with `is` or `is not`. This has a slight advantage
over equiality comparisons `== None` and `!= None`, since `__eq__` may
be overridden in Python to produce sometimes unexpected results.

Using `is None` and `is not None` is also recommended practice in
https://www.python.org/dev/peps/pep-0008:

> Comparisons to singletons like `None` should always be done with `is` or
> `is not`, never the equality operators.

Patch by Brian Gesiak!

Reviewers: ddunbar, echristo, beanz

Subscribers: llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D25168

llvm-svn: 283088
2016-10-03 04:48:13 +00:00
Daniel Dunbar
314bc61cf5 [lit] Add instructions to run lit's test suite
- Patch by Brian Gesiak.
 
 - https://reviews.llvm.org/D24968

llvm-svn: 282525
2016-09-27 18:58:50 +00:00
Daniel Dunbar
d445a1ca19 [lit] Fix refacto introduced by rL282479.
llvm-svn: 282501
2016-09-27 16:17:42 +00:00
Dimitar Vlahovski
98a4670ca6 Trying to fix lldb build breakage probably caused by rL282452
llvm-svn: 282479
2016-09-27 10:34:43 +00:00
Daniel Dunbar
52f97afa1b [lit] Add a --max-failures option.
- This is primarily useful as a "fail fast" mode for lit, where it will stop
   running tests after the first failure.

 - Patch by Max Moiseev.

llvm-svn: 282452
2016-09-26 23:38:23 +00:00
Ahmed Bougacha
839e711a0e [lit] Downgrade error to warning on gtest crashes during discovery.
Lots of unittests started failing under asan after r280455.  It seems
they've been failing for a long time, but lit silently ignored them.

Downgrade the error so we can figure out what is going on.
Filed http://llvm.org/PR30285.

llvm-svn: 280674
2016-09-05 20:53:14 +00:00
NAKAMURA Takumi
4061732e88 lit/util.py: Another fix for py3.
'str' object has no attribute 'decode'.

llvm-svn: 280641
2016-09-05 00:00:40 +00:00
NAKAMURA Takumi
268d2fea8e Make lit/util.py py3-compatible.
llvm-svn: 280579
2016-09-03 04:06:37 +00:00
Ivan Krasin
4b81ffc655 lit: print process output, if getting the list of google-tests failed.
Summary:
This is a follow up to r280455, where a check for the process exit code
was introduced. Some ASAN bots throw this error now, but it's impossible
to understand what's wrong with them, and the issue is not reproducible.

Reviewers: vitalybuka

Differential Revision: https://reviews.llvm.org/D24210

llvm-svn: 280550
2016-09-02 22:31:24 +00:00
Reid Kleckner
5b4ee7e91b Quick fix to make LIT_PRESERVES_TMP work again
llvm-svn: 280502
2016-09-02 16:33:15 +00:00
Reid Kleckner
57587191e1 [lit] Clean up temporary files created by tests
Do this by creating a temp directory in the normal system temp
directory, and cleaning it up on exit.

It is still possible for this temp directory to leak if Python exits
abnormally, but this is probably good enough for now.

Fixes PR18335

llvm-svn: 280501
2016-09-02 16:29:24 +00:00
Greg Parker
21ef229d64 [lit] Fail testing if a googletest executable crashes during test discovery
googletest formatted tests are discovered by running the test executable. 
Previously testing would silently succeed if the test executable crashed 
during the discovery process. Now testing fails with "error: unable to 
discover google-tests ..." if the test executable exits with a non-zero status.

llvm-svn: 280455
2016-09-02 02:44:07 +00:00
Reid Kleckner
6c388e7dba [lit] Use multiprocessing by default on Windows
Apparently nobody evaluated multiprocessing on Windows since Daniel
enabled multiprocessing on Unix in r193279. It works so far as I can
tell.

Today this is worth about an 8x speedup (631.29s to 73.25s) on my 24
core Windows machine. Hopefully this will improve Windows buildbot cycle
time, where currently it takes more time to run check-all than it does
to self-host with assertions enabled:
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/20
  build stage 2 ninja all ( 28 mins, 22 secs )
  ninja check 2 stage 2   ( 37 mins, 38 secs )

llvm-svn: 280382
2016-09-01 17:19:44 +00:00
Daniel Dunbar
7617e34f33 [lit] Use full config path in diagnostics.
- This allows tools like emacs to automatically find the config file path when
   you step through errors.

 - Patch by Dave Abrahams.

llvm-svn: 276357
2016-07-21 23:20:41 +00:00
Daniel Dunbar
9df5b532ab [lit] Bump version number.
llvm-svn: 276353
2016-07-21 23:17:44 +00:00
Marcin Koscielnicki
6a9131b3fe [lit] Add SANITIZER_IGNORE_CVE_2016_2143 to pass_vars.
This variable is used by ASan (and other sanitizers in the future)
on s390x-linux to override a check for CVE-2016-2143 in the running
kernel (see revision 267747 on compiler-rt).  Since the check simply
checks if the kernel version is in a whitelist of known-good versions,
it may miss distribution kernels, or manually-patched kernels - hence
the need for this variable.  To enable running the ASan testsuite on
such kernels, this variable should be passed from the environment
down to the testcases.

Differential Revision: http://reviews.llvm.org/D19888

llvm-svn: 273825
2016-06-26 21:49:58 +00:00
Daniel Dunbar
4f12eba9f0 [lit] Only gather redirected files for command failures.
- The intended use of this was just in diagnostics, so we shouldn't pay the
   cost of reading these all the time.

 - This will avoid including the full output of each command in tests which
   fail, but the most important use case for this was to gather the output of
   the specific command which failed.

llvm-svn: 272365
2016-06-10 04:17:30 +00:00
Vedant Kumar
a599512386 Revert "[lit] Use os.devnull instead of named temp files"
This reverts commit r272290. It breaks a test that depends on being able
to seek the /dev/null equivalent on Windows:

http://bb.pgr.jp/builders/ninja-clang-x64-mingw64-RA/builds/11360

llvm-svn: 272293
2016-06-09 19:36:48 +00:00
Vedant Kumar
6e905448d5 [lit] Use os.devnull instead of named temp files
Use os.devnull instead of tempfiles when substituting '/dev/null' on
Windows machines. This should make the bots just a bit speedier.

Thanks to Yunzhong Gao for testing this patch on Windows!

Differential Revision: http://reviews.llvm.org/D20549

llvm-svn: 272290
2016-06-09 18:38:41 +00:00
Daniel Dunbar
bd13a0caaa [lit] Ensure we get bytes when reading redirected output files.
llvm-svn: 272147
2016-06-08 14:41:44 +00:00
Daniel Dunbar
0e78f81b99 [lit] Ignore errors when decoding redirected output.
llvm-svn: 272066
2016-06-07 22:06:57 +00:00
Daniel Dunbar
103d296079 [lit] Fix an uninitialized var on Windows.
llvm-svn: 272052
2016-06-07 20:14:17 +00:00
Daniel Dunbar
19353b2150 [utils/lit] Show available_features with --show-suites.
llvm-svn: 272022
2016-06-07 16:22:24 +00:00
Daniel Dunbar
45d8260ac8 [lit] Improve logging with file redirection.
- This will cause lit to automatically include the first 1K of data in
   redirected output files when a command fails (previously if the command
   failed, but the main point of the test was, say, a `FileCheck` later on, then
   the log wasn't helpful in showing why the command failed).

llvm-svn: 272021
2016-06-07 16:13:40 +00:00
Daniel Dunbar
0aa30c2bae [lit] Improve readability of failing scripts.
- This only applies to scripts executed by the _internal_ shell script
   interpreter.

 - This patch reworks the log to look more like a shell transcript, and be less
   verbose (but in the interest of calling attention to the important parts).

Here is an example of the new format, for commands with/without failures and
with/without output:
```
$ true
$ echo hi
hi

$ false
note: command had no output on stdout or stderr
error: command failed with exit status 1

```

llvm-svn: 271610
2016-06-02 23:49:42 +00:00
Daniel Dunbar
5a4535da11 [lit] Factor out a helper for shell command results.
llvm-svn: 271608
2016-06-02 23:32:35 +00:00
Eric Fiselier
6ed176169a Add "REQUIRES-ANY" feature test
Summary:
This patch adds a "REQUIRES-ANY" feature test that is disjunctive. This marks a test as `UNSUPPORTED` if none of the specified features are available.

Libc++ has the need to write feature test such as `// REQUIRES-ANY: c++98, c++03`  when testing of behavior that is specific to older dialects but has since changed.


Reviewers: rnk, ddunbar

Subscribers: ddunbar, probinson, llvm-commits, cfe-commits

Differential Revision: http://reviews.llvm.org/D20757

llvm-svn: 271468
2016-06-02 01:59:57 +00:00
Rui Ueyama
b8083864d1 [lit] Add %:[STpst] to represent paths without colons on Windows.
Summary:
We need these variables to concatenate two absolute paths to construct
a valid path. Currently, %t\%t is, for example, expanded to C:\foo\C:\foo,
which is not a valid path because ":" is not a valid path character
on Windows. With this patch, %t will be expanded to C\foo.

Differential Revision: http://reviews.llvm.org/D19757

llvm-svn: 268168
2016-04-30 21:32:12 +00:00
Matthias Braun
10c7f27ee3 lit: python3 compatibility fix
llvm-svn: 265070
2016-03-31 23:08:55 +00:00
Daniel Dunbar
5f81d65876 [lit][googletest] Handle upstream gtest output
Summary:
Upstream googletest prints "Running main() from gtest_main.cc" to stdout prior
to running tests. LLVM removed that print statement in r61540. If a user were
to use lit to run tests that use upstream googletest, however, lit
reports "Running main()" as an invalid test name.

To avoid such a failure, add an extra conditional to `formats/googletest.py`.
Also add tests to demonstrate the modified behavior.

Reviewers: abdulras, ddunbar

Subscribers: ddunbar, llvm-commits, kastiglione

Differential Revision: http://reviews.llvm.org/D18606

llvm-svn: 265034
2016-03-31 18:22:55 +00:00
Filipe Cabecinhas
0cf5522f49 [lit] Enqueue tests on a separate thread to not hit limits on parallel queues
Summary:
The multiprocessing.Queue.put() call can hang if we try queueing all the
tests before starting to take them out of the queue.
The current implementation hangs if tests exceed 2^^15, on Mac OS X.
This might happen with a ninja check-all if one has a bunch of llvm
projects.

Reviewers: delcypher, bkramer

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D17609

llvm-svn: 263731
2016-03-17 18:27:33 +00:00
Chandler Carruth
a33398e005 [lit] Hack lit to allow a test suite to request that it is run "early".
This lets us for example start running the unit test suite early. For
'check-llvm' on my machine, this drops the tim e from 44s to 32s!!!!!

It's pretty ugly. I barely know how to write Python, so feel free to
just tell me how I should write it instead. =D Thanks to Filipe and
others for help.

Differential Revision: http://reviews.llvm.org/D18089

llvm-svn: 263329
2016-03-12 03:03:31 +00:00
Benjamin Kramer
57b36f1497 The canonical way to XFAIL a test for all targets is XFAIL: *, not XFAIL:
Fix the lit bug that enabled this "feature" (empty triple is substring
of all possible target triples) and change the two outliers to use the
documented * syntax.

llvm-svn: 259799
2016-02-04 16:21:38 +00:00
Yunzhong Gao
789ee55590 Add "/dev/tty" as a special file name for lit tests.
If a lit test has a RUN line that includes a redirection to "/dev/tty", the
redirection goes to the special device file corresponding to the console. It
is /dev/tty on UNIX-like systems and "CON" on Windows.

This patch is needed to implement a test like PR25717 (caused by the size limit
of the Windows system call WriteConsole() prior to Windows 8) where the test
only breaks when outputing to the console and won't fail if using a pipe.

llvm-svn: 258898
2016-01-27 01:48:20 +00:00
Dan Liew
edaf748ab2 [lit] Fix handling of per test timeout when the installed psutil version
is < ``2.0``.

Older versions of psutil (e.g. ``1.2.1`` which is the version shipped with
Ubuntu 14.04) use a different API for retrieving the child processes.
To handle this try the new API first and if that fails try the old API.

llvm-svn: 257616
2016-01-13 16:43:49 +00:00
Dan Liew
277612653e Revert "Teach the CMake build system to run lit's test suite. These can be run"
This reverts r257221.

This caused several build bot failures

* It looks like some of the tests don't work correctly under Windows
* It looks like the lit per test timeout tests fail

So I'm reverting for now. Once the above failures are fixed running
lit's tests can be enabled again.

llvm-svn: 257268
2016-01-09 21:42:57 +00:00
Dan Liew
c14975ef62 Teach the CMake build system to run lit's test suite. These can be run
directy with ``make check-lit`` and are run as part of
``make check-all``.

In principle we should run lit's testsuite before testing LLVM using lit
so that any problems with lit get discovered before testing LLVM so we
can bail out early.  However this implementation (``check-all`` runs all
tests together) seemed simpler and will still report failing lit tests.

Note that the tests and the configured ``lit.site.cfg`` have to be
copied into the build directory to avoid polluting the source tree.

llvm-svn: 257221
2016-01-08 22:36:22 +00:00
Dan Liew
d6419a3e16 [lit] Implement support of per test timeout in lit.
This should work with ShTest (executed externally or internally) and GTest
test formats.

To set the timeout a new option ``--timeout=`` has
been added which specifies the maximum run time of an individual test
in seconds. By default this 0 which causes no timeout to be enforced.

The timeout can also be set from a lit configuration file by modifying
the ``lit_config.maxIndividualTestTime`` property.

To implement a timeout we now require the psutil Python module if a
 timeout is requested. This dependency is confined to the newly added
 ``lit.util.killProcessAndChildren()``. A note has been added into the
 TODO document describing how we can remove the dependency on the
 ``pustil`` module in the future. It would be nice to remove this
 immediately but that is a lot more work and Daniel Dunbar believes it is
better that we get a working implementation first and then improve it.

To avoid breaking the existing behaviour the psutil module will not be
imported if no timeout is requested.

The included testcases are derived from test cases provided by
 Jonathan Roelofs which were in an previous attempt to add a per test
 timeout to lit (http://reviews.llvm.org/D6584). Thanks Jonathan!

Reviewers: ddunbar, jroelofs, cmatthews, MatzeB

Subscribers: cmatthews, llvm-commits

Differential Revision: http://reviews.llvm.org/D14706

llvm-svn: 256471
2015-12-27 14:03:49 +00:00
Nico Weber
569bc5db3e lit: Limit number of processes on Windows to 32.
llvm-svn: 256291
2015-12-22 23:12:00 +00:00
Dan Liew
db929f853a [lit] Fix bug when using Python3 where a failing test would not show
the script when running a ShTest with an external or internal shell.

This bug is caused by use of the ``map`` function in Python 3 which
returns an iterable (rather than a list in Python 2). After the iterable
is exhausted it won't return any more output and consequently when
``_runShTest()`` tries to access the ``script`` which has already been
iterated over it is empty. Converting to a list immediatley after
calling ``map()`` fixes this.

This fixes the ``tests/shtest-format.py`` test when running under
Python3 which was previously failing.

llvm-svn: 253556
2015-11-19 11:35:42 +00:00
Dan Liew
0394d63797 [lit] Improve error message when lit fails to executable a command by
showing the executable it tried to use.

llvm-svn: 253032
2015-11-13 11:38:07 +00:00
Dan Liew
41d8464b41 [lit] Fix bug where `lit.util.which()` would return a directory
instead of executable if the argument was found inside a directory
contained in PATH.

An example where this could cause a problem is if there was a RUN line
that ran the ``test`` command and if the user had a directory in their
PATH that contained a directory called ``test/`` (that occured before
``/usr/bin/``). Lit would try to use the directory as the executable
which would fail with the rather cryptic message.

```
Could not create process due to [Errno 13] Permission denied
```

llvm-svn: 253031
2015-11-13 11:37:25 +00:00
Matthias Braun
aa2b86a7c3 lit: Show all output with --show-all, even in combination with --succinct
I missed an earlier exit for the --succinct case when I introduced the
-a option.

llvm-svn: 252698
2015-11-11 03:03:54 +00:00
Matthias Braun
80fb3bb810 lit: Add '-a' option to display commands+output of all tests
The existing -v option only displays commands and outputs for failed
tests, the newly introduced -a displays it for all executed tests.

llvm-svn: 251806
2015-11-02 16:13:46 +00:00
Matthias Braun
0ae2b702f7 lit/TestRunner.py: Factor variable subsitution into an own function; NFCI
This is a clearer separation of concerns and makes it easier to reuse
the function.

llvm-svn: 251481
2015-10-28 02:36:45 +00:00
Matthias Braun
0dfea7241c lit/TestRunner.py: Factor out Substitution construction; NFC
This is a clearer separation of concerns and makes it easier to reuse
the functions.

llvm-svn: 251480
2015-10-28 02:36:42 +00:00
Matthias Braun
9f4c72c6f5 lit/TestRunner.py: Get execdir from test.getExecPath() instead of passing it around; NFC
llvm-svn: 251479
2015-10-28 02:36:38 +00:00
Matthias Braun
d9b899525f lit/TestRunner.py: Make parseIntegratedTestScriptCommands() keyword list a parameter; NFC
This allows the function to be easily reused and also simplifies the
code as the keyword list is next to the keyword handling now.

llvm-svn: 251478
2015-10-28 02:36:35 +00:00
NAKAMURA Takumi
05c9ec6d8e Lit: Rework r249161; Move RLIMIT_NPROC to main.py.
The message "raised the process limit..." prevented the progress bar.

llvm-svn: 250420
2015-10-15 15:37:13 +00:00
Hal Finkel
9a17051872 [lit] Raise the default soft process limit when possible
It is common to have a default soft process limit, at least on some families of
Linux distributions, of 1024. This is normally more than enough, but if you
have many cores, and you're running tests that create many threads, this can
become a problem. My POWER7 development machine has 48 cores, and when running
the lld regression tests, which often want to create up to 48 threads, I run
into problems. lit, by default, will want to run 48 tests in parallel, and
48*48 < 1024, and so many tests fail like this:

terminate called after throwing an instance of 'std::system_error'

what():  Resource temporarily unavailable
or lit fails like this when launching a test:

OSError: [Errno 11] Resource temporarily unavailable

lit can easily detect this situation and attempt to repair it before launching
tests (by raising the soft process limit to something that will allow ncpus^2
threads to be created), and should do so to prevent spurious test failures.

This is the follow-up to this thread:
http://lists.llvm.org/pipermail/llvm-dev/2015-October/090942.html

llvm-svn: 249161
2015-10-02 17:50:28 +00:00
Evgeniy Stepanov
ec37e7004e Fix passed env var name in lit for Android tests.
The variable is actually called ANDROID_SERIAL.
This was not exercised on the bots until today.
Should fix the sanitizer-x86_64-linux failures.

llvm-svn: 246898
2015-09-04 23:52:04 +00:00
Reid Kleckner
c90522baea [lit] Add basic flaky test retry functionality
The plan is to use this for the sanitizer test suite on Windows.  See
PR24554 for more details on why we need this.

Tested manually by injecting rand() into a sanitizer test and watching
what it does.

llvm-svn: 246704
2015-09-02 20:32:41 +00:00
Reid Kleckner
3f08bfd935 Revert "[lit] Speculatively fix PR24554 by manually closing the process handle"
This reverts commit r245946. It didn't help the problem:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/9179/steps/run%20tests/logs/stdio
LINK : fatal error LNK1104: cannot open file

llvm-svn: 246491
2015-08-31 21:42:02 +00:00
Peter Collingbourne
5b9a35a6d5 lit: Match UNSUPPORTED against target triple as we do for XFAIL.
llvm-svn: 246343
2015-08-28 22:17:28 +00:00
Reid Kleckner
a1bc27c2d3 [lit] Speculatively fix PR24554 by manually closing the process handle
My theory is that somehow Python's refcounting and GC strategy isn't
closing the subprocess handle in a timely fashion.  This accesses the
private '_handle' field of the Popen object, but I see no other way to
do this. If this doesn't address the problem on the sanitizer-windows
buildbot, we can revert this change. If it does, then let's keep the
hack.

llvm-svn: 245946
2015-08-25 16:07:06 +00:00
Reid Kleckner
6a2c6313aa [lit] Fix launching executables relative to the cwd after 'cd'
This was affecting test/asan/TestCases/Windows/coverage-basic.cc in
compiler-rt. It does something like:

  cd %T/mydir
  %clang %s -o t.exe
  ./t.exe

Previously, we'd end up looking for t.exe relative to the cwd of the lit
process, not the cwd of the test.

llvm-svn: 242941
2015-07-22 21:35:27 +00:00
Eric Fiselier
a7869e8070 [LIT] Fix discovery.py test once again
llvm-svn: 242758
2015-07-21 04:25:13 +00:00
Reid Kleckner
72d7c07dd6 [lit] Implement 'env' in the internal shell
The MSys 2 version of 'env' cannot be used to set 'TZ' in the
environment due to some portability hacks in the process spawning
compatibility layer[1]. This affects test/Object/archive-toc.test, which
tries to set TZ in the environment.

Other than that, this saves a subprocess invocation of a small unix
utility, which is makes the tests faster.

The internal shell does not support shell variable expansion, so this
idiom in the ASan tests isn't supported yet:
  RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:opt=1 ...

[1] https://github.com/Alexpux/MSYS2-packages/issues/294

Differential Revision: http://reviews.llvm.org/D11350

llvm-svn: 242696
2015-07-20 19:42:08 +00:00
Eric Fiselier
dba6b6d324 [LIT] Allow for executeCommand to take the stdin input.
Summary: This patch allows executeCommand to pass a string to the processes stdin.

Reviewers: ddunbar, jroelofs

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D11332

llvm-svn: 242631
2015-07-19 00:28:14 +00:00
Evgeniy Stepanov
8cf638b7e4 Pass 2 more variables to lit tests.
Pass ADB and ADB_SERIAL environment variables to lit tests.
This would allow running Android tests in compiler-rt when
there is more than one device attached to the host.

llvm-svn: 240459
2015-06-23 20:57:26 +00:00
Eric Fiselier
0e0d05323e [LIT] Fix failing LIT tests
Summary:
I spend some time trying to get the LIT test suite passing. Here are the changes that I needed to make on my machine.

I made the following changes for the following reasons.

1. google-test.py: The Google test format now checks for "[  PASSED  ] 1 test." to check if a test passes.
2. discovery.py: The output appears in a different order on my machine than it did in the test.
3. unittest-adaptor.py: The output appears in a different order on my machine than it did in the test.
4. The classname is now formed differently in `getJUnitXML(...)`.

I'm not sure what is causing the output order to differ in discovery.py and unittest-adaptor.py. Does anybody have any thoughts?

Reviewers: ddunbar, danalbert, jroelofs

Reviewed By: jroelofs

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D9864

llvm-svn: 239663
2015-06-13 06:55:44 +00:00
Arnold Schwaighofer
c3be220c44 lit: Allow configurations to restrict the set of tests to run
By setting limit_to_features to a non empty list of features a configuration can
restrict the set of tests to run to only include tests that require a feature in
this list.

rdar://21082253

llvm-svn: 238766
2015-06-01 17:50:03 +00:00
Matthias Braun
6cedce8963 Lit: Allow overriding llvm tool paths+arguments, make -D an alias for --param
These changes allow usages where you want to pass an additional
commandline option to all invocations of a specific llvm tool. Example:

> llvm-lit -Dllc=llc -enable-misched -verify-machineinstrs

Differential Revision: http://reviews.llvm.org/D9487

llvm-svn: 236461
2015-05-04 21:36:36 +00:00
Reid Kleckner
2c442cc959 [lit] Allow disabling an entire gtest suite, as is done in tsan
llvm-svn: 234336
2015-04-07 18:14:10 +00:00
Reid Kleckner
757a008206 [lit] Skip gtest names starting with DISABLED_
The sanitizer test suite uses this idiom to disable a test.  Now that we
actually check if a test ran after invoking it, we see that zero tests
ran, and complain.

Instead, ignore tests starting with DISABLED_ completely. Fixes the
sanitizer test suite failures on Windows.

llvm-svn: 234247
2015-04-06 22:16:58 +00:00
Reid Kleckner
fdff5f38ca [lit] Fix running gtest type-parameterized tests on Windows
The '/' character in the test name of a type-parameterized test is not a
path separator, and should not be '\' on Windows. We were passing a test
name to --gtest_filter which found no tests, so the exit code was zero,
indicating a passed test.

This bug has been here since r84387 in 2009, when Jeff Yasskin added the
original lit support for type-paratermized tests. Somewhere along the
line some of the ValueMapTests started failing, but we can fix those
separately.

llvm-svn: 234242
2015-04-06 21:49:55 +00:00
Reid Kleckner
0da22610a5 lit: Add 'cd' support to the internal shell and port some tests
The internal shell was already threading around a 'cwd' parameter. We
just have to make it mutable so that we can update it as the test script
executes.

If the shell ever grows support for environment variable substitution,
we could also implement support for export.

llvm-svn: 231017
2015-03-02 21:33:18 +00:00
Reid Kleckner
018690bc2a Don't warn or note if bash is missing
We haven't needed bash on Windows to run the test suite for a long time
now.

Patch by Michael Edwards!

llvm-svn: 228221
2015-02-04 22:36:52 +00:00
Sylvestre Ledru
21e7f50a74 Fix some bashims. More information on https://wiki.ubuntu.com/DashAsBinSh. Reported initially on https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=772302 & https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=772301
llvm-svn: 227744
2015-02-01 14:55:43 +00:00
Eric Fiselier
b07310b743 [lit] Format JSONMetricValue strings better.
llvm-svn: 226672
2015-01-21 16:38:31 +00:00
Rafael Espindola
0241b53c72 Don't set LD_PRELOAD to ''. It doesn't work on OpenBSD.
Patch by Brad Smith.

llvm-svn: 225890
2015-01-14 00:39:56 +00:00
Eric Fiselier
609a90af6c [LIT] Remove string decoding in gtest discovery code. lit.util.capture now does decoding.
llvm-svn: 225693
2015-01-12 20:43:34 +00:00
Eric Fiselier
f8b56c6dac [LIT] Decode string result in lit.util.capture
Summary: I think this is probably a bug, but I'm putting this up for review just to be sure. I think that `lit.util.capture` should decode the resulting string in the same way `lit.util.executeCommand` does.

Reviewers: ddunbar, EricWF

Reviewed By: EricWF

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6769

llvm-svn: 225681
2015-01-12 20:09:34 +00:00
Rafael Espindola
b47e702061 Pass LSAN_OPTIONS down so that it is possible to add suppressions.
llvm-svn: 224777
2014-12-23 18:39:02 +00:00
Eric Fiselier
91f01064d8 Split executeShTest into two parts so that it can be better leveraged by libc++
llvm-svn: 224672
2014-12-20 03:23:53 +00:00
Eric Fiselier
6dd39e2bd7 [LIT] Add JSONMetricValue type to wrap types supported by the json encoder.
Summary:
The following types can be encoded and decoded by the json library:
`dict`, `list`, `tuple`, `str`, `unicode`, `int`, `long`, `float`, `bool`, `NoneType`. 

`JSONMetricValue` can be constructed with any of these types, and used as part of Test.Result.
This patch also adds a toMetricValue function that converts a value into a MetricValue.




Reviewers: ddunbar, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits, llvm-commits

Differential Revision: http://reviews.llvm.org/D6576

llvm-svn: 224628
2014-12-19 22:29:12 +00:00
Rafael Espindola
7f81bff1d5 Now that we require a newer python, use the new exception syntax.
llvm-svn: 224130
2014-12-12 15:32:23 +00:00
Rafael Espindola
ee596e4631 Require python 2.7.
We were already requiring 2.5, which meant that people on old linux distros
had to upgrade anyway.

Requiring python 2.6 will make supporting 3.X easier as we can use the 3.X
exception syntax.

According to the discussion on llvmdev, there is not much value is requiring
just 2.6, we may as well just require 2.7.

llvm-svn: 224129
2014-12-12 15:29:31 +00:00
Eric Fiselier
0a9aaf40ed [LIT] Add support for UNSUPPORTED tag to TestRunner.parseIntegratedTestScript
Summary:
This patch gives me just enough to leverage the existing functionality in `TestRunner` for use in `libc++` and `libc++abi` .

It does the following:
* Adds the `UNSUPPORTED` tag to `TestRunner.parseIntegratedTestScript`.
* Allows `parseIntegratedTestScript` to return an empty script if a script is not required by the caller.



Reviewers: ddunbar, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits, llvm-commits

Differential Revision: http://reviews.llvm.org/D6589

llvm-svn: 223915
2014-12-10 03:42:09 +00:00
David Majnemer
97d6a1e3a0 lit: Don't use python 2.6 features
LLVM supports python 2.5, this fixes a (somewhat) recent regression.

llvm-svn: 223626
2014-12-08 08:33:30 +00:00
Chris Matthews
f31f782923 Fix for xunit output to work around issue in Jenkins when tests are at the root level
llvm-svn: 223562
2014-12-06 01:13:49 +00:00
Chris Matthews
c31e772612 Fix corner cases in lit xunit for paths with dots
llvm-svn: 223549
2014-12-06 00:21:08 +00:00
Chris Matthews
d632e02f75 Add a test-case for lit xunit output
llvm-svn: 223307
2014-12-03 23:01:35 +00:00
Chris Matthews
a69dea97e6 Don't allow test-suite names with . in them in xml output
llvm-svn: 223305
2014-12-03 22:59:15 +00:00
Chris Matthews
e15245ded8 Give lit a --xunit-xml-output option for saving results in xunit format
--xunit-xml-output saves test results to disk in JUnit's xml format. This will allow Jenkins to report the details of a lit run.
  
  Based on a patch by David Chisnall.

llvm-svn: 223163
2014-12-02 22:19:21 +00:00
Rafael Espindola
00a6342814 Handle ASAN_OPTIONS and UBSAN_OPTIONS in TestingConfig.py
Currently they are passed to tests of llvm itself, but not, for example, lld.

With this patch the options are visible in every test.

llvm-svn: 221198
2014-11-03 23:04:56 +00:00
Rafael Espindola
6214a8c737 refactor duplicated code. NFC.
llvm-svn: 221191
2014-11-03 22:17:49 +00:00
Rafael Espindola
48899041bd [lit] Forward LD_PRELOAD to tests.
With this patch I can use asan to test the gold plugin without having
to build gold itself with asan.

llvm-svn: 221183
2014-11-03 21:24:43 +00:00
Daniel Dunbar
0e45326cc9 [lit] Fix Python-3 compatibility, patch by Dan Liew.
llvm-svn: 220357
2014-10-22 01:26:06 +00:00
Daniel Dunbar
ab9d73a70e [lit] Bump version number.
llvm-svn: 220355
2014-10-22 00:48:23 +00:00
Daniel Dunbar
685b3765e0 Fix ShTest parsing error when a keyword line doesn't end with a newline.
llvm-svn: 220354
2014-10-22 00:34:31 +00:00
Dan Liew
802c28f78d Teach Lit to catch OSError exceptions when creating a process during the
execution of a shell command. This can happen for example if the
``RUN:`` line calls a python script which can work correctly under
Linux/OSX but will not work under Windows. A more useful error message
is now shown rather than an unhelpful backtrace.

llvm-svn: 220227
2014-10-20 20:14:28 +00:00
Peter Collingbourne
22590da2c9 Initial version of Go bindings.
This code is based on the existing LLVM Go bindings project hosted at:
https://github.com/go-llvm/llvm

Note that all contributors to the gollvm project have agreed to relicense
their changes under the LLVM license and submit them to the LLVM project.

Differential Revision: http://reviews.llvm.org/D5684

llvm-svn: 219976
2014-10-16 22:48:02 +00:00
Jordan Rose
6655e823e0 [lit] Parse all strings as UTF-8 rather than ASCII.
As far as I can tell UTF-8 has been supported since the beginning of Python's
codec support, and it's the de facto standard for text these days, at least
for primarily-English text. This allows us to put Unicode into lit RUN lines.

rdar://problem/18311663

llvm-svn: 217688
2014-09-12 16:46:05 +00:00
Eric Fiselier
d12eebd3f8 [LIT] Move display of unsupported and xfail tests to summary.
Summary:
This patch changes the way xfail and unsupported tests are displayed. 
This output is only displayed when the --show-unsupported/--show-xfail flags are passed to lit.

Currently xfail/unsupported tests are printed during the run of the test-suite. I think its better to display this information during the summary instead.
This patch removes the printing of these tests from when they are run to the summary.


Reviewers: ddunbar, EricWF

Reviewed By: EricWF

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D4842

llvm-svn: 215809
2014-08-16 02:16:25 +00:00
Eric Fiselier
644e75522f [lit] Add --show-xfail flag to LIT.
Summary:
This patch add a --show-xfail flag. If this flag is specified then each xfail test will be printed to output.
When it is not given xfail tests are ignored. Ignoring xfail tests is the current behavior.

This flag is meant to mirror the --show-unsupported flag that was recently added.

Reviewers: ddunbar, EricWF

Reviewed By: EricWF

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D4750

llvm-svn: 214609
2014-08-02 01:29:52 +00:00
Eric Fiselier
95d51f6cee [lit] Add --show-unsupported flag to LIT
llvm-svn: 213227
2014-07-17 05:53:00 +00:00
Hans Wennborg
f27451b3a7 lit: simplify population of the actual_inputs array
Add all inputs to the array, except those starting with @, which
are treated as response files and expanded.

llvm-svn: 211119
2014-06-17 18:17:46 +00:00
Hans Wennborg
bde907d28e Revert "lit: warn when passed invalid pathname" (r210597)
It was pointed out that this breaks the "virtual test discovery"
mechanism, which allows for narming tests in the test exec root.

Reverting until I can figure out how to fix this.

llvm-svn: 211048
2014-06-16 20:18:41 +00:00
Hans Wennborg
6393126f22 lit: warn when passed invalid pathname
It would previously say things like

  warning: input 'test/Frontend/foo.c' contained no tests

and have the user pull their hair trying to figure out what's wrong with that
file. This patch changes the message to the much clearer:

  warning: no such file or directory: 'test/Frontend/foo.c'

Differential Revision: http://reviews.llvm.org/D4097

llvm-svn: 210597
2014-06-10 22:51:58 +00:00
Alexander Potapenko
d7c37af8b4 Add detection of OS X relocatable SDK to compiler-rt as a lit.util function
Clang's lit cfg already detects the currently selected SDK via
"xcrun --show-sdk-path". The same thing should be done for compiler-rt tests,
to make them work on recent OS X versions. Instead of duplicating the detection
code, this patch extracts the detection function into a lit.util method.

Patch by Kuba Brecka (kuba.brecka@gmail.com),
reviewed at http://reviews.llvm.org/D4072

llvm-svn: 210534
2014-06-10 14:22:00 +00:00
Joerg Sonnenberger
87dad97b52 Fix test syntax to work with non-bash /bin/sh.
llvm-svn: 206119
2014-04-12 21:13:41 +00:00
Daniel Dunbar
dcb65e4744 [lit] Fix non-function style print statement.
llvm-svn: 203573
2014-03-11 14:05:49 +00:00
Daniel Dunbar
c1356cbd3a [lit] Bump dev version number.
llvm-svn: 203498
2014-03-10 21:58:16 +00:00
Daniel Dunbar
97b49237d9 [lit] Add a README.txt.
- Also, update MANIFEST.in and utils/check-sdist.

llvm-svn: 203497
2014-03-10 21:58:12 +00:00
Daniel Dunbar
1a6b374918 [lit] Add --version option.
llvm-svn: 203496
2014-03-10 21:57:48 +00:00
Alp Toker
b9c4c9d6f5 lit: Provide source locations in cfg files with older Python versions
This commit prospectively brings the benefits of r198766 to older supported
Python versions (2.5+).

Tested with Python 2.6, 2.7, 3.1 and 3.3 (!)

llvm-svn: 199009
2014-01-11 14:34:18 +00:00
Alp Toker
a9c0934bea lit: execfile() isn't present in Python 3.3
On the other hand, exec(compile()) doesn't work in older Python versions in the
2.x series.

This commit introduces exec(compile()) with a fallback to plain exec(). That'll
hopefully hit the sweet spot in terms of version support.

Followup to r198766 which added enhanced source locations for lit cfg parsing.

llvm-svn: 199006
2014-01-11 13:27:28 +00:00
Alp Toker
7638179115 lit: Provide file location in cfg error messages
Python doesn't do a good job at diagnosing string exec() so use execfile()
where available.

This should be a timesaver when trying to get to the bottom of build bot
failures.

Before:

    File "llvm/utils/lit/lit/TestingConfig.py", line 93, in load_from_path
      exec("exec data in cfg_globals")
    File "<string>", line 1, in <module>
    File "<string>", line 194, in <module>
  NameError: name 'typo' is not defined

After:

    File "llvm/utils/lit/lit/TestingConfig.py", line 95, in load_from_path
    execfile(path, cfg_globals)
    File "clang/test/lit.cfg", line 194, in <module>
      typo
      ^~~~
  NameError: name 'typo' is not defined

llvm-svn: 198766
2014-01-08 14:20:59 +00:00
Alp Toker
8f683c6ba3 Python compatibility fix for r198150
Remove the stat call error reporting for now.

It wasn't essential so silent fallback should be fine here.

llvm-svn: 198155
2013-12-29 06:51:10 +00:00
Alp Toker
0897b6644d Prospective Python 3 fix for r198150
llvm-svn: 198152
2013-12-29 05:51:07 +00:00
Alp Toker
87af14279d lit: Incremental test scheduling
Add option -i to prioritize test runs by source file modification time and
previous failure state.

This optimal scheduling reduces typical test-and-fix iteration times to a
matter of seconds by rapidly answering the questions:

  1) Did my recent change fix tests that were previously failing?
  2) Do the tests I just wrote / modified still work?

The current implementation requires write permissions to the source tree
because it uses mtimes to track failures.

llvm-svn: 198150
2013-12-29 05:09:05 +00:00
NAKAMURA Takumi
ffce6d533a Tweak lit/TestingConfig.py Py3-compatible. has_key is dead.
llvm-svn: 197462
2013-12-17 04:14:50 +00:00
Alp Toker
7f0b2395d8 lit: multiprocessing platform fix attempt
The error raised by Python varies by platform(!), so let's just catch any
exception and fall back.

Thanks to Sylvestre Ledru for noticing this on a Debian / Python 2.7 system
running code coverage.

llvm-svn: 193516
2013-10-28 10:26:13 +00:00
Alp Toker
faa5d33982 Clarify the comment about BSD versions in r193465
llvm-svn: 193508
2013-10-27 20:49:19 +00:00
Joerg Sonnenberger
c928f5557a self.path may be empty or otherwise miss the normal system directories,
so try PATH next. Assume it is sane enough to cover the usual system
bash locations too, but the old list is not good enough for NetBSD.

llvm-svn: 193471
2013-10-26 13:25:45 +00:00
Alp Toker
212cd2ef39 lit: Issue a note when multiprocessing fails to load
If multiprocessing was requested, detected as available and subsequently failed
to initialize it's worth letting the user know about it before falling back to
threads.

This condition can arise in certain OpenBSD / FreeBSD Python versions.

llvm-svn: 193465
2013-10-26 09:29:58 +00:00
Alp Toker
ea94466ed9 Fix a referenced before assignment in r193463
Some versions of Python on the builders seem strict about this.

llvm-svn: 193464
2013-10-26 08:46:05 +00:00
Alp Toker
d9e1b3620b lit: handle late multiprocessing errors gracefully
This should be a better fix for lit multiprocessing failures, replacing the
OpenBSD and FreeBSD workarounds in r193413 and r193457.

Reference: http://bugs.python.org/issue3770
llvm-svn: 193463
2013-10-26 08:22:44 +00:00
Alp Toker
1f1aa0923b Attempt to fix the FreeBSD build, disable multiprocessing
Speculative quick fix based on clang-X86_64-freebsd output:

  File "/usr/local/lib/python2.6/multiprocessing/synchronize.py", line 33, in <module>
    " function, see issue 3770.")
ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770.

llvm-svn: 193457
2013-10-26 02:43:08 +00:00
Rafael Espindola
57067f1916 Try to fix the openbsd bot.
llvm-svn: 193413
2013-10-25 15:07:59 +00:00
Rafael Espindola
21ab8e791a Actually switch the default to use multiprocessing
llvm-svn: 193282
2013-10-23 22:32:53 +00:00
Daniel Dunbar
2764343ead [lit] Stop hacking the GIL check interval.
- This was never a big win, and is irrelevant now that we commonly use
   multiprocessing based parallelism.

llvm-svn: 193280
2013-10-23 22:19:32 +00:00
Daniel Dunbar
3903598ad6 [lit] Use multiprocessing based parallelism by default, on Unix.
llvm-svn: 193279
2013-10-23 22:19:07 +00:00
NAKAMURA Takumi
9419cc1b21 Lit: LIT_PRESERVES_TMP should be aware of TMPDIR, too.
TMPDIR is preferred in Unix.

llvm-svn: 192891
2013-10-17 13:11:13 +00:00