1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2020 Cyril Hrubis <chrubis@suse.cz>
4 */
5
6 /*
7 * Test TST_EXP_PASS and TST_EXP_PASS_SILENT macro.
8 */
9
10 #include "tst_test.h"
11
fail_fn(void)12 static int fail_fn(void)
13 {
14 errno = EINVAL;
15 return -1;
16 }
17
pass_fn(void)18 static int pass_fn(void)
19 {
20 return 0;
21 }
22
inval_ret_fn(void)23 static int inval_ret_fn(void)
24 {
25 return 42;
26 }
27
do_test(void)28 static void do_test(void)
29 {
30 tst_res(TINFO, "Testing TST_EXP_PASS macro");
31 TST_EXP_PASS(fail_fn(), "fail_fn()");
32 tst_res(TINFO, "TST_PASS = %i", TST_PASS);
33 TST_EXP_PASS(pass_fn(), "pass_fn()");
34 tst_res(TINFO, "TST_PASS = %i", TST_PASS);
35 TST_EXP_PASS(inval_ret_fn(), "inval_ret_fn()");
36 tst_res(TINFO, "TST_PASS = %i", TST_PASS);
37
38 tst_res(TINFO, "Testing TST_EXP_PASS_SILENT macro");
39 TST_EXP_PASS_SILENT(fail_fn(), "fail_fn()");
40 tst_res(TINFO, "TST_PASS = %i", TST_PASS);
41 TST_EXP_PASS_SILENT(pass_fn(), "pass_fn()");
42 tst_res(TINFO, "TST_PASS = %i from TST_EXP_PASS_SILENT(pass_fn, ...)", TST_PASS);
43 TST_EXP_PASS_SILENT(inval_ret_fn(), "inval_ret_fn()");
44 tst_res(TINFO, "TST_PASS = %i", TST_PASS);
45 }
46
47 static struct tst_test test = {
48 .test_all = do_test,
49 };
50