xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/epoll_create/epoll_create01.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) Linux Test Project, 2021
4  * Author: Xie Ziyao <[email protected]>
5  */
6 
7 /*\
8  * [Description]
9  *
10  * Verify that epoll_create return a nonnegative file descriptor on success.
11  *
12  * The size argument informed the kernel of the number of file descriptors
13  * that the caller expected to add to the epoll instance, but it is no longer
14  * required.
15  */
16 
17 #include <sys/epoll.h>
18 #include "tst_test.h"
19 #include "lapi/epoll.h"
20 #include "lapi/syscalls.h"
21 #include "epoll_create.h"
22 
23 static int tc[] = {1, INT_MAX};
24 
run(unsigned int n)25 static void run(unsigned int n)
26 {
27 	TST_EXP_FD(do_epoll_create(tc[n]), "epoll_create(%d)", tc[n]);
28 
29 	if (!TST_PASS)
30 		return;
31 	SAFE_CLOSE(TST_RET);
32 }
33 
34 static struct tst_test test = {
35 	.test_variants = EPOLL_CREATE_VARIANTS,
36 	.tcnt = ARRAY_SIZE(tc),
37 	.setup = variant_info,
38 	.test = run,
39 };
40