Add a test case that exercises repeated sceduling and cancelling of a job,
with periodic dropping of the interlock.
This commit is contained in:
parent
f4bc8af01c
commit
032c1d01a1
@ -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_percpu_lifecycle(void);
|
||||
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_ */
|
||||
|
@ -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 @@ rumptest_threadpool_job_cancel(void)
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -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 @@ ATF_TC_BODY(threadpool_job_cancel, tc)
|
||||
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_TCS(tp)
|
||||
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();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user