Skip to content

Commit 413ed24

Browse files
committed
[tests] Make test harness portable.
Prior to this change, on non-Linux, the test harness will already attempt to use dispatch functionality when testing dispatch itself. This does not seem intentional, and instead appears to be intended as the Mac OS case where the platform already has Dispatch and is using that when testing the just-built version. Instead, make the Linux case the general `__unix__` case.
1 parent fff4945 commit 413ed24

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tests/bsdtestharness.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include <dispatch/dispatch.h>
2222
#include <assert.h>
23+
#include <inttypes.h>
2324
#include <stdio.h>
2425
#include <stdlib.h>
2526
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
@@ -144,7 +145,7 @@ main(int argc, char *argv[])
144145
//fprintf(stderr, "pid = %d\n", pid);
145146
assert(pid > 0);
146147

147-
#if defined(__linux__)
148+
#if defined(__unix__)
148149
int status;
149150
struct rusage usage;
150151
struct timeval tv_stop, tv_wall;
@@ -159,9 +160,9 @@ main(int argc, char *argv[])
159160

160161
assert(res2 != -1);
161162
test_long("Process exited", (WIFEXITED(status) && WEXITSTATUS(status) && WEXITSTATUS(status) != 0xff) || WIFSIGNALED(status), 0);
162-
printf("[PERF]\twall time: %ld.%06ld\n", tv_wall.tv_sec, tv_wall.tv_usec);
163-
printf("[PERF]\tuser time: %ld.%06ld\n", usage.ru_utime.tv_sec, usage.ru_utime.tv_usec);
164-
printf("[PERF]\tsystem time: %ld.%06ld\n", usage.ru_stime.tv_sec, usage.ru_stime.tv_usec);
163+
printf("[PERF]\twall time: %" PRIdMAX ".%06" PRIdMAX "\n", (intmax_t)tv_wall.tv_sec, (intmax_t)tv_wall.tv_usec);
164+
printf("[PERF]\tuser time: %" PRIdMAX ".%06" PRIdMAX"\n", (intmax_t)usage.ru_utime.tv_sec, (intmax_t)usage.ru_utime.tv_usec);
165+
printf("[PERF]\tsystem time: %" PRIdMAX ".%06" PRIdMAX "\n", (intmax_t)usage.ru_stime.tv_sec, (intmax_t)usage.ru_stime.tv_usec);
165166
printf("[PERF]\tmax resident set size: %ld\n", usage.ru_maxrss);
166167
printf("[PERF]\tpage faults: %ld\n", usage.ru_majflt);
167168
printf("[PERF]\tswaps: %ld\n", usage.ru_nswap);

0 commit comments

Comments
 (0)