aboutsummaryrefslogtreecommitdiff
path: root/tests/test/simple/generated
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-10-10 17:22:46 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-11-06 19:32:09 +0300
commitf41599c8e9435f3dfec60b872c2b4ae31177efdd (patch)
tree088f8d9bf906e4a2ed734e034699163c9ccc7306 /tests/test/simple/generated
parentac76a4fd2afff48a0d5db84592babe5cabef3a2c (diff)
Add support for test timeouts
Diffstat (limited to 'tests/test/simple/generated')
-rw-r--r--tests/test/simple/generated/buildfile3
-rw-r--r--tests/test/simple/generated/driver.cxx32
-rw-r--r--tests/test/simple/generated/testscript57
3 files changed, 89 insertions, 3 deletions
diff --git a/tests/test/simple/generated/buildfile b/tests/test/simple/generated/buildfile
index 0809bdf..0344891 100644
--- a/tests/test/simple/generated/buildfile
+++ b/tests/test/simple/generated/buildfile
@@ -6,4 +6,5 @@
./: testscript exe{driver} $b file{*.in}
-exe{driver}: cxx{driver}
+import libs = libbutl%lib{butl}
+exe{driver}: cxx{driver} $libs
diff --git a/tests/test/simple/generated/driver.cxx b/tests/test/simple/generated/driver.cxx
index 1d911df..18fd0ae 100644
--- a/tests/test/simple/generated/driver.cxx
+++ b/tests/test/simple/generated/driver.cxx
@@ -1,24 +1,52 @@
// file : tests/test/simple/generated/driver.cxx -*- C++ -*-
// license : MIT; see accompanying LICENSE file
+#ifndef _WIN32
+# include <chrono>
+# include <thread>
+#else
+# include <libbutl/win32-utility.hxx>
+#endif
+
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
+// If the -s option is specified, then also sleep for 5 seconds.
+//
int
main (int argc, char* argv[])
{
+ int i (1);
+ for (; i != argc; ++i)
+ {
+ string a (argv[i]);
+
+ if (a == "-s")
+ {
+ // MINGW GCC 4.9 doesn't implement this_thread so use Win32 Sleep().
+ //
+#ifndef _WIN32
+ this_thread::sleep_for (chrono::seconds (5));
+#else
+ Sleep (5000);
+#endif
+ }
+ else
+ break;
+ }
+
int r (0);
- if (argc == 1)
+ if (i == argc)
{
cout << "1.2.3" << endl;
}
else
{
- ifstream ifs (argv[1]);
+ ifstream ifs (argv[i]);
if (!ifs.is_open ())
cerr << "unable to open " << argv[1] << endl;
diff --git a/tests/test/simple/generated/testscript b/tests/test/simple/generated/testscript
index a04dccc..f6a89d8 100644
--- a/tests/test/simple/generated/testscript
+++ b/tests/test/simple/generated/testscript
@@ -42,3 +42,60 @@ driver = $src_root/../exe{driver}
./: file{output}: test.stdout = true
file{output}: in{output} $src_root/manifest #@@ in module
EOI
+
+: timeout
+:
+{
+ : operation
+ :
+ {
+ : no-output
+ :
+ ln -s $src_base/output.in ./;
+ $* config.test.timeout=1 <<EOI 2>>/~%EOE% != 0
+ driver = $src_root/../exe{driver}
+ ./: test = $driver
+ ./: test.options = -s
+ ./: $driver
+ EOI
+ error: test dir{./} failed
+ % error: .+ -s terminated: execution timeout expired%
+ % info: test command line: .+%
+ EOE
+
+ : output
+ :
+ ln -s $src_base/output.in ./;
+ $* config.test.timeout=1 &output &output.d <<EOI 2>>/~%EOE% != 0
+ driver = $src_root/../exe{driver}
+ ./: test = $driver
+ ./: test.options = -s
+ ./: $driver
+ ./: file{output}: test.stdout = true
+ file{output}: in{output} $src_root/manifest #@@ in module
+ EOI
+ error: test dir{./} failed
+ % error: diff .+ terminated: execution timeout expired%
+ % error: .+ -s terminated: execution timeout expired%
+ % info: test command line: .+%
+ EOE
+ }
+
+ : test
+ :
+ {
+ : no-output
+ :
+ ln -s $src_base/output.in ./;
+ $* config.test.timeout=/1 <<EOI 2>>/~%EOE% != 0
+ driver = $src_root/../exe{driver}
+ ./: test = $driver
+ ./: test.options = -s
+ ./: $driver
+ EOI
+ error: test dir{./} failed
+ % error: .+ -s terminated: execution timeout expired%
+ % info: test command line: .+%
+ EOE
+ }
+}