summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-02-01 09:46:22 -0700
committerJens Axboe <axboe@kernel.dk>2020-02-01 09:46:22 -0700
commita717b4b5cc473b0f330f3b077733057db52009e5 (patch)
tree7903536e14db2bcec7123ecf41e31473428d4035
parentfe96fe296f1b448a078d42a6e8c4c16c4a44c36e (diff)
downloadliburing-a717b4b5cc473b0f330f3b077733057db52009e5.tar.gz
liburing-a717b4b5cc473b0f330f3b077733057db52009e5.tar.bz2
test/send_recv: use stderr for errors
And include error value. Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--test/send_recv.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/test/send_recv.c b/test/send_recv.c
index 9f2c9a4..9c9b9b8 100644
--- a/test/send_recv.c
+++ b/test/send_recv.c
@@ -49,10 +49,11 @@ static int recv_prep(struct io_uring *ring, struct iovec *iov)
sqe = io_uring_get_sqe(ring);
io_uring_prep_recv(sqe, sockfd, iov->iov_base, iov->iov_len, 0);
+ sqe->user_data = 2;
ret = io_uring_submit(ring);
if (ret <= 0) {
- printf("submit failed\n");
+ fprintf(stderr, "submit failed: %d\n", ret);
goto err;
}
@@ -68,17 +69,18 @@ static int do_recv(struct io_uring *ring, struct iovec *iov)
io_uring_wait_cqe(ring, &cqe);
if (cqe->res < 0) {
- printf("failed cqe: %d\n", cqe->res);
+ fprintf(stderr, "failed cqe: %d\n", cqe->res);
goto err;
}
if (cqe->res -1 != strlen(str)) {
- printf("got wrong length\n");
+ fprintf(stderr, "got wrong length: %d/%d\n", cqe->res,
+ (int) strlen(str) + 1);
goto err;
}
if (strcmp(str, iov->iov_base)) {
- printf("string mismatch\n");
+ fprintf(stderr, "string mismatch\n");
goto err;
}
@@ -122,7 +124,7 @@ static int do_send(void)
ret = io_uring_queue_init(1, &ring, 0);
if (ret) {
- printf("queue init fail\n");
+ fprintf(stderr, "queue init fail: %d\n", ret);
return 1;
}
@@ -145,16 +147,17 @@ static int do_send(void)
sqe = io_uring_get_sqe(&ring);
io_uring_prep_send(sqe, sockfd, iov.iov_base, iov.iov_len, 0);
+ sqe->user_data = 1;
ret = io_uring_submit(&ring);
if (ret <= 0) {
- printf("submit failed\n");
+ fprintf(stderr, "submit failed: %d\n", ret);
goto err;
}
ret = io_uring_wait_cqe(&ring, &cqe);
if (cqe->res != iov.iov_len) {
- printf("failed cqe: %d\n", cqe->res);
+ fprintf(stderr, "failed cqe: %d\n", cqe->res);
goto err;
}
@@ -180,7 +183,7 @@ int main(int argc, char *argv[])
ret = pthread_create(&recv_thread, NULL, recv_fn, &mutex);
if (ret) {
- fprintf(stderr, "Thread create failed\n");
+ fprintf(stderr, "Thread create failed: %d\n", ret);
return 1;
}