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 // Solve the build error of this test code when importing the header file <sys/epoll.h>
17 #ifndef _EPOLL_WAIT_TEST
18 #define _EPOLL_WAIT_TEST
19 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
20 #undef _GNU_SOURCE
21 #undef _BSD_SOURCE
22 #endif
23 #endif
24
25 #include <errno.h>
26 #include <sys/epoll.h>
27 #include "test.h"
28
29 /**
30 * @tc.name : epoll_wait_0100
31 * @tc.desc : Regular epoll_wait
32 * @tc.level : Level 0
33 */
epoll_wait_0100(void)34 void epoll_wait_0100(void)
35 {
36 int epoll_fd = epoll_create(1);
37 if (epoll_fd == -1) {
38 t_error("%s epoll_create failed\n", __func__);
39 }
40
41 struct epoll_event events[1];
42 int result = epoll_wait(epoll_fd, events, 1, 1);
43 if (result != 0) {
44 t_error("%s epoll_pwait failed\n", __func__);
45 }
46 }
47
main(int argc, char *argv[])48 int main(int argc, char *argv[])
49 {
50 epoll_wait_0100();
51 return t_status;
52 }
53
54 #ifdef _EPOLL_WAIT_TEST
55 #undef _EPOLL_WAIT_TEST
56 #endif