• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3  *   Copyright (c) Crackerjack Project., 2007
4  *   Copyright (c) 2011 Cyril Hrubis <chrubis@suse.cz>
5  *   Copyright (c) 2017 Xiao Yang <yangx.jy@cn.fujitsu.com>
6  */
7 
8 /* Porting from Crackerjack to LTP is done
9  * by Masatake YAMATO <yamato@redhat.com>
10  *
11  * Description:
12  * io_destroy(2) fails and returns -EINVAL if ctx is invalid.
13  */
14 
15 #include <errno.h>
16 #include <string.h>
17 #include "config.h"
18 #include "tst_test.h"
19 
20 #ifdef HAVE_LIBAIO
21 #include <libaio.h>
22 
verify_io_destroy(void)23 static void verify_io_destroy(void)
24 {
25 	io_context_t ctx;
26 
27 	memset(&ctx, 0xff, sizeof(ctx));
28 
29 	TEST(io_destroy(ctx));
30 	if (TST_RET == 0) {
31 		tst_res(TFAIL, "io_destroy() succeeded unexpectedly");
32 		return;
33 	}
34 
35 	if (TST_RET == -EINVAL) {
36 		tst_res(TPASS,
37 			"io_destroy() failed as expected, returned -EINVAL");
38 	} else {
39 		tst_res(TFAIL, "io_destroy() failed unexpectedly, "
40 			"returned -%s expected -EINVAL",
41 			tst_strerrno(-TST_RET));
42 	}
43 }
44 
45 static struct tst_test test = {
46 	.test_all = verify_io_destroy,
47 };
48 
49 #else
50 	TST_TEST_TCONF("test requires libaio and it's development packages");
51 #endif
52