diff options
author | Pascal Stumpf <pascal@cvs.openbsd.org> | 2016-09-03 22:47:03 +0000 |
---|---|---|
committer | Pascal Stumpf <pascal@cvs.openbsd.org> | 2016-09-03 22:47:03 +0000 |
commit | c07c59953ad4d4f16e8c3a3e25692ad9657db3ea (patch) | |
tree | e5a516d9d25bf178ab50dad2aa60c32b8684d5ee /gnu/llvm/utils/lit/tests | |
parent | 62bc401a55deb1281a3a42cd4f08325a6839a171 (diff) |
Use the space freed up by sparc and zaurus to import LLVM.
ok hackroom@
Diffstat (limited to 'gnu/llvm/utils/lit/tests')
74 files changed, 943 insertions, 0 deletions
diff --git a/gnu/llvm/utils/lit/tests/.coveragerc b/gnu/llvm/utils/lit/tests/.coveragerc new file mode 100644 index 00000000000..c886d0ac1a6 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/.coveragerc @@ -0,0 +1,11 @@ +# .coveragerc to control coverage.py +[run] +branch = False +parallel = True +source = lit + +[html] +directory = coverage_html_report + +[report] +omit = Inputs diff --git a/gnu/llvm/utils/lit/tests/Inputs/discovery/lit.cfg b/gnu/llvm/utils/lit/tests/Inputs/discovery/lit.cfg new file mode 100644 index 00000000000..c48ca0bc036 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/discovery/lit.cfg @@ -0,0 +1,14 @@ +import lit.formats +config.name = 'top-level-suite' +config.suffixes = ['.txt'] +config.test_format = lit.formats.ShTest() + +# We intentionally don't set the source root or exec root directories here, +# because this suite gets reused for testing the exec root behavior (in +# ../exec-discovery). +# +#config.test_source_root = None +#config.test_exec_root = None + +# Check that arbitrary config values are copied (tested by subdir/lit.local.cfg). +config.an_extra_variable = False diff --git a/gnu/llvm/utils/lit/tests/Inputs/discovery/subdir/lit.local.cfg b/gnu/llvm/utils/lit/tests/Inputs/discovery/subdir/lit.local.cfg new file mode 100644 index 00000000000..631cb602b0d --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/discovery/subdir/lit.local.cfg @@ -0,0 +1,4 @@ +config.suffixes = ['.py'] + +# Check that the arbitrary config values in our parent was inherited. +assert hasattr(config, 'an_extra_variable') diff --git a/gnu/llvm/utils/lit/tests/Inputs/discovery/subdir/test-three.py b/gnu/llvm/utils/lit/tests/Inputs/discovery/subdir/test-three.py new file mode 100644 index 00000000000..b80b60b7a27 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/discovery/subdir/test-three.py @@ -0,0 +1 @@ +# RUN: true diff --git a/gnu/llvm/utils/lit/tests/Inputs/discovery/subsuite/lit.cfg b/gnu/llvm/utils/lit/tests/Inputs/discovery/subsuite/lit.cfg new file mode 100644 index 00000000000..b49329abfde --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/discovery/subsuite/lit.cfg @@ -0,0 +1,6 @@ +import lit.formats +config.name = 'sub-suite' +config.suffixes = ['.txt'] +config.test_format = lit.formats.ShTest() +config.test_source_root = None +config.test_exec_root = None diff --git a/gnu/llvm/utils/lit/tests/Inputs/discovery/subsuite/test-one.txt b/gnu/llvm/utils/lit/tests/Inputs/discovery/subsuite/test-one.txt new file mode 100644 index 00000000000..b80b60b7a27 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/discovery/subsuite/test-one.txt @@ -0,0 +1 @@ +# RUN: true diff --git a/gnu/llvm/utils/lit/tests/Inputs/discovery/subsuite/test-two.txt b/gnu/llvm/utils/lit/tests/Inputs/discovery/subsuite/test-two.txt new file mode 100644 index 00000000000..b80b60b7a27 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/discovery/subsuite/test-two.txt @@ -0,0 +1 @@ +# RUN: true diff --git a/gnu/llvm/utils/lit/tests/Inputs/discovery/test-one.txt b/gnu/llvm/utils/lit/tests/Inputs/discovery/test-one.txt new file mode 100644 index 00000000000..b80b60b7a27 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/discovery/test-one.txt @@ -0,0 +1 @@ +# RUN: true diff --git a/gnu/llvm/utils/lit/tests/Inputs/discovery/test-two.txt b/gnu/llvm/utils/lit/tests/Inputs/discovery/test-two.txt new file mode 100644 index 00000000000..b80b60b7a27 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/discovery/test-two.txt @@ -0,0 +1 @@ +# RUN: true diff --git a/gnu/llvm/utils/lit/tests/Inputs/exec-discovery-in-tree/lit.cfg b/gnu/llvm/utils/lit/tests/Inputs/exec-discovery-in-tree/lit.cfg new file mode 100644 index 00000000000..ae25b4f4acb --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/exec-discovery-in-tree/lit.cfg @@ -0,0 +1,9 @@ +import lit.formats + +# Verify that the site configuration was loaded. +if config.test_source_root is None or config.test_exec_root is None: + lit_config.fatal("No site specific configuration") + +config.name = 'exec-discovery-in-tree-suite' +config.suffixes = ['.txt'] +config.test_format = lit.formats.ShTest() diff --git a/gnu/llvm/utils/lit/tests/Inputs/exec-discovery-in-tree/obj/lit.site.cfg b/gnu/llvm/utils/lit/tests/Inputs/exec-discovery-in-tree/obj/lit.site.cfg new file mode 100644 index 00000000000..4061c894072 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/exec-discovery-in-tree/obj/lit.site.cfg @@ -0,0 +1,4 @@ +import os +config.test_exec_root = os.path.dirname(__file__) +config.test_source_root = os.path.dirname(config.test_exec_root) +lit_config.load_config(config, os.path.join(config.test_source_root, "lit.cfg"))
\ No newline at end of file diff --git a/gnu/llvm/utils/lit/tests/Inputs/exec-discovery-in-tree/test-one.txt b/gnu/llvm/utils/lit/tests/Inputs/exec-discovery-in-tree/test-one.txt new file mode 100644 index 00000000000..b80b60b7a27 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/exec-discovery-in-tree/test-one.txt @@ -0,0 +1 @@ +# RUN: true diff --git a/gnu/llvm/utils/lit/tests/Inputs/exec-discovery/lit.site.cfg b/gnu/llvm/utils/lit/tests/Inputs/exec-discovery/lit.site.cfg new file mode 100644 index 00000000000..ac273c797c5 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/exec-discovery/lit.site.cfg @@ -0,0 +1,5 @@ +# Load the discovery suite, but with a separate exec root. +import os +config.test_exec_root = os.path.dirname(__file__) +config.test_source_root = os.path.join(os.path.dirname(config.test_exec_root), "discovery") +lit_config.load_config(config, os.path.join(config.test_source_root, "lit.cfg")) diff --git a/gnu/llvm/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest b/gnu/llvm/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest new file mode 100755 index 00000000000..dd49f025b1f --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest @@ -0,0 +1,36 @@ +#!/usr/bin/env python + +import sys + +if len(sys.argv) != 2: + raise ValueError("unexpected number of args") + +if sys.argv[1] == "--gtest_list_tests": + print("""\ +FirstTest. + subTestA + subTestB +ParameterizedTest/0. + subTest +ParameterizedTest/1. + subTest""") + sys.exit(0) +elif not sys.argv[1].startswith("--gtest_filter="): + raise ValueError("unexpected argument: %r" % (sys.argv[1])) + +test_name = sys.argv[1].split('=',1)[1] +if test_name == 'FirstTest.subTestA': + print('I am subTest A, I PASS') + print('[ PASSED ] 1 test.') + sys.exit(0) +elif test_name == 'FirstTest.subTestB': + print('I am subTest B, I FAIL') + print('And I have two lines of output') + sys.exit(1) +elif test_name in ('ParameterizedTest/0.subTest', + 'ParameterizedTest/1.subTest'): + print('I am a parameterized test, I also PASS') + print('[ PASSED ] 1 test.') + sys.exit(0) +else: + raise SystemExit("error: invalid test name: %r" % (test_name,)) diff --git a/gnu/llvm/utils/lit/tests/Inputs/googletest-format/lit.cfg b/gnu/llvm/utils/lit/tests/Inputs/googletest-format/lit.cfg new file mode 100644 index 00000000000..f2f6cda8db6 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/googletest-format/lit.cfg @@ -0,0 +1,3 @@ +import lit.formats +config.name = 'googletest-format' +config.test_format = lit.formats.GoogleTest('DummySubDir', 'Test') diff --git a/gnu/llvm/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest b/gnu/llvm/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest new file mode 100755 index 00000000000..f3a90ff4cd6 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest @@ -0,0 +1,35 @@ +#!/usr/bin/env python + +import sys +import time + +if len(sys.argv) != 2: + raise ValueError("unexpected number of args") + +if sys.argv[1] == "--gtest_list_tests": + print("""\ +FirstTest. + subTestA + subTestB + subTestC +""") + sys.exit(0) +elif not sys.argv[1].startswith("--gtest_filter="): + raise ValueError("unexpected argument: %r" % (sys.argv[1])) + +test_name = sys.argv[1].split('=',1)[1] +if test_name == 'FirstTest.subTestA': + print('I am subTest A, I PASS') + print('[ PASSED ] 1 test.') + sys.exit(0) +elif test_name == 'FirstTest.subTestB': + print('I am subTest B, I am slow') + time.sleep(6) + print('[ PASSED ] 1 test.') + sys.exit(0) +elif test_name == 'FirstTest.subTestC': + print('I am subTest C, I will hang') + while True: + pass +else: + raise SystemExit("error: invalid test name: %r" % (test_name,)) diff --git a/gnu/llvm/utils/lit/tests/Inputs/googletest-timeout/lit.cfg b/gnu/llvm/utils/lit/tests/Inputs/googletest-timeout/lit.cfg new file mode 100644 index 00000000000..bf8a4db2bf9 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/googletest-timeout/lit.cfg @@ -0,0 +1,9 @@ +import lit.formats +config.name = 'googletest-timeout' +config.test_format = lit.formats.GoogleTest('DummySubDir', 'Test') + +configSetTimeout = lit_config.params.get('set_timeout', '0') + +if configSetTimeout == '1': + # Try setting the max individual test time in the configuration + lit_config.maxIndividualTestTime = 1 diff --git a/gnu/llvm/utils/lit/tests/Inputs/progress-bar/lit.cfg b/gnu/llvm/utils/lit/tests/Inputs/progress-bar/lit.cfg new file mode 100644 index 00000000000..7f31129ad11 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/progress-bar/lit.cfg @@ -0,0 +1,6 @@ +import lit.formats +config.name = 'shtest-shell' +config.suffixes = ['.txt'] +config.test_format = lit.formats.ShTest() +config.test_source_root = None +config.test_exec_root = None diff --git a/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-1.txt b/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-1.txt new file mode 100644 index 00000000000..49932c3006e --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-1.txt @@ -0,0 +1 @@ +# RUN: false diff --git a/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-2.txt b/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-2.txt new file mode 100644 index 00000000000..49932c3006e --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-2.txt @@ -0,0 +1 @@ +# RUN: false diff --git a/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-3.txt b/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-3.txt new file mode 100644 index 00000000000..49932c3006e --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-3.txt @@ -0,0 +1 @@ +# RUN: false diff --git a/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-4.txt b/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-4.txt new file mode 100644 index 00000000000..49932c3006e --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/progress-bar/test-4.txt @@ -0,0 +1 @@ +# RUN: false diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/argv0.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/argv0.txt new file mode 100644 index 00000000000..2ff289014bc --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/argv0.txt @@ -0,0 +1,6 @@ +# Check that we route argv[0] as it was written, instead of the resolved +# path. This is important for some tools, in particular '[' which at least on OS +# X only recognizes that it is in '['-mode when its argv[0] is exactly +# '['. Otherwise it will refuse to accept the trailing closing bracket. +# +# RUN: [ "A" = "A" ] diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt new file mode 100644 index 00000000000..069e37619e7 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/fail.txt @@ -0,0 +1,5 @@ +# Run a command that fails with error on stdout. +# +# RUN: echo "line 1: failed test output on stdout" +# RUN: echo "line 2: failed test output on stdout" +# RUN: cat "does-not-exist" diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt new file mode 100644 index 00000000000..f6157e66c97 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt @@ -0,0 +1,5 @@ +# Run a command that fails with error on stdout. +# +# RUN: %S/write-bad-encoding.sh +# RUN: false + diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/lit.local.cfg b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/lit.local.cfg new file mode 100644 index 00000000000..5e87c729919 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/lit.local.cfg @@ -0,0 +1,2 @@ +import lit.formats +config.test_format = lit.formats.ShTest(execute_external=True) diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/pass.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/pass.txt new file mode 100644 index 00000000000..b80b60b7a27 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/pass.txt @@ -0,0 +1 @@ +# RUN: true diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh new file mode 100755 index 00000000000..6b622cb232e --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "a line with bad encoding: Â." diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/fail.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/fail.txt new file mode 100644 index 00000000000..8c305eb416b --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/fail.txt @@ -0,0 +1,2 @@ +# RUN: printf "line 1: failed test output on stdout\nline 2: failed test output on stdout" +# RUN: false diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/lit.cfg b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/lit.cfg new file mode 100644 index 00000000000..9b47985a3d8 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/lit.cfg @@ -0,0 +1,8 @@ +import lit.formats +config.name = 'shtest-format' +config.suffixes = ['.txt'] +config.test_format = lit.formats.ShTest() +config.test_source_root = None +config.test_exec_root = None +config.target_triple = 'x86_64-unknown-unknown' +config.available_features.add('a-present-feature') diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/no-test-line.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/no-test-line.txt new file mode 100644 index 00000000000..f2316bd73ad --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/no-test-line.txt @@ -0,0 +1 @@ +# Empty! diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/pass.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/pass.txt new file mode 100644 index 00000000000..b80b60b7a27 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/pass.txt @@ -0,0 +1 @@ +# RUN: true diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/requires-missing.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/requires-missing.txt new file mode 100644 index 00000000000..9e6648d8b8f --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/requires-missing.txt @@ -0,0 +1,2 @@ +RUN: true +REQUIRES: a-missing-feature diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/requires-present.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/requires-present.txt new file mode 100644 index 00000000000..064f7074a76 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/requires-present.txt @@ -0,0 +1,2 @@ +RUN: true +REQUIRES: a-present-feature diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/unsupported_dir/lit.local.cfg b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/unsupported_dir/lit.local.cfg new file mode 100644 index 00000000000..462e3dc5d11 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/unsupported_dir/lit.local.cfg @@ -0,0 +1 @@ +config.unsupported = True diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/unsupported_dir/some-test.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/unsupported_dir/some-test.txt new file mode 100644 index 00000000000..b80b60b7a27 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/unsupported_dir/some-test.txt @@ -0,0 +1 @@ +# RUN: true diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xfail-feature.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xfail-feature.txt new file mode 100644 index 00000000000..bd6241f8e44 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xfail-feature.txt @@ -0,0 +1,2 @@ +# RUN: false +# XFAIL: a-present-feature diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xfail-target.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xfail-target.txt new file mode 100644 index 00000000000..36760bee435 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xfail-target.txt @@ -0,0 +1,2 @@ +RUN: false +XFAIL: x86_64 diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xfail.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xfail.txt new file mode 100644 index 00000000000..6814cda4014 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xfail.txt @@ -0,0 +1,2 @@ +RUN: false +XFAIL: * diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xpass.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xpass.txt new file mode 100644 index 00000000000..764d21798b3 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-format/xpass.txt @@ -0,0 +1,2 @@ +RUN: true +XFAIL: x86_64 diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/error-0.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/error-0.txt new file mode 100644 index 00000000000..631c8df233d --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/error-0.txt @@ -0,0 +1,3 @@ +# Check error on an internal shell error (unable to find command). +# +# RUN: not-a-real-command diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/error-1.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/error-1.txt new file mode 100644 index 00000000000..e5c8be6b666 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/error-1.txt @@ -0,0 +1,3 @@ +# Check error on a shell parsing failure. +# +# RUN: echo "missing quote diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/error-2.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/error-2.txt new file mode 100644 index 00000000000..a976286bdde --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/error-2.txt @@ -0,0 +1,3 @@ +# Check error on a unsupported redirect. +# +# RUN: echo "hello" 3>&1 diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/lit.cfg b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/lit.cfg new file mode 100644 index 00000000000..7f31129ad11 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/lit.cfg @@ -0,0 +1,6 @@ +import lit.formats +config.name = 'shtest-shell' +config.suffixes = ['.txt'] +config.test_format = lit.formats.ShTest() +config.test_source_root = None +config.test_exec_root = None diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/redirects.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/redirects.txt new file mode 100644 index 00000000000..6be88b67ce1 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/redirects.txt @@ -0,0 +1,41 @@ +# Check stdout redirect (> and >>). +# +# RUN: echo "not-present" > %t.stdout-write +# RUN: echo "is-present" > %t.stdout-write +# RUN: FileCheck --check-prefix=STDOUT-WRITE < %t.stdout-write %s +# +# STDOUT-WRITE-NOT: not-present +# STDOUT-WRITE: is-present +# +# RUN: echo "appended-line" >> %t.stdout-write +# RUN: FileCheck --check-prefix=STDOUT-APPEND < %t.stdout-write %s +# +# STDOUT-APPEND: is-present +# STDOUT-APPEND: appended-line + + +# Check stderr redirect (2> and 2>>). +# +# RUN: echo "not-present" > %t.stderr-write +# RUN: %S/write-to-stderr.sh 2> %t.stderr-write +# RUN: FileCheck --check-prefix=STDERR-WRITE < %t.stderr-write %s +# +# STDERR-WRITE-NOT: not-present +# STDERR-WRITE: a line on stderr +# +# RUN: %S/write-to-stderr.sh 2>> %t.stderr-write +# RUN: FileCheck --check-prefix=STDERR-APPEND < %t.stderr-write %s +# +# STDERR-APPEND: a line on stderr +# STDERR-APPEND: a line on stderr + + +# Check combined redirect (&>). +# +# RUN: echo "not-present" > %t.combined +# RUN: %S/write-to-stdout-and-stderr.sh &> %t.combined +# RUN: FileCheck --check-prefix=COMBINED-WRITE < %t.combined %s +# +# COMBINED-WRITE-NOT: not-present +# COMBINED-WRITE: a line on stdout +# COMBINED-WRITE: a line on stderr diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/sequencing-0.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/sequencing-0.txt new file mode 100644 index 00000000000..6578db25afe --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/sequencing-0.txt @@ -0,0 +1,28 @@ +# Check sequencing operations. +# +# RUN: echo "first-line" > %t.out && echo "second-line" >> %t.out +# RUN: FileCheck --check-prefix CHECK-AND < %t.out %s +# +# CHECK-AND: first-line +# CHECK-AND: second-line +# +# The false case of && is tested in sequencing-2.txt + + +# RUN: echo "first-line" > %t.out || echo "second-line" >> %t.out +# RUN: FileCheck --check-prefix CHECK-OR-1 < %t.out %s +# +# CHECK-OR-1: first-line +# CHECK-OR-1-NOT: second-line + +# RUN: false || echo "second-line" > %t.out +# RUN: FileCheck --check-prefix CHECK-OR-2 < %t.out %s +# +# CHECK-OR-2: second-line + + +# RUN: echo "first-line" > %t.out; echo "second-line" >> %t.out +# RUN: FileCheck --check-prefix CHECK-SEQ < %t.out %s +# +# CHECK-SEQ: first-line +# CHECK-SEQ: second-line diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/sequencing-1.txt b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/sequencing-1.txt new file mode 100644 index 00000000000..5a1794c26c1 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/sequencing-1.txt @@ -0,0 +1,2 @@ +# RUN: false && true +# XFAIL: * diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/write-to-stderr.sh b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/write-to-stderr.sh new file mode 100755 index 00000000000..ead3fd3ce37 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/write-to-stderr.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "a line on stderr" 1>&2 diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/write-to-stdout-and-stderr.sh b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/write-to-stdout-and-stderr.sh new file mode 100755 index 00000000000..f20de5d9042 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-shell/write-to-stdout-and-stderr.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +echo "a line on stdout" +echo "a line on stderr" 1>&2 diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/infinite_loop.py b/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/infinite_loop.py new file mode 100644 index 00000000000..55720479d33 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/infinite_loop.py @@ -0,0 +1,10 @@ +# RUN: %{python} %s +from __future__ import print_function + +import time +import sys + +print("Running infinite loop") +sys.stdout.flush() # Make sure the print gets flushed so it appears in lit output. +while True: + pass diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/lit.cfg b/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/lit.cfg new file mode 100644 index 00000000000..81b4a12120d --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/lit.cfg @@ -0,0 +1,32 @@ +# -*- Python -*- +import os +import sys + +import lit.formats + +config.name = 'per_test_timeout' + +shellType = lit_config.params.get('external', '1') + +if shellType == '0': + lit_config.note('Using internal shell') + externalShell = False +else: + lit_config.note('Using external shell') + externalShell = True + +configSetTimeout = lit_config.params.get('set_timeout', '0') + +if configSetTimeout == '1': + # Try setting the max individual test time in the configuration + lit_config.maxIndividualTestTime = 1 + +config.test_format = lit.formats.ShTest(execute_external=externalShell) +config.suffixes = ['.py'] + +config.test_source_root = os.path.dirname(__file__) +config.test_exec_root = config.test_source_root +config.target_triple = '(unused)' +src_root = os.path.join(config.test_source_root, '..') +config.environment['PYTHONPATH'] = src_root +config.substitutions.append(('%{python}', sys.executable)) diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/quick_then_slow.py b/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/quick_then_slow.py new file mode 100644 index 00000000000..b81fbe5a8bf --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/quick_then_slow.py @@ -0,0 +1,24 @@ +# RUN: %{python} %s quick +# RUN: %{python} %s slow +from __future__ import print_function + +import time +import sys + +if len(sys.argv) != 2: + print("Wrong number of args") + sys.exit(1) + +mode = sys.argv[1] + +if mode == 'slow': + print("Running in slow mode") + sys.stdout.flush() # Make sure the print gets flushed so it appears in lit output. + time.sleep(6) + sys.exit(0) +elif mode == 'quick': + print("Running in quick mode") + sys.exit(0) +else: + print("Unrecognised mode {}".format(mode)) + sys.exit(1) diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/short.py b/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/short.py new file mode 100644 index 00000000000..424b7092d83 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/short.py @@ -0,0 +1,6 @@ +# RUN: %{python} %s +from __future__ import print_function + +import sys + +print("short program") diff --git a/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/slow.py b/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/slow.py new file mode 100644 index 00000000000..2dccd633136 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/shtest-timeout/slow.py @@ -0,0 +1,9 @@ +# RUN: %{python} %s +from __future__ import print_function + +import time +import sys + +print("Running slow program") +sys.stdout.flush() # Make sure the print gets flushed so it appears in lit output. +time.sleep(6) diff --git a/gnu/llvm/utils/lit/tests/Inputs/test-data/lit.cfg b/gnu/llvm/utils/lit/tests/Inputs/test-data/lit.cfg new file mode 100644 index 00000000000..f5aba7b2177 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/test-data/lit.cfg @@ -0,0 +1,44 @@ +import os +try: + import ConfigParser +except ImportError: + import configparser as ConfigParser + +import lit.formats +import lit.Test + +class DummyFormat(lit.formats.FileBasedTest): + def execute(self, test, lit_config): + # In this dummy format, expect that each test file is actually just a + # .ini format dump of the results to report. + + source_path = test.getSourcePath() + + cfg = ConfigParser.ConfigParser() + cfg.read(source_path) + + # Create the basic test result. + result_code = cfg.get('global', 'result_code') + result_output = cfg.get('global', 'result_output') + result = lit.Test.Result(getattr(lit.Test, result_code), + result_output) + + # Load additional metrics. + for key,value_str in cfg.items('results'): + value = eval(value_str) + if isinstance(value, int): + metric = lit.Test.IntMetricValue(value) + elif isinstance(value, float): + metric = lit.Test.RealMetricValue(value) + else: + raise RuntimeError("unsupported result type") + result.addMetric(key, metric) + + return result + +config.name = 'test-data' +config.suffixes = ['.ini'] +config.test_format = DummyFormat() +config.test_source_root = None +config.test_exec_root = None +config.target_triple = None diff --git a/gnu/llvm/utils/lit/tests/Inputs/test-data/metrics.ini b/gnu/llvm/utils/lit/tests/Inputs/test-data/metrics.ini new file mode 100644 index 00000000000..01b09c5c775 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/test-data/metrics.ini @@ -0,0 +1,7 @@ +[global] +result_code = PASS +result_output = Test passed. + +[results] +value0 = 1 +value1 = 2.3456
\ No newline at end of file diff --git a/gnu/llvm/utils/lit/tests/Inputs/unittest-adaptor/lit.cfg b/gnu/llvm/utils/lit/tests/Inputs/unittest-adaptor/lit.cfg new file mode 100644 index 00000000000..9e08a8629a4 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/unittest-adaptor/lit.cfg @@ -0,0 +1,6 @@ +import lit.formats +config.name = 'unittest-adaptor' +config.suffixes = ['.txt'] +config.test_format = lit.formats.ShTest() +config.test_source_root = None +config.test_exec_root = None diff --git a/gnu/llvm/utils/lit/tests/Inputs/unittest-adaptor/test-one.txt b/gnu/llvm/utils/lit/tests/Inputs/unittest-adaptor/test-one.txt new file mode 100644 index 00000000000..b80b60b7a27 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/unittest-adaptor/test-one.txt @@ -0,0 +1 @@ +# RUN: true diff --git a/gnu/llvm/utils/lit/tests/Inputs/unittest-adaptor/test-two.txt b/gnu/llvm/utils/lit/tests/Inputs/unittest-adaptor/test-two.txt new file mode 100644 index 00000000000..49932c3006e --- /dev/null +++ b/gnu/llvm/utils/lit/tests/Inputs/unittest-adaptor/test-two.txt @@ -0,0 +1 @@ +# RUN: false diff --git a/gnu/llvm/utils/lit/tests/discovery.py b/gnu/llvm/utils/lit/tests/discovery.py new file mode 100644 index 00000000000..55e54088b58 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/discovery.py @@ -0,0 +1,97 @@ +# Check the basic discovery process, including a sub-suite. +# +# RUN: %{lit} %{inputs}/discovery \ +# RUN: -j 1 --debug --show-tests --show-suites \ +# RUN: -v > %t.out 2> %t.err +# RUN: FileCheck --check-prefix=CHECK-BASIC-OUT < %t.out %s +# RUN: FileCheck --check-prefix=CHECK-BASIC-ERR < %t.err %s +# +# CHECK-BASIC-ERR: loading suite config '{{.*}}/discovery/lit.cfg' +# CHECK-BASIC-ERR-DAG: loading suite config '{{.*}}/discovery/subsuite/lit.cfg' +# CHECK-BASIC-ERR-DAG: loading local config '{{.*}}/discovery/subdir/lit.local.cfg' +# +# CHECK-BASIC-OUT: -- Test Suites -- +# CHECK-BASIC-OUT: sub-suite - 2 tests +# CHECK-BASIC-OUT: Source Root: {{.*/discovery/subsuite$}} +# CHECK-BASIC-OUT: Exec Root : {{.*/discovery/subsuite$}} +# CHECK-BASIC-OUT: top-level-suite - 3 tests +# CHECK-BASIC-OUT: Source Root: {{.*/discovery$}} +# CHECK-BASIC-OUT: Exec Root : {{.*/discovery$}} +# +# CHECK-BASIC-OUT: -- Available Tests -- +# CHECK-BASIC-OUT: sub-suite :: test-one +# CHECK-BASIC-OUT: sub-suite :: test-two +# CHECK-BASIC-OUT: top-level-suite :: subdir/test-three +# CHECK-BASIC-OUT: top-level-suite :: test-one +# CHECK-BASIC-OUT: top-level-suite :: test-two + + +# Check discovery when exact test names are given. +# +# RUN: %{lit} \ +# RUN: %{inputs}/discovery/subdir/test-three.py \ +# RUN: %{inputs}/discovery/subsuite/test-one.txt \ +# RUN: -j 1 --show-tests --show-suites -v > %t.out +# RUN: FileCheck --check-prefix=CHECK-EXACT-TEST < %t.out %s +# +# CHECK-EXACT-TEST: -- Available Tests -- +# CHECK-EXACT-TEST: sub-suite :: test-one +# CHECK-EXACT-TEST: top-level-suite :: subdir/test-three + + +# Check discovery when using an exec path. +# +# RUN: %{lit} %{inputs}/exec-discovery \ +# RUN: -j 1 --debug --show-tests --show-suites \ +# RUN: -v > %t.out 2> %t.err +# RUN: FileCheck --check-prefix=CHECK-ASEXEC-OUT < %t.out %s +# RUN: FileCheck --check-prefix=CHECK-ASEXEC-ERR < %t.err %s +# +# CHECK-ASEXEC-ERR: loading suite config '{{.*}}/exec-discovery/lit.site.cfg' +# CHECK-ASEXEC-ERR: load_config from '{{.*}}/discovery/lit.cfg' +# CHECK-ASEXEC-ERR: loaded config '{{.*}}/discovery/lit.cfg' +# CHECK-ASEXEC-ERR: loaded config '{{.*}}/exec-discovery/lit.site.cfg' +# CHECK-ASEXEC-ERR-DAG: loading suite config '{{.*}}/discovery/subsuite/lit.cfg' +# CHECK-ASEXEC-ERR-DAG: loading local config '{{.*}}/discovery/subdir/lit.local.cfg' +# +# CHECK-ASEXEC-OUT: -- Test Suites -- +# CHECK-ASEXEC-OUT: sub-suite - 2 tests +# CHECK-ASEXEC-OUT: Source Root: {{.*/discovery/subsuite$}} +# CHECK-ASEXEC-OUT: Exec Root : {{.*/discovery/subsuite$}} +# CHECK-ASEXEC-OUT: top-level-suite - 3 tests +# CHECK-ASEXEC-OUT: Source Root: {{.*/discovery$}} +# CHECK-ASEXEC-OUT: Exec Root : {{.*/exec-discovery$}} +# +# CHECK-ASEXEC-OUT: -- Available Tests -- +# CHECK-ASEXEC-OUT: sub-suite :: test-one +# CHECK-ASEXEC-OUT: sub-suite :: test-two +# CHECK-ASEXEC-OUT: top-level-suite :: subdir/test-three +# CHECK-ASEXEC-OUT: top-level-suite :: test-one +# CHECK-ASEXEC-OUT: top-level-suite :: test-two + +# Check discovery when exact test names are given. +# +# FIXME: Note that using a path into a subsuite doesn't work correctly here. +# +# RUN: %{lit} \ +# RUN: %{inputs}/exec-discovery/subdir/test-three.py \ +# RUN: -j 1 --show-tests --show-suites -v > %t.out +# RUN: FileCheck --check-prefix=CHECK-ASEXEC-EXACT-TEST < %t.out %s +# +# CHECK-ASEXEC-EXACT-TEST: -- Available Tests -- +# CHECK-ASEXEC-EXACT-TEST: top-level-suite :: subdir/test-three + + +# Check that we don't recurse infinitely when loading an site specific test +# suite located inside the test source root. +# +# RUN: %{lit} \ +# RUN: %{inputs}/exec-discovery-in-tree/obj/ \ +# RUN: -j 1 --show-tests --show-suites -v > %t.out +# RUN: FileCheck --check-prefix=CHECK-ASEXEC-INTREE < %t.out %s +# +# CHECK-ASEXEC-INTREE: exec-discovery-in-tree-suite - 1 tests +# CHECK-ASEXEC-INTREE-NEXT: Source Root: {{.*/exec-discovery-in-tree$}} +# CHECK-ASEXEC-INTREE-NEXT: Exec Root : {{.*/exec-discovery-in-tree/obj$}} +# CHECK-ASEXEC-INTREE-NEXT: -- Available Tests -- +# CHECK-ASEXEC-INTREE-NEXT: exec-discovery-in-tree-suite :: test-one diff --git a/gnu/llvm/utils/lit/tests/googletest-format.py b/gnu/llvm/utils/lit/tests/googletest-format.py new file mode 100644 index 00000000000..a62fd1b3cca --- /dev/null +++ b/gnu/llvm/utils/lit/tests/googletest-format.py @@ -0,0 +1,20 @@ +# Check the various features of the GoogleTest format. +# +# RUN: not %{lit} -j 1 -v %{inputs}/googletest-format > %t.out +# RUN: FileCheck < %t.out %s +# +# END. + +# CHECK: -- Testing: +# CHECK: PASS: googletest-format :: DummySubDir/OneTest/FirstTest.subTestA +# CHECK: FAIL: googletest-format :: DummySubDir/OneTest/FirstTest.subTestB +# CHECK-NEXT: *** TEST 'googletest-format :: DummySubDir/OneTest/FirstTest.subTestB' FAILED *** +# CHECK-NEXT: I am subTest B, I FAIL +# CHECK-NEXT: And I have two lines of output +# CHECK: *** +# CHECK: PASS: googletest-format :: DummySubDir/OneTest/ParameterizedTest/0.subTest +# CHECK: PASS: googletest-format :: DummySubDir/OneTest/ParameterizedTest/1.subTest +# CHECK: Failing Tests (1) +# CHECK: Expected Passes : 3 +# CHECK: Unexpected Failures: 1 + diff --git a/gnu/llvm/utils/lit/tests/googletest-timeout.py b/gnu/llvm/utils/lit/tests/googletest-timeout.py new file mode 100644 index 00000000000..46acf32b3a6 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/googletest-timeout.py @@ -0,0 +1,29 @@ +# REQUIRES: python-psutil + +# Check that the per test timeout is enforced when running GTest tests. +# +# RUN: not %{lit} -j 1 -v %{inputs}/googletest-timeout --timeout=1 > %t.cmd.out +# RUN: FileCheck < %t.cmd.out %s + +# Check that the per test timeout is enforced when running GTest tests via +# the configuration file +# +# RUN: not %{lit} -j 1 -v %{inputs}/googletest-timeout \ +# RUN: --param set_timeout=1 > %t.cfgset.out 2> %t.cfgset.err +# RUN: FileCheck < %t.cfgset.out %s + +# CHECK: -- Testing: +# CHECK: PASS: googletest-timeout :: DummySubDir/OneTest/FirstTest.subTestA +# CHECK: TIMEOUT: googletest-timeout :: DummySubDir/OneTest/FirstTest.subTestB +# CHECK: TIMEOUT: googletest-timeout :: DummySubDir/OneTest/FirstTest.subTestC +# CHECK: Expected Passes : 1 +# CHECK: Individual Timeouts: 2 + +# Test per test timeout via a config file and on the command line. +# The value set on the command line should override the config file. +# RUN: not %{lit} -j 1 -v %{inputs}/googletest-timeout \ +# RUN: --param set_timeout=1 --timeout=2 > %t.cmdover.out 2> %t.cmdover.err +# RUN: FileCheck < %t.cmdover.out %s +# RUN: FileCheck --check-prefix=CHECK-CMDLINE-OVERRIDE-ERR < %t.cmdover.err %s + +# CHECK-CMDLINE-OVERRIDE-ERR: Forcing timeout to be 2 seconds diff --git a/gnu/llvm/utils/lit/tests/lit.cfg b/gnu/llvm/utils/lit/tests/lit.cfg new file mode 100644 index 00000000000..4b38241d5a7 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/lit.cfg @@ -0,0 +1,54 @@ +# -*- Python -*- + +import os +import sys + +import lit.formats + +# Configuration file for the 'lit' test runner. + +# name: The name of this test suite. +config.name = 'lit' + +# testFormat: The test format to use to interpret tests. +config.test_format = lit.formats.ShTest(execute_external=False) + +# suffixes: A list of file extensions to treat as test files. +config.suffixes = ['.py'] + +# excludes: A list of individual files to exclude. +config.excludes = ['Inputs'] + +# test_source_root: The root path where tests are located. +config.test_source_root = os.path.dirname(__file__) +config.test_exec_root = config.test_source_root + +config.target_triple = '(unused)' + +src_root = os.path.join(config.test_source_root, '..') +config.environment['PYTHONPATH'] = src_root +config.substitutions.append(('%{src_root}', src_root)) +config.substitutions.append(('%{inputs}', os.path.join( + src_root, 'tests', 'Inputs'))) +config.substitutions.append(('%{lit}', "%%{python} %s" % ( + os.path.join(src_root, 'lit.py'),))) +config.substitutions.append(('%{python}', sys.executable)) + +# Enable coverage.py reporting, assuming the coverage module has been installed +# and sitecustomize.py in the virtualenv has been modified appropriately. +if lit_config.params.get('check-coverage', None): + config.environment['COVERAGE_PROCESS_START'] = os.path.join( + os.path.dirname(__file__), ".coveragerc") + +# Add a feature to detect the Python version. +config.available_features.add("python%d.%d" % (sys.version_info[0], + sys.version_info[1])) + +# Add a feature to detect if psutil is available +try: + import psutil + lit_config.note('Found python psutil module') + config.available_features.add("python-psutil") +except ImportError: + lit_config.warning('Could not import psutil. Some tests will be skipped and' + ' the --timeout command line argument will not work.') diff --git a/gnu/llvm/utils/lit/tests/progress-bar.py b/gnu/llvm/utils/lit/tests/progress-bar.py new file mode 100644 index 00000000000..d0467485082 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/progress-bar.py @@ -0,0 +1,13 @@ +# Check the simple progress bar. +# +# RUN: not %{lit} -j 1 -s %{inputs}/progress-bar > %t.out +# RUN: FileCheck < %t.out %s +# +# CHECK: Testing: 0 .. 10.. 20 +# CHECK: FAIL: shtest-shell :: test-1.txt (1 of 4) +# CHECK: Testing: 0 .. 10.. 20.. 30.. 40.. +# CHECK: FAIL: shtest-shell :: test-2.txt (2 of 4) +# CHECK: Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70 +# CHECK: FAIL: shtest-shell :: test-3.txt (3 of 4) +# CHECK: Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90.. +# CHECK: FAIL: shtest-shell :: test-4.txt (4 of 4) diff --git a/gnu/llvm/utils/lit/tests/shell-parsing.py b/gnu/llvm/utils/lit/tests/shell-parsing.py new file mode 100644 index 00000000000..a07e988861f --- /dev/null +++ b/gnu/llvm/utils/lit/tests/shell-parsing.py @@ -0,0 +1,3 @@ +# Just run the ShUtil unit tests. +# +# RUN: %{python} -m lit.ShUtil diff --git a/gnu/llvm/utils/lit/tests/shtest-encoding.py b/gnu/llvm/utils/lit/tests/shtest-encoding.py new file mode 100644 index 00000000000..dfc987f6df7 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/shtest-encoding.py @@ -0,0 +1,3 @@ +# RUN: true + +# Here is a string that cannot be decoded in line mode: Â. diff --git a/gnu/llvm/utils/lit/tests/shtest-format.py b/gnu/llvm/utils/lit/tests/shtest-format.py new file mode 100644 index 00000000000..751f0d70803 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/shtest-format.py @@ -0,0 +1,77 @@ +# Check the various features of the ShTest format. +# +# RUN: not %{lit} -j 1 -v %{inputs}/shtest-format > %t.out +# RUN: FileCheck < %t.out %s +# +# END. + +# CHECK: -- Testing: + +# CHECK: PASS: shtest-format :: argv0.txt +# CHECK: FAIL: shtest-format :: external_shell/fail.txt +# CHECK-NEXT: *** TEST 'shtest-format :: external_shell/fail.txt' FAILED *** +# CHECK: Command Output (stdout): +# CHECK-NEXT: -- +# CHECK-NEXT: line 1: failed test output on stdout +# CHECK-NEXT: line 2: failed test output on stdout +# CHECK: Command Output (stderr): +# CHECK-NEXT: -- +# CHECK-NEXT: cat: does-not-exist: No such file or directory +# CHECK: -- + +# CHECK: FAIL: shtest-format :: external_shell/fail_with_bad_encoding.txt +# CHECK-NEXT: *** TEST 'shtest-format :: external_shell/fail_with_bad_encoding.txt' FAILED *** +# CHECK: Command Output (stdout): +# CHECK-NEXT: -- +# CHECK-NEXT: a line with bad encoding: +# CHECK: -- + +# CHECK: PASS: shtest-format :: external_shell/pass.txt + +# CHECK: FAIL: shtest-format :: fail.txt +# CHECK-NEXT: *** TEST 'shtest-format :: fail.txt' FAILED *** +# CHECK-NEXT: Script: +# CHECK-NEXT: -- +# CHECK-NEXT: printf "line 1 +# CHECK-NEXT: false +# CHECK-NEXT: -- +# CHECK-NEXT: Exit Code: 1 +# +# CHECK: Command Output (stdout): +# CHECK-NEXT: -- +# CHECK-NEXT: Command 0: "printf" +# CHECK-NEXT: Command 0 Result: 0 +# CHECK-NEXT: Command 0 Output: +# CHECK-NEXT: line 1: failed test output on stdout +# CHECK-NEXT: line 2: failed test output on stdout + +# CHECK: UNRESOLVED: shtest-format :: no-test-line.txt +# CHECK: PASS: shtest-format :: pass.txt +# CHECK: UNSUPPORTED: shtest-format :: requires-missing.txt +# CHECK: PASS: shtest-format :: requires-present.txt +# CHECK: UNSUPPORTED: shtest-format :: unsupported_dir/some-test.txt +# CHECK: XFAIL: shtest-format :: xfail-feature.txt +# CHECK: XFAIL: shtest-format :: xfail-target.txt +# CHECK: XFAIL: shtest-format :: xfail.txt +# CHECK: XPASS: shtest-format :: xpass.txt +# CHECK-NEXT: *** TEST 'shtest-format :: xpass.txt' FAILED *** +# CHECK-NEXT: Script +# CHECK-NEXT: -- +# CHECK-NEXT: true +# CHECK-NEXT: -- +# CHECK: Testing Time + +# CHECK: Unexpected Passing Tests (1) +# CHECK: shtest-format :: xpass.txt + +# CHECK: Failing Tests (3) +# CHECK: shtest-format :: external_shell/fail.txt +# CHECK: shtest-format :: external_shell/fail_with_bad_encoding.txt +# CHECK: shtest-format :: fail.txt + +# CHECK: Expected Passes : 4 +# CHECK: Expected Failures : 3 +# CHECK: Unsupported Tests : 2 +# CHECK: Unresolved Tests : 1 +# CHECK: Unexpected Passes : 1 +# CHECK: Unexpected Failures: 3 diff --git a/gnu/llvm/utils/lit/tests/shtest-shell.py b/gnu/llvm/utils/lit/tests/shtest-shell.py new file mode 100644 index 00000000000..32479e19a10 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/shtest-shell.py @@ -0,0 +1,33 @@ +# Check the internal shell handling component of the ShTest format. +# +# RUN: not %{lit} -j 1 -v %{inputs}/shtest-shell > %t.out +# RUN: FileCheck < %t.out %s +# +# END. + +# CHECK: -- Testing: + +# CHECK: FAIL: shtest-shell :: error-0.txt +# CHECK: *** TEST 'shtest-shell :: error-0.txt' FAILED *** +# CHECK: Command 0: "not-a-real-command" +# CHECK: Command 0 Result: 127 +# CHECK: Command 0 Stderr: +# CHECK: 'not-a-real-command': command not found +# CHECK: *** + +# FIXME: The output here sucks. +# +# CHECK: FAIL: shtest-shell :: error-1.txt +# CHECK: *** TEST 'shtest-shell :: error-1.txt' FAILED *** +# CHECK: shell parser error on: 'echo "missing quote' +# CHECK: *** + +# CHECK: FAIL: shtest-shell :: error-2.txt +# CHECK: *** TEST 'shtest-shell :: error-2.txt' FAILED *** +# CHECK: Unsupported redirect: +# CHECK: *** + +# CHECK: PASS: shtest-shell :: redirects.txt +# CHECK: PASS: shtest-shell :: sequencing-0.txt +# CHECK: XFAIL: shtest-shell :: sequencing-1.txt +# CHECK: Failing Tests (3) diff --git a/gnu/llvm/utils/lit/tests/shtest-timeout.py b/gnu/llvm/utils/lit/tests/shtest-timeout.py new file mode 100644 index 00000000000..e6b2947a4f7 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/shtest-timeout.py @@ -0,0 +1,116 @@ +# REQUIRES: python-psutil + +# Test per test timeout using external shell +# RUN: not %{lit} \ +# RUN: %{inputs}/shtest-timeout/infinite_loop.py \ +# RUN: %{inputs}/shtest-timeout/quick_then_slow.py \ +# RUN: %{inputs}/shtest-timeout/short.py \ +# RUN: %{inputs}/shtest-timeout/slow.py \ +# RUN: -j 1 -v --debug --timeout 1 --param external=1 > %t.extsh.out 2> %t.extsh.err +# RUN: FileCheck --check-prefix=CHECK-OUT-COMMON < %t.extsh.out %s +# RUN: FileCheck --check-prefix=CHECK-EXTSH-ERR < %t.extsh.err %s +# +# CHECK-EXTSH-ERR: Using external shell + +# Test per test timeout using internal shell +# RUN: not %{lit} \ +# RUN: %{inputs}/shtest-timeout/infinite_loop.py \ +# RUN: %{inputs}/shtest-timeout/quick_then_slow.py \ +# RUN: %{inputs}/shtest-timeout/short.py \ +# RUN: %{inputs}/shtest-timeout/slow.py \ +# RUN: -j 1 -v --debug --timeout 1 --param external=0 > %t.intsh.out 2> %t.intsh.err +# RUN: FileCheck --check-prefix=CHECK-OUT-COMMON < %t.intsh.out %s +# RUN: FileCheck --check-prefix=CHECK-INTSH-OUT < %t.intsh.out %s +# RUN: FileCheck --check-prefix=CHECK-INTSH-ERR < %t.intsh.err %s +# +# CHECK-INTSH-OUT: TIMEOUT: per_test_timeout :: infinite_loop.py +# CHECK-INTSH-OUT: Command 0 Reached Timeout: True +# CHECK-INTSH-OUT: Command 0 Output: +# CHECK-INTSH-OUT-NEXT: Running infinite loop + + +# CHECK-INTSH-OUT: TIMEOUT: per_test_timeout :: quick_then_slow.py +# CHECK-INTSH-OUT: Timeout: Reached timeout of 1 seconds +# CHECK-INTSH-OUT: Command Output +# CHECK-INTSH-OUT: Command 0 Reached Timeout: False +# CHECK-INTSH-OUT: Command 0 Output: +# CHECK-INTSH-OUT-NEXT: Running in quick mode +# CHECK-INTSH-OUT: Command 1 Reached Timeout: True +# CHECK-INTSH-OUT: Command 1 Output: +# CHECK-INTSH-OUT-NEXT: Running in slow mode + +# CHECK-INTSH-OUT: TIMEOUT: per_test_timeout :: slow.py +# CHECK-INTSH-OUT: Command 0 Reached Timeout: True +# CHECK-INTSH-OUT: Command 0 Output: +# CHECK-INTSH-OUT-NEXT: Running slow program + +# CHECK-INTSH-ERR: Using internal shell + +# Test per test timeout set via a config file rather than on the command line +# RUN: not %{lit} \ +# RUN: %{inputs}/shtest-timeout/infinite_loop.py \ +# RUN: %{inputs}/shtest-timeout/quick_then_slow.py \ +# RUN: %{inputs}/shtest-timeout/short.py \ +# RUN: %{inputs}/shtest-timeout/slow.py \ +# RUN: -j 1 -v --debug --param external=0 \ +# RUN: --param set_timeout=1 > %t.cfgset.out 2> %t.cfgset.err +# RUN: FileCheck --check-prefix=CHECK-OUT-COMMON < %t.cfgset.out %s +# RUN: FileCheck --check-prefix=CHECK-CFGSET-ERR < %t.cfgset.err %s +# +# CHECK-CFGSET-ERR: Using internal shell + +# CHECK-OUT-COMMON: TIMEOUT: per_test_timeout :: infinite_loop.py +# CHECK-OUT-COMMON: Timeout: Reached timeout of 1 seconds +# CHECK-OUT-COMMON: Command {{([0-9]+ )?}}Output +# CHECK-OUT-COMMON: Running infinite loop + +# CHECK-OUT-COMMON: TIMEOUT: per_test_timeout :: quick_then_slow.py +# CHECK-OUT-COMMON: Timeout: Reached timeout of 1 seconds +# CHECK-OUT-COMMON: Command {{([0-9]+ )?}}Output +# CHECK-OUT-COMMON: Running in quick mode +# CHECK-OUT-COMMON: Running in slow mode + +# CHECK-OUT-COMMON: PASS: per_test_timeout :: short.py + +# CHECK-OUT-COMMON: TIMEOUT: per_test_timeout :: slow.py +# CHECK-OUT-COMMON: Timeout: Reached timeout of 1 seconds +# CHECK-OUT-COMMON: Command {{([0-9]+ )?}}Output +# CHECK-OUT-COMMON: Running slow program + +# CHECK-OUT-COMMON: Expected Passes{{ *}}: 1 +# CHECK-OUT-COMMON: Individual Timeouts{{ *}}: 3 + +# Test per test timeout via a config file and on the command line. +# The value set on the command line should override the config file. +# RUN: not %{lit} \ +# RUN: %{inputs}/shtest-timeout/infinite_loop.py \ +# RUN: %{inputs}/shtest-timeout/quick_then_slow.py \ +# RUN: %{inputs}/shtest-timeout/short.py \ +# RUN: %{inputs}/shtest-timeout/slow.py \ +# RUN: -j 1 -v --debug --param external=0 \ +# RUN: --param set_timeout=1 --timeout=2 > %t.cmdover.out 2> %t.cmdover.err +# RUN: FileCheck --check-prefix=CHECK-CMDLINE-OVERRIDE-OUT < %t.cmdover.out %s +# RUN: FileCheck --check-prefix=CHECK-CMDLINE-OVERRIDE-ERR < %t.cmdover.err %s + +# CHECK-CMDLINE-OVERRIDE-ERR: Forcing timeout to be 2 seconds + +# CHECK-CMDLINE-OVERRIDE-OUT: TIMEOUT: per_test_timeout :: infinite_loop.py +# CHECK-CMDLINE-OVERRIDE-OUT: Timeout: Reached timeout of 2 seconds +# CHECK-CMDLINE-OVERRIDE-OUT: Command {{([0-9]+ )?}}Output +# CHECK-CMDLINE-OVERRIDE-OUT: Running infinite loop + +# CHECK-CMDLINE-OVERRIDE-OUT: TIMEOUT: per_test_timeout :: quick_then_slow.py +# CHECK-CMDLINE-OVERRIDE-OUT: Timeout: Reached timeout of 2 seconds +# CHECK-CMDLINE-OVERRIDE-OUT: Command {{([0-9]+ )?}}Output +# CHECK-CMDLINE-OVERRIDE-OUT: Running in quick mode +# CHECK-CMDLINE-OVERRIDE-OUT: Running in slow mode + +# CHECK-CMDLINE-OVERRIDE-OUT: PASS: per_test_timeout :: short.py + +# CHECK-CMDLINE-OVERRIDE-OUT: TIMEOUT: per_test_timeout :: slow.py +# CHECK-CMDLINE-OVERRIDE-OUT: Timeout: Reached timeout of 2 seconds +# CHECK-CMDLINE-OVERRIDE-OUT: Command {{([0-9]+ )?}}Output +# CHECK-CMDLINE-OVERRIDE-OUT: Running slow program + +# CHECK-CMDLINE-OVERRIDE-OUT: Expected Passes{{ *}}: 1 +# CHECK-CMDLINE-OVERRIDE-OUT: Individual Timeouts{{ *}}: 3 diff --git a/gnu/llvm/utils/lit/tests/test-data.py b/gnu/llvm/utils/lit/tests/test-data.py new file mode 100644 index 00000000000..54909d7338e --- /dev/null +++ b/gnu/llvm/utils/lit/tests/test-data.py @@ -0,0 +1,12 @@ +# Test features related to formats which support reporting additional test data. + +# RUN: %{lit} -j 1 -v %{inputs}/test-data > %t.out +# RUN: FileCheck < %t.out %s + +# CHECK: -- Testing: + +# CHECK: PASS: test-data :: metrics.ini +# CHECK-NEXT: *** TEST 'test-data :: metrics.ini' RESULTS *** +# CHECK-NEXT: value0: 1 +# CHECK-NEXT: value1: 2.3456 +# CHECK-NEXT: *** diff --git a/gnu/llvm/utils/lit/tests/test-output.py b/gnu/llvm/utils/lit/tests/test-output.py new file mode 100644 index 00000000000..a50442741b9 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/test-output.py @@ -0,0 +1,19 @@ +# RUN: %{lit} -j 1 -v %{inputs}/test-data --output %t.results.out > %t.out +# RUN: FileCheck < %t.results.out %s + +# CHECK: { +# CHECK: "__version__" +# CHECK: "elapsed" +# CHECK-NEXT: "tests": [ +# CHECK-NEXT: { +# CHECK-NEXT: "code": "PASS", +# CHECK-NEXT: "elapsed": {{[0-9.]+}}, +# CHECK-NEXT: "metrics": { +# CHECK-NEXT: "value0": 1, +# CHECK-NEXT: "value1": 2.3456 +# CHECK-NEXT: } +# CHECK-NEXT: "name": "test-data :: metrics.ini", +# CHECK-NEXT: "output": "Test passed." +# CHECK-NEXT: } +# CHECK-NEXT: ] +# CHECK-NEXT: } diff --git a/gnu/llvm/utils/lit/tests/unittest-adaptor.py b/gnu/llvm/utils/lit/tests/unittest-adaptor.py new file mode 100644 index 00000000000..0848cd22baa --- /dev/null +++ b/gnu/llvm/utils/lit/tests/unittest-adaptor.py @@ -0,0 +1,18 @@ +# Check the lit adaption to run under unittest. +# +# RUN: %{python} %s %{inputs}/unittest-adaptor 2> %t.err +# RUN: FileCheck < %t.err %s +# +# CHECK-DAG: unittest-adaptor :: test-two.txt ... FAIL +# CHECK-DAG: unittest-adaptor :: test-one.txt ... ok + +import unittest +import sys + +import lit +import lit.discovery + +input_path = sys.argv[1] +unittest_suite = lit.discovery.load_test_suite([input_path]) +runner = unittest.TextTestRunner(verbosity=2) +runner.run(unittest_suite) diff --git a/gnu/llvm/utils/lit/tests/usage.py b/gnu/llvm/utils/lit/tests/usage.py new file mode 100644 index 00000000000..e10d6134a03 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/usage.py @@ -0,0 +1,6 @@ +# Basic sanity check that usage works. +# +# RUN: %{lit} --help > %t.out +# RUN: FileCheck < %t.out %s +# +# CHECK: Usage: lit.py [options] {file-or-path} diff --git a/gnu/llvm/utils/lit/tests/xunit-output.py b/gnu/llvm/utils/lit/tests/xunit-output.py new file mode 100644 index 00000000000..3f493953637 --- /dev/null +++ b/gnu/llvm/utils/lit/tests/xunit-output.py @@ -0,0 +1,10 @@ +# Check xunit output +# RUN: %{lit} --xunit-xml-output %t.xunit.xml %{inputs}/test-data +# RUN: FileCheck < %t.xunit.xml %s + +# CHECK: <?xml version="1.0" encoding="UTF-8" ?> +# CHECK: <testsuites> +# CHECK: <testsuite name='test-data' tests='1' failures='0'> +# CHECK: <testcase classname='test-data.test-data' name='metrics.ini' time='0.{{[0-9]+}}'/> +# CHECK: </testsuite> +# CHECK: </testsuites> |