提交 a3a42c48 编写于 作者: D dhy308

Add case for Sigchain

Issue: I6AEEI
Test: Build & Boot Devices
Signed-off-by: Ndhy308 <tony.gan@huawei.com>
上级 935f0ffb
/*
* 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.
*/
#define SIGCHIAN_TEST_SET_MASK(set, fun, signo, num) do{ \
int result = sigemptyset(&set); \
if (result != 0) { \
EXPECT_FALSE(fun, (result == 0)); \
} \
for (int i = 0; i < num; i++) { \
result = sigaddset(&set, signo[i]); \
if (result != 0) { \
EXPECT_FALSE(fun, (result == 0)); \
} \
} \
result = sigprocmask(SIG_BLOCK, &set, NULL); \
if (result != 0) { \
EXPECT_FALSE(fun, (result == 0)); \
} \
} while (0)
# Copyright (c) 2022 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.
import("../../../test_template.gni")
import("test_src_functionalext_sigchain.gni")
foreach(s, functionalext_sigchain_list) {
test_unittest(s) {
target_dir = "functionalext/sigchain"
}
}
group("functionalext_sigchain_test") {
testonly = true
deps = []
foreach(s, functionalext_sigchain_list) {
deps += [ ":${s}" ]
}
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @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);
return true;
}
/**
* @tc.name : sigchain_add_special_handler_001
* @tc.desc : Add a special handler for a signal that is not registered with
* the kernel in sigchain.
* @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);
sigset_t set = {0};
int signo[1] = {SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_001", signo, 1);
}
int main(void)
{
sigchain_add_special_handler_001();
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
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", signo, SIGSEGV);
return;
}
/**
* @tc.name : sigchain_add_special_handler_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_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);
sigset_t set = {0};
int signo[1] = {SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_002", signo, 1);
}
int main(void)
{
sigchain_add_special_handler_002();
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_003", signo, SIGSEGV);
return false;
}
/**
* @brief the signal handler
*/
static void signal_sigaction(int signo)
{
EXPECT_EQ("sigchain_add_special_handler_003", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_add_special_handler_003
* @tc.desc : Add a special handler for a signal that is registered with
* the kernel (Using sigaction interface) in sigchain.
* @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);
sigset_t set = {0};
int signo[1] = {SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_003", signo, 1);
}
int main(void)
{
sigchain_add_special_handler_003();
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_004", signo, SIGSEGV);
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_004", signo, SIGSEGV);
return true;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_add_special_handler_004", false);
return false;
}
/**
* @tc.name : sigchain_add_special_handler_004
* @tc.desc : Add multiple special handlers for a signal that is not registered with
* the kernel in sigchain.
* @tc.level : Level 0
*/
static void sigchain_add_special_handler_004()
{
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 sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = SIGCHAIN_ALLOW_NORETURN,
};
add_special_signal_handler(SIGSEGV, &sigsegv1);
struct signal_chain_action sigsegv2 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv2);
sigset_t set = {0};
int signo[1] = {SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_004", signo, 1);
}
int main(void)
{
sigchain_add_special_handler_004();
raise(SIGSEGV);
raise(SIGSEGV);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_005", signo, SIGSEGV);
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_005", signo, SIGSEGV);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_add_special_handler_005", false);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler(int signo)
{
EXPECT_EQ("sigchain_add_special_handler_005", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_add_special_handler_005
* @tc.desc : Add multiple special handlers for a signal that is registered with
* the kernel (Using signal interface) in sigchain.
* @tc.level : Level 0
*/
static void sigchain_add_special_handler_005()
{
signal(SIGSEGV, 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 sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv1);
struct signal_chain_action sigsegv2 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv2);
sigset_t set = {0};
int signo[1] = {SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_005", signo, 1);
}
int main(void)
{
sigchain_add_special_handler_005();
raise(SIGSEGV);
raise(SIGSEGV);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_006", signo, SIGSEGV);
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_006", signo, SIGSEGV);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_add_special_handler_006", false);
return false;
}
/**
* @brief the signal handler
*/
static void signal_sigaction(int signo)
{
EXPECT_EQ("sigchain_add_special_handler_006", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_add_special_handler_006
* @tc.desc : Add multiple special handlers for a signal that is registered with
* the kernel (Using sigaction interface) in sigchain.
* @tc.level : Level 0
*/
static void sigchain_add_special_handler_006()
{
struct sigaction sigsegv1 = {
.sa_handler = signal_sigaction,
};
sigaction(SIGSEGV, &sigsegv1, 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 sigsegv2 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv2);
struct signal_chain_action sigsegv3 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv3);
sigset_t set = {0};
int signo[1] = {SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_006", signo, 1);
}
int main(void)
{
sigchain_add_special_handler_006();
raise(SIGSEGV);
raise(SIGSEGV);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
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)
{
EXPECT_EQ("sigchain_add_special_handler_007", signo, SIGHUP);
return true;
}
/**
* @tc.name : sigchain_add_special_handler_007
* @tc.desc : Add multiple special handlers for the different signals that is not registered with
* the kernel in sigchain.
* @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 sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv1);
sigset_t set = {0};
int signo[2] = {SIGSEGV, SIGHUP};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_007", signo, 2);
}
int main(void)
{
sigchain_add_special_handler_007();
raise(SIGHUP);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @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);
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);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler(int signo)
{
if (signo == SIGHUP) {
EXPECT_EQ("sigchain_add_special_handler_008", signo, SIGHUP);
} else {
EXPECT_EQ("sigchain_add_special_handler_008", signo, SIGSEGV);
}
}
/**
* @tc.name : sigchain_add_special_handler_008
* @tc.desc : Add multiple special handlers for the different signals that is registered with
* the kernel (Using signal interface) in sigchain.
* @tc.level : Level 0
*/
static void sigchain_add_special_handler_008()
{
signal(SIGSEGV, 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 sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv1);
sigset_t set = {0};
int signo[2] = {SIGSEGV, SIGHUP};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_008", signo, 2);
}
int main(void)
{
sigchain_add_special_handler_008();
raise(SIGHUP);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
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)
{
EXPECT_EQ("sigchain_add_special_handler_009", signo, SIGHUP);
return false;
}
/**
* @brief the signal handler
*/
static void signal_sigaction(int signo)
{
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 : Add multiple special handlers for the different signals that is registered with
* the kernel (Using sigaction interface) in sigchain.
* @tc.level : Level 0
*/
static void sigchain_add_special_handler_009()
{
struct sigaction sigsegv1 = {
.sa_handler = signal_sigaction,
};
sigaction(SIGSEGV, &sigsegv1, 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 sigsegv2 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv2);
sigset_t set = {0};
int signo[2] = {SIGSEGV, SIGHUP};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_009", signo, 2);
}
int main(void)
{
sigchain_add_special_handler_009();
raise(SIGHUP);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
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)
{
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)
{
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)
{
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)
{
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)
{
EXPECT_EQ("sigchain_add_special_handler_010", signo, 37);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_010", signo, 43);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_010", signo, 50);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_010", signo, 56);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_010", signo, 64);
return false;
}
/**
* @tc.name : sigchain_add_special_handler_010
* @tc.desc : Add multiple special handlers for the different signals that is not registered with
* the kernel in sigchain.
* @tc.level : Level 0
*/
static void sigchain_add_special_handler_010()
{
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGABRT, &sigsegv1);
struct signal_chain_action sigsegv2 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv2);
struct signal_chain_action sigsegv3 = {
.sca_sigaction = sigchain_special_handler4,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGURG, &sigsegv3);
struct signal_chain_action sigsegv4 = {
.sca_sigaction = sigchain_special_handler5,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSYS, &sigsegv4);
struct signal_chain_action sigsegv5 = {
.sca_sigaction = sigchain_special_handler6,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(37, &sigsegv5);
struct signal_chain_action sigsegv6 = {
.sca_sigaction = sigchain_special_handler7,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(43, &sigsegv6);
struct signal_chain_action sigsegv7 = {
.sca_sigaction = sigchain_special_handler8,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(50, &sigsegv7);
struct signal_chain_action sigsegv8 = {
.sca_sigaction = sigchain_special_handler9,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(56, &sigsegv8);
struct signal_chain_action sigsegv9 = {
.sca_sigaction = sigchain_special_handler10,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(64, &sigsegv9);
sigset_t set = {0};
int signo[10] = {SIGHUP, SIGABRT, SIGSEGV, SIGURG, SIGSYS, 37, 43, 50, 56, 64};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_010", signo, 10);
}
int main(void)
{
sigchain_add_special_handler_010();
raise(SIGHUP);
raise(SIGABRT);
raise(SIGSEGV);
raise(SIGURG);
raise(SIGSYS);
raise(37);
raise(43);
raise(50);
raise(56);
raise(64);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
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)
{
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)
{
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)
{
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)
{
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)
{
EXPECT_EQ("sigchain_add_special_handler_011", signo, 37);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_011", signo, 43);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_011", signo, 50);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_011", signo, 56);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_011", signo, 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 == 37) {
EXPECT_EQ("sigchain_add_special_handler_011", signo, 37);
} else if (signo == 43) {
EXPECT_EQ("sigchain_add_special_handler_011", signo, 43);
} else if (signo == 50) {
EXPECT_EQ("sigchain_add_special_handler_011", signo, 50);
} else if (signo ==56) {
EXPECT_EQ("sigchain_add_special_handler_011", signo, 56);
} else {
EXPECT_EQ("sigchain_add_special_handler_011", signo, 64);
}
}
/**
* @tc.name : sigchain_add_special_handler_011
* @tc.desc : Add multiple special handlers for the different signals that is registered with
* the kernel (Using signal interface) in sigchain.
* @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(37, signal_handler);
signal(43, signal_handler);
signal(50, signal_handler);
signal(56, signal_handler);
signal(64, signal_handler);
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGABRT, &sigsegv1);
struct signal_chain_action sigsegv2 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv2);
struct signal_chain_action sigsegv3 = {
.sca_sigaction = sigchain_special_handler4,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGURG, &sigsegv3);
struct signal_chain_action sigsegv4 = {
.sca_sigaction = sigchain_special_handler5,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSYS, &sigsegv4);
struct signal_chain_action sigsegv5 = {
.sca_sigaction = sigchain_special_handler6,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(37, &sigsegv5);
struct signal_chain_action sigsegv6 = {
.sca_sigaction = sigchain_special_handler7,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(43, &sigsegv6);
struct signal_chain_action sigsegv7 = {
.sca_sigaction = sigchain_special_handler8,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(50, &sigsegv7);
struct signal_chain_action sigsegv8 = {
.sca_sigaction = sigchain_special_handler9,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(56, &sigsegv8);
struct signal_chain_action sigsegv9 = {
.sca_sigaction = sigchain_special_handler10,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(64, &sigsegv9);
sigset_t set = {0};
int signo[10] = {SIGHUP, SIGABRT, SIGSEGV, SIGURG, SIGSYS, 37, 43, 50, 56, 64};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_011", signo, 10);
}
int main(void)
{
sigchain_add_special_handler_011();
raise(SIGHUP);
raise(SIGABRT);
raise(SIGSEGV);
raise(SIGURG);
raise(SIGSYS);
raise(37);
raise(43);
raise(50);
raise(56);
raise(64);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <signal.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
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)
{
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)
{
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)
{
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)
{
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)
{
EXPECT_EQ("sigchain_add_special_handler_012", signo, 37);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_012", signo, 43);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_012", signo, 50);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_012", signo, 56);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_add_special_handler_012", signo, 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 == 37) {
EXPECT_EQ("sigchain_add_special_handler_012", signo, 37);
} else if (signo == 43) {
EXPECT_EQ("sigchain_add_special_handler_012", signo, 43);
} else if (signo == 50) {
EXPECT_EQ("sigchain_add_special_handler_012", signo, 50);
} else if (signo ==56) {
EXPECT_EQ("sigchain_add_special_handler_012", signo, 56);
} else {
EXPECT_EQ("sigchain_add_special_handler_012", signo, 64);
}
}
/**
* @tc.name : sigchain_add_special_handler_012
* @tc.desc : Add multiple special handlers for the different signals that is registered with
* the kernel (Using sigaction interface) in sigchain.
* @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(37, &sigaction5, NULL);
struct sigaction sigaction6 = {
.sa_handler = signal_sigaction,
};
sigaction(43, &sigaction6, NULL);
struct sigaction sigaction7 = {
.sa_handler = signal_sigaction,
};
sigaction(50, &sigaction7, NULL);
struct sigaction sigaction8 = {
.sa_handler = signal_sigaction,
};
sigaction(56, &sigaction8, NULL);
struct sigaction sigaction9 = {
.sa_handler = signal_sigaction,
};
sigaction(64, &sigaction9, NULL);
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = SIGCHAIN_ALLOW_NORETURN,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = SIGCHAIN_ALLOW_NORETURN,
};
add_special_signal_handler(SIGABRT, &sigsegv1);
struct signal_chain_action sigsegv2 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = SIGCHAIN_ALLOW_NORETURN,
};
add_special_signal_handler(SIGSEGV, &sigsegv2);
struct signal_chain_action sigsegv3 = {
.sca_sigaction = sigchain_special_handler4,
.sca_mask = {},
.sca_flags = SIGCHAIN_ALLOW_NORETURN,
};
add_special_signal_handler(SIGURG, &sigsegv3);
struct signal_chain_action sigsegv4 = {
.sca_sigaction = sigchain_special_handler5,
.sca_mask = {},
.sca_flags = SIGCHAIN_ALLOW_NORETURN,
};
add_special_signal_handler(SIGSYS, &sigsegv4);
struct signal_chain_action sigsegv5 = {
.sca_sigaction = sigchain_special_handler6,
.sca_mask = {},
.sca_flags = SIGCHAIN_ALLOW_NORETURN,
};
add_special_signal_handler(37, &sigsegv5);
struct signal_chain_action sigsegv6 = {
.sca_sigaction = sigchain_special_handler7,
.sca_mask = {},
.sca_flags = SIGCHAIN_ALLOW_NORETURN,
};
add_special_signal_handler(43, &sigsegv6);
struct signal_chain_action sigsegv7 = {
.sca_sigaction = sigchain_special_handler8,
.sca_mask = {},
.sca_flags = SIGCHAIN_ALLOW_NORETURN,
};
add_special_signal_handler(50, &sigsegv7);
struct signal_chain_action sigsegv8 = {
.sca_sigaction = sigchain_special_handler9,
.sca_mask = {},
.sca_flags = SIGCHAIN_ALLOW_NORETURN,
};
add_special_signal_handler(56, &sigsegv8);
struct signal_chain_action sigsegv9 = {
.sca_sigaction = sigchain_special_handler10,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(64, &sigsegv9);
sigset_t set = {0};
int signo[10] = {SIGHUP, SIGABRT, SIGSEGV, SIGURG, SIGSYS, 37, 43, 50, 56, 64};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_012", signo, 10);
}
int main(void)
{
sigchain_add_special_handler_012();
raise(SIGHUP);
raise(SIGABRT);
raise(SIGSEGV);
raise(SIGURG);
raise(SIGSYS);
raise(37);
raise(43);
raise(50);
raise(56);
raise(64);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_add_special_handler_013", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_add_special_handler_013", false);
return false;
}
/**
* @tc.name : sigchain_add_special_handler_013
* @tc.desc : Add the special handler with wrong signal
* @tc.level : Level 2
*/
static void sigchain_add_special_handler_013()
{
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(0, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(65, &sigsegv1);
}
int main(void)
{
sigchain_add_special_handler_013();
return t_status;
}
\ No newline at end of file
/*
* 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 <signal.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
/**
* @brief the special handler
*/
static void signal_handler1(int signo)
{
EXPECT_EQ("sigchain_intercept_sigaction_001", signo, SIGHUP);
}
/**
* @brief the special handler
*/
static void signal_handler2(int signo)
{
EXPECT_EQ("sigchain_intercept_sigaction_001", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_intercept_sigaction_001
* @tc.desc : Test the influence of sigchain on sigaction, the signals are not registered with
* the special handler
* @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);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_intercept_sigaction_002", signo, SIGHUP);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_intercept_sigaction_002", signo, SIGSEGV);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler1(int signo)
{
EXPECT_EQ("sigchain_intercept_sigaction_002", signo, SIGHUP);
}
/**
* @brief the signal handler
*/
static void signal_handler2(int signo)
{
EXPECT_EQ("sigchain_intercept_sigaction_002", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_intercept_sigaction_002
* @tc.desc : Test the influence of sigchain on sigaction. the signals are registered with
* the special handler
* @tc.level : Level 0
*/
static void sigchain_intercept_sigaction_002()
{
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv1);
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[2] = {SIGSEGV, SIGHUP};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_intercept_sigaction_002", signo, 2);
}
int main(void)
{
sigchain_intercept_sigaction_002();
raise(SIGHUP);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
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)
{
EXPECT_EQ("sigchain_intercept_sigaction_003", signo, SIGSEGV);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler1(int signo)
{
EXPECT_EQ("sigchain_intercept_sigaction_003", signo, SIGHUP);
}
/**
* @brief the signal handler
*/
static void signal_handler2(int signo)
{
EXPECT_EQ("sigchain_intercept_sigaction_003", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_intercept_sigaction_003
* @tc.desc : Test the influence of sigchain on sigaction. the signals are registered with
* the special handler, and remove the special handler.
* @tc.level : Level 0
*/
static void sigchain_intercept_sigaction_003()
{
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv1);
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[2] = {SIGSEGV, SIGHUP};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_intercept_sigaction_002", signo, 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);
return t_status;
}
\ No newline at end of file
/*
* 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 <signal.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
/**
* @brief the signal handler
*/
static void signal_handler1(int signo)
{
EXPECT_EQ("sigchain_intercept_signal_001", signo, SIGHUP);
}
/**
* @brief the signal handler
*/
static void signal_handler2(int signo)
{
EXPECT_EQ("sigchain_intercept_signal_001", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_add_special_handler_025
* @tc.desc : Test the influence of sigchain on signal, the signals are not registered with
* the special handler
* @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);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_intercept_signal_002", signo, SIGHUP);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_intercept_signal_002", signo, SIGSEGV);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler1(int signo)
{
EXPECT_EQ("sigchain_intercept_signal_002", signo, SIGHUP);
}
/**
* @brief the signal handler
*/
static void signal_handler2(int signo)
{
EXPECT_EQ("sigchain_intercept_signal_002", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_intercept_signal_002
* @tc.desc : Test the influence of sigchain on signal. the signals are registered with
* the special handler
* @tc.level : Level 0
*/
static void sigchain_intercept_signal_002()
{
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv1);
signal(SIGHUP, signal_handler1);
signal(SIGSEGV, signal_handler2);
sigset_t set = {0};
int signo[2] = {SIGSEGV, SIGHUP};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_intercept_signal_002", signo, 2);
}
int main(void)
{
sigchain_intercept_signal_002();
raise(SIGHUP);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
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)
{
EXPECT_EQ("sigchain_intercept_signal_003", signo, SIGSEGV);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler1(int signo)
{
EXPECT_EQ("sigchain_intercept_signal_003", signo, SIGHUP);
}
/**
* @brief the signal handler
*/
static void signal_handler2(int signo)
{
EXPECT_EQ("sigchain_intercept_signal_003", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_intercept_signal_003
* @tc.desc : Test the influence of sigchain on signal. the signals are registered with
* the special handler, and remove the special handler.
* @tc.level : Level 0
*/
static void sigchain_intercept_signal_003()
{
struct signal_chain_action sigsegv0 = {
.sca_sigaction = sigchain_special_handler,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv0);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv1);
signal(SIGHUP, signal_handler1);
signal(SIGSEGV, signal_handler2);
remove_special_signal_handler(SIGHUP, sigchain_special_handler);
remove_special_signal_handler(SIGSEGV, sigchain_special_handler1);
sigset_t set = {0};
int signo[2] = {SIGSEGV, SIGHUP};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_intercept_sigaction_002", signo, 2);
}
int main(void)
{
sigchain_intercept_signal_003();
raise(SIGHUP);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <signal.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the signal handler
*/
static void signal_handler1(int signo)
{
EXPECT_FALSE("sigchain_intercept_sigprocmask_001", false);
}
/**
* @brief the signal handler
*/
static void signal_handler2(int signo)
{
EXPECT_FALSE("sigchain_intercept_sigprocmask_001", false);
}
/**
* @tc.name : sigchain_intercept_sigprocmask_001
* @tc.desc : Test the influence of sigchain on sigprocmask, the signals are not registered with
* the special handler
* @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[2] = {SIGHUP, SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_001", signo, 2);
}
int main(void)
{
sigchain_intercept_sigprocmask_001();
raise(SIGHUP);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
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)
{
EXPECT_EQ("sigchain_intercept_sigprocmask_002", signo, SIGSEGV);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler1(int signo)
{
EXPECT_EQ("sigchain_intercept_sigprocmask_002", signo, SIGHUP);
}
/**
* @brief the signal handler
*/
static void signal_handler2(int signo)
{
EXPECT_EQ("sigchain_intercept_sigprocmask_002", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_intercept_sigprocmask_002
* @tc.desc : Test the influence of sigchain on sigprocmask, the signals are registered with
* the special handler
* @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 sigsegv = {
.sca_sigaction = sigchain_special_handler,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv1);
sigset_t set = {0};
int signo[2] = {SIGHUP, SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_002", signo, 2);
}
int main(void)
{
sigchain_intercept_sigprocmask_002();
raise(SIGHUP);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_intercept_sigprocmask_003", signo, SIGHUP);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_intercept_sigprocmask_003", signo, SIGHUP);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler1(int signo)
{
EXPECT_EQ("sigchain_intercept_sigprocmask_003", signo, SIGHUP);
}
/**
* @brief the signal handler
*/
static void signal_handler2(int signo)
{
EXPECT_EQ("sigchain_intercept_sigprocmask_003", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_intercept_sigprocmask_003
* @tc.desc : Test the influence of sigchain on sigprocmask. the signals are registered with
* the special handler, and remove the special handler.
* @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 sigsegv = {
.sca_sigaction = sigchain_special_handler,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv1);
sigset_t set = {0};
int signo[2] = {SIGHUP, SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_003", signo, 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);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include <threads.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_intercept_sigprocmask_004", signo, SIGHUP);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_EQ("sigchain_intercept_sigprocmask_004", signo, SIGHUP);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler1(int signo)
{
EXPECT_EQ("sigchain_intercept_sigprocmask_004", signo, SIGHUP);
}
/**
* @brief the signal handler
*/
static void signal_handler2(int signo)
{
EXPECT_EQ("sigchain_intercept_sigprocmask_004", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_intercept_sigprocmask_004
* @tc.desc : Test the influence of sigchain on sigprocmask. the signals are registered with
* the special handler, and the case is called by multiple threads
* @tc.level : Level 0
*/
static void sigchain_intercept_sigprocmask_004()
{
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 sigsegv = {
.sca_sigaction = sigchain_special_handler,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv1);
sigset_t set = {0};
int signo[2] = {SIGHUP, SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_intercept_sigprocmask_004", signo, 2);
}
void thread_func(void *data)
{
sigchain_intercept_sigprocmask_004();
raise(SIGHUP);
raise(SIGSEGV);
}
int main(void)
{
thrd_t t1, t2, t3, t4;
thrd_create(&t1, (thrd_start_t)thread_func, NULL);
thrd_create(&t2, (thrd_start_t)thread_func, NULL);
thrd_create(&t3, (thrd_start_t)thread_func, NULL);
thrd_create(&t4, (thrd_start_t)thread_func, NULL);
thrd_join(t1, NULL);
thrd_join(t2, NULL);
thrd_join(t3, NULL);
thrd_join(t4, NULL);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_001", false);
return false;
}
/**
* @tc.name : sigchain_rm_special_handler_001
* @tc.desc : remove a special handler for a signal that is not registered with
* the kernel in sigchain.
* @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);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_002", false);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler(int signo)
{
EXPECT_EQ("sigchain_rm_special_handler_002", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_rm_special_handler_002
* @tc.desc : Remove a special handler for a signal that is registered with
* the kernel (Using signal interface) in sigchain.
* @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);
sigset_t set = {0};
int signo[1] = {SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_add_special_handler_002", signo, 1);
remove_special_signal_handler(SIGSEGV, sigchain_special_handler);
}
int main(void)
{
sigchain_rm_special_handler_002();
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_003", false);
return true;
}
/**
* @brief the signal handler
*/
static void signal_sigaction(int signo)
{
EXPECT_EQ("sigchain_rm_special_handler_003", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_rm_special_handler_003
* @tc.desc : Remove a special handler for a signal that is registered with
* the kernel (Using sigaction interface) in sigchain.
* @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);
sigset_t set = {0};
int signo[1] = {SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_rm_special_handler_003", signo, 1);
remove_special_signal_handler(SIGSEGV, sigchain_special_handler);
}
int main(void)
{
sigchain_rm_special_handler_003();
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_004", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_004", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler3(int signo, siginfo_t* siginfo, void* ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_004", false);
return false;
}
/**
* @tc.name : sigchain_rm_special_handler_004
* @tc.desc : remove multiple special handlers for a signal that is not registered with
* the kernel in sigchain.
* @tc.level : Level 0
*/
static void sigchain_rm_special_handler_004()
{
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv1);
struct signal_chain_action sigsegv2 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv2);
sigset_t set = {0};
int signo[1] = {SIGHUP};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_rm_special_handler_004", signo, 1);
remove_special_signal_handler(SIGHUP, sigchain_special_handler3);
remove_special_signal_handler(SIGHUP, sigchain_special_handler2);
remove_special_signal_handler(SIGHUP, sigchain_special_handler1);
}
int main(void)
{
sigchain_rm_special_handler_004();
raise(SIGHUP);
raise(SIGHUP);
raise(SIGHUP);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_005", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_005", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_005", false);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler(int signo)
{
EXPECT_EQ("sigchain_rm_special_handler_005", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_rm_special_handler_005
* @tc.desc : Remove multiple special handlers for a signal that is registered with
* the kernel (Using signal interface) in sigchain.
* @tc.level : Level 0
*/
static void sigchain_rm_special_handler_005()
{
signal(SIGSEGV, 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 sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv1);
struct signal_chain_action sigsegv2 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv2);
sigset_t set = {0};
int signo[1] = {SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_rm_special_handler_005", signo, 1);
remove_special_signal_handler(SIGSEGV, sigchain_special_handler3);
remove_special_signal_handler(SIGSEGV, sigchain_special_handler2);
remove_special_signal_handler(SIGSEGV, sigchain_special_handler1);
}
int main(void)
{
sigchain_rm_special_handler_005();
raise(SIGSEGV);
raise(SIGSEGV);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_006", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_006", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_006", false);
return false;
}
/**
* @brief the signal handler
*/
static void signal_sigaction(int signo)
{
EXPECT_EQ("sigchain_rm_special_handler_006", signo, SIGSEGV);
}
/**
* @tc.name : sigchain_rm_special_handler_006
* @tc.desc : Remove multiple special handlers for a signal that is registered with
* the kernel (Using sigaction interface) in sigchain.
* @tc.level : Level 0
*/
static void sigchain_rm_special_handler_006()
{
struct sigaction sigsegv1 = {
.sa_handler = signal_sigaction,
};
sigaction(SIGSEGV, &sigsegv1, 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 sigsegv2 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv2);
struct signal_chain_action sigsegv3 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv3);
sigset_t set = {0};
int signo[1] = {SIGSEGV};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_rm_special_handler_006", signo, 1);
remove_special_signal_handler(SIGSEGV, sigchain_special_handler3);
remove_special_signal_handler(SIGSEGV, sigchain_special_handler2);
remove_special_signal_handler(SIGSEGV, sigchain_special_handler1);
}
int main(void)
{
sigchain_rm_special_handler_006();
raise(SIGSEGV);
raise(SIGSEGV);
raise(SIGSEGV);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_007", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_007", false);
return false;
}
/**
* @tc.name : sigchain_rm_special_handler_007
* @tc.desc : Remove the special handlers for the different signals that is not registered with
* the kernel in sigchain.
* @tc.level : Level 0
*/
static void sigchain_rm_special_handler_007()
{
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(64, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv1);
sigset_t set = {0};
int signo[2] = {SIGSEGV, SIGHUP};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_rm_special_handler_007", signo, 2);
remove_special_signal_handler(SIGHUP, sigchain_special_handler1);
remove_special_signal_handler(64, sigchain_special_handler2);
}
int main(void)
{
sigchain_rm_special_handler_007();
raise(SIGHUP);
raise(64);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_008", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_008", false);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler(int signo)
{
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 : Add the special handler for the different signals that is registered with
* the kernel (Using signal interface) in sigchain.
* @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 sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv1);
sigset_t set = {0};
int signo[2] = {SIGSEGV, SIGHUP};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_rm_special_handler_008", signo, 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);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
#include "sigchain_util.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_009", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_009", false);
return false;
}
/**
* @brief the signal handler
*/
static void signal_sigaction(int signo)
{
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 : Add the special handler for the different signals that is registered with
* the kernel (Using sigaction interface) in sigchain.
* @tc.level : Level 0
*/
static void sigchain_rm_special_handler_009()
{
struct sigaction sigsegv1 = {
.sa_handler = signal_sigaction,
};
sigaction(SIGSEGV, &sigsegv1, NULL);
struct sigaction sigsegv2 = {
.sa_handler = signal_sigaction,
};
sigaction(SIGHUP, &sigsegv2, 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);
sigset_t set = {0};
int signo[2] = {SIGSEGV, SIGHUP};
SIGCHIAN_TEST_SET_MASK(set, "sigchain_rm_special_handler_009", signo, 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);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_010", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_010", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_010", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler4(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_010", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler5(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_010", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler6(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_010", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_010", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_010", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_010", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_010", false);
return false;
}
/**
* @tc.name : sigchain_rm_special_handler_010
* @tc.desc : Remove multiple special handlers for the different signals that are not registered with
* the kernel in sigchain.
* @tc.level : Level 0
*/
static void sigchain_rm_special_handler_010()
{
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGABRT, &sigsegv1);
struct signal_chain_action sigsegv2 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv2);
struct signal_chain_action sigsegv3 = {
.sca_sigaction = sigchain_special_handler4,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGURG, &sigsegv3);
struct signal_chain_action sigsegv4 = {
.sca_sigaction = sigchain_special_handler5,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSYS, &sigsegv4);
struct signal_chain_action sigsegv5 = {
.sca_sigaction = sigchain_special_handler6,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(37, &sigsegv5);
struct signal_chain_action sigsegv6 = {
.sca_sigaction = sigchain_special_handler7,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(43, &sigsegv6);
struct signal_chain_action sigsegv7 = {
.sca_sigaction = sigchain_special_handler8,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(50, &sigsegv7);
struct signal_chain_action sigsegv8 = {
.sca_sigaction = sigchain_special_handler9,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(56, &sigsegv8);
struct signal_chain_action sigsegv9 = {
.sca_sigaction = sigchain_special_handler10,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(64, &sigsegv9);
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(37, sigchain_special_handler6);
remove_special_signal_handler(43, sigchain_special_handler7);
remove_special_signal_handler(50, sigchain_special_handler8);
remove_special_signal_handler(56, sigchain_special_handler9);
remove_special_signal_handler(64, sigchain_special_handler10);
raise(SIGHUP);
raise(SIGURG);
raise(37);
raise(43);
raise(50);
raise(56);
raise(64);
}
int main(void)
{
sigchain_rm_special_handler_010();
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_011", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_011", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_011", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler4(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_011", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler5(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_011", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler6(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_011", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_011", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_011", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_011", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_011", false);
return false;
}
/**
* @brief the signal handler
*/
static void signal_handler(int signo)
{
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 == 37) {
EXPECT_EQ("sigchain_rm_special_handler_011", signo, 37);
} else if (signo == 43) {
EXPECT_EQ("sigchain_rm_special_handler_011", signo, 43);
} else if (signo == 50) {
EXPECT_EQ("sigchain_rm_special_handler_011", signo, 50);
} else if (signo == 56) {
EXPECT_EQ("sigchain_rm_special_handler_011", signo, 56);
} else {
EXPECT_EQ("sigchain_rm_special_handler_011", signo, 64);
}
}
/**
* @tc.name : sigchain_rm_special_handler_011
* @tc.desc : Remove multiple special handlers for the different signals that is registered with
* the kernel (Using signal interface) in sigchain.
* @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(37, signal_handler);
signal(43, signal_handler);
signal(50, signal_handler);
signal(56, signal_handler);
signal(64, signal_handler);
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGABRT, &sigsegv1);
struct signal_chain_action sigsegv2 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv2);
struct signal_chain_action sigsegv3 = {
.sca_sigaction = sigchain_special_handler4,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGURG, &sigsegv3);
struct signal_chain_action sigsegv4 = {
.sca_sigaction = sigchain_special_handler5,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSYS, &sigsegv4);
struct signal_chain_action sigsegv5 = {
.sca_sigaction = sigchain_special_handler6,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(37, &sigsegv5);
struct signal_chain_action sigsegv6 = {
.sca_sigaction = sigchain_special_handler7,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(43, &sigsegv6);
struct signal_chain_action sigsegv7 = {
.sca_sigaction = sigchain_special_handler8,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(50, &sigsegv7);
struct signal_chain_action sigsegv8 = {
.sca_sigaction = sigchain_special_handler9,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(56, &sigsegv8);
struct signal_chain_action sigsegv9 = {
.sca_sigaction = sigchain_special_handler10,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(64, &sigsegv9);
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(37, sigchain_special_handler6);
remove_special_signal_handler(43, sigchain_special_handler7);
remove_special_signal_handler(50, sigchain_special_handler8);
remove_special_signal_handler(56, sigchain_special_handler9);
remove_special_signal_handler(64, sigchain_special_handler10);
}
int main(void)
{
sigchain_rm_special_handler_011();
raise(SIGHUP);
raise(SIGABRT);
raise(SIGSEGV);
raise(SIGURG);
raise(SIGSYS);
raise(37);
raise(43);
raise(50);
raise(56);
raise(64);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_012", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler2(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_012", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler3(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_012", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler4(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_012", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler5(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_012", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler6(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_012", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler7(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_012", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler8(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_012", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler9(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_012", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler10(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_012", false);
return false;
}
/**
* @brief the signal handler
*/
static void signal_sigaction(int signo)
{
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 == 37) {
EXPECT_EQ("sigchain_rm_special_handler_012", signo, 37);
} else if (signo == 43) {
EXPECT_EQ("sigchain_rm_special_handler_012", signo, 43);
} else if (signo == 50) {
EXPECT_EQ("sigchain_rm_special_handler_012", signo, 50);
} else if (signo == 56) {
EXPECT_EQ("sigchain_rm_special_handler_012", signo, 56);
} else {
EXPECT_EQ("sigchain_rm_special_handler_012", signo, 64);
}
}
/**
* @tc.name : sigchain_rm_special_handler_012
* @tc.desc : Remove multiple special handlers for the different signals that is registered with
* the kernel (Using sigaction interface) in sigchain.
* @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(37, &sigaction5, NULL);
struct sigaction sigaction6 = {
.sa_handler = signal_sigaction,
};
sigaction(43, &sigaction6, NULL);
struct sigaction sigaction7 = {
.sa_handler = signal_sigaction,
};
sigaction(50, &sigaction7, NULL);
struct sigaction sigaction8 = {
.sa_handler = signal_sigaction,
};
sigaction(56, &sigaction8, NULL);
struct sigaction sigaction9 = {
.sa_handler = signal_sigaction,
};
sigaction(64, &sigaction9, NULL);
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGHUP, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler2,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGABRT, &sigsegv1);
struct signal_chain_action sigsegv2 = {
.sca_sigaction = sigchain_special_handler3,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSEGV, &sigsegv2);
struct signal_chain_action sigsegv3 = {
.sca_sigaction = sigchain_special_handler4,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGURG, &sigsegv3);
struct signal_chain_action sigsegv4 = {
.sca_sigaction = sigchain_special_handler5,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(SIGSYS, &sigsegv4);
struct signal_chain_action sigsegv5 = {
.sca_sigaction = sigchain_special_handler6,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(37, &sigsegv5);
struct signal_chain_action sigsegv6 = {
.sca_sigaction = sigchain_special_handler7,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(43, &sigsegv6);
struct signal_chain_action sigsegv7 = {
.sca_sigaction = sigchain_special_handler8,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(50, &sigsegv7);
struct signal_chain_action sigsegv8 = {
.sca_sigaction = sigchain_special_handler9,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(56, &sigsegv8);
struct signal_chain_action sigsegv9 = {
.sca_sigaction = sigchain_special_handler10,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(64, &sigsegv9);
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(37, sigchain_special_handler6);
remove_special_signal_handler(43, sigchain_special_handler7);
remove_special_signal_handler(50, sigchain_special_handler8);
remove_special_signal_handler(56, sigchain_special_handler9);
remove_special_signal_handler(64, sigchain_special_handler10);
}
int main(void)
{
sigchain_rm_special_handler_012();
raise(SIGHUP);
raise(SIGABRT);
raise(SIGSEGV);
raise(SIGURG);
raise(SIGSYS);
raise(37);
raise(43);
raise(50);
raise(56);
raise(64);
return t_status;
}
\ No newline at end of file
/*
* 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 <sigchain.h>
#include <wchar.h>
#include <stdlib.h>
#include "test.h"
#include "functionalext.h"
/**
* @brief the special handler
*/
static bool sigchain_special_handler(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_013", false);
return false;
}
/**
* @brief the special handler
*/
static bool sigchain_special_handler1(int signo, siginfo_t *siginfo, void *ucontext_raw)
{
EXPECT_FALSE("sigchain_rm_special_handler_013", false);
return false;
}
/**
* @tc.name : sigchain_rm_special_handler_013
* @tc.desc : Remove the special handler with wrong signal
* @tc.level : Level 0
*/
static void sigchain_rm_special_handler_013()
{
struct signal_chain_action sigsegv = {
.sca_sigaction = sigchain_special_handler,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(0, &sigsegv);
struct signal_chain_action sigsegv1 = {
.sca_sigaction = sigchain_special_handler1,
.sca_mask = {},
.sca_flags = 0,
};
add_special_signal_handler(65, &sigsegv1);
remove_special_signal_handler(0, sigchain_special_handler);
remove_special_signal_handler(65, sigchain_special_handler1);
}
int main(void)
{
sigchain_rm_special_handler_013();
return t_status;
}
\ No newline at end of file
# Copyright (c) 2022 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.
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_add_special_handler_m",
"sigchain_rm_special_handler_a",
"sigchain_rm_special_handler_b",
"sigchain_rm_special_handler_c",
"sigchain_rm_special_handler_d",
"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_rm_special_handler_m",
"sigchain_intercept_sigaction_a",
"sigchain_intercept_sigaction_b",
"sigchain_intercept_sigaction_c",
"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",
]
\ No newline at end of file
......@@ -25,4 +25,5 @@ functionalext_list = [
"supplement:functionalext_supplement_test",
"fortify:functionalext_fortify_test",
"symver:functionalext_symver_test",
"sigchain:functionalext_sigchain_test",
]
......@@ -231,6 +231,12 @@ template("test_unittest") {
}
}
}
if (target_dir == "functionalext/sigchain") {
include_dirs += [ "//${musl_base_dir}/include" ]
ldflags += [ "-Wl,-rpath=./" ]
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册