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_CREATE_TEST
18 #define _EPOLL_CREATE_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_create_0100
31 * @tc.desc : Returns a file descriptor referring to the new epoll instance
32 * @tc.level : Level 0
33 */
epoll_create_0100(void)34 void epoll_create_0100(void)
35 {
36 errno = 0;
37 int epoll_fd = epoll_create(1);
38 if (epoll_fd == -1) {
39 t_error("%s epoll_create failed\n", __func__);
40 }
41 if (errno != 0) {
42 t_error("%s errno is %d, not 0\n", __func__, errno);
43 }
44 }
45
main(int argc, char *argv[])46 int main(int argc, char *argv[])
47 {
48 epoll_create_0100();
49 return t_status;
50 }
51
52 #ifdef _EPOLL_CREATE_TEST
53 #undef _EPOLL_CREATE_TEST
54 #endif