aboutsummaryrefslogtreecommitdiff
path: root/utils/lit/tests/Inputs
diff options
context:
space:
mode:
Diffstat (limited to 'utils/lit/tests/Inputs')
-rwxr-xr-xutils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest35
-rw-r--r--utils/lit/tests/Inputs/googletest-timeout/lit.cfg9
-rw-r--r--utils/lit/tests/Inputs/shtest-timeout/infinite_loop.py10
-rw-r--r--utils/lit/tests/Inputs/shtest-timeout/lit.cfg32
-rw-r--r--utils/lit/tests/Inputs/shtest-timeout/quick_then_slow.py24
-rw-r--r--utils/lit/tests/Inputs/shtest-timeout/short.py6
-rw-r--r--utils/lit/tests/Inputs/shtest-timeout/slow.py9
7 files changed, 125 insertions, 0 deletions
diff --git a/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest b/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest
new file mode 100755
index 0000000000000..f3a90ff4cd675
--- /dev/null
+++ b/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/utils/lit/tests/Inputs/googletest-timeout/lit.cfg b/utils/lit/tests/Inputs/googletest-timeout/lit.cfg
new file mode 100644
index 0000000000000..bf8a4db2bf90e
--- /dev/null
+++ b/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/utils/lit/tests/Inputs/shtest-timeout/infinite_loop.py b/utils/lit/tests/Inputs/shtest-timeout/infinite_loop.py
new file mode 100644
index 0000000000000..55720479d3331
--- /dev/null
+++ b/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/utils/lit/tests/Inputs/shtest-timeout/lit.cfg b/utils/lit/tests/Inputs/shtest-timeout/lit.cfg
new file mode 100644
index 0000000000000..81b4a12120d88
--- /dev/null
+++ b/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/utils/lit/tests/Inputs/shtest-timeout/quick_then_slow.py b/utils/lit/tests/Inputs/shtest-timeout/quick_then_slow.py
new file mode 100644
index 0000000000000..b81fbe5a8bfe5
--- /dev/null
+++ b/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/utils/lit/tests/Inputs/shtest-timeout/short.py b/utils/lit/tests/Inputs/shtest-timeout/short.py
new file mode 100644
index 0000000000000..424b7092d8392
--- /dev/null
+++ b/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/utils/lit/tests/Inputs/shtest-timeout/slow.py b/utils/lit/tests/Inputs/shtest-timeout/slow.py
new file mode 100644
index 0000000000000..2dccd6331360b
--- /dev/null
+++ b/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)