xref: /aosp_15_r20/external/ltp/lib/newlib_tests/test_runtime01.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) 2018, Linux Test Project
4*49cdfc7eSAndroid Build Coastguard Worker  *
5*49cdfc7eSAndroid Build Coastguard Worker  * Runs for 4 seconds for each test iteration.
6*49cdfc7eSAndroid Build Coastguard Worker  */
7*49cdfc7eSAndroid Build Coastguard Worker #include <stdlib.h>
8*49cdfc7eSAndroid Build Coastguard Worker #include <unistd.h>
9*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
10*49cdfc7eSAndroid Build Coastguard Worker 
run(void)11*49cdfc7eSAndroid Build Coastguard Worker static void run(void)
12*49cdfc7eSAndroid Build Coastguard Worker {
13*49cdfc7eSAndroid Build Coastguard Worker 	int runtime;
14*49cdfc7eSAndroid Build Coastguard Worker 
15*49cdfc7eSAndroid Build Coastguard Worker 	tst_res(TINFO, "Running variant %i", tst_variant);
16*49cdfc7eSAndroid Build Coastguard Worker 
17*49cdfc7eSAndroid Build Coastguard Worker 	do {
18*49cdfc7eSAndroid Build Coastguard Worker 		runtime = tst_remaining_runtime();
19*49cdfc7eSAndroid Build Coastguard Worker 		tst_res(TINFO, "Remaining runtime %d", runtime);
20*49cdfc7eSAndroid Build Coastguard Worker 		sleep(1);
21*49cdfc7eSAndroid Build Coastguard Worker 	} while (runtime);
22*49cdfc7eSAndroid Build Coastguard Worker 
23*49cdfc7eSAndroid Build Coastguard Worker 	tst_res(TPASS, "Finished loop!");
24*49cdfc7eSAndroid Build Coastguard Worker }
25*49cdfc7eSAndroid Build Coastguard Worker 
26*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
27*49cdfc7eSAndroid Build Coastguard Worker 	.test_all = run,
28*49cdfc7eSAndroid Build Coastguard Worker 	.max_runtime = 4,
29*49cdfc7eSAndroid Build Coastguard Worker 	.test_variants = 2,
30*49cdfc7eSAndroid Build Coastguard Worker };
31