Skip to content

Commit

Permalink
Remove e2e tests dependency on linux/aio_abi.h header
Browse files Browse the repository at this point in the history
  • Loading branch information
kmeisthax committed Nov 21, 2021
1 parent 399265e commit 6c09ad5
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 7 deletions.
41 changes: 37 additions & 4 deletions tests/e2e/aio_rw/aio_rw.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <linux/aio_abi.h>
#include <sys/syscall.h>
#include <fcntl.h>
#include <stdio.h>
Expand All @@ -7,6 +6,40 @@
#include <errno.h>
#include <stdint.h>

typedef uint64_t aio_context_t;

enum {
IOCB_CMD_PREAD = 0,
IOCB_CMD_PWRITE = 1,
IOCB_CMD_FSYNC = 2,
IOCB_CMD_FDSYNC = 3,
IOCB_CMD_NOOP = 6,
IOCB_CMD_PREADV = 7,
IOCB_CMD_PWRITEV = 8,
};

struct iocb {
uint64_t aio_data;
uint32_t aio_key;
uint32_t aio_rw_flags;
uint16_t aio_lio_opcode;
int16_t aio_reqprio;
uint32_t aio_fildes;
uint64_t aio_buf;
uint64_t aio_nbytes;
int64_t aio_offset;
uint64_t aio_reserved2;
uint32_t aio_flags;
uint32_t aio_resfd;
};

struct io_event {
uint64_t data;
uint64_t obj;
int64_t res;
int64_t res2;
};

const char* info = "Welcome to ASYNC world!";

void main() {
Expand Down Expand Up @@ -69,7 +102,7 @@ void main() {
printf("evt.obj matches &req\n");
} else {
printf("evt.obj does NOT match &req, 0x%llX given\n", evt.obj);
printf("(&req is 0x%llX)\n", (__u64)(uintptr_t)&req);
printf("(&req is 0x%llX)\n", (uint64_t)(uintptr_t)&req);
}

printf("evt.res: %lld\n", evt.res);
Expand Down Expand Up @@ -106,11 +139,11 @@ void main() {
printf("io_getevents success: %d\n", err);
printf("evt.data: 0x%llX\n", evt.data);

if (evt.obj == (__u32)&req) {
if (evt.obj == (uint32_t)&req) {
printf("evt.obj matches &req\n");
} else {
printf("evt.obj does NOT match &req, 0x%llX given\n", evt.obj);
printf("(&req is 0x%llX)\n", (__u64)(__u32)&req);
printf("(&req is 0x%llX)\n", (uint64_t)(uint32_t)&req);
}

printf("evt.res: %lld\n", evt.res);
Expand Down
39 changes: 36 additions & 3 deletions tests/e2e/aio_rw_vectored/aio_rw_vectored.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include <linux/aio_abi.h>
#include <sys/syscall.h>
#include <sys/uio.h>
#include <fcntl.h>
Expand All @@ -8,6 +7,40 @@
#include <errno.h>
#include <stdint.h>

typedef uint64_t aio_context_t;

enum {
IOCB_CMD_PREAD = 0,
IOCB_CMD_PWRITE = 1,
IOCB_CMD_FSYNC = 2,
IOCB_CMD_FDSYNC = 3,
IOCB_CMD_NOOP = 6,
IOCB_CMD_PREADV = 7,
IOCB_CMD_PWRITEV = 8,
};

struct iocb {
uint64_t aio_data;
uint32_t aio_key;
uint32_t aio_rw_flags;
uint16_t aio_lio_opcode;
int16_t aio_reqprio;
uint32_t aio_fildes;
uint64_t aio_buf;
uint64_t aio_nbytes;
int64_t aio_offset;
uint64_t aio_reserved2;
uint32_t aio_flags;
uint32_t aio_resfd;
};

struct io_event {
uint64_t data;
uint64_t obj;
int64_t res;
int64_t res2;
};

const char* info0 = "Welcome to ASYNC world - ";
const char* info1 = "now you're writing with vectors";

Expand Down Expand Up @@ -77,7 +110,7 @@ void main() {
printf("evt.obj matches &req\n");
} else {
printf("evt.obj does NOT match &req, 0x%llX given\n", evt.obj);
printf("(&req is 0x%llX)\n", (__u64)(uintptr_t)&req);
printf("(&req is 0x%llX)\n", (uint64_t)(uintptr_t)&req);
}

printf("evt.res: %lld\n", evt.res);
Expand Down Expand Up @@ -126,7 +159,7 @@ void main() {
printf("evt.obj matches &req\n");
} else {
printf("evt.obj does NOT match &req, 0x%llX given\n", evt.obj);
printf("(&req is 0x%llX)\n", (__u64)(uintptr_t)&req);
printf("(&req is 0x%llX)\n", (uint64_t)(uintptr_t)&req);
}

printf("evt.res: %lld\n", evt.res);
Expand Down

0 comments on commit 6c09ad5

Please sign in to comment.