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