diff --git a/tests/bsdtests.c b/tests/bsdtests.c index 6307180fd..3ea91a381 100644 --- a/tests/bsdtests.c +++ b/tests/bsdtests.c @@ -164,6 +164,20 @@ test_uint32_format(uint32_t actual, uint32_t expected, const char *format, ...) _test_uint32(NULL, 0, desc, actual, expected); } +void +_test_uint32_not(const char* file, long line, const char* desc, uint32_t actual, uint32_t unexpected) +{ + _test_print(file, line, desc, + (actual != unexpected), "%u", actual, "!%u", unexpected); +} + +void +test_uint32_not_format(uint32_t actual, uint32_t unexpected, const char *format, ...) +{ + GENERATE_DESC + _test_uint32_not(NULL, 0, desc, actual, unexpected); +} + void _test_int32(const char* file, long line, const char* desc, int32_t actual, int32_t expected) { diff --git a/tests/bsdtests.h b/tests/bsdtests.h index e8e292e6e..6c579efa1 100644 --- a/tests/bsdtests.h +++ b/tests/bsdtests.h @@ -111,6 +111,10 @@ void _test_uint32(const char* file, long line, const char* desc, uint32_t actual #define test_uint32(a,b,c) _test_uint32(__SOURCE_FILE__, __LINE__, a, b, c) void test_uint32_format(uint32_t actual, uint32_t expected, const char *format, ...) __printflike(3,4); +void _test_uint32_not(const char* file, long line, const char* desc, uint32_t actual, uint32_t unexpected); +#define test_uint32_not(a,b,c) _test_uint32(__SOURCE_FILE__, __LINE__, a, b, c) +void test_uint32_not_format(uint32_t actual, uint32_t unexpected, const char *format, ...) __printflike(3,4); + void _test_int32(const char* file, long line, const char* desc, int32_t actual, int32_t expected); #define test_int32(a,b,c) _test_int32(__SOURCE_FILE__, __LINE__, a, b, c) void test_int32_format(int32_t actual, int32_t expected, const char* format, ...) __printflike(3,4); diff --git a/tests/dispatch_workqueue.c b/tests/dispatch_workqueue.c index c12598b69..f7f4cb6e5 100644 --- a/tests/dispatch_workqueue.c +++ b/tests/dispatch_workqueue.c @@ -55,7 +55,8 @@ activecpu(void) activecpu = si.dwNumberOfProcessors; #else size_t s = sizeof(activecpu); - sysctlbyname("hw.activecpu", &activecpu, &s, NULL, 0); + if (sysctlbyname("hw.activecpu", &activecpu, &s, NULL, 0) != 0) + return 0; #endif return activecpu; } @@ -66,6 +67,7 @@ int main(void) { uint32_t ncpu = activecpu(); + test_uint32_not("Failed to get CPU count", ncpu, 0); dispatch_test_start("Dispatch workqueue");