Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions tests/bsdtests.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 4 additions & 0 deletions tests/bsdtests.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion tests/dispatch_workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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");

Expand Down