aboutsummaryrefslogtreecommitdiff
path: root/tests/process-term/driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/process-term/driver.cxx')
-rw-r--r--tests/process-term/driver.cxx56
1 files changed, 23 insertions, 33 deletions
diff --git a/tests/process-term/driver.cxx b/tests/process-term/driver.cxx
index 0e92c2b..799757c 100644
--- a/tests/process-term/driver.cxx
+++ b/tests/process-term/driver.cxx
@@ -10,9 +10,6 @@
# include <libbutl/win32-utility.hxx>
#endif
-#include <cassert>
-
-#ifndef __cpp_lib_modules_ts
#include <string>
#include <cerrno> // ERANGE
#include <utility> // move()
@@ -23,23 +20,13 @@
#ifndef _WIN32
# include <chrono>
#endif
-#endif
-// Other includes.
+#include <libbutl/process.hxx>
+#include <libbutl/optional.hxx>
+#include <libbutl/fdstream.hxx>
-#ifdef __cpp_modules_ts
-#ifdef __cpp_lib_modules_ts
-import std.core;
-import std.io;
-#endif
-import butl.process;
-import butl.optional;
-import butl.fdstream;
-#else
-#include <libbutl/process.mxx>
-#include <libbutl/optional.mxx>
-#include <libbutl/fdstream.mxx>
-#endif
+#undef NDEBUG
+#include <cassert>
using namespace std;
using namespace butl;
@@ -98,6 +85,7 @@ main (int argc, const char* argv[])
assert (!s.empty ());
char* e (nullptr);
+ errno = 0; // We must clear it according to POSIX.
uint64_t r (strtoull (s.c_str (), &e, 10)); // Can't throw.
assert (errno != ERANGE && e == s.c_str () + s.size ());
@@ -224,9 +212,9 @@ main (int argc, const char* argv[])
//
{
fdpipe pipe (fdopen_pipe ());
- process p (process_start (0, pipe, 2, argv[0], "-s", 10, "-e"));
+ process p (process_start (0, pipe, 2, argv[0], "-s", 60, "-e"));
- sleep (2); // Give the child some time to initialize.
+ sleep (3); // Give the child some time to initialize.
p.term ();
assert (test_out (move (pipe), ""));
@@ -243,9 +231,9 @@ main (int argc, const char* argv[])
{
fdpipe pipe (fdopen_pipe ());
process p (process_start (0, pipe, 2,
- argv[0], "-s", 10, "-t", "exit", "-e", "-c", 5));
+ argv[0], "-s", 60, "-t", "exit", "-e", "-c", 5));
- sleep (2); // Give the child some time to initialize.
+ sleep (3); // Give the child some time to initialize.
p.term ();
assert (test_out (move (pipe), "exiting"));
@@ -262,9 +250,9 @@ main (int argc, const char* argv[])
fdpipe pipe (fdopen_pipe ());
process p (
process_start (0, pipe, 2,
- argv[0], "-s", 10, "-t", "default", "-e", "-c", 5));
+ argv[0], "-s", 60, "-t", "default", "-e", "-c", 5));
- sleep (2); // Give the child some time to initialize.
+ sleep (3); // Give the child some time to initialize.
p.term ();
assert (test_out (move (pipe), ""));
@@ -280,9 +268,9 @@ main (int argc, const char* argv[])
{
fdpipe pipe (fdopen_pipe ());
process p (process_start (0, pipe, 2,
- argv[0], "-s", 10, "-t", "ignore", "-e"));
+ argv[0], "-s", 60, "-t", "ignore", "-e"));
- sleep (2); // Give the child some time to initialize.
+ sleep (3); // Give the child some time to initialize.
p.term ();
assert (!p.timed_wait (chrono::seconds (1)));
@@ -303,7 +291,7 @@ main (int argc, const char* argv[])
fdpipe pipe (fdopen_pipe ());
process p (process_start (0, pipe, 2, argv[0], "-s", 0, "-c", 5));
- sleep (4);
+ sleep (4); // Give the child some time to terminate.
p.term ();
assert (test_out (move (pipe), ""));
@@ -318,7 +306,7 @@ main (int argc, const char* argv[])
//
{
fdpipe pipe (fdopen_pipe ());
- process p (process_start (0, pipe, 2, argv[0], "-s", 10));
+ process p (process_start (0, pipe, 2, argv[0], "-s", 60));
p.term ();
p.term ();
@@ -334,7 +322,7 @@ main (int argc, const char* argv[])
//
{
fdpipe pipe (fdopen_pipe ());
- process p (process_start (0, pipe, 2, argv[0], "-s", 10));
+ process p (process_start (0, pipe, 2, argv[0], "-s", 60));
p.term ();
p.kill ();
@@ -351,7 +339,7 @@ main (int argc, const char* argv[])
//
{
fdpipe pipe (fdopen_pipe ());
- process p (process_start (0, pipe, 2, argv[0], "-s", 10));
+ process p (process_start (0, pipe, 2, argv[0], "-s", 60));
p.kill ();
p.kill ();
@@ -368,8 +356,9 @@ main (int argc, const char* argv[])
//
{
fdpipe pipe (fdopen_pipe ());
- process p (process_start (0, pipe, 2, argv[0], "-s", 10, "-e"));
+ process p (process_start (0, pipe, 2, argv[0], "-s", 60, "-e"));
+ sleep (3); // Give the child some time to initialize.
p.term ();
assert (test_out (move (pipe), ""));
@@ -383,8 +372,9 @@ main (int argc, const char* argv[])
//
{
fdpipe pipe (fdopen_pipe ());
- process p (process_start (0, pipe, 2, argv[0], "-s", 10, "-e"));
+ process p (process_start (0, pipe, 2, argv[0], "-s", 60, "-e"));
+ sleep (3); // Give the child some time to initialize.
p.kill ();
assert (test_out (move (pipe), ""));
@@ -400,7 +390,7 @@ main (int argc, const char* argv[])
fdpipe pipe (fdopen_pipe ());
process p (process_start (0, pipe, 2, argv[0], "-s", 0, "-c", 5));
- sleep (4);
+ sleep (4); // Give the child some time to terminate.
p.kill ();
assert (test_out (move (pipe), ""));