xref: /third_party/ltp/lib/newlib_tests/variant.c (revision f08c3bdf)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Copyright (c) 2019 Cyril Hrubis <chrubis@suse.cz>
4 */
5
6#include "tst_test.h"
7
8static void do_test(void)
9{
10	switch (tst_variant) {
11	case 0:
12		/* This is skipped after first iteration */
13		tst_brk(TCONF, "Test skipped");
14	break;
15	case 1:
16		/* This test is correctly looped with -i opt */
17		tst_res(TPASS, "Test passed");
18	break;
19	case 2:
20		/* This exits the test immediately */
21		tst_brk(TBROK, "Test broken");
22	break;
23	}
24
25	tst_res(TINFO, "test() function exiting normally");
26}
27
28static void setup(void)
29{
30	tst_res(TINFO, "Running test setup()");
31
32	switch (tst_variant) {
33	case 0:
34		tst_res(TINFO, "Starting tst_brk(TCONF) test");
35	break;
36	case 1:
37		tst_res(TINFO, "Starting tst_res(TPASS) test");
38	break;
39	case 2:
40		tst_res(TINFO, "Starting tst_brk(TBROK) test");
41	break;
42	}
43}
44
45static void cleanup(void)
46{
47	tst_res(TINFO, "Running test cleanup()");
48}
49
50static struct tst_test test = {
51	.test_all = do_test,
52	.test_variants = 3,
53	.setup = setup,
54	.cleanup = cleanup,
55};
56