summaryrefslogtreecommitdiffstats
path: root/test/lib/test-process-sync.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/test-process-sync.c')
-rw-r--r--test/lib/test-process-sync.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/lib/test-process-sync.c b/test/lib/test-process-sync.c
new file mode 100644
index 0000000..b47bdc6
--- /dev/null
+++ b/test/lib/test-process-sync.c
@@ -0,0 +1,47 @@
+
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include <process/process.h>
+#include <waiter/waiter.h>
+#include <talloc/talloc.h>
+
+static int do_child(void)
+{
+ return 42;
+}
+
+int main(int argc, char **argv)
+{
+ struct waitset *waitset;
+ struct process *process;
+ const char *child_argv[3];
+ void *ctx;
+
+ if (argc == 2 && !strcmp(argv[1], "child"))
+ return do_child();
+
+ ctx = talloc_new(NULL);
+
+ waitset = waitset_create(ctx);
+
+ process_init(ctx, waitset);
+
+ child_argv[0] = argv[0];
+ child_argv[1] = "child";
+ child_argv[2] = NULL;
+
+ process = process_create(ctx);
+ process->path = child_argv[0];
+ process->argv = child_argv;
+
+ process_run_sync(process);
+
+ assert(WIFEXITED(process->exit_status));
+ assert(WEXITSTATUS(process->exit_status) == 42);
+
+ talloc_free(ctx);
+
+ return EXIT_SUCCESS;
+}
OpenPOWER on IntegriCloud