xref: /aosp_15_r20/external/ltp/include/tst_timer_test.h (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) 2017 Cyril Hrubis <[email protected]>
4*49cdfc7eSAndroid Build Coastguard Worker  */
5*49cdfc7eSAndroid Build Coastguard Worker 
6*49cdfc7eSAndroid Build Coastguard Worker  /*
7*49cdfc7eSAndroid Build Coastguard Worker 
8*49cdfc7eSAndroid Build Coastguard Worker     Timer measuring library.
9*49cdfc7eSAndroid Build Coastguard Worker 
10*49cdfc7eSAndroid Build Coastguard Worker     The test is supposed to define sampling function and set it in the tst_test
11*49cdfc7eSAndroid Build Coastguard Worker     structure the rest of the work is then done by the library.
12*49cdfc7eSAndroid Build Coastguard Worker 
13*49cdfc7eSAndroid Build Coastguard Worker     int sample(int clk_id, long long usec)
14*49cdfc7eSAndroid Build Coastguard Worker     {
15*49cdfc7eSAndroid Build Coastguard Worker 	// Any setup done here
16*49cdfc7eSAndroid Build Coastguard Worker 
17*49cdfc7eSAndroid Build Coastguard Worker 	tst_timer_start(clk_id);
18*49cdfc7eSAndroid Build Coastguard Worker 	// Call that is being measured sleeps for usec
19*49cdfc7eSAndroid Build Coastguard Worker 	tst_timer_stop();
20*49cdfc7eSAndroid Build Coastguard Worker 	tst_timer_sample();
21*49cdfc7eSAndroid Build Coastguard Worker 
22*49cdfc7eSAndroid Build Coastguard Worker 	// Any cleanup done here
23*49cdfc7eSAndroid Build Coastguard Worker 
24*49cdfc7eSAndroid Build Coastguard Worker 	// Non-zero return exits the test
25*49cdfc7eSAndroid Build Coastguard Worker     }
26*49cdfc7eSAndroid Build Coastguard Worker 
27*49cdfc7eSAndroid Build Coastguard Worker     struct tst_test test = {
28*49cdfc7eSAndroid Build Coastguard Worker 	.scall = "syscall_name()",
29*49cdfc7eSAndroid Build Coastguard Worker 	.sample = sample,
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 #ifndef TST_TIMER_TEST__
35*49cdfc7eSAndroid Build Coastguard Worker #define TST_TIMER_TEST__
36*49cdfc7eSAndroid Build Coastguard Worker 
37*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
38*49cdfc7eSAndroid Build Coastguard Worker #include "tst_timer.h"
39*49cdfc7eSAndroid Build Coastguard Worker 
40*49cdfc7eSAndroid Build Coastguard Worker void tst_timer_sample(void);
41*49cdfc7eSAndroid Build Coastguard Worker 
42*49cdfc7eSAndroid Build Coastguard Worker # ifdef TST_NO_DEFAULT_MAIN
43*49cdfc7eSAndroid Build Coastguard Worker struct tst_test *tst_timer_test_setup(struct tst_test *test);
44*49cdfc7eSAndroid Build Coastguard Worker # endif /* TST_NO_DEFAULT_MAIN */
45*49cdfc7eSAndroid Build Coastguard Worker #endif /* TST_TIMER_TEST__ */
46