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 that exercises repeated sceduling...



details:   https://anonhg.NetBSD.org/src/rev/3adb0bab3c5a
branches:  trunk
changeset: 447024:3adb0bab3c5a
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Dec 28 19:54:36 2018 +0000

description:
Add a test case that exercises repeated sceduling and cancelling of a job,
with periodic dropping of the interlock.

diffstat:

 tests/rump/kernspace/kernspace.h   |   3 ++-
 tests/rump/kernspace/threadpool.c  |  32 ++++++++++++++++++++++++++++++--
 tests/rump/rumpkern/t_threadpool.c |  21 ++++++++++++++++++++-
 3 files changed, 52 insertions(+), 4 deletions(-)

diffs (108 lines):

diff -r 26a0c63fdaa5 -r 3adb0bab3c5a tests/rump/kernspace/kernspace.h
--- a/tests/rump/kernspace/kernspace.h  Fri Dec 28 18:44:11 2018 +0000
+++ b/tests/rump/kernspace/kernspace.h  Fri Dec 28 19:54:36 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kernspace.h,v 1.7 2018/12/24 21:42:05 thorpej Exp $    */
+/*     $NetBSD: kernspace.h,v 1.8 2018/12/28 19:54:36 thorpej Exp $    */
 
 /*-
  * Copyright (c) 2010, 2018 The NetBSD Foundation, Inc.
@@ -51,5 +51,6 @@
 void rumptest_threadpool_unbound_schedule(void);
 void rumptest_threadpool_percpu_schedule(void);
 void rumptest_threadpool_job_cancel(void);
+void rumptest_threadpool_job_cancelthrash(void);
 
 #endif /* _TESTS_RUMP_KERNSPACE_KERNSPACE_H_ */
diff -r 26a0c63fdaa5 -r 3adb0bab3c5a tests/rump/kernspace/threadpool.c
--- a/tests/rump/kernspace/threadpool.c Fri Dec 28 18:44:11 2018 +0000
+++ b/tests/rump/kernspace/threadpool.c Fri Dec 28 19:54:36 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: threadpool.c,v 1.3 2018/12/26 18:54:20 thorpej Exp $   */
+/*     $NetBSD: threadpool.c,v 1.4 2018/12/28 19:54:36 thorpej Exp $   */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: threadpool.c,v 1.3 2018/12/26 18:54:20 thorpej Exp $");
+__RCSID("$NetBSD: threadpool.c,v 1.4 2018/12/28 19:54:36 thorpej Exp $");
 #endif /* !lint */
 
 #include <sys/param.h>
@@ -237,3 +237,31 @@
 
        threadpool_put(pool, PRI_NONE);
 }
+
+void
+rumptest_threadpool_job_cancelthrash(void)
+{
+       struct test_job_data data;
+       struct threadpool *pool;
+       int i, error;
+
+       error = threadpool_get(&pool, PRI_NONE);
+       KASSERT(error == 0);
+
+       init_test_job_data(&data, test_job_func_cancel);
+
+       mutex_enter(&data.mutex);
+       for (i = 0; i < 10000; i++) {
+               threadpool_schedule_job(pool, &data.job);
+               if ((i % 3) == 0) {
+                       mutex_exit(&data.mutex);
+                       mutex_enter(&data.mutex);
+               }
+               threadpool_cancel_job(pool, &data.job);
+       }
+       mutex_exit(&data.mutex);
+
+       fini_test_job_data(&data);
+
+       threadpool_put(pool, PRI_NONE);
+}
diff -r 26a0c63fdaa5 -r 3adb0bab3c5a tests/rump/rumpkern/t_threadpool.c
--- a/tests/rump/rumpkern/t_threadpool.c        Fri Dec 28 18:44:11 2018 +0000
+++ b/tests/rump/rumpkern/t_threadpool.c        Fri Dec 28 19:54:36 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_threadpool.c,v 1.1 2018/12/24 21:42:05 thorpej Exp $ */
+/*     $NetBSD: t_threadpool.c,v 1.2 2018/12/28 19:54:36 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -126,6 +126,24 @@
        rump_unschedule();
 }
 
+ATF_TC(threadpool_job_cancelthrash);
+ATF_TC_HEAD(threadpool_job_cancelthrash, tc)
+{
+
+       atf_tc_set_md_var(tc, "descr",
+           "Tests thrashing job scheduling / cancellation");
+}
+
+ATF_TC_BODY(threadpool_job_cancelthrash, tc)
+{
+
+       rump_init();
+
+       rump_schedule();
+       rumptest_threadpool_job_cancelthrash(); /* panics if fails */
+       rump_unschedule();
+}
+
 ATF_TP_ADD_TCS(tp)
 {
        ATF_TP_ADD_TC(tp, threadpool_unbound_lifecycle);
@@ -133,6 +151,7 @@
        ATF_TP_ADD_TC(tp, threadpool_unbound_schedule);
        ATF_TP_ADD_TC(tp, threadpool_percpu_schedule);
        ATF_TP_ADD_TC(tp, threadpool_job_cancel);
+       ATF_TP_ADD_TC(tp, threadpool_job_cancelthrash);
 
        return atf_no_error();
 }



Home | Main Index | Thread Index | Old Index