1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2023 Petr Vorel <[email protected]>
4 */
5
6 /*
7 * Test tst_res() flags.
8 */
9
10 #include "tst_test.h"
11
12 #define FLAG(x) .flag = x, .str = #x
13 static struct tcase {
14 int flag;
15 const char *str;
16 const char *note;
17 } tcases[] = {
18 {FLAG(TPASS)},
19 {FLAG(TFAIL)},
20 {FLAG(TBROK)},
21 {FLAG(TCONF)},
22 {FLAG(TWARN)},
23 {FLAG(TINFO)},
24 {FLAG(TDEBUG), " (printed only with -D or LTP_ENABLE_DEBUG=1)"},
25 };
26
do_cleanup(void)27 static void do_cleanup(void)
28 {
29 tst_brk(TBROK, "TBROK message should be TWARN in cleanup");
30 }
31
do_test(void)32 static void do_test(void)
33 {
34 size_t i;
35
36 for (i = 0; i < ARRAY_SIZE(tcases); i++)
37 tst_res(tcases[i].flag, "%s message%s", tcases[i].str,
38 tcases[i].note ?: "");
39 }
40
41 static struct tst_test test = {
42 .test_all = do_test,
43 .cleanup = do_cleanup,
44 };
45