diff --git a/libc-test/src/functionalext/common/sigchain_util.h b/libc-test/src/functionalext/common/sigchain_util.h index c9674e5185da706a3a4ec5c54fcc6580454873ee..494957513f81a3cc4472bd4e3e76fd8d1c641230 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 0000000000000000000000000000000000000000..3bbbd256fcd9b502ce03ccdca96d1a050a67fee6 --- /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 a1076f50f3bcdcb3c598ba4b1c581c9910cfc089..0000000000000000000000000000000000000000 --- 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 8ea149e8dcc4fc07587097d580ebfc6b0af1267f..0000000000000000000000000000000000000000 --- 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 4e31310bd4dbe56aee5de11d8916b85a68b3cb75..0000000000000000000000000000000000000000 --- 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 34f1f63355c4b1160def64624d4cad38fcce1725..0000000000000000000000000000000000000000 --- 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 697d1650b8311e932f1a84cec2b97002d2742f4c..0000000000000000000000000000000000000000 --- 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 4e54f3dd9e65e7bf014d9721a10f2c6b5b76f55e..0000000000000000000000000000000000000000 --- 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 17997ef1fdca15aa07836cbc244f3052332ba638..0000000000000000000000000000000000000000 --- 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 fcc0fda5d28ab447afc29de3fd7558b6bb0fd2a9..0000000000000000000000000000000000000000 --- 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 c644c5a9d3287eda6abd84e1789bbf15b6c5d59e..0000000000000000000000000000000000000000 --- 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 c6b92259f0fdd1f286f2f79b49da246dd77f254f..0000000000000000000000000000000000000000 --- 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 9131830c51ce982a22d0a7bcd74c1a23c008edd8..0000000000000000000000000000000000000000 --- 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 632be73acbeece8da6c0de4dfe25f752eb14d418..0000000000000000000000000000000000000000 --- 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 866bd04882f7b41f4478dbbcf165363979960b75..0000000000000000000000000000000000000000 --- 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 3e1e75a6c42e51f3ed938f33b881565a8b61b2cc..2b5bdbb6c0fa5b20c790a825adb479d658bf4eda 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 279d70b983e653595f07317dd819718a04898dcb..f27ed9b55674c3e33e46e11ce686c1ab45798f06 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 df00e397cb0f5c580aff6d0c4b46398e50252fb5..0000000000000000000000000000000000000000 --- 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 52ae85aa93645beec8fc8eba9bec28bf05d76116..0000000000000000000000000000000000000000 --- 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 ef7e4520d1bdce45ed13c23940529579d263140c..0000000000000000000000000000000000000000 --- 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 f14b833f1ef949c86257e79acc56f9ec545699dd..f8399f6558d26e73f172054bea89809cf9cba0f7 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 6161d20f936bf01c71c145f98adb54a9f84e134d..0000000000000000000000000000000000000000 --- 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 eee8fbbd096a5bd7172238d980b67669ac90e1a2..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..9d996b1ef7e8063227a4ae08e470f21d0c4da7b2 --- /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 5b6bca1bec95bb5054d4a9f8d9fba67bb37a6d5e..0000000000000000000000000000000000000000 --- 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 2b7147038a2b092ea4d5f1282ba0e478d92b9bfd..0000000000000000000000000000000000000000 --- 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 bee02a9aab7393725cd719658152a5bf0c6be375..0000000000000000000000000000000000000000 --- 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 e145c7ae31184e5950021a7cdee3070bd30acf66..0000000000000000000000000000000000000000 --- 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 75923e6459fee56fffd4f395f39d37f2b4122f05..0000000000000000000000000000000000000000 --- 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 429a97d95675fd958e9259962f25d25ab38388ff..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..0c5962f459424255e7573cba96a1643959919cff --- /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 78ecb82435397c0bf4b0cc0b393d3c39371fc50b..0000000000000000000000000000000000000000 --- 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 ce1cbc4398d4af51b5b80f5d1353c5ba4e70385b..0000000000000000000000000000000000000000 --- 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 0fee4a364f8e4c8836f533ca5a262f20c3b7dd3d..0000000000000000000000000000000000000000 --- 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 2f3d6f04fd3b62f6b5a291258d55cebed7a34b8c..0000000000000000000000000000000000000000 --- 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 85a594d8337a2fcdda158056058920da267f0438..0000000000000000000000000000000000000000 --- 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 e54c4595ad752fe634dcbad12e73a24791db705d..0000000000000000000000000000000000000000 --- 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 9c0852aa950b898901b7d7c9fe679899bcd74469..0000000000000000000000000000000000000000 --- 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 dd87cd73b80ab397b210c56b80057c88ed266567..0000000000000000000000000000000000000000 --- 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 71d47a470f3b6c18f13e32659a7d556570749e19..0000000000000000000000000000000000000000 --- 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 47f739dcd073940c5d3a5965127cb26531f9386e..0000000000000000000000000000000000000000 --- 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 0c7a5a0d10876017e5952281f584abceac886119..0000000000000000000000000000000000000000 --- 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 b9726f73f437b631f3fad76db25ca85bcb3be739..0000000000000000000000000000000000000000 --- 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 fb80c5c3aa887fcbd8fedc16ce91d8f80ad1c912..4a4086b9043d52b3e794dab4815ec13ca2ec7310 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 3ff0f90a50269ee67987d40ae11ccd7de46174d1..23b374de96c66edb9a2be5ce4ce75d07ef766997 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 d38d8ffafe4d64712f5858002cd806f3be8e3604..ca099dd6e18ebd80d9faf615ff266689530f5cc6 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;