1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
4 */
5
6 /*
7 * Test that child process that returns to test library code is reported.
8 */
9
10 #include "tst_test.h"
11
setup(void)12 static void setup(void)
13 {
14 tst_res(TINFO, "setup() executed by pid %i", getpid());
15 }
16
cleanup(void)17 static void cleanup(void)
18 {
19 tst_res(TINFO, "cleanup() executed by pid %i", getpid());
20 }
21
do_test(void)22 static void do_test(void)
23 {
24 pid_t pid = SAFE_FORK();
25
26 switch (pid) {
27 case 0:
28 tst_res(TPASS, "Child (%i) reports", getpid());
29 break;
30 default:
31 tst_res(TPASS, "Parent (%i) reports", getpid());
32 break;
33 }
34 }
35
36 static struct tst_test test = {
37 .test_all = do_test,
38 .setup = setup,
39 .cleanup = cleanup,
40 .forks_child = 1,
41 };
42