Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
a3a42c48
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a3a42c48
编写于
1月 18, 2023
作者:
D
dhy308
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add case for Sigchain
Issue: I6AEEI Test: Build & Boot Devices Signed-off-by:
N
dhy308
<
tony.gan@huawei.com
>
上级
935f0ffb
变更
41
隐藏空白更改
内联
并排
Showing
41 changed file
with
4172 addition
and
0 deletion
+4172
-0
libc-test/src/functionalext/common/sigchain_util.h
libc-test/src/functionalext/common/sigchain_util.h
+31
-0
libc-test/src/functionalext/sigchain/BUILD.gn
libc-test/src/functionalext/sigchain/BUILD.gn
+28
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_a.c
...c/functionalext/sigchain/sigchain_add_special_handler_a.c
+57
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_b.c
...c/functionalext/sigchain/sigchain_add_special_handler_b.c
+68
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_c.c
...c/functionalext/sigchain/sigchain_add_special_handler_c.c
+70
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_d.c
...c/functionalext/sigchain/sigchain_add_special_handler_d.c
+91
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_e.c
...c/functionalext/sigchain/sigchain_add_special_handler_e.c
+101
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_f.c
...c/functionalext/sigchain/sigchain_add_special_handler_f.c
+104
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_g.c
...c/functionalext/sigchain/sigchain_add_special_handler_g.c
+74
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_h.c
...c/functionalext/sigchain/sigchain_add_special_handler_h.c
+88
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_i.c
...c/functionalext/sigchain/sigchain_add_special_handler_i.c
+91
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_j.c
...c/functionalext/sigchain/sigchain_add_special_handler_j.c
+210
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_k.c
...c/functionalext/sigchain/sigchain_add_special_handler_k.c
+249
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_l.c
...c/functionalext/sigchain/sigchain_add_special_handler_l.c
+289
-0
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_m.c
...c/functionalext/sigchain/sigchain_add_special_handler_m.c
+66
-0
libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_a.c
...c/functionalext/sigchain/sigchain_intercept_sigaction_a.c
+63
-0
libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_b.c
...c/functionalext/sigchain/sigchain_intercept_sigaction_b.c
+100
-0
libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_c.c
...c/functionalext/sigchain/sigchain_intercept_sigaction_c.c
+103
-0
libc-test/src/functionalext/sigchain/sigchain_intercept_signal_a.c
.../src/functionalext/sigchain/sigchain_intercept_signal_a.c
+56
-0
libc-test/src/functionalext/sigchain/sigchain_intercept_signal_b.c
.../src/functionalext/sigchain/sigchain_intercept_signal_b.c
+93
-0
libc-test/src/functionalext/sigchain/sigchain_intercept_signal_c.c
.../src/functionalext/sigchain/sigchain_intercept_signal_c.c
+96
-0
libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_a.c
...functionalext/sigchain/sigchain_intercept_sigprocmask_a.c
+68
-0
libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_b.c
...functionalext/sigchain/sigchain_intercept_sigprocmask_b.c
+100
-0
libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_c.c
...functionalext/sigchain/sigchain_intercept_sigprocmask_c.c
+103
-0
libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_d.c
...functionalext/sigchain/sigchain_intercept_sigprocmask_d.c
+114
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_a.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_a.c
+54
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_b.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_b.c
+69
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_c.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_c.c
+72
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_d.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_d.c
+95
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_e.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_e.c
+105
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_f.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_f.c
+108
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_g.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_g.c
+77
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_h.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_h.c
+92
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_i.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_i.c
+99
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_j.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_j.c
+214
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_k.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_k.c
+255
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_l.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_l.c
+294
-0
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_m.c
...rc/functionalext/sigchain/sigchain_rm_special_handler_m.c
+69
-0
libc-test/src/functionalext/sigchain/test_src_functionalext_sigchain.gni
...unctionalext/sigchain/test_src_functionalext_sigchain.gni
+49
-0
libc-test/src/functionalext/test_src_functionalext.gni
libc-test/src/functionalext/test_src_functionalext.gni
+1
-0
libc-test/test_template.gni
libc-test/test_template.gni
+6
-0
未找到文件。
libc-test/src/functionalext/common/sigchain_util.h
0 → 100644
浏览文件 @
a3a42c48
/*
* 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)
libc-test/src/functionalext/sigchain/BUILD.gn
0 → 100644
浏览文件 @
a3a42c48
# 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_a.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_b.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_c.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_d.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_e.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_f.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_g.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_h.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_i.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_j.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_k.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_l.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_add_special_handler_m.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_a.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_b.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_intercept_sigaction_c.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_intercept_signal_a.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_intercept_signal_b.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_intercept_signal_c.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_a.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_b.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_c.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_intercept_sigprocmask_d.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_a.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_b.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_c.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_d.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_e.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_f.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_g.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_h.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_i.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_j.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_k.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_l.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/sigchain_rm_special_handler_m.c
0 → 100644
浏览文件 @
a3a42c48
/*
* 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
libc-test/src/functionalext/sigchain/test_src_functionalext_sigchain.gni
0 → 100644
浏览文件 @
a3a42c48
# 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
libc-test/src/functionalext/test_src_functionalext.gni
浏览文件 @
a3a42c48
...
...
@@ -25,4 +25,5 @@ functionalext_list = [
"supplement:functionalext_supplement_test",
"fortify:functionalext_fortify_test",
"symver:functionalext_symver_test",
"sigchain:functionalext_sigchain_test",
]
libc-test/test_template.gni
浏览文件 @
a3a42c48
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录