summaryrefslogtreecommitdiff
path: root/harness/cases/3.t
blob: 0d72241c65704fc402dcce69a6f82023094eabe3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* 3.t
- io_submit/io_getevents with invalid addresses (3.t)

*/
#include "aio_setup.h"

int attempt(io_context_t ctx, long nr, struct iocb *ios[], int expect)
{
	int res;

	printf("expect %3d: io_submit(%10p, %3ld, %10p) = ", expect, ctx, nr, ios);
	fflush(stdout);
	res = io_submit(ctx, nr, ios);
	printf("%3d [%s]%s\n", res, (res <= 0) ? strerror(-res) : "",
		(res != expect) ? " -- FAILED" : "");
	if (res != expect)
		return 1;

	return 0;
}

int test_main(void)
{
	struct iocb a, b;
	struct iocb *good_ios[] = { &a, &b };
	struct iocb *bad1_ios[] = { NULL, &b };
	struct iocb *bad2_ios[] = { KERNEL_RW_POINTER, &a };
	int	status = 0;

	status |= attempt(BAD_CTX, 1,   good_ios, -EINVAL);
	status |= attempt( io_ctx, 0,   good_ios,       0);
	status |= attempt( io_ctx, 1,       NULL, -EFAULT);
	status |= attempt( io_ctx, 1, (void *)-1, -EFAULT);
	status |= attempt( io_ctx, 2,   bad1_ios, -EFAULT);
	status |= attempt( io_ctx, 2,   bad2_ios, -EFAULT);
	status |= attempt( io_ctx, -1,  good_ios, -EINVAL);

	return status;
}