Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/rump/kernspace Functionalize some routines to add new ...



details:   https://anonhg.NetBSD.org/src/rev/c66d5b4fbc3d
branches:  trunk
changeset: 358407:c66d5b4fbc3d
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Dec 28 07:09:31 2017 +0000

description:
Functionalize some routines to add new tests easily (NFC)

diffstat:

 tests/rump/kernspace/workqueue.c |  37 +++++++++++++++++++++++++------------
 1 files changed, 25 insertions(+), 12 deletions(-)

diffs (77 lines):

diff -r daf3281d0525 -r c66d5b4fbc3d tests/rump/kernspace/workqueue.c
--- a/tests/rump/kernspace/workqueue.c  Thu Dec 28 07:06:36 2017 +0000
+++ b/tests/rump/kernspace/workqueue.c  Thu Dec 28 07:09:31 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: workqueue.c,v 1.3 2017/12/28 04:38:02 ozaki-r Exp $    */
+/*     $NetBSD: workqueue.c,v 1.4 2017/12/28 07:09:31 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.3 2017/12/28 04:38:02 ozaki-r Exp $");
+__RCSID("$NetBSD: workqueue.c,v 1.4 2017/12/28 07:09:31 ozaki-r Exp $");
 #endif /* !lint */
 
 #include <sys/param.h>
@@ -61,19 +61,15 @@
        mutex_exit(&sc->mtx);
 }
 
-void
-rumptest_workqueue1()
+static struct test_softc *
+create_sc(void)
 {
-
        int rv;
-
        struct test_softc *sc;
 
        sc = kmem_zalloc(sizeof(*sc), KM_SLEEP);
-
        mutex_init(&sc->mtx, MUTEX_DEFAULT, IPL_NONE);
        cv_init(&sc->cv, "rumpwqcv");
-
        rv = workqueue_create(&sc->wq, "rumpwq",
            rump_work1, sc, PRI_SOFTNET, IPL_SOFTNET, 0);
        if (rv)
@@ -81,6 +77,25 @@
 
        sc->counter = 0;
 
+       return sc;
+}
+
+static void
+destroy_sc(struct test_softc *sc)
+{
+
+       cv_destroy(&sc->cv);
+       mutex_destroy(&sc->mtx);
+       workqueue_destroy(sc->wq);
+}
+
+void
+rumptest_workqueue1()
+{
+       struct test_softc *sc;
+
+       sc = create_sc();
+
 #define ITERATIONS 12435
        for (size_t i = 0; i < ITERATIONS; ++i) {
                int e;
@@ -94,8 +109,6 @@
 
        KASSERT(sc->counter == ITERATIONS);
 
-       cv_destroy(&sc->cv);
-       mutex_destroy(&sc->mtx);
-       workqueue_destroy(sc->wq);
+       destroy_sc(sc);
+#undef ITERATIONS
 }
-



Home | Main Index | Thread Index | Old Index