xref: /aosp_15_r20/external/ltp/lib/newlib_tests/test07.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1*49cdfc7eSAndroid Build Coastguard Worker // SPDX-License-Identifier: GPL-2.0-or-later
2*49cdfc7eSAndroid Build Coastguard Worker /*
3*49cdfc7eSAndroid Build Coastguard Worker  * Copyright (c) 2016 Cyril Hrubis <[email protected]>
4*49cdfc7eSAndroid Build Coastguard Worker  */
5*49cdfc7eSAndroid Build Coastguard Worker 
6*49cdfc7eSAndroid Build Coastguard Worker /*
7*49cdfc7eSAndroid Build Coastguard Worker  * Test for result propagation.
8*49cdfc7eSAndroid Build Coastguard Worker  */
9*49cdfc7eSAndroid Build Coastguard Worker 
10*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
11*49cdfc7eSAndroid Build Coastguard Worker 
setup(void)12*49cdfc7eSAndroid Build Coastguard Worker static void setup(void)
13*49cdfc7eSAndroid Build Coastguard Worker {
14*49cdfc7eSAndroid Build Coastguard Worker 	tst_res(TINFO, "setup() executed by pid %i", getpid());
15*49cdfc7eSAndroid Build Coastguard Worker }
16*49cdfc7eSAndroid Build Coastguard Worker 
cleanup(void)17*49cdfc7eSAndroid Build Coastguard Worker static void cleanup(void)
18*49cdfc7eSAndroid Build Coastguard Worker {
19*49cdfc7eSAndroid Build Coastguard Worker 	tst_res(TINFO, "cleanup() executed by pid %i", getpid());
20*49cdfc7eSAndroid Build Coastguard Worker }
21*49cdfc7eSAndroid Build Coastguard Worker 
do_test(void)22*49cdfc7eSAndroid Build Coastguard Worker static void do_test(void)
23*49cdfc7eSAndroid Build Coastguard Worker {
24*49cdfc7eSAndroid Build Coastguard Worker 	unsigned int i;
25*49cdfc7eSAndroid Build Coastguard Worker 
26*49cdfc7eSAndroid Build Coastguard Worker 	for (i = 0; i < 100; i++) {
27*49cdfc7eSAndroid Build Coastguard Worker 		if (SAFE_FORK() == 0) {
28*49cdfc7eSAndroid Build Coastguard Worker 			tst_res(TPASS, "Child (%i)", getpid());
29*49cdfc7eSAndroid Build Coastguard Worker 			return;
30*49cdfc7eSAndroid Build Coastguard Worker 		}
31*49cdfc7eSAndroid Build Coastguard Worker 	}
32*49cdfc7eSAndroid Build Coastguard Worker }
33*49cdfc7eSAndroid Build Coastguard Worker 
34*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
35*49cdfc7eSAndroid Build Coastguard Worker 	.test_all = do_test,
36*49cdfc7eSAndroid Build Coastguard Worker 	.setup = setup,
37*49cdfc7eSAndroid Build Coastguard Worker 	.cleanup = cleanup,
38*49cdfc7eSAndroid Build Coastguard Worker 	.forks_child = 1,
39*49cdfc7eSAndroid Build Coastguard Worker };
40