]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: always exit() from the child process
authorEmil Velikov <emil.l.velikov@gmail.com>
Fri, 13 Jun 2025 16:45:34 +0000 (17:45 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Mon, 16 Jun 2025 12:37:42 +0000 (07:37 -0500)
Update the existing code-paths to always exit() for the child process.
We already handle that in a few places, but the error-paths are
(understandably) off.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/371
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
testsuite/testsuite.c

index 785f45d063024918ffecd37db5e116e15ca350e5..b8cfdfcf4f9425a42903e60d9ce0b52756b8e026 100644 (file)
@@ -140,12 +140,9 @@ static int test_spawn_test(const struct test *t)
        return EXIT_FAILURE;
 }
 
-static int test_run_spawned(const struct test *t)
+static noreturn int test_run_spawned(const struct test *t)
 {
-       int err = t->func();
-       exit(err);
-
-       return EXIT_FAILURE;
+       exit(t->func());
 }
 
 int test_spawn_prog(const char *prog, const char *const args[])
@@ -218,8 +215,8 @@ static void test_export_environ(const struct test *t)
                setenv(env->key, env->val, 1);
 }
 
-static inline int test_run_child(const struct test *t, int fdout[2], int fderr[2],
-                                int fdmonitor[2])
+static noreturn inline int test_run_child(const struct test *t, int fdout[2],
+                                         int fderr[2], int fdmonitor[2])
 {
        /* kill child if parent dies */
        prctl(PR_SET_PDEATHSIG, SIGTERM);
@@ -267,7 +264,7 @@ static inline int test_run_child(const struct test *t, int fdout[2], int fderr[2
                }
        }
 
-       return test_spawn_test(t);
+       exit(test_spawn_test(t));
 }
 
 #define BUFSZ 4096
@@ -1185,5 +1182,5 @@ int test_run(const struct test *t)
        if (pid > 0)
                return test_run_parent(t, fdout, fderr, fdmonitor, pid);
 
-       return test_run_child(t, fdout, fderr, fdmonitor);
+       test_run_child(t, fdout, fderr, fdmonitor);
 }