xref: /aosp_15_r20/external/ltp/lib/newlib_tests/test_runtime02.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) 2021, Linux Test Project
4*49cdfc7eSAndroid Build Coastguard Worker  */
5*49cdfc7eSAndroid Build Coastguard Worker /*
6*49cdfc7eSAndroid Build Coastguard Worker  * This test is set up so that the timeout is not long enough to guarantee
7*49cdfc7eSAndroid Build Coastguard Worker  * enough runtime for two iterations, i.e. the timeout without offset and after
8*49cdfc7eSAndroid Build Coastguard Worker  * scaling is too small and the tests ends up with TBROK.
9*49cdfc7eSAndroid Build Coastguard Worker  *
10*49cdfc7eSAndroid Build Coastguard Worker  * The default timeout in the test library is set to 30 seconds. The test
11*49cdfc7eSAndroid Build Coastguard Worker  * runtime is set to 5 so the test should timeout after 35 seconds.
12*49cdfc7eSAndroid Build Coastguard Worker  */
13*49cdfc7eSAndroid Build Coastguard Worker 
14*49cdfc7eSAndroid Build Coastguard Worker #include <stdlib.h>
15*49cdfc7eSAndroid Build Coastguard Worker #include <unistd.h>
16*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
17*49cdfc7eSAndroid Build Coastguard Worker 
run(void)18*49cdfc7eSAndroid Build Coastguard Worker static void run(void)
19*49cdfc7eSAndroid Build Coastguard Worker {
20*49cdfc7eSAndroid Build Coastguard Worker 	tst_res(TINFO, "Sleeping for 40 seconds");
21*49cdfc7eSAndroid Build Coastguard Worker 	sleep(40);
22*49cdfc7eSAndroid Build Coastguard Worker 	tst_res(TFAIL, "Still alive");
23*49cdfc7eSAndroid Build Coastguard Worker }
24*49cdfc7eSAndroid Build Coastguard Worker 
25*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
26*49cdfc7eSAndroid Build Coastguard Worker 	.test_all = run,
27*49cdfc7eSAndroid Build Coastguard Worker 	.max_runtime = 5,
28*49cdfc7eSAndroid Build Coastguard Worker };
29