Lines Matching +full:test +full:- +full:cpu
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2020-2021 Kyle Evans <kevans@FreeBSD.org>
41 #include <atf-c.h>
91 return ("Unexpected post-attach affinity"); in do_jail_errstr()
105 -1, sizeof(*mask), mask)); in skip_ltncpu()
107 atf_tc_skip("Test requires %d or more cores.", ncpu); in skip_ltncpu()
113 atf_tc_set_md_var(tc, "descr", "Test cpuset(2)"); in ATF_TC_HEAD()
120 ATF_REQUIRE_EQ(0, cpuset_getid(CPU_LEVEL_CPUSET, CPU_WHICH_TID, -1, in ATF_TC_BODY()
128 ATF_REQUIRE_EQ(0, cpuset_getid(CPU_LEVEL_CPUSET, CPU_WHICH_TID, -1, in ATF_TC_BODY()
137 "Test that transient cpusets are freed."); in ATF_TC_HEAD()
143 ATF_REQUIRE_EQ(0, cpuset_getid(CPU_LEVEL_CPUSET, CPU_WHICH_PID, -1, in ATF_TC_BODY()
154 ATF_REQUIRE_EQ(0, cpuset_setid(CPU_WHICH_PID, -1, isetid)); in ATF_TC_BODY()
155 ATF_REQUIRE_EQ(-1, cpuset_getid(CPU_LEVEL_CPUSET, CPU_WHICH_CPUSET, in ATF_TC_BODY()
163 atf_tc_set_md_var(tc, "descr", "Test against disjoint cpusets."); in ATF_TC_HEAD()
172 /* Make sure we have 3 cpus, so we test partial overlap. */ in ATF_TC_BODY()
187 for (i = fcpu - 1, found = 0; i < CPU_MAXSIZE && found != ncpu; i++) { in ATF_TC_BODY()
203 -1, sizeof(mask), &mask)); in ATF_TC_BODY()
206 ATF_REQUIRE_EQ(-1, cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, in ATF_TC_BODY()
207 -1, sizeof(dismask), &dismask)); in ATF_TC_BODY()
217 -1, sizeof(mask), &mask)); in ATF_TC_BODY()
219 -1, sizeof(dismask), &dismask)); in ATF_TC_BODY()
221 -1, sizeof(mask), &mask)); in ATF_TC_BODY()
231 ATF_REQUIRE_EQ(-1, cpuset_setaffinity(CPU_LEVEL_CPUSET, CPU_WHICH_PID, in ATF_TC_BODY()
232 -1, sizeof(dismask), &dismask)); in ATF_TC_BODY()
244 if (asprintf(&name, "cpuset_%d", getpid()) == -1) in do_jail()
259 -1, sizeof(info.jail_tidmask), &info.jail_tidmask); in do_jail()
263 error = cpuset_getid(CPU_LEVEL_ROOT, CPU_WHICH_TID, -1, in do_jail()
267 error = cpuset_getid(CPU_LEVEL_CPUSET, CPU_WHICH_TID, -1, in do_jail()
289 ATF_REQUIRE_EQ(0, cpuset_getid(CPU_LEVEL_ROOT, CPU_WHICH_PID, -1, in do_jail_test()
295 -1, &cbp.setid)); in do_jail_test()
300 /* Not every test needs early setup. */ in do_jail_test()
305 ATF_REQUIRE((pid = fork()) != -1); in do_jail_test()
318 while ((error = waitpid(pid, &status, 0)) == -1 && in do_jail_test()
347 mask = &cbp->mask; in jail_attach_mutate_pro()
349 /* Knock out the first cpu. */ in jail_attach_mutate_pro()
351 CPU_CLR(CPU_FFS(mask) - 1, mask); in jail_attach_mutate_pro()
352 ATF_REQUIRE_EQ(count - 1, CPU_COUNT(mask)); in jail_attach_mutate_pro()
354 -1, sizeof(*mask), mask)); in jail_attach_mutate_pro()
363 info = &cbp->info; in jail_attach_newbase_epi()
364 mask = &cbp->mask; in jail_attach_newbase_epi()
367 * The rootid test has been thrown in because a bug was discovered in jail_attach_newbase_epi()
372 ATF_REQUIRE(info->jail_cpuset != cbp->rootid); in jail_attach_newbase_epi()
373 ATF_REQUIRE(info->jail_cpuset != cbp->setid); in jail_attach_newbase_epi()
374 ATF_REQUIRE(info->jail_cpuset != info->jail_child_cpuset); in jail_attach_newbase_epi()
375 ATF_REQUIRE_EQ(0, CPU_CMP(mask, &info->jail_tidmask)); in jail_attach_newbase_epi()
382 "Test jail attachment effect on affinity with a new base cpuset."); in ATF_TC_HEAD()
388 /* Need >= 2 cpus to test restriction. */ in ATF_TC_BODY()
397 "Test jail attachment effect on affinity with a new, unmodified base cpuset."); in ATF_TC_HEAD()
416 info = &cbp->info; in jail_attach_jset_epi()
417 mask = &cbp->mask; in jail_attach_jset_epi()
419 ATF_REQUIRE(info->jail_cpuset != cbp->setid); in jail_attach_jset_epi()
420 ATF_REQUIRE_EQ(info->jail_cpuset, info->jail_child_cpuset); in jail_attach_jset_epi()
421 ATF_REQUIRE_EQ(0, CPU_CMP(mask, &info->jail_tidmask)); in jail_attach_jset_epi()
428 "Test jail attachment effect on affinity without a new base."); in ATF_TC_HEAD()
441 if (cbp->setid != cbp->rootid) in jail_attach_plain_pro()
449 "Test jail attachment effect on affinity without specialization."); in ATF_TC_HEAD()
465 if (asprintf(&name, "cpuset_%d", getpid()) == -1) in jail_attach_disjoint_newjail()
503 } while (error == -1 && errno == EINTR); in wait_jail()
527 if (jail_attach(jid) == -1) { in try_attach_child()
539 -1, sizeof(mask), &mask) != 0) { in try_attach_child()
557 ATF_REQUIRE((pid = fork()) != -1); in try_attach()
561 while ((error = waitpid(pid, &status, 0)) == -1 && errno == EINTR) { in try_attach()
581 "Test root attachment into completely disjoint jail cpuset."); in ATF_TC_HEAD()
595 fcpu = CPU_FFS(&jmask) - 1; in ATF_TC_BODY()
599 ATF_REQUIRE((pid = pdfork(&pfd, 0)) != -1); in ATF_TC_BODY()
615 * This process will be clamped down to the first cpu, while the jail in ATF_TC_BODY()
616 * will simply have the first CPU removed to make it a completely in ATF_TC_BODY()
624 * We'll test with the first and second cpu set as well. Only the in ATF_TC_BODY()
625 * second cpu should be used. in ATF_TC_BODY()
627 scpu = CPU_FFS(&jmask) - 1; in ATF_TC_BODY()
648 "Test parent assignment when assigning a new cpuset."); in ATF_TC_HEAD()
655 /* Need to mask off at least one CPU. */ in ATF_TC_BODY()
658 ATF_REQUIRE_EQ(0, cpuset_getid(CPU_LEVEL_CPUSET, CPU_WHICH_TID, -1, in ATF_TC_BODY()
664 * Mask off the first CPU, then we'll reparent ourselves to our original in ATF_TC_BODY()
667 CPU_CLR(CPU_FFS(&mask) - 1, &mask); in ATF_TC_BODY()
669 -1, sizeof(mask), &mask)); in ATF_TC_BODY()
671 ATF_REQUIRE_EQ(0, cpuset_setid(CPU_WHICH_PID, -1, origsetid)); in ATF_TC_BODY()
672 ATF_REQUIRE_EQ(0, cpuset_getid(CPU_LEVEL_CPUSET, CPU_WHICH_TID, -1, in ATF_TC_BODY()