Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/rump Add a test case for workqueue_wait
details: https://anonhg.NetBSD.org/src/rev/8a42ece17312
branches: trunk
changeset: 358408:8a42ece17312
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Thu Dec 28 07:10:25 2017 +0000
description:
Add a test case for workqueue_wait
diffstat:
tests/rump/kernspace/kernspace.h | 3 ++-
tests/rump/kernspace/workqueue.c | 29 +++++++++++++++++++++++++++--
tests/rump/rumpkern/t_workqueue.c | 20 +++++++++++++++++++-
3 files changed, 48 insertions(+), 4 deletions(-)
diffs (101 lines):
diff -r c66d5b4fbc3d -r 8a42ece17312 tests/rump/kernspace/kernspace.h
--- a/tests/rump/kernspace/kernspace.h Thu Dec 28 07:09:31 2017 +0000
+++ b/tests/rump/kernspace/kernspace.h Thu Dec 28 07:10:25 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kernspace.h,v 1.5 2017/09/29 13:19:57 maya Exp $ */
+/* $NetBSD: kernspace.h,v 1.6 2017/12/28 07:10:25 ozaki-r Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -41,6 +41,7 @@
void rumptest_alloc(size_t);
void rumptest_lockme(enum locktest);
void rumptest_workqueue1(void);
+void rumptest_workqueue_wait(void);
void rumptest_sendsig(char *);
void rumptest_localsig(int);
diff -r c66d5b4fbc3d -r 8a42ece17312 tests/rump/kernspace/workqueue.c
--- a/tests/rump/kernspace/workqueue.c Thu Dec 28 07:09:31 2017 +0000
+++ b/tests/rump/kernspace/workqueue.c Thu Dec 28 07:10:25 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: workqueue.c,v 1.4 2017/12/28 07:09:31 ozaki-r Exp $ */
+/* $NetBSD: workqueue.c,v 1.5 2017/12/28 07:10:25 ozaki-r Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: workqueue.c,v 1.4 2017/12/28 07:09:31 ozaki-r Exp $");
+__RCSID("$NetBSD: workqueue.c,v 1.5 2017/12/28 07:10:25 ozaki-r Exp $");
#endif /* !lint */
#include <sys/param.h>
@@ -112,3 +112,28 @@
destroy_sc(sc);
#undef ITERATIONS
}
+
+void
+rumptest_workqueue_wait(void)
+{
+ struct test_softc *sc;
+ struct work dummy;
+
+ sc = create_sc();
+
+#define ITERATIONS 12435
+ for (size_t i = 0; i < ITERATIONS; ++i) {
+ KASSERT(sc->counter == i);
+ workqueue_enqueue(sc->wq, &sc->wk, NULL);
+ workqueue_wait(sc->wq, &sc->wk);
+ KASSERT(sc->counter == (i + 1));
+ }
+
+ KASSERT(sc->counter == ITERATIONS);
+
+ /* Wait for a work that is not enqueued. Just return immediately. */
+ workqueue_wait(sc->wq, &dummy);
+
+ destroy_sc(sc);
+#undef ITERATIONS
+}
diff -r c66d5b4fbc3d -r 8a42ece17312 tests/rump/rumpkern/t_workqueue.c
--- a/tests/rump/rumpkern/t_workqueue.c Thu Dec 28 07:09:31 2017 +0000
+++ b/tests/rump/rumpkern/t_workqueue.c Thu Dec 28 07:10:25 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_workqueue.c,v 1.1 2017/09/29 12:42:37 maya Exp $ */
+/* $NetBSD: t_workqueue.c,v 1.2 2017/12/28 07:10:26 ozaki-r Exp $ */
/*-
* Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -55,9 +55,27 @@
rump_unschedule();
}
+ATF_TC(workqueue_wait);
+ATF_TC_HEAD(workqueue_wait, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Checks workqueue_wait");
+}
+
+ATF_TC_BODY(workqueue_wait, tc)
+{
+
+ rump_init();
+
+ rump_schedule();
+ rumptest_workqueue_wait(); /* panics if fails */
+ rump_unschedule();
+}
+
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, workqueue1);
+ ATF_TP_ADD_TC(tp, workqueue_wait);
return atf_no_error();
}
Home |
Main Index |
Thread Index |
Old Index