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