1 1.2 thorpej /* $NetBSD: t_threadpool.c,v 1.2 2018/12/28 19:54:36 thorpej Exp $ */ 2 1.1 thorpej 3 1.1 thorpej /*- 4 1.1 thorpej * Copyright (c) 2018 The NetBSD Foundation, Inc. 5 1.1 thorpej * All rights reserved. 6 1.1 thorpej * 7 1.1 thorpej * Redistribution and use in source and binary forms, with or without 8 1.1 thorpej * modification, are permitted provided that the following conditions 9 1.1 thorpej * are met: 10 1.1 thorpej * 1. Redistributions of source code must retain the above copyright 11 1.1 thorpej * notice, this list of conditions and the following disclaimer. 12 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright 13 1.1 thorpej * notice, this list of conditions and the following disclaimer in the 14 1.1 thorpej * documentation and/or other materials provided with the distribution. 15 1.1 thorpej * 16 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 17 1.1 thorpej * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 18 1.1 thorpej * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19 1.1 thorpej * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 1.1 thorpej * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 21 1.1 thorpej * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 1.1 thorpej * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23 1.1 thorpej * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25 1.1 thorpej * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26 1.1 thorpej * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27 1.1 thorpej * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 1.1 thorpej */ 29 1.1 thorpej 30 1.1 thorpej #include <sys/types.h> 31 1.1 thorpej #include <sys/mount.h> 32 1.1 thorpej #include <sys/sysctl.h> 33 1.1 thorpej 34 1.1 thorpej #include <rump/rump.h> 35 1.1 thorpej 36 1.1 thorpej #include <atf-c.h> 37 1.1 thorpej 38 1.1 thorpej #include "h_macros.h" 39 1.1 thorpej #include "../kernspace/kernspace.h" 40 1.1 thorpej 41 1.1 thorpej ATF_TC(threadpool_unbound_lifecycle); 42 1.1 thorpej ATF_TC_HEAD(threadpool_unbound_lifecycle, tc) 43 1.1 thorpej { 44 1.1 thorpej 45 1.1 thorpej atf_tc_set_md_var(tc, "descr", "Tests unbound threadpool lifecycle"); 46 1.1 thorpej } 47 1.1 thorpej 48 1.1 thorpej ATF_TC_BODY(threadpool_unbound_lifecycle, tc) 49 1.1 thorpej { 50 1.1 thorpej 51 1.1 thorpej rump_init(); 52 1.1 thorpej 53 1.1 thorpej rump_schedule(); 54 1.1 thorpej rumptest_threadpool_unbound_lifecycle(); /* panics if fails */ 55 1.1 thorpej rump_unschedule(); 56 1.1 thorpej } 57 1.1 thorpej 58 1.1 thorpej ATF_TC(threadpool_percpu_lifecycle); 59 1.1 thorpej ATF_TC_HEAD(threadpool_percpu_lifecycle, tc) 60 1.1 thorpej { 61 1.1 thorpej 62 1.1 thorpej atf_tc_set_md_var(tc, "descr", "Tests percpu threadpool lifecycle"); 63 1.1 thorpej } 64 1.1 thorpej 65 1.1 thorpej ATF_TC_BODY(threadpool_percpu_lifecycle, tc) 66 1.1 thorpej { 67 1.1 thorpej 68 1.1 thorpej rump_init(); 69 1.1 thorpej 70 1.1 thorpej rump_schedule(); 71 1.1 thorpej rumptest_threadpool_percpu_lifecycle(); /* panics if fails */ 72 1.1 thorpej rump_unschedule(); 73 1.1 thorpej } 74 1.1 thorpej 75 1.1 thorpej ATF_TC(threadpool_unbound_schedule); 76 1.1 thorpej ATF_TC_HEAD(threadpool_unbound_schedule, tc) 77 1.1 thorpej { 78 1.1 thorpej 79 1.1 thorpej atf_tc_set_md_var(tc, "descr", 80 1.1 thorpej "Tests scheduling on unbound threadpools"); 81 1.1 thorpej } 82 1.1 thorpej 83 1.1 thorpej ATF_TC_BODY(threadpool_unbound_schedule, tc) 84 1.1 thorpej { 85 1.1 thorpej 86 1.1 thorpej rump_init(); 87 1.1 thorpej 88 1.1 thorpej rump_schedule(); 89 1.1 thorpej rumptest_threadpool_unbound_schedule(); /* panics if fails */ 90 1.1 thorpej rump_unschedule(); 91 1.1 thorpej } 92 1.1 thorpej 93 1.1 thorpej ATF_TC(threadpool_percpu_schedule); 94 1.1 thorpej ATF_TC_HEAD(threadpool_percpu_schedule, tc) 95 1.1 thorpej { 96 1.1 thorpej 97 1.1 thorpej atf_tc_set_md_var(tc, "descr", 98 1.1 thorpej "Tests scheduling on percpu threadpools"); 99 1.1 thorpej } 100 1.1 thorpej 101 1.1 thorpej ATF_TC_BODY(threadpool_percpu_schedule, tc) 102 1.1 thorpej { 103 1.1 thorpej 104 1.1 thorpej rump_init(); 105 1.1 thorpej 106 1.1 thorpej rump_schedule(); 107 1.1 thorpej rumptest_threadpool_percpu_schedule(); /* panics if fails */ 108 1.1 thorpej rump_unschedule(); 109 1.1 thorpej } 110 1.1 thorpej 111 1.1 thorpej ATF_TC(threadpool_job_cancel); 112 1.1 thorpej ATF_TC_HEAD(threadpool_job_cancel, tc) 113 1.1 thorpej { 114 1.1 thorpej 115 1.1 thorpej atf_tc_set_md_var(tc, "descr", 116 1.1 thorpej "Tests synchronizing with job cancellation"); 117 1.1 thorpej } 118 1.1 thorpej 119 1.1 thorpej ATF_TC_BODY(threadpool_job_cancel, tc) 120 1.1 thorpej { 121 1.1 thorpej 122 1.1 thorpej rump_init(); 123 1.1 thorpej 124 1.1 thorpej rump_schedule(); 125 1.1 thorpej rumptest_threadpool_job_cancel(); /* panics if fails */ 126 1.1 thorpej rump_unschedule(); 127 1.1 thorpej } 128 1.1 thorpej 129 1.2 thorpej ATF_TC(threadpool_job_cancelthrash); 130 1.2 thorpej ATF_TC_HEAD(threadpool_job_cancelthrash, tc) 131 1.2 thorpej { 132 1.2 thorpej 133 1.2 thorpej atf_tc_set_md_var(tc, "descr", 134 1.2 thorpej "Tests thrashing job scheduling / cancellation"); 135 1.2 thorpej } 136 1.2 thorpej 137 1.2 thorpej ATF_TC_BODY(threadpool_job_cancelthrash, tc) 138 1.2 thorpej { 139 1.2 thorpej 140 1.2 thorpej rump_init(); 141 1.2 thorpej 142 1.2 thorpej rump_schedule(); 143 1.2 thorpej rumptest_threadpool_job_cancelthrash(); /* panics if fails */ 144 1.2 thorpej rump_unschedule(); 145 1.2 thorpej } 146 1.2 thorpej 147 1.1 thorpej ATF_TP_ADD_TCS(tp) 148 1.1 thorpej { 149 1.1 thorpej ATF_TP_ADD_TC(tp, threadpool_unbound_lifecycle); 150 1.1 thorpej ATF_TP_ADD_TC(tp, threadpool_percpu_lifecycle); 151 1.1 thorpej ATF_TP_ADD_TC(tp, threadpool_unbound_schedule); 152 1.1 thorpej ATF_TP_ADD_TC(tp, threadpool_percpu_schedule); 153 1.1 thorpej ATF_TP_ADD_TC(tp, threadpool_job_cancel); 154 1.2 thorpej ATF_TP_ADD_TC(tp, threadpool_job_cancelthrash); 155 1.1 thorpej 156 1.1 thorpej return atf_no_error(); 157 1.1 thorpej } 158