• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *   http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <errno.h>
17 #include <signal.h>
18 #include <unistd.h>
19 #include "functionalext.h"
20 
21 #define TEST_ALARM_TIME 2
22 
23 int gtest_pause_flag = 0;
signal_func(int signum)24 static void signal_func(int signum)
25 {
26     if (signum == SIGALRM) {
27         gtest_pause_flag = 1;
28     }
29 }
30 
31 /**
32  * @tc.name      : pause_0100
33  * @tc.desc      : Wake up a suspended process with a signal
34  * @tc.level     : Level 0
35  */
pause_0100(void)36 void pause_0100(void)
37 {
38     struct sigaction act;
39     act.sa_handler = signal_func;
40     act.sa_flags = 0;
41     sigaction(SIGALRM, &act, NULL);
42 
43     alarm(TEST_ALARM_TIME);
44     EXPECT_FALSE("pause_0100", gtest_pause_flag);
45     int ret = pause();
46     EXPECT_EQ("pause_0100", ret, ERREXPECT);
47     EXPECT_EQ("pause_0100", errno, EINTR);
48     EXPECT_TRUE("pause_0100", gtest_pause_flag);
49 }
50 
main(void)51 int main(void)
52 {
53     // pause_0100();
54     return t_status;
55 }