Skip to content

Commit b903d45

Browse files
committed
testsuite: consolidate final exit() call
Currently we call exit() in a handful of places within test_run_child(). Where the latter is annotated as `noreturn int` and we never check the return value. Just move the exit() further up the call stack and remove the noreturn notation. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
1 parent 2b0496e commit b903d45

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

testsuite/testsuite.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ static void test_export_environ(const struct test *t)
227227
setenv(env->key, env->val, 1);
228228
}
229229

230-
static noreturn inline int test_run_child(const struct test *t, int fdout[2],
231-
int fderr[2], int fdmonitor[2])
230+
static inline int test_run_child(const struct test *t, int fdout[2], int fderr[2],
231+
int fdmonitor[2])
232232
{
233233
/* kill child if parent dies */
234234
prctl(PR_SET_PDEATHSIG, SIGTERM);
@@ -240,15 +240,15 @@ static noreturn inline int test_run_child(const struct test *t, int fdout[2],
240240
close(fdout[0]);
241241
if (dup2(fdout[1], STDOUT_FILENO) < 0) {
242242
ERR("could not redirect stdout to pipe: %m\n");
243-
exit(EXIT_FAILURE);
243+
return EXIT_FAILURE;
244244
}
245245
}
246246

247247
if (t->output.err != NULL) {
248248
close(fderr[0]);
249249
if (dup2(fderr[1], STDERR_FILENO) < 0) {
250250
ERR("could not redirect stderr to pipe: %m\n");
251-
exit(EXIT_FAILURE);
251+
return EXIT_FAILURE;
252252
}
253253
}
254254

@@ -261,22 +261,22 @@ static noreturn inline int test_run_child(const struct test *t, int fdout[2],
261261

262262
if (stat(stamp, &stampst) != 0) {
263263
ERR("could not stat %s\n - %m", stamp);
264-
exit(EXIT_FAILURE);
264+
return EXIT_FAILURE;
265265
}
266266

267267
if (stat(rootfs, &rootfsst) != 0) {
268268
ERR("could not stat %s\n - %m", rootfs);
269-
exit(EXIT_FAILURE);
269+
return EXIT_FAILURE;
270270
}
271271

272272
if (stat_mstamp(&rootfsst) > stat_mstamp(&stampst)) {
273273
ERR("rootfs %s is dirty, please run 'meson compile testsuite/create-rootfs' before running this test\n",
274274
rootfs);
275-
exit(EXIT_FAILURE);
275+
return EXIT_FAILURE;
276276
}
277277
}
278278

279-
exit(test_spawn_test(t));
279+
return test_spawn_test(t);
280280
}
281281

282282
#define BUFSZ 4096
@@ -1194,5 +1194,5 @@ int test_run(const struct test *t)
11941194
if (pid > 0)
11951195
return test_run_parent(t, fdout, fderr, fdmonitor, pid);
11961196

1197-
test_run_child(t, fdout, fderr, fdmonitor);
1197+
exit(test_run_child(t, fdout, fderr, fdmonitor));
11981198
}

0 commit comments

Comments
 (0)