• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *   Copyright (c) Crackerjack Project., 2007
3  *   Copyright (c) 2011 Cyril Hrubis <chrubis@suse.cz>
4  *   Copyright (c) 2017 Xiao Yang <yangx.jy@cn.fujitsu.com>
5  *
6  *   This program is free software;  you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation; either version 2 of the License, or
9  *   (at your option) any later version.
10  *
11  *   This program is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
14  *   the GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with this program;  if not, write to the Free Software
18  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /* Porting from Crackerjack to LTP is done
22  * by Masatake YAMATO <yamato@redhat.com>
23  *
24  * Description:
25  * io_destroy(2) fails and returns -EINVAL if ctx is invalid.
26  */
27 
28 #include <errno.h>
29 #include <string.h>
30 #include "config.h"
31 #include "tst_test.h"
32 
33 #ifdef HAVE_LIBAIO
34 #include <libaio.h>
35 
verify_io_destroy(void)36 static void verify_io_destroy(void)
37 {
38 	io_context_t ctx;
39 
40 	memset(&ctx, 0xff, sizeof(ctx));
41 
42 	TEST(io_destroy(ctx));
43 	if (TST_RET == 0) {
44 		tst_res(TFAIL, "io_destroy() succeeded unexpectedly");
45 		return;
46 	}
47 
48 	if (TST_RET == -EINVAL) {
49 		tst_res(TPASS,
50 			"io_destroy() failed as expected, returned -EINVAL");
51 	} else {
52 		tst_res(TFAIL, "io_destroy() failed unexpectedly, "
53 			"returned -%s expected -EINVAL",
54 			tst_strerrno(-TST_RET));
55 	}
56 }
57 
58 static struct tst_test test = {
59 	.test_all = verify_io_destroy,
60 };
61 
62 #else
63 	TST_TEST_TCONF("test requires libaio and it's development packages");
64 #endif
65