1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Copyright (c) 2021 Yang Xu <xuyang2018.jy@fujitsu.com>
4 */
5
6 /*
7 * Test TST_EXP_PID and TST_EXP_PID_SILENT macro.
8 */
9
10 #include "tst_test.h"
11
fail_pid(void)12 static int fail_pid(void)
13 {
14 errno = EINVAL;
15 return -1;
16 }
17
pass_pid(void)18 static int pass_pid(void)
19 {
20 return 42;
21 }
22
inval_val(void)23 static int inval_val(void)
24 {
25 return -42;
26 }
27
zero_val(void)28 static int zero_val(void)
29 {
30 return 0;
31 }
32
do_test(void)33 static void do_test(void)
34 {
35 tst_res(TINFO, "Testing TST_EXP_PID macro");
36 TST_EXP_PID(fail_pid(), "fail_pid()");
37 tst_res(TINFO, "TST_PASS = %i", TST_PASS);
38 TST_EXP_PID(pass_pid(), "pass_pid()");
39 tst_res(TINFO, "TST_PASS = %i", TST_PASS);
40 TST_EXP_PID(inval_val(), "inval_val()");
41 tst_res(TINFO, "TST_PASS = %i", TST_PASS);
42 TST_EXP_PID(zero_val(), "zero_val()");
43 tst_res(TINFO, "TST_PASS = %i", TST_PASS);
44
45 tst_res(TINFO, "Testing TST_EXP_PID_SILENT macro");
46 TST_EXP_PID_SILENT(fail_pid(), "fail_pid()");
47 tst_res(TINFO, "TST_PASS = %i", TST_PASS);
48 TST_EXP_PID_SILENT(pass_pid(), "%s", "pass_pid()");
49 tst_res(TINFO, "TST_PASS = %i from TST_EXP_PID_SILENT(pass_pid, ...)", TST_PASS);
50 TST_EXP_PID_SILENT(inval_val(), "inval_val()");
51 tst_res(TINFO, "TST_PASS = %i", TST_PASS);
52 TST_EXP_PID_SILENT(zero_val(), "zero_val()");
53 tst_res(TINFO, "TST_PASS = %i from TST_EXP_PID_SILENT(zero_val, ...)", TST_PASS);
54 }
55
56 static struct tst_test test = {
57 .test_all = do_test,
58 };
59