xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/timerfd/timerfd_create01.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) 2014 Fujitsu Ltd.
4  *         Zeng Linggang <[email protected]>
5  * Copyright (C) 2023 SUSE LLC Andrea Cervesato <[email protected]>
6  */
7 /*\
8  * [Description]
9  *
10  * This test verifies that:
11  * - clockid argument is neither CLOCK_MONOTONIC nor CLOCK_REALTIME,
12  * EINVAL would return.
13  * - flags is invalid, EINVAL would return.
14  */
15 
16 #include <errno.h>
17 
18 #include "tst_test.h"
19 #include "tst_safe_timerfd.h"
20 
21 static struct test_case_t {
22 	int clockid;
23 	int flags;
24 	int exp_errno;
25 } tcases[] = {
26 	{ -1,  0, EINVAL },
27 	{  0, -1, EINVAL },
28 };
29 
run(unsigned int i)30 static void run(unsigned int i)
31 {
32 	struct test_case_t *test = &tcases[i];
33 
34 	TST_EXP_FAIL(timerfd_create(test->clockid, test->flags), test->exp_errno);
35 }
36 
37 static struct tst_test test = {
38 	.test = run,
39 	.tcnt = ARRAY_SIZE(tcases),
40 };
41