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