Skip to content

Commit

Permalink
Remove implicit coercions in tests so that they don't sign-extend thi…
Browse files Browse the repository at this point in the history
…ngs they shouldn't
  • Loading branch information
kmeisthax committed Oct 31, 2021
1 parent f2df5ae commit abd4692
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
13 changes: 7 additions & 6 deletions tests/e2e/aio_rw/aio_rw.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>

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

Expand Down Expand Up @@ -34,7 +35,7 @@ void main() {
req.aio_data = 0xDEADBEEF;
req.aio_lio_opcode = IOCB_CMD_PWRITE;
req.aio_fildes = fd;
req.aio_buf = (__u64)info;
req.aio_buf = (uintptr_t)info;
req.aio_nbytes = strlen(info);
req.aio_offset = 0;

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

if (evt.obj == (__u64)&req) {
if (evt.obj == (uintptr_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)&req);
printf("(&req is 0x%llX)\n", (__u64)(uintptr_t)&req);
}

printf("evt.res: %lld\n", evt.res);
Expand All @@ -80,7 +81,7 @@ void main() {
req.aio_data = 0xCAFEBABE;
req.aio_lio_opcode = IOCB_CMD_PREAD;
req.aio_fildes = fd;
req.aio_buf = (__u64)rbuf;
req.aio_buf = (uintptr_t)rbuf;
req.aio_nbytes = 512;
req.aio_offset = 0;

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

if (evt.obj == (__u64)&req) {
if (evt.obj == (__u32)&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)&req);
printf("(&req is 0x%llX)\n", (__u64)(__u32)&req);
}

printf("evt.res: %lld\n", evt.res);
Expand Down
15 changes: 8 additions & 7 deletions tests/e2e/aio_rw_vectored/aio_rw_vectored.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#include <linux/aio_abi.h>
#include <sys/syscall.h>
#include <sys/uio.h>;
#include <sys/uio.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <stdint.h>

const char* info0 = "Welcome to ASYNC world - ";
const char* info1 = "now you're writing with vectors";
Expand Down Expand Up @@ -42,7 +43,7 @@ void main() {
req.aio_data = 0x31337;
req.aio_lio_opcode = IOCB_CMD_PWRITEV;
req.aio_fildes = fd;
req.aio_buf = (__u64)&req_vecs;
req.aio_buf = (uintptr_t)&req_vecs;
req.aio_nbytes = 2;
req.aio_offset = 0;

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

if (evt.obj == (__u64)&req) {
if (evt.obj == (uintptr_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)&req);
printf("(&req is 0x%llX)\n", (__u64)(uintptr_t)&req);
}

printf("evt.res: %lld\n", evt.res);
Expand All @@ -96,7 +97,7 @@ void main() {
req.aio_data = 0xCAFEBABE;
req.aio_lio_opcode = IOCB_CMD_PREADV;
req.aio_fildes = fd;
req.aio_buf = (__u64)req_vecs;
req.aio_buf = (uintptr_t)req_vecs;
req.aio_nbytes = 2;
req.aio_offset = 0;

Expand All @@ -121,11 +122,11 @@ void main() {
printf("io_getevents success: %d\n", err);
printf("evt.data: 0x%llX\n", evt.data);

if (evt.obj == (__u64)&req) {
if (evt.obj == (uintptr_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)&req);
printf("(&req is 0x%llX)\n", (__u64)(uintptr_t)&req);
}

printf("evt.res: %lld\n", evt.res);
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/aio_rw_vectored/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ rbuf[0]: Welcome to ASYNC world -
rbuf[1]: now you're writing with
close success
io_destroy success

0 comments on commit abd4692

Please sign in to comment.