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) 2019 Cyril Hrubis <[email protected]>
4*49cdfc7eSAndroid Build Coastguard Worker */
5*49cdfc7eSAndroid Build Coastguard Worker
6*49cdfc7eSAndroid Build Coastguard Worker #include "tst_test.h"
7*49cdfc7eSAndroid Build Coastguard Worker
do_test(void)8*49cdfc7eSAndroid Build Coastguard Worker static void do_test(void)
9*49cdfc7eSAndroid Build Coastguard Worker {
10*49cdfc7eSAndroid Build Coastguard Worker switch (tst_variant) {
11*49cdfc7eSAndroid Build Coastguard Worker case 0:
12*49cdfc7eSAndroid Build Coastguard Worker /* This is skipped after first iteration */
13*49cdfc7eSAndroid Build Coastguard Worker tst_brk(TCONF, "Test skipped");
14*49cdfc7eSAndroid Build Coastguard Worker break;
15*49cdfc7eSAndroid Build Coastguard Worker case 1:
16*49cdfc7eSAndroid Build Coastguard Worker /* This test is correctly looped with -i opt */
17*49cdfc7eSAndroid Build Coastguard Worker tst_res(TPASS, "Test passed");
18*49cdfc7eSAndroid Build Coastguard Worker break;
19*49cdfc7eSAndroid Build Coastguard Worker case 2:
20*49cdfc7eSAndroid Build Coastguard Worker /* This exits the test immediately */
21*49cdfc7eSAndroid Build Coastguard Worker tst_brk(TBROK, "Test broken");
22*49cdfc7eSAndroid Build Coastguard Worker break;
23*49cdfc7eSAndroid Build Coastguard Worker }
24*49cdfc7eSAndroid Build Coastguard Worker
25*49cdfc7eSAndroid Build Coastguard Worker tst_res(TINFO, "test() function exiting normally");
26*49cdfc7eSAndroid Build Coastguard Worker }
27*49cdfc7eSAndroid Build Coastguard Worker
setup(void)28*49cdfc7eSAndroid Build Coastguard Worker static void setup(void)
29*49cdfc7eSAndroid Build Coastguard Worker {
30*49cdfc7eSAndroid Build Coastguard Worker tst_res(TINFO, "Running test setup()");
31*49cdfc7eSAndroid Build Coastguard Worker
32*49cdfc7eSAndroid Build Coastguard Worker switch (tst_variant) {
33*49cdfc7eSAndroid Build Coastguard Worker case 0:
34*49cdfc7eSAndroid Build Coastguard Worker tst_res(TINFO, "Starting tst_brk(TCONF) test");
35*49cdfc7eSAndroid Build Coastguard Worker break;
36*49cdfc7eSAndroid Build Coastguard Worker case 1:
37*49cdfc7eSAndroid Build Coastguard Worker tst_res(TINFO, "Starting tst_res(TPASS) test");
38*49cdfc7eSAndroid Build Coastguard Worker break;
39*49cdfc7eSAndroid Build Coastguard Worker case 2:
40*49cdfc7eSAndroid Build Coastguard Worker tst_res(TINFO, "Starting tst_brk(TBROK) test");
41*49cdfc7eSAndroid Build Coastguard Worker break;
42*49cdfc7eSAndroid Build Coastguard Worker }
43*49cdfc7eSAndroid Build Coastguard Worker }
44*49cdfc7eSAndroid Build Coastguard Worker
cleanup(void)45*49cdfc7eSAndroid Build Coastguard Worker static void cleanup(void)
46*49cdfc7eSAndroid Build Coastguard Worker {
47*49cdfc7eSAndroid Build Coastguard Worker tst_res(TINFO, "Running test cleanup()");
48*49cdfc7eSAndroid Build Coastguard Worker }
49*49cdfc7eSAndroid Build Coastguard Worker
50*49cdfc7eSAndroid Build Coastguard Worker static struct tst_test test = {
51*49cdfc7eSAndroid Build Coastguard Worker .test_all = do_test,
52*49cdfc7eSAndroid Build Coastguard Worker .test_variants = 3,
53*49cdfc7eSAndroid Build Coastguard Worker .setup = setup,
54*49cdfc7eSAndroid Build Coastguard Worker .cleanup = cleanup,
55*49cdfc7eSAndroid Build Coastguard Worker };
56