* [PATCH] test/timeout-new: test for timeout feature
@ 2020-11-23 7:07 Hao Xu
2020-11-26 12:55 ` Hao Xu
2020-11-26 17:39 ` Jens Axboe
0 siblings, 2 replies; 4+ messages in thread
From: Hao Xu @ 2020-11-23 7:07 UTC (permalink / raw)
To: Jens Axboe; +Cc: io-uring, Joseph Qi
Signed-off-by: Hao Xu <[email protected]>
---
Hi Jens,
This is a simple test for the new getevent timeout feature. Sorry for
the delay.
test/Makefile | 6 ++++--
test/timeout-new.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 insertions(+), 2 deletions(-)
create mode 100644 test/timeout-new.c
diff --git a/test/Makefile b/test/Makefile
index cbbd400391dd..53dd4afa42e5 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -25,7 +25,8 @@ all_targets += poll poll-cancel ring-leak fsync io_uring_setup io_uring_register
short-read openat2 probe shared-wq personality eventfd \
send_recv eventfd-ring across-fork sq-poll-kthread splice \
lfs-openat lfs-openat-write iopoll d4ae271dfaae-test \
- eventfd-disable close-opath ce593a6c480a-test cq-overflow-peek
+ eventfd-disable close-opath ce593a6c480a-test cq-overflow-peek \
+ timeout-new
include ../Makefile.quiet
@@ -65,7 +66,8 @@ test_srcs := poll.c poll-cancel.c ring-leak.c fsync.c io_uring_setup.c \
madvise.c short-read.c openat2.c probe.c shared-wq.c \
personality.c eventfd.c eventfd-ring.c across-fork.c sq-poll-kthread.c \
splice.c lfs-openat.c lfs-openat-write.c iopoll.c d4ae271dfaae-test.c \
- eventfd-disable.c close-opath.c ce593a6c480a-test.c cq-overflow-peek.c
+ eventfd-disable.c close-opat h.c ce593a6c480a-test.c cq-overflow-peek.c \
+ timeout-new.c
ifdef CONFIG_HAVE_STATX
test_srcs += statx.c
diff --git a/test/timeout-new.c b/test/timeout-new.c
new file mode 100644
index 000000000000..03e03eb1bba7
--- /dev/null
+++ b/test/timeout-new.c
@@ -0,0 +1,49 @@
+/* SPDX-License-Identifier: MIT */
+/*
+ * Description: tests for getevents timeout
+ *
+ */
+#include <stdio.h>
+
+#include "liburing.h"
+
+static int test_timeout(struct io_uring *ring)
+{
+ struct io_uring_cqe *cqe;
+ int ret;
+ struct __kernel_timespec timeout;
+
+ timeout.tv_sec = 1;
+ timeout.tv_nsec = 0;
+
+ ret = io_uring_wait_cqe_timeout(ring, &cqe, &timeout);
+ if (ret != -ETIME) {
+ fprintf(stderr, "timeout error: %d\n", ret);
+ return 1;
+ }
+
+ return 0;
+}
+
+int main(int argc, char *argv[])
+{
+ struct io_uring ring;
+ int ret;
+
+ if (argc > 1)
+ return 0;
+
+ ret = io_uring_queue_init(8, &ring, 0);
+ if (ret) {
+ fprintf(stderr, "ring setup failed: %d\n", ret);
+ return 1;
+ }
+
+ ret = test_timeout(&ring);
+ if (ret) {
+ fprintf(stderr, "test_timeout failed\n");
+ return ret;
+ }
+
+ return 0;
+}
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] test/timeout-new: test for timeout feature
2020-11-23 7:07 [PATCH] test/timeout-new: test for timeout feature Hao Xu
@ 2020-11-26 12:55 ` Hao Xu
2020-11-26 17:39 ` Jens Axboe
1 sibling, 0 replies; 4+ messages in thread
From: Hao Xu @ 2020-11-26 12:55 UTC (permalink / raw)
To: Jens Axboe; +Cc: io-uring, Joseph Qi
在 2020/11/23 下午3:07, Hao Xu 写道:
a gentle ping
> Signed-off-by: Hao Xu <[email protected]>
> ---
>
> Hi Jens,
> This is a simple test for the new getevent timeout feature. Sorry for
> the delay.
>
> test/Makefile | 6 ++++--
> test/timeout-new.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 53 insertions(+), 2 deletions(-)
> create mode 100644 test/timeout-new.c
>
> diff --git a/test/Makefile b/test/Makefile
> index cbbd400391dd..53dd4afa42e5 100644
> --- a/test/Makefile
> +++ b/test/Makefile
> @@ -25,7 +25,8 @@ all_targets += poll poll-cancel ring-leak fsync io_uring_setup io_uring_register
> short-read openat2 probe shared-wq personality eventfd \
> send_recv eventfd-ring across-fork sq-poll-kthread splice \
> lfs-openat lfs-openat-write iopoll d4ae271dfaae-test \
> - eventfd-disable close-opath ce593a6c480a-test cq-overflow-peek
> + eventfd-disable close-opath ce593a6c480a-test cq-overflow-peek \
> + timeout-new
>
> include ../Makefile.quiet
>
> @@ -65,7 +66,8 @@ test_srcs := poll.c poll-cancel.c ring-leak.c fsync.c io_uring_setup.c \
> madvise.c short-read.c openat2.c probe.c shared-wq.c \
> personality.c eventfd.c eventfd-ring.c across-fork.c sq-poll-kthread.c \
> splice.c lfs-openat.c lfs-openat-write.c iopoll.c d4ae271dfaae-test.c \
> - eventfd-disable.c close-opath.c ce593a6c480a-test.c cq-overflow-peek.c
> + eventfd-disable.c close-opat h.c ce593a6c480a-test.c cq-overflow-peek.c \
> + timeout-new.c
>
> ifdef CONFIG_HAVE_STATX
> test_srcs += statx.c
> diff --git a/test/timeout-new.c b/test/timeout-new.c
> new file mode 100644
> index 000000000000..03e03eb1bba7
> --- /dev/null
> +++ b/test/timeout-new.c
> @@ -0,0 +1,49 @@
> +/* SPDX-License-Identifier: MIT */
> +/*
> + * Description: tests for getevents timeout
> + *
> + */
> +#include <stdio.h>
> +
> +#include "liburing.h"
> +
> +static int test_timeout(struct io_uring *ring)
> +{
> + struct io_uring_cqe *cqe;
> + int ret;
> + struct __kernel_timespec timeout;
> +
> + timeout.tv_sec = 1;
> + timeout.tv_nsec = 0;
> +
> + ret = io_uring_wait_cqe_timeout(ring, &cqe, &timeout);
> + if (ret != -ETIME) {
> + fprintf(stderr, "timeout error: %d\n", ret);
> + return 1;
> + }
> +
> + return 0;
> +}
> +
> +int main(int argc, char *argv[])
> +{
> + struct io_uring ring;
> + int ret;
> +
> + if (argc > 1)
> + return 0;
> +
> + ret = io_uring_queue_init(8, &ring, 0);
> + if (ret) {
> + fprintf(stderr, "ring setup failed: %d\n", ret);
> + return 1;
> + }
> +
> + ret = test_timeout(&ring);
> + if (ret) {
> + fprintf(stderr, "test_timeout failed\n");
> + return ret;
> + }
> +
> + return 0;
> +}
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] test/timeout-new: test for timeout feature
2020-11-23 7:07 [PATCH] test/timeout-new: test for timeout feature Hao Xu
2020-11-26 12:55 ` Hao Xu
@ 2020-11-26 17:39 ` Jens Axboe
2020-11-27 3:03 ` Hao Xu
1 sibling, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2020-11-26 17:39 UTC (permalink / raw)
To: Hao Xu; +Cc: io-uring, Joseph Qi
On 11/23/20 12:07 AM, Hao Xu wrote:
> Signed-off-by: Hao Xu <[email protected]>
> ---
>
> Hi Jens,
> This is a simple test for the new getevent timeout feature. Sorry for
> the delay.
We need a lot more in this test case, to be honest. Maybe test that
it returns around 1 second? Test that if we have an event it doesn't
wait, etc. This is as bare bones as it gets, a test case for a new
addition/change really should test all the interesting cases around
it.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] test/timeout-new: test for timeout feature
2020-11-26 17:39 ` Jens Axboe
@ 2020-11-27 3:03 ` Hao Xu
0 siblings, 0 replies; 4+ messages in thread
From: Hao Xu @ 2020-11-27 3:03 UTC (permalink / raw)
To: Jens Axboe; +Cc: io-uring, Joseph Qi
在 2020/11/27 上午1:39, Jens Axboe 写道:
> On 11/23/20 12:07 AM, Hao Xu wrote:
>> Signed-off-by: Hao Xu <[email protected]>
>> ---
>>
>> Hi Jens,
>> This is a simple test for the new getevent timeout feature. Sorry for
>> the delay.
>
> We need a lot more in this test case, to be honest. Maybe test that
> it returns around 1 second? Test that if we have an event it doesn't
> wait, etc. This is as bare bones as it gets, a test case for a new
> addition/change really should test all the interesting cases around
> it.
>
Agree, I'll consider more on this.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-27 3:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-23 7:07 [PATCH] test/timeout-new: test for timeout feature Hao Xu
2020-11-26 12:55 ` Hao Xu
2020-11-26 17:39 ` Jens Axboe
2020-11-27 3:03 ` Hao Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox