xref: /aosp_15_r20/external/ltp/testcases/kernel/syscalls/io_destroy/io_destroy02.c (revision 49cdfc7efb34551c7342be41a7384b9c40d7cab7)
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  * Copyright (c) Crackerjack Project., 2007
4  * Ported from Crackerjack to LTP by Masatake YAMATO <[email protected]>
5  * Copyright (c) 2011 Cyril Hrubis <[email protected]>
6  * Copyright (c) 2017 Xiao Yang <[email protected]>
7  * Copyright (c) 2021 Xie Ziyao <[email protected]>
8  */
9 
10 /*\
11  * [Description]
12  *
13  * Test io_destroy invoked via syscall(2) with an invalid ctx and expects
14  * it to return EINVAL.
15  */
16 
17 #include <linux/aio_abi.h>
18 
19 #include "config.h"
20 #include "tst_test.h"
21 #include "lapi/syscalls.h"
22 
run(void)23 static void run(void)
24 {
25 	aio_context_t ctx;
26 
27 	memset(&ctx, 0xff, sizeof(ctx));
28 	TST_EXP_FAIL(tst_syscall(__NR_io_destroy, ctx), EINVAL,
29 		     "io_destroy() with an invalid ctx");
30 }
31 
32 static struct tst_test test = {
33 	.needs_kconfigs = (const char *[]) {
34 		"CONFIG_AIO=y",
35 		NULL
36 	},
37 	.test_all = run,
38 };
39