summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2017-12-17 08:42:21 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2017-12-17 08:42:21 +0100
commitb227e47b1f7bf4a1adcfea823e2efc7be40d171b (patch)
tree0cef947028e9690d64dd559639f300c73e7ba832
parentd8953ce923ec3bee1b0e4459e737e315472ec808 (diff)
rename librt test, add tst-posix_spawn
-rw-r--r--test/.gitignore3
-rw-r--r--test/librt/Makefile.in8
-rw-r--r--test/rt/Makefile (renamed from test/librt/Makefile)0
-rw-r--r--test/rt/Makefile.in7
-rw-r--r--test/rt/tst-posix_spawn.c48
-rw-r--r--test/rt/tst-shm.c (renamed from test/librt/shmtest.c)0
6 files changed, 57 insertions, 9 deletions
diff --git a/test/.gitignore b/test/.gitignore
index 0d19285..b1370ac 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -51,7 +51,8 @@ inet/tst-network
inet/tst-ntoa
inet/tst-res
inet/tst-sock-nonblock
-librt/shmtest
+rt/tst-shm
+rt/tst-posix_spawn
locale/bug-iconv-trans
locale/bug-usesetlocale
locale/C
diff --git a/test/librt/Makefile.in b/test/librt/Makefile.in
deleted file mode 100644
index b2a829d..0000000
--- a/test/librt/Makefile.in
+++ /dev/null
@@ -1,8 +0,0 @@
-# uClibc-ng shm tests
-# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
-
-LDFLAGS_shmtest := -lrt
-
-ifeq ($(ARCH_USE_MMU),)
-TESTS_DISABLED := shmtest
-endif
diff --git a/test/librt/Makefile b/test/rt/Makefile
index 1021afe..1021afe 100644
--- a/test/librt/Makefile
+++ b/test/rt/Makefile
diff --git a/test/rt/Makefile.in b/test/rt/Makefile.in
new file mode 100644
index 0000000..38a7b5a
--- /dev/null
+++ b/test/rt/Makefile.in
@@ -0,0 +1,7 @@
+# uClibc-ng realtime tests
+# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+
+LDFLAGS_tst-shm := -lrt
+TESTS_DISABLED := tst-shm
+
+OPTS_tst-posix_spawn := ls
diff --git a/test/rt/tst-posix_spawn.c b/test/rt/tst-posix_spawn.c
new file mode 100644
index 0000000..28b6500
--- /dev/null
+++ b/test/rt/tst-posix_spawn.c
@@ -0,0 +1,48 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <unistd.h>
+#include <spawn.h>
+#include <sys/wait.h>
+
+extern char **environ;
+
+void run_cmd(char *cmd)
+{
+ pid_t pid;
+ posix_spawnattr_t attrs;
+ posix_spawn_file_actions_t actions;
+ sigset_t defsignals;
+ char *argv[] = {"sh", "-c", cmd, NULL};
+ int status;
+
+ sigemptyset(&defsignals);
+ sigaddset(&defsignals, SIGTERM);
+ sigaddset(&defsignals, SIGCHLD);
+ sigaddset(&defsignals, SIGPIPE);
+
+ posix_spawnattr_init(&attrs);
+ posix_spawnattr_setflags(&attrs, POSIX_SPAWN_SETPGROUP | POSIX_SPAWN_SETSIGDEF);
+ posix_spawnattr_setpgroup(&attrs, 0);
+ posix_spawnattr_setsigdefault(&attrs, &defsignals);
+
+ printf("Run command: %s\n", cmd);
+ status = posix_spawn(&pid, "/bin/sh", &actions, &attrs, argv, environ);
+ if (status == 0) {
+ printf("Child pid: %i\n", pid);
+ if (waitpid(pid, &status, 0) != -1) {
+ printf("Child exited with status %i\n", status);
+ } else {
+ perror("waitpid");
+ }
+ } else {
+ printf("posix_spawn: %s\n", strerror(status));
+ }
+}
+
+int main(int argc, char* argv[])
+{
+ run_cmd(argv[1]);
+ return 0;
+}
diff --git a/test/librt/shmtest.c b/test/rt/tst-shm.c
index a14302d..a14302d 100644
--- a/test/librt/shmtest.c
+++ b/test/rt/tst-shm.c