The comment says that it would be enough to just trigger the chain of
events. This test did not even fail if the binary to execute was not
there, not sure how much of the chain was exercised.
This patch makes the parent wait for what actually happens and should
return errors, should they happen. It prepares for another patch using
fork/exec.

Signed-off-by: Henning Schild <[email protected]>
---
 testsuite/smokey/posix-fork/posix-fork.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/testsuite/smokey/posix-fork/posix-fork.c 
b/testsuite/smokey/posix-fork/posix-fork.c
index 8a44510b3..d88ac527d 100644
--- a/testsuite/smokey/posix-fork/posix-fork.c
+++ b/testsuite/smokey/posix-fork/posix-fork.c
@@ -10,6 +10,8 @@
 #include <unistd.h>
 #include <errno.h>
 #include <error.h>
+#include <sys/types.h>
+#include <sys/wait.h>
 #include <xeno_config.h>
 #include <boilerplate/libc.h>
 #include <smokey/smokey.h>
@@ -37,9 +39,11 @@ smokey_test_plugin(posix_fork,
  */
 static int run_posix_fork(struct smokey_test *t, int argc, char *const argv[])
 {
-       struct timespec req;
+       int wstatus = 0;
+       pid_t pid;
 
-       switch (do_fork()) {
+       pid = do_fork();
+       switch (pid) {
        case -1:
                error(1, errno, "fork/vfork");
        case 0:
@@ -48,12 +52,17 @@ static int run_posix_fork(struct smokey_test *t, int argc, 
char *const argv[])
                 * enough for creating a shadow context.
                 */
                execl(XENO_TEST_DIR "/smokey", "smokey", NULL);
-               _exit(99);
+               error(1, errno, "execl %s/smokey", XENO_TEST_DIR);
        default:
-               req.tv_sec = 0;
-               req.tv_nsec = 20000000;
-               clock_nanosleep(CLOCK_MONOTONIC, 0, &req, NULL);
+               waitpid(pid, &wstatus, 0);
        }
 
-       return 0;
+       if WIFEXITED(wstatus)
+               return WEXITSTATUS(wstatus);
+
+       if WIFSIGNALED(wstatus)
+               fprintf(stderr, "%s %s\n",
+                       strsignal(WTERMSIG(wstatus)),
+                       WCOREDUMP(wstatus) ? "(core dumped)" : "");
+       return 1;
 }
-- 
2.16.1


_______________________________________________
Xenomai mailing list
[email protected]
https://xenomai.org/mailman/listinfo/xenomai

Reply via email to