1 #include <sys/cdefs.h> 2 __FBSDID("$FreeBSD$"); 3 4 #include <sys/types.h> 5 #include <sys/cpuset.h> 6 7 #include <stdio.h> 8 #include <libutil.h> 9 #include <atf-c.h> 10 11 ATF_TC(invalid); 12 ATF_TC_HEAD(invalid, tc) 13 { 14 atf_tc_set_md_var(tc, "descr", "Test invalid cpu"); 15 } 16 17 ATF_TC_BODY(invalid, tc) 18 { 19 cpuset_t mask; 20 char testvalue[BUFSIZ]; 21 22 snprintf(testvalue, sizeof(testvalue), "%d", CPU_SETSIZE + 1); 23 24 ATF_CHECK_EQ(cpuset_parselist(testvalue, &mask), CPUSET_PARSE_INVALID_CPU); 25 } 26 27 ATF_TC(invalidchar); 28 ATF_TC_HEAD(invalidchar, tc) 29 { 30 atf_tc_set_md_var(tc, "descr", "Test invalid char"); 31 } 32 33 ATF_TC_BODY(invalidchar, tc) 34 { 35 cpuset_t mask; 36 37 ATF_CHECK_EQ(cpuset_parselist("1+3", &mask), CPUSET_PARSE_ERROR); 38 } 39 40 ATF_TC(all); 41 ATF_TC_HEAD(all, tc) 42 { 43 atf_tc_set_md_var(tc, "descr", "Test 'all' special cpu-list"); 44 } 45 46 ATF_TC_BODY(all, tc) 47 { 48 cpuset_t mask; 49 50 ATF_CHECK_EQ(cpuset_parselist("all", &mask), CPUSET_PARSE_OK); 51 } 52 53 ATF_TC(normalsyntax); 54 ATF_TC_HEAD(normalsyntax, tc) 55 { 56 atf_tc_set_md_var(tc, "descr", "Test normal cpu-list syntax"); 57 } 58 59 ATF_TC_BODY(normalsyntax, tc) 60 { 61 cpuset_t mask; 62 63 ATF_CHECK_EQ(cpuset_parselist("1-3,6", &mask), CPUSET_PARSE_OK); 64 } 65 66 ATF_TP_ADD_TCS(tp) 67 { 68 ATF_TP_ADD_TC(tp, invalid); 69 ATF_TP_ADD_TC(tp, invalidchar); 70 ATF_TP_ADD_TC(tp, all); 71 ATF_TP_ADD_TC(tp, normalsyntax); 72 return (atf_no_error()); 73 } 74