diff options
Diffstat (limited to 'source/tests')
-rw-r--r-- | source/tests/array_ref.test.c | 10 | ||||
-rw-r--r-- | source/tests/secure_random.test.c | 6 | ||||
-rw-r--r-- | source/tests/test_interprocess.c | 16 |
3 files changed, 19 insertions, 13 deletions
diff --git a/source/tests/array_ref.test.c b/source/tests/array_ref.test.c index 921e9fd..036e802 100644 --- a/source/tests/array_ref.test.c +++ b/source/tests/array_ref.test.c @@ -26,8 +26,14 @@ TEST("array ref equal") { REQUIRE(AR_EQUAL(foo_ref, bar_ref)); } -static int compare(int *left, int *right) { - return *left - *right; +static i8 compare(void *left_, void *right_) { + int *left = (int *) left_; + int *right = (int *) right_; + if (*left < *right) + return -1; + if (*left > *right) + return 1; + return 0; } TEST("array ref compare") { diff --git a/source/tests/secure_random.test.c b/source/tests/secure_random.test.c index 3452521..b397ff9 100644 --- a/source/tests/secure_random.test.c +++ b/source/tests/secure_random.test.c @@ -5,7 +5,7 @@ #include "../kit/test.h" TEST("secure random") { - int v[20]; + i32 v[20]; memset(v, 0, sizeof v); REQUIRE_EQ(secure_random(40, v), KIT_OK); @@ -13,8 +13,8 @@ TEST("secure random") { int repeats = 0; - for (int i = 1; i < sizeof v / sizeof *v; i++) - for (int j = 0; j < i; j++) + for (i32 i = 1; i < (i32) (sizeof v / sizeof *v); i++) + for (i32 j = 0; j < i; j++) if (v[i] == v[j]) repeats++; diff --git a/source/tests/test_interprocess.c b/source/tests/test_interprocess.c index 7655192..027f4ae 100644 --- a/source/tests/test_interprocess.c +++ b/source/tests/test_interprocess.c @@ -21,7 +21,7 @@ int run_writer() { SZ(NAME), sizeof(shared_data_t), SHARED_MEMORY_CREATE); if (mem.status != KIT_OK) { - printf("%s: kit_shared_memory_open failed.\n", __FUNCTION__); + printf("Writer: kit_shared_memory_open failed.\n"); fflush(stdout); return 1; } @@ -52,7 +52,7 @@ int run_writer() { timespec_get(&t1, TIME_UTC); if (t1.tv_sec - t0.tv_sec > TIMEOUT) { - printf("%s: timeout.\n", __FUNCTION__); + printf("Writer: Timeout.\n"); shared_memory_close(&mem); return 1; } @@ -63,7 +63,7 @@ int run_writer() { shared_unlock(&p->m); if (shared_memory_close(&mem) != KIT_OK) { - printf("%s: kit_shared_memory_close failed.\n", __FUNCTION__); + printf("Writer: kit_shared_memory_close failed.\n"); fflush(stdout); return 1; } @@ -86,7 +86,7 @@ int run_reader() { timespec_get(&t1, TIME_UTC); if (t1.tv_sec - t0.tv_sec > TIMEOUT) { - printf("%s: timeout.\n", __FUNCTION__); + printf("Reader: Timeout.\n"); return 1; } @@ -104,7 +104,7 @@ int run_reader() { timespec_get(&t1, TIME_UTC); if (t1.tv_sec - t0.tv_sec > TIMEOUT) { - printf("%s: timeout.\n", __FUNCTION__); + printf("Reader: Timeout.\n"); return 1; } @@ -116,7 +116,7 @@ int run_reader() { for (i32 i = 0; i < DATA_SIZE; i++) if (p->bytes[i] != i) { - printf("%s: wrong byte %d\n", __FUNCTION__, i); + printf("Reader: Wrong byte %d\n", i); fflush(stdout); status = 1; } @@ -128,7 +128,7 @@ int run_reader() { unique_unlock(&p->m); if (shared_memory_close(&mem) != KIT_OK) { - printf("%s: kit_shared_memory_close failed.\n", __FUNCTION__); + printf("Reader: kit_shared_memory_close failed.\n"); fflush(stdout); status = 1; } @@ -154,7 +154,7 @@ int main(int argc, char **argv) { i64 sec = t1.tv_sec - t0.tv_sec; i64 nsec = t1.tv_nsec - t0.tv_nsec; - printf("Done in %.2lf msec\n", + printf("Writer: Done in %.2lf msec\n", (sec * 1000000000 + nsec) * 0.000001); fflush(stdout); |