Module Name: src
Committed By: maya
Date: Fri Sep 29 12:42:37 UTC 2017
Modified Files:
src/distrib/sets/lists/debug: mi
src/distrib/sets/lists/tests: mi
src/tests/rump/kernspace: Makefile
src/tests/rump/rumpkern: Makefile
Added Files:
src/tests/rump/kernspace: workqueue.c
src/tests/rump/rumpkern: t_workqueue.c
Log Message:
Add simple test for workqueue(9)
To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/distrib/sets/lists/debug/mi
cvs rdiff -u -r1.762 -r1.763 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.5 -r1.6 src/tests/rump/kernspace/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/rump/kernspace/workqueue.c
cvs rdiff -u -r1.15 -r1.16 src/tests/rump/rumpkern/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/rump/rumpkern/t_workqueue.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/debug/mi
diff -u src/distrib/sets/lists/debug/mi:1.224 src/distrib/sets/lists/debug/mi:1.225
--- src/distrib/sets/lists/debug/mi:1.224 Wed Aug 16 13:53:19 2017
+++ src/distrib/sets/lists/debug/mi Fri Sep 29 12:42:36 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.224 2017/08/16 13:53:19 joerg Exp $
+# $NetBSD: mi,v 1.225 2017/09/29 12:42:36 maya Exp $
./etc/mtree/set.debug comp-sys-root
./usr/lib comp-sys-usr compatdir
./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib,compatfile
@@ -2306,6 +2306,7 @@
./usr/libdata/debug/usr/tests/rump/rumpkern/t_signals.debug tests-syscall-debug debug,atf,rump
./usr/libdata/debug/usr/tests/rump/rumpkern/t_threads.debug tests-syscall-debug debug,atf,rump
./usr/libdata/debug/usr/tests/rump/rumpkern/t_tsleep.debug tests-syscall-debug debug,atf,rump
+./usr/libdata/debug/usr/tests/rump/rumpkern/t_workqueue.debug tests-syscall-debug debug,atf,rump
./usr/libdata/debug/usr/tests/rump/rumpkern/t_vm.debug tests-syscall-debug debug,atf,rump
./usr/libdata/debug/usr/tests/rump/rumpvfs/t_basic.debug tests-syscall-debug debug,atf,rump
./usr/libdata/debug/usr/tests/rump/rumpvfs/t_etfs.debug tests-syscall-debug debug,atf,rump
Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.762 src/distrib/sets/lists/tests/mi:1.763
--- src/distrib/sets/lists/tests/mi:1.762 Wed Sep 20 09:36:20 2017
+++ src/distrib/sets/lists/tests/mi Fri Sep 29 12:42:36 2017
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.762 2017/09/20 09:36:20 ozaki-r Exp $
+# $NetBSD: mi,v 1.763 2017/09/29 12:42:36 maya Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -3416,6 +3416,7 @@
./usr/tests/rump/rumpkern/t_sp tests-rump-tests atf,rump
./usr/tests/rump/rumpkern/t_threads tests-rump-tests atf,rump
./usr/tests/rump/rumpkern/t_tsleep tests-rump-tests atf,rump
+./usr/tests/rump/rumpkern/t_workqueue tests-rump-tests atf,rump
./usr/tests/rump/rumpkern/t_vm tests-rump-tests atf,rump
./usr/tests/rump/rumpnet tests-rump-tests compattestfile,atf
./usr/tests/rump/rumpnet/Atffile tests-rump-tests atf,rump
Index: src/tests/rump/kernspace/Makefile
diff -u src/tests/rump/kernspace/Makefile:1.5 src/tests/rump/kernspace/Makefile:1.6
--- src/tests/rump/kernspace/Makefile:1.5 Fri Jan 14 13:08:00 2011
+++ src/tests/rump/kernspace/Makefile Fri Sep 29 12:42:36 2017
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.5 2011/01/14 13:08:00 pooka Exp $
+# $NetBSD: Makefile,v 1.6 2017/09/29 12:42:36 maya Exp $
#
.include <bsd.own.mk>
LIB= kernspace
-SRCS= thread.c busypage.c tsleep.c alloc.c lockme.c sendsig.c
+SRCS= thread.c busypage.c tsleep.c alloc.c lockme.c workqueue.c sendsig.c
RUMPTOP=${NETBSDSRCDIR}/sys/rump
Index: src/tests/rump/rumpkern/Makefile
diff -u src/tests/rump/rumpkern/Makefile:1.15 src/tests/rump/rumpkern/Makefile:1.16
--- src/tests/rump/rumpkern/Makefile:1.15 Tue Jun 10 04:28:40 2014
+++ src/tests/rump/rumpkern/Makefile Fri Sep 29 12:42:37 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.15 2014/06/10 04:28:40 he Exp $
+# $NetBSD: Makefile,v 1.16 2017/09/29 12:42:37 maya Exp $
.include <bsd.own.mk>
@@ -12,6 +12,7 @@ TESTS_C+= t_modlinkset
TESTS_C+= t_signals
TESTS_C+= t_threads
TESTS_C+= t_tsleep
+TESTS_C+= t_workqueue
TESTS_C+= t_vm
TESTS_SH= t_sp
Added files:
Index: src/tests/rump/kernspace/workqueue.c
diff -u /dev/null src/tests/rump/kernspace/workqueue.c:1.1
--- /dev/null Fri Sep 29 12:42:37 2017
+++ src/tests/rump/kernspace/workqueue.c Fri Sep 29 12:42:36 2017
@@ -0,0 +1,98 @@
+/* $NetBSD: workqueue.c,v 1.1 2017/09/29 12:42:36 maya Exp $ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#if !defined(lint)
+__RCSID("$NetBSD: workqueue.c,v 1.1 2017/09/29 12:42:36 maya Exp $");
+#endif /* !lint */
+
+#include <sys/param.h>
+#include <sys/condvar.h>
+#include <sys/kernel.h>
+#include <sys/kmem.h>
+#include <sys/kthread.h>
+#include <sys/mutex.h>
+#include <sys/workqueue.h>
+
+#include "kernspace.h"
+
+struct test_softc {
+ kmutex_t mtx;
+ kcondvar_t cv;
+ struct workqueue *wq;
+ struct work wk;
+ int counter;
+};
+
+static void
+rump_work1(struct work *wk, void *arg)
+{
+ struct test_softc *sc = arg;
+
+ mutex_enter(&sc->mtx);
+ ++sc->counter;
+ cv_broadcast(&sc->cv);
+ mutex_exit(&sc->mtx);
+}
+
+void
+rumptest_workqueue1()
+{
+
+ 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)
+ panic("workqueue creation failed: %d", rv);
+
+ sc->counter = 0;
+
+#define ITERATIONS 12435
+ for (size_t i = 0; i < ITERATIONS; ++i) {
+ workqueue_enqueue(sc->wq, &sc->wk, NULL);
+ mutex_enter(&sc->mtx);
+ cv_timedwait(&sc->cv, &sc->mtx, 2);
+ mutex_exit(&sc->mtx);
+ }
+
+ KASSERT(sc->counter == ITERATIONS);
+
+ cv_destroy(&sc->cv);
+ mutex_destroy(&sc->mtx);
+ workqueue_destroy(sc->wq);
+}
+
Index: src/tests/rump/rumpkern/t_workqueue.c
diff -u /dev/null src/tests/rump/rumpkern/t_workqueue.c:1.1
--- /dev/null Fri Sep 29 12:42:37 2017
+++ src/tests/rump/rumpkern/t_workqueue.c Fri Sep 29 12:42:37 2017
@@ -0,0 +1,63 @@
+/* $NetBSD: t_workqueue.c,v 1.1 2017/09/29 12:42:37 maya Exp $ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
+ * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <sys/sysctl.h>
+
+#include <rump/rump.h>
+
+#include <atf-c.h>
+
+#include "h_macros.h"
+#include "../kernspace/kernspace.h"
+
+ATF_TC(workqueue1);
+ATF_TC_HEAD(workqueue1, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Checks workqueue basics");
+}
+
+ATF_TC_BODY(workqueue1, tc)
+{
+
+ rump_init();
+
+ rump_schedule();
+ rumptest_workqueue1(); /* panics if fails */
+ rump_unschedule();
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, workqueue1);
+
+ return atf_no_error();
+}