From 657191d0ca7c9429a8fcb058e04c44362747c437 Mon Sep 17 00:00:00 2001 From: dhy308 Date: Tue, 21 Feb 2023 16:55:24 +0800 Subject: [PATCH] Fix review issues. Issue: I6AEEI Test: Build & Boot Devices Signed-off-by: dhy308 --- .../src/functionalext/common/sigchain_util.h | 11 +- .../sigchain/sigchain_add_special_handler.c | 391 ++++++++++++++++++ .../sigchain/sigchain_add_special_handler_a.c | 61 --- .../sigchain/sigchain_add_special_handler_b.c | 75 ---- .../sigchain/sigchain_add_special_handler_c.c | 76 ---- .../sigchain/sigchain_add_special_handler_d.c | 79 ---- .../sigchain/sigchain_add_special_handler_e.c | 90 ---- .../sigchain/sigchain_add_special_handler_f.c | 93 ----- .../sigchain/sigchain_add_special_handler_g.c | 80 ---- .../sigchain/sigchain_add_special_handler_h.c | 101 ----- .../sigchain/sigchain_add_special_handler_i.c | 103 ----- .../sigchain/sigchain_add_special_handler_j.c | 230 ----------- .../sigchain/sigchain_add_special_handler_k.c | 269 ------------ .../sigchain/sigchain_add_special_handler_l.c | 308 -------------- .../sigchain_call_special_handler_a.c | 76 ---- ...mask_e.c => sigchain_handler_call_order.c} | 96 +++-- ...ion_b.c => sigchain_intercept_sigaction.c} | 107 +++-- .../sigchain/sigchain_intercept_sigaction_a.c | 68 --- .../sigchain/sigchain_intercept_sigaction_c.c | 111 ----- .../sigchain/sigchain_intercept_sigaction_d.c | 71 ---- ...signal_b.c => sigchain_intercept_signal.c} | 93 +++-- .../sigchain/sigchain_intercept_signal_a.c | 60 --- .../sigchain/sigchain_intercept_signal_c.c | 104 ----- .../sigchain/sigchain_intercept_sigprocmask.c | 182 ++++++++ .../sigchain_intercept_sigprocmask_a.c | 72 ---- .../sigchain_intercept_sigprocmask_b.c | 117 ------ .../sigchain_intercept_sigprocmask_c.c | 118 ------ .../sigchain_intercept_sigprocmask_d.c | 92 ----- .../sigchain_intercept_sigprocmask_f.c | 40 -- .../sigchain_intercept_sigprocmask_g.c | 76 ---- .../sigchain/sigchain_rm_special_handler.c | 355 ++++++++++++++++ .../sigchain/sigchain_rm_special_handler_a.c | 57 --- .../sigchain/sigchain_rm_special_handler_b.c | 75 ---- .../sigchain/sigchain_rm_special_handler_c.c | 78 ---- .../sigchain/sigchain_rm_special_handler_d.c | 82 ---- .../sigchain/sigchain_rm_special_handler_e.c | 93 ----- .../sigchain/sigchain_rm_special_handler_f.c | 96 ----- .../sigchain/sigchain_rm_special_handler_g.c | 83 ---- .../sigchain/sigchain_rm_special_handler_h.c | 99 ----- .../sigchain/sigchain_rm_special_handler_i.c | 106 ----- .../sigchain/sigchain_rm_special_handler_j.c | 226 ---------- .../sigchain/sigchain_rm_special_handler_k.c | 270 ------------ .../sigchain/sigchain_rm_special_handler_l.c | 309 -------------- .../test_src_functionalext_sigchain.gni | 45 +- libc-test/test_template.gni | 2 - porting/linux/user/src/signal/sigprocmask.c | 9 +- 46 files changed, 1151 insertions(+), 4284 deletions(-) create mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_a.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_b.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_c.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_d.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_e.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_f.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_g.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_h.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_i.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_j.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_k.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_add_special_handler_l.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_call_special_handler_a.c rename libc-test/src/functionalext/sigchain/{sigchain_intercept_sigprocmask_e.c => sigchain_handler_call_order.c} (50%) rename libc-test/src/functionalext/sigchain/{sigchain_intercept_sigaction_b.c => sigchain_intercept_sigaction.c} (52%) delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_a.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_c.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_d.c rename libc-test/src/functionalext/sigchain/{sigchain_intercept_signal_b.c => sigchain_intercept_signal.c} (55%) delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_signal_a.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_signal_c.c create mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_a.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_b.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_c.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_d.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_f.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_g.c create mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_a.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_b.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_c.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_d.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_e.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_f.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_g.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_h.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_i.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_j.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_k.c delete mode 100644 libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_l.c diff --git a/libc-test/src/functionalext/common/sigchain_util.h b/libc-test/src/functionalext/common/sigchain_util.h index c9674e51..49495751 100644 --- a/libc-test/src/functionalext/common/sigchain_util.h +++ b/libc-test/src/functionalext/common/sigchain_util.h @@ -38,13 +38,16 @@ #define SIGCHIAN_TEST_SIGNAL_NUM_2 2 #define SIGCHIAN_TEST_SIGNAL_NUM_3 3 #define SIGCHIAN_TEST_SIGNAL_NUM_4 4 -#define SIGCHIAN_TEST_SIGNAL_NUM_10 10 +#define SIGCHIAN_TEST_SIGNAL_NUM_5 5 +#define SIGCHIAN_TEST_SIGNAL_NUM_6 6 +#define SIGCHIAN_TEST_SIGNAL_NUM_8 8 +#define SIGCHIAN_TEST_SIGNAL_NUM_9 9 +#define SIGCHIAN_TEST_SIGNAL_NUM_11 11 +#define SIGCHIAN_TEST_SIGNAL_NUM_13 13 +#define SIGCHIAN_TEST_SIGNAL_NUM_14 14 #define SIGCHAIN_SIGNAL_37 37 #define SIGCHAIN_SIGNAL_43 43 -#define SIGCHAIN_SIGNAL_50 50 -#define SIGCHAIN_SIGNAL_56 56 #define SIGCHAIN_SIGNAL_64 64 -#define SIGCHAIN_SIGNAL_65 65 extern bool get_sigchain_mask_enable(); \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler.c new file mode 100644 index 00000000..3bbbd256 --- /dev/null +++ b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler.c @@ -0,0 +1,391 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "test.h" +#include "functionalext.h" +#include "sigchain_util.h" + +static int g_count = 0; +/** + * @brief the special handler + */ +static bool sigchain_special_sigabrt_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_001", signo, SIGABRT); + return false; +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sigabrt_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_001", signo, SIGABRT); + return true; +} + +/** + * @tc.name : sigchain_add_special_handler_001 + * @tc.desc : The signal are not registered with the kernel, call add_special_signal_handler to add + * two special handlers + * @tc.level : Level 0 + */ +static void sigchain_add_special_handler_001() +{ + struct signal_chain_action sigabrt = { + .sca_sigaction = sigchain_special_sigabrt_handler1, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGABRT, &sigabrt); + + struct signal_chain_action sigabrt1 = { + .sca_sigaction = sigchain_special_sigabrt_handler2, + .sca_mask = {}, + .sca_flags = SIGCHAIN_ALLOW_NORETURN, + }; + add_special_signal_handler(SIGABRT, &sigabrt1); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGABRT}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_001", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + + raise(SIGABRT); + EXPECT_EQ("sigchain_add_special_handler_001", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sighup_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_002", signo, SIGHUP); + return false; +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sighup_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_002", signo, SIGHUP); + return false; +} + +/** + * @brief the signal handler + */ +static void signal_sighup_handler(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_002", signo, SIGHUP); +} + +/** + * @tc.name : sigchain_add_special_handler_002 + * @tc.desc : The signal are registered with the kernel(Using signal), call + * add_special_signal_handler to add two special handlers + * @tc.level : Level 0 + */ +static void sigchain_add_special_handler_002() +{ + signal(SIGHUP, signal_sighup_handler); + + struct signal_chain_action sighup = { + .sca_sigaction = sigchain_special_sighup_handler1, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGHUP, &sighup); + + struct signal_chain_action sighup1 = { + .sca_sigaction = sigchain_special_sighup_handler2, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGHUP, &sighup1); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGHUP}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + raise(SIGHUP); + EXPECT_EQ("sigchain_add_special_handler_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_5); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sigsegv_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_003", signo, SIGSEGV); + return false; +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sigsegv_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_003", signo, SIGSEGV); + return false; +} + +/** + * @brief the signal handler + */ +static void signal_sigsegv_sigaction(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_003", signo, SIGSEGV); +} + +/** + * @tc.name : sigchain_add_special_handler_003 + * @tc.desc : the signal that are registered with the kernel(Using sigaction), call + * add_special_signal_handler to add two special handlers + * @tc.level : Level 0 + */ +static void sigchain_add_special_handler_003() +{ + struct sigaction sigac = { + .sa_handler = signal_sigsegv_sigaction, + }; + sigaction(SIGSEGV, &sigac, NULL); + + struct signal_chain_action sigsegv = { + .sca_sigaction = sigchain_special_sigsegv_handler1, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGSEGV, &sigsegv); + + struct signal_chain_action sigsegv2 = { + .sca_sigaction = sigchain_special_sigsegv_handler2, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGSEGV, &sigsegv2); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_003", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + raise(SIGSEGV); + EXPECT_EQ("sigchain_add_special_handler_003", g_count, SIGCHIAN_TEST_SIGNAL_NUM_8); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sigterm_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_004", signo, SIGTERM); + return true; +} + +/** + * @tc.name : sigchain_add_special_handler_004 + * @tc.desc : the signal is not registered with the kernel, call add_special_signal_handler to add + * a special handler. + * @tc.level : Level 0 + */ +static void sigchain_add_special_handler_004() +{ + struct signal_chain_action sigterm = { + .sca_sigaction = sigchain_special_sigterm_handler, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGTERM, &sigterm); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGTERM}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_004", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + + raise(SIGTERM); + EXPECT_EQ("sigchain_add_special_handler_004", g_count, SIGCHIAN_TEST_SIGNAL_NUM_9); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_64_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + EXPECT_EQ("sigchain_add_special_handler_005", signo, SIGCHAIN_SIGNAL_64); + g_count++; + return false; +} + +/** + * @brief the signal handler + */ +static void signal_64_handler(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_005", signo, SIGCHAIN_SIGNAL_64); +} + +/** + * @tc.name : sigchain_add_special_handler_005 + * @tc.desc : the signal is registered with the kernel(Using signal), call add_special_signal_handler to add + * a special handler. + * @tc.level : Level 0 + */ +static void sigchain_add_special_handler_005() +{ + signal(SIGCHAIN_SIGNAL_64, signal_64_handler); + + struct signal_chain_action sighup = { + .sca_sigaction = sigchain_special_64_handler, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGCHAIN_SIGNAL_64, &sighup); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGCHAIN_SIGNAL_64}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_005", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + raise(SIGCHAIN_SIGNAL_64); + EXPECT_EQ("sigchain_add_special_handler_005", g_count, SIGCHIAN_TEST_SIGNAL_NUM_11); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_37_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_006", signo, SIGCHAIN_SIGNAL_37); + return false; +} + +/** + * @brief the signal handler + */ +static void signal_37_sigaction(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_006", signo, SIGCHAIN_SIGNAL_37); +} + +/** + * @tc.name : sigchain_add_special_handler_006 + * @tc.desc : the signal is registered with the kernel(Using sigaction), call add_special_signal_handler + * to add a special handler. + * @tc.level : Level 0 + */ +static void sigchain_add_special_handler_006() +{ + struct sigaction sigac = { + .sa_handler = signal_37_sigaction, + }; + sigaction(SIGCHAIN_SIGNAL_37, &sigac, NULL); + + struct signal_chain_action sig37 = { + .sca_sigaction = sigchain_special_37_handler, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGCHAIN_SIGNAL_37, &sig37); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGCHAIN_SIGNAL_37}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_006", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + + raise(SIGCHAIN_SIGNAL_37); + EXPECT_EQ("sigchain_add_special_handler_006", g_count, SIGCHIAN_TEST_SIGNAL_NUM_13); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_43_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_add_special_handler_007", signo, SIGCHAIN_SIGNAL_43); + return true; +} + +/** + * @brief the signal handler + */ +static void signal_43_sigaction(int signo) +{ + g_count++; + EXPECT_FALSE("sigchain_intercept_sigprocmask_003", true); +} + +/** + * @tc.name : sigchain_add_special_handler_007 + * @tc.desc : Multiple signal are registered with the kernel(Using sigaction), sigchain_special_43_handler return + * true. + * @tc.level : Level 0 + */ +static void sigchain_add_special_handler_007() +{ + struct sigaction sigac = { + .sa_handler = signal_43_sigaction, + }; + sigaction(SIGCHAIN_SIGNAL_43, &sigac, NULL); + + struct signal_chain_action sig43 = { + .sca_sigaction = sigchain_special_43_handler, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGCHAIN_SIGNAL_43, &sig43); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGCHAIN_SIGNAL_43}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_007", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + + raise(SIGCHAIN_SIGNAL_43); + EXPECT_EQ("sigchain_add_special_handler_007", g_count, SIGCHIAN_TEST_SIGNAL_NUM_14); +} + +int main(void) +{ + sigchain_add_special_handler_001(); + sigchain_add_special_handler_002(); + sigchain_add_special_handler_003(); + sigchain_add_special_handler_004(); + sigchain_add_special_handler_005(); + sigchain_add_special_handler_006(); + sigchain_add_special_handler_007(); + return t_status; +} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_a.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_a.c deleted file mode 100644 index a1076f50..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_a.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - EXPECT_EQ("sigchain_add_special_handler_001", signo, SIGSEGV); - g_count++; - return true; -} - -/** - * @tc.name : sigchain_add_special_handler_001 - * @tc.desc : Call add_special_signal_handler when the signal that is not registered with the kernel - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_001() -{ - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = SIGCHAIN_ALLOW_NORETURN, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_001", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } -} - -int main(void) -{ - sigchain_add_special_handler_001(); - raise(SIGSEGV); - EXPECT_EQ("sigchain_add_special_handler_001", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_b.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_b.c deleted file mode 100644 index 8ea149e8..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_b.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_002", signo, SIGSEGV); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler(int signo) -{ - EXPECT_EQ("sigchain_add_special_handler_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); - g_count++; - EXPECT_EQ("sigchain_add_special_handler_002", signo, SIGSEGV); - return; -} - -/** - * @tc.name : sigchain_add_special_handler_002 - * @tc.desc : Call add_special_signal_handler after the signal that is registered with - * the kernel (using signal) - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_002() -{ - signal(SIGSEGV, signal_handler); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } -} - -int main(void) -{ - sigchain_add_special_handler_002(); - raise(SIGSEGV); - EXPECT_EQ("sigchain_add_special_handler_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_c.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_c.c deleted file mode 100644 index 4e31310b..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_c.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_003", signo, SIGSEGV); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_sigaction(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_003", signo, SIGSEGV); -} - -/** - * @tc.name : sigchain_add_special_handler_003 - * @tc.desc : Call add_special_signal_handler after the signal that is registered with - * the kernel (using sigaction) - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_003() -{ - struct sigaction sigsegv1 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGSEGV, &sigsegv1, NULL); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_003", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } -} - -int main(void) -{ - sigchain_add_special_handler_003(); - raise(SIGSEGV); - EXPECT_EQ("sigchain_add_special_handler_003", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_d.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_d.c deleted file mode 100644 index 34f1f633..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_d.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_004", signo, SIGABRT); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_004", signo, SIGABRT); - return true; -} - -/** - * @tc.name : sigchain_add_special_handler_004 - * @tc.desc : The signal are not registered with the kernel, call add_special_signal_handler to add - * two special handlers - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_004() -{ - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigabrt1 = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = SIGCHAIN_ALLOW_NORETURN, - }; - add_special_signal_handler(SIGABRT, &sigabrt1); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGABRT}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_004", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } -} - -int main(void) -{ - sigchain_add_special_handler_004(); - raise(SIGABRT); - EXPECT_EQ("sigchain_add_special_handler_004", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_e.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_e.c deleted file mode 100644 index 697d1650..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_e.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_005", signo, SIGABRT); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_005", signo, SIGABRT); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_005", signo, SIGABRT); -} - -/** - * @tc.name : sigchain_add_special_handler_005 - * @tc.desc : The signal are registered with the kernel(Using signal), call - * add_special_signal_handler to add two special handlers - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_005() -{ - signal(SIGABRT, signal_handler); - - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigabrt1 = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt1); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGABRT}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_005", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } -} - -int main(void) -{ - sigchain_add_special_handler_005(); - raise(SIGABRT); - EXPECT_EQ("sigchain_add_special_handler_005", g_count, SIGCHIAN_TEST_SIGNAL_NUM_3); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_f.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_f.c deleted file mode 100644 index 4e54f3dd..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_f.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_006", signo, SIGABRT); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_006", signo, SIGABRT); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_sigaction(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_006", signo, SIGABRT); -} - -/** - * @tc.name : sigchain_add_special_handler_006 - * @tc.desc : the signal that are registered with the kernel(Using sigaction), call - * add_special_signal_handler to add two special handlers - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_006() -{ - struct sigaction sigac = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGABRT, &sigac, NULL); - - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigabrt2 = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt2); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGABRT}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_006", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } -} - -int main(void) -{ - sigchain_add_special_handler_006(); - raise(SIGABRT); - EXPECT_EQ("sigchain_add_special_handler_006", g_count, SIGCHIAN_TEST_SIGNAL_NUM_3); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_g.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_g.c deleted file mode 100644 index 17997ef1..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_g.c +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_007", signo, SIGSEGV); - return true; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_007", signo, SIGHUP); - return true; -} - -/** - * @tc.name : sigchain_add_special_handler_007 - * @tc.desc : Multiple signal are not registered with the kernel, call add_special_signal_handler - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_007() -{ - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGSEGV, SIGHUP}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_007", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); - } -} - -int main(void) -{ - sigchain_add_special_handler_007(); - raise(SIGHUP); - EXPECT_EQ("sigchain_add_special_handler_007", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); - raise(SIGSEGV); - EXPECT_EQ("sigchain_add_special_handler_007", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_h.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_h.c deleted file mode 100644 index fcc0fda5..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_h.c +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -#define SIGCHAIN_CALL_SPECIAL_HANDLER1 1 -#define SIGCHAIN_CALL_SPECIAL_HANDLER2 2 -#define SIGCHAIN_CALL_HANDLER_SIGSEGV 4 -#define SIGCHAIN_CALL_HANDLER_SIGUP 8 -#define SIGCHAIN_CALL_CHECK_NUM 7 -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - EXPECT_EQ("sigchain_add_special_handler_008", signo, SIGSEGV); - g_count += SIGCHAIN_CALL_SPECIAL_HANDLER1; - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - EXPECT_EQ("sigchain_add_special_handler_008", signo, SIGHUP); - g_count += SIGCHAIN_CALL_SPECIAL_HANDLER2; - return true; -} - -/** - * @brief the signal handler - */ -static void signal_handler(int signo) -{ - if (signo == SIGHUP) { - g_count += SIGCHAIN_CALL_HANDLER_SIGUP; - EXPECT_EQ("sigchain_add_special_handler_008", signo, SIGHUP); - } else { - g_count += SIGCHAIN_CALL_HANDLER_SIGSEGV; - EXPECT_EQ("sigchain_add_special_handler_008", signo, SIGSEGV); - } -} - -/** - * @tc.name : sigchain_add_special_handler_008 - * @tc.desc : Multiple signal are registered with the kernel(Using signal), call add_special_signal_handler - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_008() -{ - signal(SIGSEGV, signal_handler); - signal(SIGHUP, signal_handler); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGSEGV, SIGHUP}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_008", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); - } -} - -int main(void) -{ - sigchain_add_special_handler_008(); - raise(SIGHUP); - raise(SIGSEGV); - EXPECT_EQ("sigchain_add_special_handler_008", g_count, SIGCHAIN_CALL_CHECK_NUM); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_i.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_i.c deleted file mode 100644 index c644c5a9..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_i.c +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_009", signo, SIGSEGV); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_009", signo, SIGHUP); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_sigaction(int signo) -{ - g_count++; - if (signo == SIGHUP) { - EXPECT_EQ("sigchain_add_special_handler_009", signo, SIGHUP); - } else { - EXPECT_EQ("sigchain_add_special_handler_009", signo, SIGSEGV); - } -} - -/** - * @tc.name : sigchain_add_special_handler_009 - * @tc.desc : Multiple signal are registered with the kernel(Using sigaction), call add_special_signal_handler - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_009() -{ - struct sigaction sigac = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGSEGV, &sigac, NULL); - - struct sigaction sigac1 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGHUP, &sigac1, NULL); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGSEGV, SIGHUP}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_009", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); - } -} - -int main(void) -{ - sigchain_add_special_handler_009(); - raise(SIGHUP); - EXPECT_EQ("sigchain_add_special_handler_009", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - raise(SIGSEGV); - EXPECT_EQ("sigchain_add_special_handler_009", g_count, SIGCHIAN_TEST_SIGNAL_NUM_4); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_j.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_j.c deleted file mode 100644 index c6b92259..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_j.c +++ /dev/null @@ -1,230 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_010", signo, SIGHUP); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_010", signo, SIGABRT); - return true; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_010", signo, SIGSEGV); - return true; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler4(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_010", signo, SIGURG); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler5(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_010", signo, SIGSYS); - return true; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler6(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_010", signo, SIGCHAIN_SIGNAL_37); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_010", signo, SIGCHAIN_SIGNAL_43); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_010", signo, SIGCHAIN_SIGNAL_50); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_010", signo, SIGCHAIN_SIGNAL_56); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_010", signo, SIGCHAIN_SIGNAL_64); - return false; -} - -/** - * @tc.name : sigchain_add_special_handler_010 - * @tc.desc : Multiple different signals((Coverage signal range)) are not registered with the kernel, - * call add_special_signal_handler - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_010() -{ - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler3, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct signal_chain_action sigurg = { - .sca_sigaction = sigchain_special_handler4, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGURG, &sigurg); - - struct signal_chain_action sigsys = { - .sca_sigaction = sigchain_special_handler5, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSYS, &sigsys); - - struct signal_chain_action sig37 = { - .sca_sigaction = sigchain_special_handler6, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_37, &sig37); - - struct signal_chain_action sig43 = { - .sca_sigaction = sigchain_special_handler7, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_43, &sig43); - - struct signal_chain_action sig50 = { - .sca_sigaction = sigchain_special_handler8, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_50, &sig50); - - struct signal_chain_action sig56 = { - .sca_sigaction = sigchain_special_handler9, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_56, &sig56); - - struct signal_chain_action sig64 = { - .sca_sigaction = sigchain_special_handler10, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_64, &sig64); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_10] = {SIGHUP, SIGABRT, - SIGSEGV, SIGURG, SIGSYS, - SIGCHAIN_SIGNAL_37, - SIGCHAIN_SIGNAL_43, - SIGCHAIN_SIGNAL_50, - SIGCHAIN_SIGNAL_56, - SIGCHAIN_SIGNAL_64}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_010", signo, SIGCHIAN_TEST_SIGNAL_NUM_10); - } -} - -int main(void) -{ - sigchain_add_special_handler_010(); - raise(SIGHUP); - raise(SIGABRT); - raise(SIGSEGV); - raise(SIGURG); - raise(SIGSYS); - raise(SIGCHAIN_SIGNAL_37); - raise(SIGCHAIN_SIGNAL_43); - raise(SIGCHAIN_SIGNAL_50); - raise(SIGCHAIN_SIGNAL_56); - raise(SIGCHAIN_SIGNAL_64); - EXPECT_EQ("sigchain_add_special_handler_010", g_count, SIGCHIAN_TEST_SIGNAL_NUM_10); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_k.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_k.c deleted file mode 100644 index 9131830c..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_k.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGHUP); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGABRT); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGSEGV); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler4(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGURG); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler5(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGSYS); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler6(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGCHAIN_SIGNAL_37); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGCHAIN_SIGNAL_43); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGCHAIN_SIGNAL_50); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGCHAIN_SIGNAL_56); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGCHAIN_SIGNAL_64); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler(int signo) -{ - if (signo == SIGHUP) { - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGHUP); - } else if (signo == SIGABRT) { - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGABRT); - } else if (signo == SIGSEGV) { - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGSEGV); - } else if (signo == SIGURG) { - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGURG); - } else if (signo == SIGSYS) { - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGSYS); - } else if (signo == SIGCHAIN_SIGNAL_37) { - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGCHAIN_SIGNAL_37); - } else if (signo == SIGCHAIN_SIGNAL_43) { - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGCHAIN_SIGNAL_43); - } else if (signo == SIGCHAIN_SIGNAL_50) { - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGCHAIN_SIGNAL_50); - } else if (signo ==SIGCHAIN_SIGNAL_56) { - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGCHAIN_SIGNAL_56); - } else { - EXPECT_EQ("sigchain_add_special_handler_011", signo, SIGCHAIN_SIGNAL_64); - } -} - -/** - * @tc.name : sigchain_add_special_handler_011 - * @tc.desc : Multiple different signals(Coverage signal range) are registered with the kernel(using signal), - * call add_special_signal_handler - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_011() -{ - signal(SIGHUP, signal_handler); - signal(SIGABRT, signal_handler); - signal(SIGSEGV, signal_handler); - signal(SIGURG, signal_handler); - signal(SIGSYS, signal_handler); - signal(SIGCHAIN_SIGNAL_37, signal_handler); - signal(SIGCHAIN_SIGNAL_43, signal_handler); - signal(SIGCHAIN_SIGNAL_50, signal_handler); - signal(SIGCHAIN_SIGNAL_56, signal_handler); - signal(SIGCHAIN_SIGNAL_64, signal_handler); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler3, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct signal_chain_action sigurg = { - .sca_sigaction = sigchain_special_handler4, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGURG, &sigurg); - - struct signal_chain_action sigsys = { - .sca_sigaction = sigchain_special_handler5, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSYS, &sigsys); - - struct signal_chain_action sig37 = { - .sca_sigaction = sigchain_special_handler6, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_37, &sig37); - - struct signal_chain_action sig43 = { - .sca_sigaction = sigchain_special_handler7, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_43, &sig43); - - struct signal_chain_action sig50 = { - .sca_sigaction = sigchain_special_handler8, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_50, &sig50); - - struct signal_chain_action sig56= { - .sca_sigaction = sigchain_special_handler9, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_56, &sig56); - - struct signal_chain_action sig64 = { - .sca_sigaction = sigchain_special_handler10, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_64, &sig64); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_10] = {SIGHUP, SIGABRT, SIGSEGV, - SIGURG, SIGSYS, - SIGCHAIN_SIGNAL_37, - SIGCHAIN_SIGNAL_43, - SIGCHAIN_SIGNAL_50, - SIGCHAIN_SIGNAL_56, - SIGCHAIN_SIGNAL_64}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_011", signo, SIGCHIAN_TEST_SIGNAL_NUM_10); - } -} - -int main(void) -{ - sigchain_add_special_handler_011(); - raise(SIGHUP); - raise(SIGABRT); - raise(SIGSEGV); - raise(SIGURG); - raise(SIGSYS); - raise(SIGCHAIN_SIGNAL_37); - raise(SIGCHAIN_SIGNAL_43); - raise(SIGCHAIN_SIGNAL_50); - raise(SIGCHAIN_SIGNAL_56); - raise(SIGCHAIN_SIGNAL_64); - EXPECT_EQ("sigchain_add_special_handler_011", g_count, SIGCHIAN_TEST_SIGNAL_NUM_10); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_l.c b/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_l.c deleted file mode 100644 index 632be73a..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_add_special_handler_l.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGHUP); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGABRT); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGSEGV); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler4(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGURG); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler5(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGSYS); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler6(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGCHAIN_SIGNAL_37); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGCHAIN_SIGNAL_43); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGCHAIN_SIGNAL_50); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGCHAIN_SIGNAL_56); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGCHAIN_SIGNAL_64); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_sigaction(int signo) -{ - if (signo == SIGHUP) { - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGHUP); - } else if (signo == SIGABRT) { - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGABRT); - } else if (signo == SIGSEGV) { - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGSEGV); - } else if (signo == SIGURG) { - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGURG); - } else if (signo == SIGSYS) { - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGSYS); - } else if (signo == SIGCHAIN_SIGNAL_37) { - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGCHAIN_SIGNAL_37); - } else if (signo == SIGCHAIN_SIGNAL_43) { - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGCHAIN_SIGNAL_43); - } else if (signo == SIGCHAIN_SIGNAL_50) { - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGCHAIN_SIGNAL_50); - } else if (signo ==SIGCHAIN_SIGNAL_56) { - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGCHAIN_SIGNAL_56); - } else { - EXPECT_EQ("sigchain_add_special_handler_012", signo, SIGCHAIN_SIGNAL_64); - } -} - -/** - * @tc.name : sigchain_add_special_handler_012 - * @tc.desc : Multiple different signals(Coverage signal range) are registered with the kernel(using signal), - * call add_special_signal_handler - * @tc.level : Level 0 - */ -static void sigchain_add_special_handler_012() -{ - struct sigaction sigaction0 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGHUP, &sigaction0, NULL); - - struct sigaction sigaction1 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGABRT, &sigaction1, NULL); - - struct sigaction sigaction2 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGSEGV, &sigaction2, NULL); - - struct sigaction sigaction3 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGURG, &sigaction3, NULL); - - struct sigaction sigaction4 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGSYS, &sigaction4, NULL); - - struct sigaction sigaction5 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGCHAIN_SIGNAL_37, &sigaction5, NULL); - - struct sigaction sigaction6 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGCHAIN_SIGNAL_43, &sigaction6, NULL); - - struct sigaction sigaction7 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGCHAIN_SIGNAL_50, &sigaction7, NULL); - - struct sigaction sigaction8 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGCHAIN_SIGNAL_56, &sigaction8, NULL); - - struct sigaction sigaction9 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGCHAIN_SIGNAL_64, &sigaction9, NULL); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = SIGCHAIN_ALLOW_NORETURN, - }; - add_special_signal_handler(SIGHUP, &sighup); - - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = SIGCHAIN_ALLOW_NORETURN, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler3, - .sca_mask = {}, - .sca_flags = SIGCHAIN_ALLOW_NORETURN, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct signal_chain_action sigurg = { - .sca_sigaction = sigchain_special_handler4, - .sca_mask = {}, - .sca_flags = SIGCHAIN_ALLOW_NORETURN, - }; - add_special_signal_handler(SIGURG, &sigurg); - - struct signal_chain_action sigsys = { - .sca_sigaction = sigchain_special_handler5, - .sca_mask = {}, - .sca_flags = SIGCHAIN_ALLOW_NORETURN, - }; - add_special_signal_handler(SIGSYS, &sigsys); - - struct signal_chain_action sig37 = { - .sca_sigaction = sigchain_special_handler6, - .sca_mask = {}, - .sca_flags = SIGCHAIN_ALLOW_NORETURN, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_37, &sig37); - - struct signal_chain_action sig43 = { - .sca_sigaction = sigchain_special_handler7, - .sca_mask = {}, - .sca_flags = SIGCHAIN_ALLOW_NORETURN, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_43, &sig43); - - struct signal_chain_action sig50 = { - .sca_sigaction = sigchain_special_handler8, - .sca_mask = {}, - .sca_flags = SIGCHAIN_ALLOW_NORETURN, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_50, &sig50); - - struct signal_chain_action sig56 = { - .sca_sigaction = sigchain_special_handler9, - .sca_mask = {}, - .sca_flags = SIGCHAIN_ALLOW_NORETURN, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_56, &sig56); - - struct signal_chain_action sig64 = { - .sca_sigaction = sigchain_special_handler10, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_64, &sig64); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_10] = {SIGHUP, SIGABRT, SIGSEGV, SIGURG, SIGSYS, - SIGCHAIN_SIGNAL_37, - SIGCHAIN_SIGNAL_43, - SIGCHAIN_SIGNAL_50, - SIGCHAIN_SIGNAL_56, - SIGCHAIN_SIGNAL_64}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_012", signo, SIGCHIAN_TEST_SIGNAL_NUM_10); - } -} - -int main(void) -{ - sigchain_add_special_handler_012(); - raise(SIGHUP); - raise(SIGABRT); - raise(SIGSEGV); - raise(SIGURG); - raise(SIGSYS); - raise(SIGCHAIN_SIGNAL_37); - raise(SIGCHAIN_SIGNAL_43); - raise(SIGCHAIN_SIGNAL_50); - raise(SIGCHAIN_SIGNAL_56); - raise(SIGCHAIN_SIGNAL_64); - EXPECT_EQ("sigchain_add_special_handler_012", g_count, SIGCHIAN_TEST_SIGNAL_NUM_10); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_call_special_handler_a.c b/libc-test/src/functionalext/sigchain/sigchain_call_special_handler_a.c deleted file mode 100644 index 866bd048..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_call_special_handler_a.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -#define SIGCHAIN_CALL_SPECIAL_HANDLER_TAG 1 -static int g_count = 0; - -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - EXPECT_EQ("sigchain_call_special_handler_001", signo, SIGSEGV); - g_count++; - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler(int signo) -{ - EXPECT_EQ("sigchain_call_special_handler_001", signo, SIGSEGV); - EXPECT_EQ("sigchain_call_special_handler_001", g_count, SIGCHAIN_CALL_SPECIAL_HANDLER_TAG); - g_count++; - return; -} - -/** - * @tc.name : sigchain_call_special_handler_001 - * @tc.desc : Test the call order of the special handler and user's handler. - * @tc.level : Level 0 - */ -static void sigchain_call_special_handler_001() -{ - signal(SIGSEGV, signal_handler); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_call_special_handler_001", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } -} - -int main(void) -{ - sigchain_call_special_handler_001(); - raise(SIGSEGV); - EXPECT_EQ("sigchain_call_special_handler_001", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_e.c b/libc-test/src/functionalext/sigchain/sigchain_handler_call_order.c similarity index 50% rename from libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_e.c rename to libc-test/src/functionalext/sigchain/sigchain_handler_call_order.c index 3e1e75a6..2b5bdbb6 100644 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_e.c +++ b/libc-test/src/functionalext/sigchain/sigchain_handler_call_order.c @@ -27,15 +27,13 @@ static int g_count = 0; */ static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) { - EXPECT_EQ("sigchain_intercept_sigprocmask_005", signo, SIGHUP); - if (g_count == 0) { - sigset_t set = {0}; - int signal[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGHUP, SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_001", signal, SIGCHIAN_TEST_SIGNAL_NUM_2); - raise(SIGSEGV); - g_count++; - } - return true; + EXPECT_EQ("sigchain_handler_call_order_001", signo, SIGHUP); + sigset_t set = {0}; + int signal[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGHUP, SIGSEGV}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_001", signal, SIGCHIAN_TEST_SIGNAL_NUM_2); + raise(SIGSEGV); + g_count++; + return false; } /** @@ -43,39 +41,31 @@ static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *uconte */ static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) { - EXPECT_EQ("sigchain_intercept_sigprocmask_005", signo, SIGSEGV); - EXPECT_EQ("sigchain_intercept_sigprocmask_005", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); + EXPECT_EQ("sigchain_handler_call_order_001", signo, SIGSEGV); + EXPECT_EQ("sigchain_handler_call_order_001", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); + g_count++; return false; } - /** * @brief the signal handler */ static void signal_handler(int signo) { g_count++; - EXPECT_TRUE("sigchain_intercept_sigprocmask_005", true); + EXPECT_TRUE("sigchain_handler_call_order_001", true); } - /** - * @tc.name : sigchain_intercept_sigprocmask_005 + * @tc.name : sigchain_handler_call_order_001 * @tc.desc : The signals are registered with the special handler, and mask and rasie the signal * at the special handler. Test the influence of sigchain on sigprocmask. * @tc.level : Level 0 */ -static void sigchain_intercept_sigprocmask_005() +static void sigchain_handler_call_order_001() { - struct sigaction siga1 = { - .sa_handler = signal_handler, - }; - sigaction(SIGSEGV, &siga1, NULL); - - struct sigaction siga2 = { - .sa_handler = signal_handler, - }; - sigaction(SIGHUP, &siga2, NULL); + signal(SIGHUP, signal_handler); + signal(SIGSEGV, signal_handler); struct signal_chain_action sighup = { .sca_sigaction = sigchain_special_handler, @@ -91,19 +81,55 @@ static void sigchain_intercept_sigprocmask_005() }; add_special_signal_handler(SIGSEGV, &sigsegv); - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGHUP, SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_005", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); + raise(SIGHUP); + EXPECT_EQ("sigchain_handler_call_order_001", g_count, SIGCHIAN_TEST_SIGNAL_NUM_4); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + EXPECT_EQ("sigchain_handler_call_order_002", signo, SIGSYS); + g_count++; + return false; +} + +/** + * @brief the signal handler + */ +static void signal_handler3(int signo) +{ + EXPECT_EQ("sigchain_handler_call_order_002", signo, SIGSYS); + EXPECT_EQ("sigchain_handler_call_order_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_5); + g_count++; + return; +} + +/** + * @tc.name : sigchain_handler_call_order_002 + * @tc.desc : Add a special handler for a signal that is registered with + * the kernel (Using signal interface) in sigchain. + * @tc.level : Level 0 + */ +static void sigchain_handler_call_order_002() +{ + signal(SIGSYS, signal_handler3); + + struct signal_chain_action sigsegv = { + .sca_sigaction = sigchain_special_handler3, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGSYS, &sigsegv); + + raise(SIGSYS); + EXPECT_EQ("sigchain_handler_call_order_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_6); } int main(void) { - sigchain_intercept_sigprocmask_005(); - raise(SIGHUP); - if (get_sigchain_mask_enable()) { - EXPECT_EQ("sigchain_intercept_sigprocmask_005", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - } else { - EXPECT_EQ("sigchain_intercept_sigprocmask_005", g_count, 0); - } + sigchain_handler_call_order_001(); + sigchain_handler_call_order_002(); return t_status; } \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_b.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction.c similarity index 52% rename from libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_b.c rename to libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction.c index 279d70b9..f27ed9b5 100644 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_b.c +++ b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include "test.h" @@ -24,30 +25,37 @@ static int g_count = 0; /** * @brief the special handler */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) +static void signal_handler1(int signo) { g_count++; - EXPECT_EQ("sigchain_intercept_sigaction_002", signo, SIGHUP); - return false; + EXPECT_EQ("sigchain_intercept_sigaction_001", signo, SIGHUP); } /** - * @brief the special handler + * @tc.name : sigchain_intercept_sigaction_001 + * @tc.desc : The signals are not registered with the special handler, test the influence of sigchain + * on sigaction. + * @tc.level : Level 0 */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) +static void sigchain_intercept_sigaction_001() { - g_count++; - EXPECT_EQ("sigchain_intercept_sigaction_002", signo, SIGSEGV); - return false; + struct sigaction siga1 = { + .sa_handler = signal_handler1, + }; + sigaction(SIGHUP, &siga1, NULL); + + raise(SIGHUP); + EXPECT_EQ("sigchain_intercept_sigaction_001", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); } /** - * @brief the signal handler + * @brief the special handler */ -static void signal_handler1(int signo) +static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) { g_count++; - EXPECT_EQ("sigchain_intercept_sigaction_002", signo, SIGHUP); + EXPECT_EQ("sigchain_intercept_sigaction_002", signo, SIGSEGV); + return false; } /** @@ -59,6 +67,7 @@ static void signal_handler2(int signo) EXPECT_EQ("sigchain_intercept_sigaction_002", signo, SIGSEGV); } + /** * @tc.name : sigchain_intercept_sigaction_002 * @tc.desc : The signals are registered with the special handler, test the influence of sigchain on sigaction. @@ -66,25 +75,13 @@ static void signal_handler2(int signo) */ static void sigchain_intercept_sigaction_002() { - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler1, + .sca_sigaction = sigchain_special_handler2, .sca_mask = {}, .sca_flags = 0, }; add_special_signal_handler(SIGSEGV, &sigsegv); - struct sigaction siga1 = { - .sa_handler = signal_handler1, - }; - sigaction(SIGHUP, &siga1, NULL); - struct sigaction siga2 = { .sa_handler = signal_handler2, }; @@ -92,17 +89,67 @@ static void sigchain_intercept_sigaction_002() if (get_sigchain_mask_enable()) { sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGSEGV, SIGHUP}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigaction_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigaction_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); } + + raise(SIGSEGV); + EXPECT_EQ("sigchain_intercept_sigaction_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_3); } +/** + * @brief the special handler + */ +static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_intercept_sigaction_003", signo, SIGURG); + return false; +} + +/** + * @brief the signal handler + */ +static void signal_handler3(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_intercept_sigaction_003", signo, SIGURG); +} + +/** + * @tc.name : sigchain_intercept_sigaction_003 + * @tc.desc : the signals are registered with the special handler, and remove the special handler. Test + * the influence of sigchain on sigaction. + * @tc.level : Level 0 + */ +static void sigchain_intercept_sigaction_003() +{ + struct signal_chain_action sigurg = { + .sca_sigaction = sigchain_special_handler3, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGURG, &sigurg); + + struct sigaction siga2 = { + .sa_handler = signal_handler3, + }; + sigaction(SIGURG, &siga2, NULL); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGURG}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigaction_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + + remove_special_signal_handler(SIGURG, sigchain_special_handler3); + raise(SIGURG); + EXPECT_EQ("sigchain_intercept_sigaction_003", g_count, SIGCHIAN_TEST_SIGNAL_NUM_4); +} int main(void) { + sigchain_intercept_sigaction_001(); sigchain_intercept_sigaction_002(); - raise(SIGHUP); - EXPECT_EQ("sigchain_intercept_sigaction_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - raise(SIGSEGV); - EXPECT_EQ("sigchain_intercept_sigaction_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_4); + sigchain_intercept_sigaction_003(); return t_status; } \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_a.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_a.c deleted file mode 100644 index df00e397..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_a.c +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static void signal_handler1(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigaction_001", signo, SIGHUP); -} - -/** - * @brief the special handler - */ -static void signal_handler2(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigaction_001", signo, SIGSEGV); -} - -/** - * @tc.name : sigchain_intercept_sigaction_001 - * @tc.desc : The signals are not registered with the special handler, test the influence of sigchain - * on sigaction. - * @tc.level : Level 0 - */ -static void sigchain_intercept_sigaction_001() -{ - struct sigaction siga1 = { - .sa_handler = signal_handler1, - }; - sigaction(SIGHUP, &siga1, NULL); - - struct sigaction siga2 = { - .sa_handler = signal_handler2, - }; - sigaction(SIGSEGV, &siga2, NULL); -} - -int main(void) -{ - sigchain_intercept_sigaction_001(); - raise(SIGHUP); - raise(SIGSEGV); - EXPECT_EQ("sigchain_intercept_sigaction_001", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_c.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_c.c deleted file mode 100644 index 52ae85aa..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_c.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigaction_003", signo, SIGHUP); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigaction_003", signo, SIGSEGV); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler1(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigaction_003", signo, SIGHUP); -} - -/** - * @brief the signal handler - */ -static void signal_handler2(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigaction_003", signo, SIGSEGV); -} - -/** - * @tc.name : sigchain_intercept_sigaction_003 - * @tc.desc : the signals are registered with the special handler, and remove the special handler. Test - * the influence of sigchain on sigaction. - * @tc.level : Level 0 - */ -static void sigchain_intercept_sigaction_003() -{ - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct sigaction siga1 = { - .sa_handler = signal_handler1, - }; - sigaction(SIGHUP, &siga1, NULL); - - struct sigaction siga2 = { - .sa_handler = signal_handler2, - }; - sigaction(SIGSEGV, &siga2, NULL); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGSEGV, SIGHUP}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigaction_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); - } - - remove_special_signal_handler(SIGHUP, sigchain_special_handler); - remove_special_signal_handler(SIGSEGV, sigchain_special_handler1); -} - -int main(void) -{ - sigchain_intercept_sigaction_003(); - raise(SIGHUP); - raise(SIGSEGV); - EXPECT_EQ("sigchain_intercept_sigaction_003", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_d.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_d.c deleted file mode 100644 index ef7e4520..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_d.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static void signal_handler1(int signo) -{ - EXPECT_EQ("sigchain_intercept_sigaction_004", signo, SIGHUP); - sigset_t set = {0}; - int signal[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGSEGV, SIGHUP}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigaction_004", signal, SIGCHIAN_TEST_SIGNAL_NUM_2); - g_count++; - raise(SIGSEGV); -} - -/** - * @brief the special handler - */ -static void signal_handler2(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigaction_004", signo, SIGSEGV); -} - -/** - * @tc.name : sigchain_intercept_sigaction_004 - * @tc.desc : The signals are not registered with the special handler, and mask and rasie the signal - * at the special handler. Test the influence of sigchain on sigaction. - * @tc.level : Level 0 - */ -static void sigchain_intercept_sigaction_004() -{ - struct sigaction siga1 = { - .sa_handler = signal_handler1, - }; - sigaction(SIGHUP, &siga1, NULL); - - struct sigaction siga2 = { - .sa_handler = signal_handler2, - }; - sigaction(SIGSEGV, &siga2, NULL); -} - -int main(void) -{ - sigchain_intercept_sigaction_004(); - raise(SIGHUP); - EXPECT_EQ("sigchain_intercept_sigaction_004", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_signal_b.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_signal.c similarity index 55% rename from libc-test/src/functionalext/sigchain/sigchain_intercept_signal_b.c rename to libc-test/src/functionalext/sigchain/sigchain_intercept_signal.c index f14b833f..f8399f65 100644 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_signal_b.c +++ b/libc-test/src/functionalext/sigchain/sigchain_intercept_signal.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include "test.h" @@ -22,32 +23,34 @@ static int g_count = 0; /** - * @brief the special handler + * @brief the signal handler */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) +static void signal_handler1(int signo) { g_count++; - EXPECT_EQ("sigchain_intercept_signal_002", signo, SIGHUP); - return false; + EXPECT_EQ("sigchain_intercept_signal_001", signo, SIGHUP); } /** - * @brief the special handler + * @tc.name : sigchain_add_special_handler_025 + * @tc.desc : The signals are not registered with the special handler, test the influence of sigchain on signal + * @tc.level : Level 0 */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) +static void sigchain_intercept_signal_001() { - g_count++; - EXPECT_EQ("sigchain_intercept_signal_002", signo, SIGSEGV); - return false; + signal(SIGHUP, signal_handler1); + raise(SIGHUP); + EXPECT_EQ("sigchain_intercept_signal_001", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); } /** - * @brief the signal handler + * @brief the special handler */ -static void signal_handler1(int signo) +static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) { g_count++; - EXPECT_EQ("sigchain_intercept_signal_002", signo, SIGHUP); + EXPECT_EQ("sigchain_intercept_signal_002", signo, SIGSEGV); + return false; } /** @@ -66,13 +69,6 @@ static void signal_handler2(int signo) */ static void sigchain_intercept_signal_002() { - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - struct signal_chain_action sigsegv = { .sca_sigaction = sigchain_special_handler1, .sca_mask = {}, @@ -80,21 +76,68 @@ static void sigchain_intercept_signal_002() }; add_special_signal_handler(SIGSEGV, &sigsegv); - signal(SIGHUP, signal_handler1); signal(SIGSEGV, signal_handler2); if (get_sigchain_mask_enable()) { sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGSEGV, SIGHUP}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_signal_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_signal_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); } + raise(SIGSEGV); + EXPECT_EQ("sigchain_intercept_signal_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_3); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_intercept_signal_003", signo, SIGURG); + return false; +} + +/** + * @brief the signal handler + */ +static void signal_handler3(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_intercept_signal_003", signo, SIGURG); } + +/** + * @tc.name : sigchain_intercept_signal_003 + * @tc.desc : The signals are registered with the special handler, and remove the special handler. + * Test the influence of sigchain on signal + * @tc.level : Level 0 + */ +static void sigchain_intercept_signal_003() +{ + struct signal_chain_action sigurg = { + .sca_sigaction = sigchain_special_handler3, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGURG, &sigurg); + + signal(SIGURG, signal_handler3); + + remove_special_signal_handler(SIGURG, sigchain_special_handler3); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGURG}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigaction_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + raise(SIGURG); + EXPECT_EQ("sigchain_intercept_signal_003", g_count, SIGCHIAN_TEST_SIGNAL_NUM_4); +} int main(void) { + sigchain_intercept_signal_001(); sigchain_intercept_signal_002(); - raise(SIGHUP); - raise(SIGSEGV); - EXPECT_EQ("sigchain_intercept_signal_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_4); + sigchain_intercept_signal_003(); return t_status; } \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_signal_a.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_signal_a.c deleted file mode 100644 index 6161d20f..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_signal_a.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the signal handler - */ -static void signal_handler1(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_signal_001", signo, SIGHUP); -} - -/** - * @brief the signal handler - */ -static void signal_handler2(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_signal_001", signo, SIGSEGV); -} - -/** - * @tc.name : sigchain_add_special_handler_025 - * @tc.desc : The signals are not registered with the special handler, test the influence of sigchain on signal - * @tc.level : Level 0 - */ -static void sigchain_intercept_signal_001() -{ - signal(SIGHUP, signal_handler1); - signal(SIGSEGV, signal_handler2); -} - -int main(void) -{ - sigchain_intercept_signal_001(); - raise(SIGHUP); - raise(SIGSEGV); - EXPECT_EQ("sigchain_intercept_sigaction_001", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_signal_c.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_signal_c.c deleted file mode 100644 index eee8fbbd..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_signal_c.c +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_signal_003", signo, SIGHUP); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_signal_003", signo, SIGSEGV); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler1(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_signal_003", signo, SIGHUP); -} - -/** - * @brief the signal handler - */ -static void signal_handler2(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_signal_003", signo, SIGSEGV); -} - -/** - * @tc.name : sigchain_intercept_signal_003 - * @tc.desc : The signals are registered with the special handler, and remove the special handler. - * Test the influence of sigchain on signal - * @tc.level : Level 0 - */ -static void sigchain_intercept_signal_003() -{ - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - signal(SIGHUP, signal_handler1); - signal(SIGSEGV, signal_handler2); - - remove_special_signal_handler(SIGHUP, sigchain_special_handler); - remove_special_signal_handler(SIGSEGV, sigchain_special_handler1); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGSEGV, SIGHUP}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigaction_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); - } -} - -int main(void) -{ - sigchain_intercept_signal_003(); - raise(SIGHUP); - raise(SIGSEGV); - EXPECT_EQ("sigchain_intercept_signal_003", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask.c new file mode 100644 index 00000000..9d996b1e --- /dev/null +++ b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask.c @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include "test.h" +#include "functionalext.h" +#include "sigchain_util.h" + +static int g_count = 0; + +/** + * @brief the special handler + */ +static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_EQ("sigchain_intercept_sigprocmask_001", signo, SIGSEGV); + return false; +} + +/** + * @brief the signal handler + */ +static void signal_handler2(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_intercept_sigprocmask_001", signo, SIGSEGV); +} + +/** + * @tc.name : sigchain_intercept_sigprocmask_001 + * @tc.desc : The signals are registered with the special handler, test the influence of sigchain + * on sigprocmask. + * @tc.level : Level 0 + */ +static void sigchain_intercept_sigprocmask_001() +{ + struct sigaction siga2 = { + .sa_handler = signal_handler2, + }; + sigaction(SIGSEGV, &siga2, NULL); + + struct signal_chain_action sigsegv = { + .sca_sigaction = sigchain_special_handler2, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGSEGV, &sigsegv); + + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_001", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + raise(SIGSEGV); + if (get_sigchain_mask_enable()) { + EXPECT_EQ("sigchain_intercept_sigprocmask_001", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); + } else { + EXPECT_EQ("sigchain_intercept_sigprocmask_001", g_count, 0); + } +} + +/** + * @brief the special handler + */ +static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_FALSE("sigchain_intercept_sigprocmask_002", true); + return false; +} + +/** + * @brief the signal handler + */ +static void signal_handler3(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_intercept_sigprocmask_002", signo, SIGSYS); +} + +/** + * @tc.name : sigchain_intercept_sigprocmask_002 + * @tc.desc : The signals are registered with the special handler, and remove the special handler. + * Test the influence of sigchain on sigprocmask. + * @tc.level : Level 0 + */ +static void sigchain_intercept_sigprocmask_002() +{ + struct sigaction siga2 = { + .sa_handler = signal_handler3, + }; + sigaction(SIGSYS, &siga2, NULL); + + struct signal_chain_action sigsegv = { + .sca_sigaction = sigchain_special_handler3, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGSYS, &sigsegv); + + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSYS}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + + remove_special_signal_handler(SIGSYS, sigchain_special_handler3); + + raise(SIGSYS); + if (get_sigchain_mask_enable()) { + EXPECT_EQ("sigchain_intercept_sigprocmask_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_3); + } else { + EXPECT_EQ("sigchain_intercept_sigprocmask_002", g_count, 0); + } +} + + +/** + * @brief the signal handler + */ +static void signal_handler1(int signo) +{ + g_count++; + EXPECT_FALSE("sigchain_intercept_sigprocmask_001", true); +} + +/** + * @tc.name : sigchain_intercept_sigprocmask_003 + * @tc.desc : The signals are not registered with the special handler, test the influence of sigchain + * on sigprocmask. + * @tc.level : Level 0 + */ +static void sigchain_intercept_sigprocmask_003() +{ + struct sigaction siga1 = { + .sa_handler = signal_handler1, + }; + sigaction(SIGHUP, &siga1, NULL); + + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGHUP}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_003", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + raise(SIGHUP); + if (get_sigchain_mask_enable()) { + EXPECT_EQ("sigchain_intercept_sigprocmask_003", g_count, SIGCHIAN_TEST_SIGNAL_NUM_3); + } else { + EXPECT_EQ("sigchain_intercept_sigprocmask_003", g_count, 0); + } +} + +/** + * @tc.name : sigchain_intercept_sigprocmask_004 + * @tc.desc : The new set is null, call sigprocmask. + * @tc.level : Level 0 + */ +static void sigchain_intercept_sigprocmask_004() +{ + int result = sigprocmask(SIG_BLOCK, NULL, NULL); + if (result != 0) { + EXPECT_FALSE("sigchain_intercept_sigprocmask_004", true); + } +} +int main(void) +{ + sigchain_intercept_sigprocmask_001(); + sigchain_intercept_sigprocmask_002(); + sigchain_intercept_sigprocmask_003(); + sigchain_intercept_sigprocmask_004(); + return t_status; +} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_a.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_a.c deleted file mode 100644 index 5b6bca1b..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_a.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the signal handler - */ -static void signal_handler1(int signo) -{ - g_count++; - EXPECT_FALSE("sigchain_intercept_sigprocmask_001", true); -} - -/** - * @brief the signal handler - */ -static void signal_handler2(int signo) -{ - g_count++; - EXPECT_FALSE("sigchain_intercept_sigprocmask_001", true); -} - -/** - * @tc.name : sigchain_intercept_sigprocmask_001 - * @tc.desc : The signals are not registered with the special handler, test the influence of sigchain - * on sigprocmask. - * @tc.level : Level 0 - */ -static void sigchain_intercept_sigprocmask_001() -{ - struct sigaction siga1 = { - .sa_handler = signal_handler1, - }; - sigaction(SIGHUP, &siga1, NULL); - - struct sigaction siga2 = { - .sa_handler = signal_handler2, - }; - sigaction(SIGSEGV, &siga2, NULL); - - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGHUP, SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_001", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); -} - -int main(void) -{ - sigchain_intercept_sigprocmask_001(); - raise(SIGHUP); - raise(SIGSEGV); - EXPECT_EQ("sigchain_intercept_sigprocmask_001", g_count, 0); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_b.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_b.c deleted file mode 100644 index 2b714703..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_b.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigprocmask_002", signo, SIGHUP); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigprocmask_002", signo, SIGSEGV); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler1(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigprocmask_002", signo, SIGHUP); -} - -/** - * @brief the signal handler - */ -static void signal_handler2(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigprocmask_002", signo, SIGSEGV); -} - -/** - * @tc.name : sigchain_intercept_sigprocmask_002 - * @tc.desc : The signals are registered with the special handler, test the influence of sigchain - * on sigprocmask. - * @tc.level : Level 0 - */ -static void sigchain_intercept_sigprocmask_002() -{ - struct sigaction siga1 = { - .sa_handler = signal_handler1, - }; - sigaction(SIGHUP, &siga1, NULL); - - struct sigaction siga2 = { - .sa_handler = signal_handler2, - }; - sigaction(SIGSEGV, &siga2, NULL); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGHUP, SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); -} - -int main(void) -{ - sigchain_intercept_sigprocmask_002(); - raise(SIGHUP); - if (get_sigchain_mask_enable()) { - EXPECT_EQ("sigchain_intercept_sigprocmask_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - } else { - EXPECT_EQ("sigchain_intercept_sigprocmask_002", g_count, 0); - } - - raise(SIGSEGV); - if (get_sigchain_mask_enable()) { - EXPECT_EQ("sigchain_intercept_sigprocmask_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_4); - } else { - EXPECT_EQ("sigchain_intercept_sigprocmask_002", g_count, 0); - } - - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_c.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_c.c deleted file mode 100644 index bee02a9a..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_c.c +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_intercept_sigprocmask_003", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_intercept_sigprocmask_003", true); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler1(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigprocmask_003", signo, SIGHUP); -} - -/** - * @brief the signal handler - */ -static void signal_handler2(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigprocmask_003", signo, SIGSEGV); -} - -/** - * @tc.name : sigchain_intercept_sigprocmask_003 - * @tc.desc : The signals are registered with the special handler, and remove the special handler. - * Test the influence of sigchain on sigprocmask. - * @tc.level : Level 0 - */ -static void sigchain_intercept_sigprocmask_003() -{ - struct sigaction siga1 = { - .sa_handler = signal_handler1, - }; - sigaction(SIGHUP, &siga1, NULL); - - struct sigaction siga2 = { - .sa_handler = signal_handler2, - }; - sigaction(SIGSEGV, &siga2, NULL); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGHUP, SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_003", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); - - remove_special_signal_handler(SIGHUP, sigchain_special_handler); - remove_special_signal_handler(SIGSEGV, sigchain_special_handler1); -} - -int main(void) -{ - sigchain_intercept_sigprocmask_003(); - raise(SIGHUP); - if (get_sigchain_mask_enable()) { - EXPECT_EQ("sigchain_intercept_sigprocmask_003", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); - } else { - EXPECT_EQ("sigchain_intercept_sigprocmask_003", g_count, 0); - } - raise(SIGSEGV); - if (get_sigchain_mask_enable()) { - EXPECT_EQ("sigchain_intercept_sigprocmask_003", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - } else { - EXPECT_EQ("sigchain_intercept_sigprocmask_003", g_count, 0); - } - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_d.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_d.c deleted file mode 100644 index e145c7ae..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_d.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - return false; -} - - -/** - * @brief the signal handler - */ -static void signal_handler(int signo) -{ - g_count++; -} - - -/** - * @tc.name : sigchain_intercept_sigprocmask_004 - * @tc.desc : The signals are registered with the special handler.Test the multiple threads call - * sigprocmask and add_special_signal_handler. - * @tc.level : Level 0 - */ -static void sigchain_intercept_sigprocmask_004(int signo) -{ - struct sigaction siga = { - .sa_handler = signal_handler, - }; - sigaction(signo, &siga, NULL); - - struct signal_chain_action sig_ca = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(signo, &sig_ca); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signal[SIGCHIAN_TEST_SIGNAL_NUM_1] = {signo}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_004", signal, SIGCHIAN_TEST_SIGNAL_NUM_1); - } -} - -void thread_func1(void *data) -{ - sigchain_intercept_sigprocmask_004(SIGHUP); -} - -void thread_func2(void *data) -{ - sigchain_intercept_sigprocmask_004(SIGSEGV); -} - -int main(void) -{ - thrd_t t1, t2; - thrd_create(&t1, (thrd_start_t)thread_func1, NULL); - thrd_create(&t2, (thrd_start_t)thread_func2, NULL); - thrd_join(t1, NULL); - thrd_join(t2, NULL); - raise(SIGHUP); - raise(SIGSEGV); - EXPECT_EQ("sigchain_intercept_sigprocmask_004", g_count, SIGCHIAN_TEST_SIGNAL_NUM_4); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_f.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_f.c deleted file mode 100644 index 75923e64..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_f.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -/** - * @tc.name : sigchain_intercept_sigprocmask_006 - * @tc.desc : The new set is null, call sigprocmask. - * @tc.level : Level 0 - */ -static void sigchain_intercept_sigprocmask_006() -{ - int result = sigprocmask(SIG_BLOCK, NULL, NULL); - if (result != 0) { - EXPECT_FALSE("sigchain_intercept_sigprocmask_006", true); - } -} - -int main(void) -{ - sigchain_intercept_sigprocmask_006(); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_g.c b/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_g.c deleted file mode 100644 index 429a97d9..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_g.c +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_EQ("sigchain_intercept_sigprocmask_007", signo, SIGSEGV); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler(int signo) -{ - EXPECT_EQ("sigchain_intercept_sigprocmask_007", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); - g_count++; - EXPECT_EQ("sigchain_intercept_sigprocmask_007", signo, SIGSEGV); - return; -} - -/** - * @tc.name : sigchain_intercept_sigprocmask_007 - * @tc.desc : The 'musl.sigchain.procmask' is false, call the sigprocmask - * @tc.level : Level 0 - */ -static void sigchain_intercept_sigprocmask_007() -{ - signal(SIGSEGV, signal_handler); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_007", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); -} - -int main(void) -{ - sigchain_intercept_sigprocmask_007(); - raise(SIGSEGV); - if (get_sigchain_mask_enable()) { - EXPECT_EQ("sigchain_intercept_sigprocmask_007", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - } else { - EXPECT_EQ("sigchain_intercept_sigprocmask_007", g_count, 0); - } - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler.c new file mode 100644 index 00000000..0c5962f4 --- /dev/null +++ b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler.c @@ -0,0 +1,355 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "test.h" +#include "functionalext.h" +#include "sigchain_util.h" + +static int g_count = 0; +/** + * @brief the special handler + */ +static bool sigchain_special_sigabrt_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_FALSE("sigchain_rm_special_handler_001", true); + return false; +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sigabrt_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_FALSE("sigchain_rm_special_handler_001", true); + return true; +} + +/** + * @tc.name : sigchain_rm_special_handler_001 + * @tc.desc : The signal are not registered with the kernel, call remove_special_signal_handler to remove + * two special handlers + * @tc.level : Level 0 + */ +static void sigchain_rm_special_handler_001() +{ + struct signal_chain_action sigabrt = { + .sca_sigaction = sigchain_special_sigabrt_handler1, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGABRT, &sigabrt); + + struct signal_chain_action sigabrt1 = { + .sca_sigaction = sigchain_special_sigabrt_handler2, + .sca_mask = {}, + .sca_flags = SIGCHAIN_ALLOW_NORETURN, + }; + add_special_signal_handler(SIGABRT, &sigabrt1); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGABRT}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_001", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + remove_special_signal_handler(SIGABRT, sigchain_special_sigabrt_handler1); + remove_special_signal_handler(SIGABRT, sigchain_special_sigabrt_handler2); + + raise(SIGABRT); + EXPECT_EQ("sigchain_rm_special_handler_001", g_count, 0); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sighup_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_FALSE("sigchain_rm_special_handler_002", true); + return false; +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sighup_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_FALSE("sigchain_rm_special_handler_002", true); + return false; +} + +/** + * @brief the signal handler + */ +static void signal_sighup_handler(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_rm_special_handler_002", signo, SIGHUP); +} + +/** + * @tc.name : sigchain_rm_special_handler_002 + * @tc.desc : The signal are registered with the kernel(Using signal), call + * remove_special_signal_handler to remove two special handlers + * @tc.level : Level 0 + */ +static void sigchain_rm_special_handler_002() +{ + signal(SIGHUP, signal_sighup_handler); + + struct signal_chain_action sighup = { + .sca_sigaction = sigchain_special_sighup_handler1, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGHUP, &sighup); + + struct signal_chain_action sighup1 = { + .sca_sigaction = sigchain_special_sighup_handler2, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGHUP, &sighup1); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGHUP}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + remove_special_signal_handler(SIGHUP, sigchain_special_sighup_handler1); + remove_special_signal_handler(SIGHUP, sigchain_special_sighup_handler2); + + raise(SIGHUP); + EXPECT_EQ("sigchain_rm_special_handler_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sigsegv_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_FALSE("sigchain_rm_special_handler_003", true); + return false; +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sigsegv_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_FALSE("sigchain_rm_special_handler_003", true); + return false; +} + +/** + * @brief the signal handler + */ +static void signal_sigsegv_sigaction(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_rm_special_handler_003", signo, SIGSEGV); +} + +/** + * @tc.name : sigchain_rm_special_handler_003 + * @tc.desc : the signal that are registered with the kernel(Using sigaction), call + * remove_special_signal_handler to remove two special handlers + * @tc.level : Level 0 + */ +static void sigchain_rm_special_handler_003() +{ + struct sigaction sigac = { + .sa_handler = signal_sigsegv_sigaction, + }; + sigaction(SIGSEGV, &sigac, NULL); + + struct signal_chain_action sigsegv = { + .sca_sigaction = sigchain_special_sigsegv_handler1, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGSEGV, &sigsegv); + + struct signal_chain_action sigsegv2 = { + .sca_sigaction = sigchain_special_sigsegv_handler2, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGSEGV, &sigsegv2); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_003", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + + remove_special_signal_handler(SIGSEGV, sigchain_special_sigsegv_handler1); + remove_special_signal_handler(SIGSEGV, sigchain_special_sigsegv_handler2); + raise(SIGSEGV); + EXPECT_EQ("sigchain_rm_special_handler_003", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_sigterm_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_FALSE("sigchain_rm_special_handler_004", true); + return true; +} + +/** + * @tc.name : sigchain_rm_special_handler_004 + * @tc.desc : the signal is not registered with the kernel, call remove_special_signal_handler to remove + * a special handler. + * @tc.level : Level 0 + */ +static void sigchain_rm_special_handler_004() +{ + struct signal_chain_action sigsegv = { + .sca_sigaction = sigchain_special_sigterm_handler, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGTERM, &sigsegv); + + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGTERM}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_004", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + remove_special_signal_handler(SIGTERM, sigchain_special_sigterm_handler); + + raise(SIGTERM); + EXPECT_EQ("sigchain_rm_special_handler_004", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_64_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + EXPECT_FALSE("sigchain_rm_special_handler_005", true); + g_count++; + return false; +} + +/** + * @brief the signal handler + */ +static void signal_64_handler(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_rm_special_handler_005", signo, SIGCHAIN_SIGNAL_64); +} + +/** + * @tc.name : sigchain_rm_special_handler_005 + * @tc.desc : the signal is registered with the kernel(Using signal), call remove_special_signal_handler to remove + * a special handler. + * @tc.level : Level 0 + */ +static void sigchain_rm_special_handler_005() +{ + signal(SIGCHAIN_SIGNAL_64, signal_64_handler); + + + struct signal_chain_action sighup = { + .sca_sigaction = sigchain_special_64_handler, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGCHAIN_SIGNAL_64, &sighup); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGCHAIN_SIGNAL_64}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_005", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + remove_special_signal_handler(SIGCHAIN_SIGNAL_64, sigchain_special_64_handler); + + raise(SIGCHAIN_SIGNAL_64); + EXPECT_EQ("sigchain_rm_special_handler_005", g_count, SIGCHIAN_TEST_SIGNAL_NUM_3); +} + +/** + * @brief the special handler + */ +static bool sigchain_special_37_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) +{ + g_count++; + EXPECT_FALSE("sigchain_rm_special_handler_006", true); + return false; +} + +/** + * @brief the signal handler + */ +static void signal_37_sigaction(int signo) +{ + g_count++; + EXPECT_EQ("sigchain_rm_special_handler_006", signo, SIGCHAIN_SIGNAL_37); +} + +/** + * @tc.name : sigchain_rm_special_handler_006 + * @tc.desc : the signal is registered with the kernel(Using sigaction), call remove_special_signal_handler + * to remove a special handler. + * @tc.level : Level 0 + */ +static void sigchain_rm_special_handler_006() +{ + struct sigaction sigac = { + .sa_handler = signal_37_sigaction, + }; + sigaction(SIGCHAIN_SIGNAL_37, &sigac, NULL); + + struct signal_chain_action sig37 = { + .sca_sigaction = sigchain_special_37_handler, + .sca_mask = {}, + .sca_flags = 0, + }; + add_special_signal_handler(SIGCHAIN_SIGNAL_37, &sig37); + + if (get_sigchain_mask_enable()) { + sigset_t set = {0}; + int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGCHAIN_SIGNAL_37}; + SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_006", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); + } + remove_special_signal_handler(SIGCHAIN_SIGNAL_37, sigchain_special_37_handler); + + raise(SIGCHAIN_SIGNAL_37); + EXPECT_EQ("sigchain_rm_special_handler_006", g_count, SIGCHIAN_TEST_SIGNAL_NUM_4); +} + +int main(void) +{ + sigchain_rm_special_handler_001(); + sigchain_rm_special_handler_002(); + sigchain_rm_special_handler_003(); + sigchain_rm_special_handler_004(); + sigchain_rm_special_handler_005(); + sigchain_rm_special_handler_006(); + return t_status; +} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_a.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_a.c deleted file mode 100644 index 78ecb824..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_a.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_001", true); - return false; -} - -/** - * @tc.name : sigchain_rm_special_handler_001 - * @tc.desc : The signal is not registered with the kernel, and add the special handler. - * Call the remove_special_signal_handler - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_001() -{ - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sigsegv); - - remove_special_signal_handler(SIGHUP, sigchain_special_handler); -} - -int main(void) -{ - sigchain_rm_special_handler_001(); - raise(SIGHUP); - EXPECT_EQ("sigchain_rm_special_handler_001", g_count, 0); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_b.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_b.c deleted file mode 100644 index ce1cbc43..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_b.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_002", true); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_rm_special_handler_002", signo, SIGSEGV); -} - -/** - * @tc.name : sigchain_rm_special_handler_002 - * @tc.desc : The signal is registered with the kernel(using signal), and add the special handler. - * Call the remove_special_signal_handler - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_002() -{ - signal(SIGSEGV, signal_handler); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_add_special_handler_002", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } - - remove_special_signal_handler(SIGSEGV, sigchain_special_handler); -} - -int main(void) -{ - sigchain_rm_special_handler_002(); - raise(SIGSEGV); - EXPECT_EQ("sigchain_rm_special_handler_002", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_c.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_c.c deleted file mode 100644 index 0fee4a36..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_c.c +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_003", true); - return true; -} - -/** - * @brief the signal handler - */ -static void signal_sigaction(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_rm_special_handler_003", signo, SIGSEGV); -} - -/** - * @tc.name : sigchain_rm_special_handler_003 - * @tc.desc : The signal is registered with the kernel(using sigaction), and add the special handler. - * Call the remove_special_signal_handler - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_003() -{ - struct sigaction sigsegv1 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGSEGV, &sigsegv1, NULL); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGSEGV}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_003", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } - - remove_special_signal_handler(SIGSEGV, sigchain_special_handler); -} - -int main(void) -{ - sigchain_rm_special_handler_003(); - raise(SIGSEGV); - EXPECT_EQ("sigchain_rm_special_handler_003", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_d.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_d.c deleted file mode 100644 index 2f3d6f04..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_d.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_004", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_004", true); - return false; -} - -/** - * @tc.name : sigchain_rm_special_handler_004 - * @tc.desc : The signal is not registered with the kernel, and add two special handler. - * Call the remove_special_signal_handler to remove the two special handler. - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_004() -{ - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigabrt1 = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt1); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGABRT}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_004", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } - - remove_special_signal_handler(SIGABRT, sigchain_special_handler2); - remove_special_signal_handler(SIGABRT, sigchain_special_handler1); -} - -int main(void) -{ - sigchain_rm_special_handler_004(); - raise(SIGABRT); - EXPECT_EQ("sigchain_rm_special_handler_004", g_count, 0); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_e.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_e.c deleted file mode 100644 index 85a594d8..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_e.c +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_005", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_005", true); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_rm_special_handler_005", signo, SIGABRT); -} - -/** - * @tc.name : sigchain_rm_special_handler_005 - * @tc.desc : The signal is registered with the kernel(using signal), and add two special handler. - * Call the remove_special_signal_handler to remove the two special handler. - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_005() -{ - signal(SIGABRT, signal_handler); - - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigabrt1 = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt1); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGABRT}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_005", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } - - remove_special_signal_handler(SIGABRT, sigchain_special_handler2); - remove_special_signal_handler(SIGABRT, sigchain_special_handler1); -} - -int main(void) -{ - sigchain_rm_special_handler_005(); - raise(SIGABRT); - EXPECT_EQ("sigchain_rm_special_handler_005", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_f.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_f.c deleted file mode 100644 index e54c4595..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_f.c +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_006", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_006", true); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_sigaction(int signo) -{ - g_count++; - EXPECT_EQ("sigchain_rm_special_handler_006", signo, SIGABRT); -} - -/** - * @tc.name : sigchain_rm_special_handler_006 - * @tc.desc : The signal is registered with the kernel(using sigaction), and add two special handler. - * Call the remove_special_signal_handler to remove the two special handler. - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_006() -{ - struct sigaction sigac = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGABRT, &sigac, NULL); - - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigabrt2 = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt2); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_1] = {SIGABRT}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_006", signo, SIGCHIAN_TEST_SIGNAL_NUM_1); - } - - remove_special_signal_handler(SIGABRT, sigchain_special_handler2); - remove_special_signal_handler(SIGABRT, sigchain_special_handler1); -} - -int main(void) -{ - sigchain_rm_special_handler_006(); - raise(SIGABRT); - EXPECT_EQ("sigchain_rm_special_handler_006", g_count, SIGCHIAN_TEST_SIGNAL_NUM_1); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_g.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_g.c deleted file mode 100644 index 9c0852aa..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_g.c +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_007", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_007", true); - return false; -} - -/** - * @tc.name : sigchain_rm_special_handler_007 - * @tc.desc : The two signals are not registered with the kernel, and add the special handler for the two signals. - * Call the remove_special_signal_handler to remove the two signal's special handler. - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_007() -{ - struct signal_chain_action sig64 = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_64, &sig64); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGCHAIN_SIGNAL_64, SIGHUP}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_007", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); - } - - remove_special_signal_handler(SIGHUP, sigchain_special_handler2); - remove_special_signal_handler(SIGCHAIN_SIGNAL_64, sigchain_special_handler1); -} - -int main(void) -{ - sigchain_rm_special_handler_007(); - raise(SIGHUP); - raise(SIGCHAIN_SIGNAL_64); - EXPECT_EQ("sigchain_rm_special_handler_007", g_count, 0); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_h.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_h.c deleted file mode 100644 index dd87cd73..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_h.c +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_008", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_008", true); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler(int signo) -{ - g_count++; - if (signo == SIGHUP) { - EXPECT_EQ("sigchain_rm_special_handler_008", signo, SIGHUP); - } else { - EXPECT_EQ("sigchain_rm_special_handler_008", signo, SIGSEGV); - } -} - -/** - * @tc.name : sigchain_rm_special_handler_008 - * @tc.desc : The two signals are registered with the kernel(using signal), and add the special handler for - * the two signals. Call the remove_special_signal_handler to remove the two signal's special handler. - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_008() -{ - signal(SIGSEGV, signal_handler); - signal(SIGHUP, signal_handler); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGSEGV, SIGHUP}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_008", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); - } - - remove_special_signal_handler(SIGHUP, sigchain_special_handler2); - remove_special_signal_handler(SIGSEGV, sigchain_special_handler1); -} - -int main(void) -{ - sigchain_rm_special_handler_008(); - raise(SIGHUP); - raise(SIGSEGV); - EXPECT_EQ("sigchain_rm_special_handler_008", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_i.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_i.c deleted file mode 100644 index 71d47a47..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_i.c +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_009", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_009", true); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_sigaction(int signo) -{ - g_count++; - if (signo == SIGHUP) { - EXPECT_EQ("sigchain_rm_special_handler_009", signo, SIGHUP); - } else { - EXPECT_EQ("sigchain_rm_special_handler_009", signo, SIGSEGV); - } -} - -/** - * @tc.name : sigchain_rm_special_handler_008 - * @tc.desc : The two signals are registered with the kernel(using sigaction), and add the special handler for - * the two signals. Call the remove_special_signal_handler to remove the two signal's special handler. - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_009() -{ - struct sigaction sigac_segv = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGSEGV, &sigac_segv, NULL); - - struct sigaction sigac_hup = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGHUP, &sigac_hup, NULL); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - if (get_sigchain_mask_enable()) { - sigset_t set = {0}; - int signo[SIGCHIAN_TEST_SIGNAL_NUM_2] = {SIGSEGV, SIGHUP}; - SIGCHAIN_TEST_SET_MASK(set, "sigchain_rm_special_handler_009", signo, SIGCHIAN_TEST_SIGNAL_NUM_2); - } - - remove_special_signal_handler(SIGHUP, sigchain_special_handler2); - remove_special_signal_handler(SIGSEGV, sigchain_special_handler1); -} - -int main(void) -{ - sigchain_rm_special_handler_009(); - raise(SIGHUP); - raise(SIGSEGV); - EXPECT_EQ("sigchain_rm_special_handler_009", g_count, SIGCHIAN_TEST_SIGNAL_NUM_2); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_j.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_j.c deleted file mode 100644 index 47f739dc..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_j.c +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_010", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_010", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_010", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler4(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_010", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler5(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_010", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler6(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_010", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_010", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_010", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_010", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_010", true); - return false; -} - -/** - * @tc.name : sigchain_rm_special_handler_010 - * @tc.desc : The multiple signals(Coverage signal range) are not registered with the kernel, - * and add the special handler. Call the remove_special_signal_handler to remove - * the signals's special handler. - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_010() -{ - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler3, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct signal_chain_action sigurg = { - .sca_sigaction = sigchain_special_handler4, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGURG, &sigurg); - - struct signal_chain_action sigsys = { - .sca_sigaction = sigchain_special_handler5, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSYS, &sigsys); - - struct signal_chain_action sig37 = { - .sca_sigaction = sigchain_special_handler6, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_37, &sig37); - - struct signal_chain_action sig43 = { - .sca_sigaction = sigchain_special_handler7, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_43, &sig43); - - struct signal_chain_action sig50 = { - .sca_sigaction = sigchain_special_handler8, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_50, &sig50); - - struct signal_chain_action sig56 = { - .sca_sigaction = sigchain_special_handler9, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_56, &sig56); - - struct signal_chain_action sig64 = { - .sca_sigaction = sigchain_special_handler10, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_64, &sig64); - - remove_special_signal_handler(SIGHUP, sigchain_special_handler1); - remove_special_signal_handler(SIGABRT, sigchain_special_handler2); - remove_special_signal_handler(SIGSEGV, sigchain_special_handler3); - remove_special_signal_handler(SIGURG, sigchain_special_handler4); - remove_special_signal_handler(SIGSYS, sigchain_special_handler5); - remove_special_signal_handler(SIGCHAIN_SIGNAL_37, sigchain_special_handler6); - remove_special_signal_handler(SIGCHAIN_SIGNAL_43, sigchain_special_handler7); - remove_special_signal_handler(SIGCHAIN_SIGNAL_50, sigchain_special_handler8); - remove_special_signal_handler(SIGCHAIN_SIGNAL_56, sigchain_special_handler9); - remove_special_signal_handler(SIGCHAIN_SIGNAL_64, sigchain_special_handler10); - - raise(SIGCHAIN_SIGNAL_37); - raise(SIGCHAIN_SIGNAL_43); - raise(SIGCHAIN_SIGNAL_50); - raise(SIGCHAIN_SIGNAL_56); - raise(SIGCHAIN_SIGNAL_64); -} - -int main(void) -{ - sigchain_rm_special_handler_010(); - EXPECT_EQ("sigchain_rm_special_handler_010", g_count, 0); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_k.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_k.c deleted file mode 100644 index 0c7a5a0d..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_k.c +++ /dev/null @@ -1,270 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_011", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_011", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_011", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler4(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_011", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler5(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_011", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler6(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_011", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_011", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_011", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_011", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_011", true); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_handler(int signo) -{ - g_count++; - if (signo == SIGHUP) { - EXPECT_EQ("sigchain_rm_special_handler_011", signo, SIGHUP); - } else if (signo == SIGABRT) { - EXPECT_EQ("sigchain_rm_special_handler_011", signo, SIGABRT); - } else if (signo == SIGSEGV) { - EXPECT_EQ("sigchain_rm_special_handler_011", signo, SIGSEGV); - } else if (signo == SIGURG) { - EXPECT_EQ("sigchain_rm_special_handler_011", signo, SIGURG); - } else if (signo == SIGSYS) { - EXPECT_EQ("sigchain_rm_special_handler_011", signo, SIGSYS); - } else if (signo == SIGCHAIN_SIGNAL_37) { - EXPECT_EQ("sigchain_rm_special_handler_011", signo, SIGCHAIN_SIGNAL_37); - } else if (signo == SIGCHAIN_SIGNAL_43) { - EXPECT_EQ("sigchain_rm_special_handler_011", signo, SIGCHAIN_SIGNAL_43); - } else if (signo == SIGCHAIN_SIGNAL_50) { - EXPECT_EQ("sigchain_rm_special_handler_011", signo, SIGCHAIN_SIGNAL_50); - } else if (signo == SIGCHAIN_SIGNAL_56) { - EXPECT_EQ("sigchain_rm_special_handler_011", signo, SIGCHAIN_SIGNAL_56); - } else { - EXPECT_EQ("sigchain_rm_special_handler_011", signo, SIGCHAIN_SIGNAL_64); - } -} - -/** - * @tc.name : sigchain_rm_special_handler_011 - * @tc.desc : The multiple signals(Coverage signal range) are registered with the kernel(using signal), - * and add the special handler. Call the remove_special_signal_handler to remove - * the signals's special handler. - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_011() -{ - signal(SIGHUP, signal_handler); - signal(SIGABRT, signal_handler); - signal(SIGSEGV, signal_handler); - signal(SIGURG, signal_handler); - signal(SIGSYS, signal_handler); - signal(SIGCHAIN_SIGNAL_37, signal_handler); - signal(SIGCHAIN_SIGNAL_43, signal_handler); - signal(SIGCHAIN_SIGNAL_50, signal_handler); - signal(SIGCHAIN_SIGNAL_56, signal_handler); - signal(SIGCHAIN_SIGNAL_64, signal_handler); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler3, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct signal_chain_action sigurg = { - .sca_sigaction = sigchain_special_handler4, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGURG, &sigurg); - - struct signal_chain_action sigsys = { - .sca_sigaction = sigchain_special_handler5, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSYS, &sigsys); - - struct signal_chain_action sig37 = { - .sca_sigaction = sigchain_special_handler6, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_37, &sig37); - - struct signal_chain_action sig43 = { - .sca_sigaction = sigchain_special_handler7, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_43, &sig43); - - struct signal_chain_action sig50 = { - .sca_sigaction = sigchain_special_handler8, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_50, &sig50); - - struct signal_chain_action sig56 = { - .sca_sigaction = sigchain_special_handler9, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_56, &sig56); - - struct signal_chain_action sig64 = { - .sca_sigaction = sigchain_special_handler10, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_64, &sig64); - - remove_special_signal_handler(SIGHUP, sigchain_special_handler1); - remove_special_signal_handler(SIGABRT, sigchain_special_handler2); - remove_special_signal_handler(SIGSEGV, sigchain_special_handler3); - remove_special_signal_handler(SIGURG, sigchain_special_handler4); - remove_special_signal_handler(SIGSYS, sigchain_special_handler5); - remove_special_signal_handler(SIGCHAIN_SIGNAL_37, sigchain_special_handler6); - remove_special_signal_handler(SIGCHAIN_SIGNAL_43, sigchain_special_handler7); - remove_special_signal_handler(SIGCHAIN_SIGNAL_50, sigchain_special_handler8); - remove_special_signal_handler(SIGCHAIN_SIGNAL_56, sigchain_special_handler9); - remove_special_signal_handler(SIGCHAIN_SIGNAL_64, sigchain_special_handler10); -} - -int main(void) -{ - sigchain_rm_special_handler_011(); - raise(SIGHUP); - raise(SIGABRT); - raise(SIGSEGV); - raise(SIGURG); - raise(SIGSYS); - raise(SIGCHAIN_SIGNAL_37); - raise(SIGCHAIN_SIGNAL_43); - raise(SIGCHAIN_SIGNAL_50); - raise(SIGCHAIN_SIGNAL_56); - raise(SIGCHAIN_SIGNAL_64); - EXPECT_EQ("sigchain_rm_special_handler_011", g_count, SIGCHIAN_TEST_SIGNAL_NUM_10); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_l.c b/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_l.c deleted file mode 100644 index b9726f73..00000000 --- a/libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_l.c +++ /dev/null @@ -1,309 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include "test.h" -#include "functionalext.h" -#include "sigchain_util.h" - -static int g_count = 0; -/** - * @brief the special handler - */ -static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_012", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_012", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_012", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler4(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_012", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler5(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_012", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler6(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_012", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_012", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_012", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_012", true); - return false; -} - -/** - * @brief the special handler - */ -static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw) -{ - g_count++; - EXPECT_FALSE("sigchain_rm_special_handler_012", true); - return false; -} - -/** - * @brief the signal handler - */ -static void signal_sigaction(int signo) -{ - g_count++; - if (signo == SIGHUP) { - EXPECT_EQ("sigchain_rm_special_handler_012", signo, SIGHUP); - } else if (signo == SIGABRT) { - EXPECT_EQ("sigchain_rm_special_handler_012", signo, SIGABRT); - } else if (signo == SIGSEGV) { - EXPECT_EQ("sigchain_rm_special_handler_012", signo, SIGSEGV); - } else if (signo == SIGURG) { - EXPECT_EQ("sigchain_rm_special_handler_012", signo, SIGURG); - } else if (signo == SIGSYS) { - EXPECT_EQ("sigchain_rm_special_handler_012", signo, SIGSYS); - } else if (signo == SIGCHAIN_SIGNAL_37) { - EXPECT_EQ("sigchain_rm_special_handler_012", signo, SIGCHAIN_SIGNAL_37); - } else if (signo == SIGCHAIN_SIGNAL_43) { - EXPECT_EQ("sigchain_rm_special_handler_012", signo, SIGCHAIN_SIGNAL_43); - } else if (signo == SIGCHAIN_SIGNAL_50) { - EXPECT_EQ("sigchain_rm_special_handler_012", signo, SIGCHAIN_SIGNAL_50); - } else if (signo == SIGCHAIN_SIGNAL_56) { - EXPECT_EQ("sigchain_rm_special_handler_012", signo, SIGCHAIN_SIGNAL_56); - } else { - EXPECT_EQ("sigchain_rm_special_handler_012", signo, SIGCHAIN_SIGNAL_64); - } -} - -/** - * @tc.name : sigchain_rm_special_handler_012 - * @tc.desc : The multiple signals(Coverage signal range) are registered with the kernel(using sigaction), - * and add the special handler. Call the remove_special_signal_handler to remove - * the signals's special handler. - * @tc.level : Level 0 - */ -static void sigchain_rm_special_handler_012() -{ - struct sigaction sigaction0 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGHUP, &sigaction0, NULL); - - struct sigaction sigaction1 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGABRT, &sigaction1, NULL); - - struct sigaction sigaction2 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGSEGV, &sigaction2, NULL); - - struct sigaction sigaction3 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGURG, &sigaction3, NULL); - - struct sigaction sigaction4 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGSYS, &sigaction4, NULL); - - struct sigaction sigaction5 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGCHAIN_SIGNAL_37, &sigaction5, NULL); - - struct sigaction sigaction6 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGCHAIN_SIGNAL_43, &sigaction6, NULL); - - struct sigaction sigaction7 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGCHAIN_SIGNAL_50, &sigaction7, NULL); - - struct sigaction sigaction8 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGCHAIN_SIGNAL_56, &sigaction8, NULL); - - struct sigaction sigaction9 = { - .sa_handler = signal_sigaction, - }; - sigaction(SIGCHAIN_SIGNAL_64, &sigaction9, NULL); - - struct signal_chain_action sighup = { - .sca_sigaction = sigchain_special_handler1, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGHUP, &sighup); - - struct signal_chain_action sigabrt = { - .sca_sigaction = sigchain_special_handler2, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGABRT, &sigabrt); - - struct signal_chain_action sigsegv = { - .sca_sigaction = sigchain_special_handler3, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSEGV, &sigsegv); - - struct signal_chain_action sigurg = { - .sca_sigaction = sigchain_special_handler4, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGURG, &sigurg); - - struct signal_chain_action sigsys = { - .sca_sigaction = sigchain_special_handler5, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGSYS, &sigsys); - - struct signal_chain_action sig37 = { - .sca_sigaction = sigchain_special_handler6, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_37, &sig37); - - struct signal_chain_action sig43 = { - .sca_sigaction = sigchain_special_handler7, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_43, &sig43); - - struct signal_chain_action sig50 = { - .sca_sigaction = sigchain_special_handler8, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_50, &sig50); - - struct signal_chain_action sig56 = { - .sca_sigaction = sigchain_special_handler9, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_56, &sig56); - - struct signal_chain_action sig64 = { - .sca_sigaction = sigchain_special_handler10, - .sca_mask = {}, - .sca_flags = 0, - }; - add_special_signal_handler(SIGCHAIN_SIGNAL_64, &sig64); - - remove_special_signal_handler(SIGHUP, sigchain_special_handler1); - remove_special_signal_handler(SIGABRT, sigchain_special_handler2); - remove_special_signal_handler(SIGSEGV, sigchain_special_handler3); - remove_special_signal_handler(SIGURG, sigchain_special_handler4); - remove_special_signal_handler(SIGSYS, sigchain_special_handler5); - remove_special_signal_handler(SIGCHAIN_SIGNAL_37, sigchain_special_handler6); - remove_special_signal_handler(SIGCHAIN_SIGNAL_43, sigchain_special_handler7); - remove_special_signal_handler(SIGCHAIN_SIGNAL_50, sigchain_special_handler8); - remove_special_signal_handler(SIGCHAIN_SIGNAL_56, sigchain_special_handler9); - remove_special_signal_handler(SIGCHAIN_SIGNAL_64, sigchain_special_handler10); -} - -int main(void) -{ - sigchain_rm_special_handler_012(); - raise(SIGHUP); - raise(SIGABRT); - raise(SIGSEGV); - raise(SIGURG); - raise(SIGSYS); - raise(SIGCHAIN_SIGNAL_37); - raise(SIGCHAIN_SIGNAL_43); - raise(SIGCHAIN_SIGNAL_50); - raise(SIGCHAIN_SIGNAL_56); - raise(SIGCHAIN_SIGNAL_64); - EXPECT_EQ("sigchain_rm_special_handler_012", g_count, SIGCHIAN_TEST_SIGNAL_NUM_10); - return t_status; -} \ No newline at end of file diff --git a/libc-test/src/functionalext/sigchain/test_src_functionalext_sigchain.gni b/libc-test/src/functionalext/sigchain/test_src_functionalext_sigchain.gni index fb80c5c3..4a4086b9 100644 --- a/libc-test/src/functionalext/sigchain/test_src_functionalext_sigchain.gni +++ b/libc-test/src/functionalext/sigchain/test_src_functionalext_sigchain.gni @@ -11,43 +11,10 @@ # See the License for the specific language governing permissions and # limitations under the License. functionalext_sigchain_list = [ - "sigchain_add_special_handler_a", - "sigchain_add_special_handler_b", - "sigchain_add_special_handler_c", - "sigchain_add_special_handler_d", - "sigchain_add_special_handler_e", - "sigchain_add_special_handler_f", - "sigchain_add_special_handler_g", - "sigchain_add_special_handler_h", - "sigchain_add_special_handler_i", - "sigchain_add_special_handler_j", - "sigchain_add_special_handler_k", - "sigchain_add_special_handler_l", - "sigchain_rm_special_handler_a", - "sigchain_rm_special_handler_b", - "sigchain_rm_special_handler_c", - "sigchain_rm_special_handler_d", - "sigchain_rm_special_handler_e", - "sigchain_rm_special_handler_f", - "sigchain_rm_special_handler_g", - "sigchain_rm_special_handler_h", - "sigchain_rm_special_handler_i", - "sigchain_rm_special_handler_j", - "sigchain_rm_special_handler_k", - "sigchain_rm_special_handler_l", - "sigchain_intercept_sigaction_a", - "sigchain_intercept_sigaction_b", - "sigchain_intercept_sigaction_c", - "sigchain_intercept_sigaction_d", - "sigchain_intercept_signal_a", - "sigchain_intercept_signal_b", - "sigchain_intercept_signal_c", - "sigchain_intercept_sigprocmask_a", - "sigchain_intercept_sigprocmask_b", - "sigchain_intercept_sigprocmask_c", - "sigchain_intercept_sigprocmask_d", - "sigchain_intercept_sigprocmask_e", - "sigchain_intercept_sigprocmask_f", - "sigchain_intercept_sigprocmask_g", - "sigchain_call_special_handler_a", + "sigchain_add_special_handler", + "sigchain_rm_special_handler", + "sigchain_intercept_sigaction", + "sigchain_intercept_signal", + "sigchain_intercept_sigprocmask", + "sigchain_handler_call_order", ] diff --git a/libc-test/test_template.gni b/libc-test/test_template.gni index 3ff0f90a..23b374de 100644 --- a/libc-test/test_template.gni +++ b/libc-test/test_template.gni @@ -236,8 +236,6 @@ template("test_unittest") { if (target_dir == "functionalext/sigchain") { include_dirs += [ "//${musl_base_dir}/include" ] - - ldflags += [ "-Wl,-rpath=./" ] } } } diff --git a/porting/linux/user/src/signal/sigprocmask.c b/porting/linux/user/src/signal/sigprocmask.c index d38d8ffa..ca099dd6 100644 --- a/porting/linux/user/src/signal/sigprocmask.c +++ b/porting/linux/user/src/signal/sigprocmask.c @@ -14,12 +14,11 @@ static const char *param_name = "musl.sigchain.procmask"; bool get_sigchain_mask_enable() { #ifdef OHOS_ENABLE_PARAMETER - static CachedHandle musl_log_Handle = NULL; - if (musl_log_Handle == NULL) { - musl_log_Handle = CachedParameterCreate(param_name, "false"); + static CachedHandle sigchain_procmask_handle = NULL; + if (sigchain_procmask_handle == NULL) { + sigchain_procmask_handle = CachedParameterCreate(param_name, "false"); } - char *param_value = CachedParameterGet(musl_log_Handle); - + char *param_value = CachedParameterGet(sigchain_procmask_handle); if (param_value != NULL) { if (strcmp(param_value, "true") == 0) { return true; -- GitLab