Skip to content
Browse files

test, bench: remove C99 macro, use fprintf

  • Loading branch information...
1 parent 77d9261 commit afc993c816cd0cbda2aa7303ea91a700c1edb3d2 @bnoordhuis bnoordhuis committed Dec 27, 2012
View
2 test/benchmark-getaddrinfo.c
@@ -83,7 +83,7 @@ BENCHMARK_IMPL(getaddrinfo) {
ASSERT(calls_initiated == TOTAL_CALLS);
ASSERT(calls_completed == TOTAL_CALLS);
- LOGF("getaddrinfo: %.0f req/s\n",
+ fprintf(stderr, "getaddrinfo: %.0f req/s\n",
(double) calls_completed / (double) (end_time - start_time) * 1000.0);
MAKE_VALGRIND_HAPPY();
View
4 test/benchmark-loop-count.c
@@ -62,7 +62,7 @@ BENCHMARK_IMPL(loop_count) {
ASSERT(ticks == NUM_TICKS);
- LOGF("loop_count: %d ticks in %.2fs (%.0f/s)\n",
+ fprintf(stderr, "loop_count: %d ticks in %.2fs (%.0f/s)\n",
NUM_TICKS,
ns / 1e9,
NUM_TICKS / (ns / 1e9));
@@ -83,7 +83,7 @@ BENCHMARK_IMPL(loop_count_timed) {
uv_run(loop);
- LOGF("loop_count: %lu ticks (%.0f ticks/s)\n", ticks, ticks / 5.0);
+ fprintf(stderr, "loop_count: %lu ticks (%.0f ticks/s)\n", ticks, ticks / 5.0);
MAKE_VALGRIND_HAPPY();
return 0;
View
2 test/benchmark-million-timers.c
@@ -70,7 +70,7 @@ BENCHMARK_IMPL(million_timers) {
ASSERT(close_cb_called == NUM_TIMERS);
free(timers);
- LOGF("%.2f seconds\n", (after - before) / 1e9);
+ fprintf(stderr, "%.2f seconds\n", (after - before) / 1e9);
MAKE_VALGRIND_HAPPY();
return 0;
View
2 test/benchmark-ping-pongs.c
@@ -83,7 +83,7 @@ static void pinger_close_cb(uv_handle_t* handle) {
pinger_t* pinger;
pinger = (pinger_t*)handle->data;
- LOGF("ping_pongs: %d roundtrips/s\n", (1000 * pinger->pongs) / TIME);
+ fprintf(stderr, "ping_pongs: %d roundtrips/s\n", (1000 * pinger->pongs) / TIME);
free(pinger);
View
2 test/benchmark-pound.c
@@ -294,7 +294,7 @@ static int pound_it(int concurrency,
/* Number of fractional seconds it took to run the benchmark. */
secs = (double)(end_time - start_time) / NANOSEC;
- LOGF("%s-conn-pound-%d: %.0f accepts/s (%d failed)\n",
+ fprintf(stderr, "%s-conn-pound-%d: %.0f accepts/s (%d failed)\n",
type,
concurrency,
closed_streams / secs,
View
11 test/benchmark-pump.c
@@ -90,7 +90,7 @@ static void show_stats(uv_timer_t* handle, int status) {
int i;
#if PRINT_STATS
- LOGF("connections: %d, write: %.1f gbit/s\n",
+ fprintf(stderr, "connections: %d, write: %.1f gbit/s\n",
write_sockets,
gbit(nsent, STATS_INTERVAL));
#endif
@@ -101,7 +101,7 @@ static void show_stats(uv_timer_t* handle, int status) {
uv_update_time(loop);
diff = uv_now(loop) - start_time;
- LOGF("%s_pump%d_client: %.1f gbit/s\n", type == TCP ? "tcp" : "pipe", write_sockets,
+ fprintf(stderr, "%s_pump%d_client: %.1f gbit/s\n", type == TCP ? "tcp" : "pipe", write_sockets,
gbit(nsent_total, diff));
for (i = 0; i < write_sockets; i++) {
@@ -123,7 +123,7 @@ static void read_show_stats() {
uv_update_time(loop);
diff = uv_now(loop) - start_time;
- LOGF("%s_pump%d_server: %.1f gbit/s\n", type == TCP ? "tcp" : "pipe", max_read_sockets,
+ fprintf(stderr, "%s_pump%d_server: %.1f gbit/s\n", type == TCP ? "tcp" : "pipe", max_read_sockets,
gbit(nrecv_total, diff));
}
@@ -212,7 +212,10 @@ static void do_write(uv_stream_t* stream) {
static void connect_cb(uv_connect_t* req, int status) {
int i;
- if (status) LOG(uv_strerror(uv_last_error(loop)));
+ if (status) {
+ fputs(uv_strerror(uv_last_error(loop)), stderr);
+ }
+
ASSERT(status == 0);
write_sockets++;
View
34 test/benchmark-sizes.c
@@ -24,22 +24,22 @@
BENCHMARK_IMPL(sizes) {
- LOGF("uv_shutdown_t: %u bytes\n", (unsigned int) sizeof(uv_shutdown_t));
- LOGF("uv_write_t: %u bytes\n", (unsigned int) sizeof(uv_write_t));
- LOGF("uv_connect_t: %u bytes\n", (unsigned int) sizeof(uv_connect_t));
- LOGF("uv_udp_send_t: %u bytes\n", (unsigned int) sizeof(uv_udp_send_t));
- LOGF("uv_tcp_t: %u bytes\n", (unsigned int) sizeof(uv_tcp_t));
- LOGF("uv_pipe_t: %u bytes\n", (unsigned int) sizeof(uv_pipe_t));
- LOGF("uv_tty_t: %u bytes\n", (unsigned int) sizeof(uv_tty_t));
- LOGF("uv_prepare_t: %u bytes\n", (unsigned int) sizeof(uv_prepare_t));
- LOGF("uv_check_t: %u bytes\n", (unsigned int) sizeof(uv_check_t));
- LOGF("uv_idle_t: %u bytes\n", (unsigned int) sizeof(uv_idle_t));
- LOGF("uv_async_t: %u bytes\n", (unsigned int) sizeof(uv_async_t));
- LOGF("uv_timer_t: %u bytes\n", (unsigned int) sizeof(uv_timer_t));
- LOGF("uv_fs_poll_t: %u bytes\n", (unsigned int) sizeof(uv_fs_poll_t));
- LOGF("uv_fs_event_t: %u bytes\n", (unsigned int) sizeof(uv_fs_event_t));
- LOGF("uv_process_t: %u bytes\n", (unsigned int) sizeof(uv_process_t));
- LOGF("uv_poll_t: %u bytes\n", (unsigned int) sizeof(uv_poll_t));
- LOGF("uv_loop_t: %u bytes\n", (unsigned int) sizeof(uv_loop_t));
+ fprintf(stderr, "uv_shutdown_t: %u bytes\n", (unsigned int) sizeof(uv_shutdown_t));
+ fprintf(stderr, "uv_write_t: %u bytes\n", (unsigned int) sizeof(uv_write_t));
+ fprintf(stderr, "uv_connect_t: %u bytes\n", (unsigned int) sizeof(uv_connect_t));
+ fprintf(stderr, "uv_udp_send_t: %u bytes\n", (unsigned int) sizeof(uv_udp_send_t));
+ fprintf(stderr, "uv_tcp_t: %u bytes\n", (unsigned int) sizeof(uv_tcp_t));
+ fprintf(stderr, "uv_pipe_t: %u bytes\n", (unsigned int) sizeof(uv_pipe_t));
+ fprintf(stderr, "uv_tty_t: %u bytes\n", (unsigned int) sizeof(uv_tty_t));
+ fprintf(stderr, "uv_prepare_t: %u bytes\n", (unsigned int) sizeof(uv_prepare_t));
+ fprintf(stderr, "uv_check_t: %u bytes\n", (unsigned int) sizeof(uv_check_t));
+ fprintf(stderr, "uv_idle_t: %u bytes\n", (unsigned int) sizeof(uv_idle_t));
+ fprintf(stderr, "uv_async_t: %u bytes\n", (unsigned int) sizeof(uv_async_t));
+ fprintf(stderr, "uv_timer_t: %u bytes\n", (unsigned int) sizeof(uv_timer_t));
+ fprintf(stderr, "uv_fs_poll_t: %u bytes\n", (unsigned int) sizeof(uv_fs_poll_t));
+ fprintf(stderr, "uv_fs_event_t: %u bytes\n", (unsigned int) sizeof(uv_fs_event_t));
+ fprintf(stderr, "uv_process_t: %u bytes\n", (unsigned int) sizeof(uv_process_t));
+ fprintf(stderr, "uv_poll_t: %u bytes\n", (unsigned int) sizeof(uv_poll_t));
+ fprintf(stderr, "uv_loop_t: %u bytes\n", (unsigned int) sizeof(uv_loop_t));
return 0;
}
View
2 test/benchmark-spawn.c
@@ -155,7 +155,7 @@ BENCHMARK_IMPL(spawn) {
uv_update_time(loop);
end_time = uv_now(loop);
- LOGF("spawn: %.0f spawns/s\n",
+ fprintf(stderr, "spawn: %.0f spawns/s\n",
(double) N / (double) (end_time - start_time) * 1000.0);
MAKE_VALGRIND_HAPPY();
View
2 test/run-benchmarks.c
@@ -43,7 +43,7 @@ int main(int argc, char **argv) {
case 2: return maybe_run_test(argc, argv);
case 3: return run_test_part(argv[1], argv[2]);
default:
- LOGF("Too many arguments.\n");
+ fprintf(stderr, "Too many arguments.\n");
return 1;
}
}
View
2 test/run-tests.c
@@ -57,7 +57,7 @@ int main(int argc, char **argv) {
case 2: return maybe_run_test(argc, argv);
case 3: return run_test_part(argv[1], argv[2]);
default:
- LOGF("Too many arguments.\n");
+ fprintf(stderr, "Too many arguments.\n");
return 1;
}
}
View
20 test/runner.c
@@ -33,7 +33,7 @@ static void log_progress(int total, int passed, int failed, const char* name) {
if (total == 0)
total = 1;
- LOGF("[%% %3d|+ %3d|- %3d]: %s", (int) ((passed + failed) / ((double) total) * 100.0),
+ fprintf(stderr, "[%% %3d|+ %3d|- %3d]: %s", (int) ((passed + failed) / ((double) total) * 100.0),
passed, failed, name);
}
@@ -244,40 +244,40 @@ int run_test(const char* test, int timeout, int benchmark_output) {
/* Show error and output from processes if the test failed. */
if (status != 0 || task->show_output) {
if (status != 0) {
- LOGF("\n`%s` failed: %s\n", test, errmsg);
+ fprintf(stderr, "\n`%s` failed: %s\n", test, errmsg);
} else {
- LOGF("\n");
+ fprintf(stderr, "\n");
}
for (i = 0; i < process_count; i++) {
switch (process_output_size(&processes[i])) {
case -1:
- LOGF("Output from process `%s`: (unavailable)\n",
+ fprintf(stderr, "Output from process `%s`: (unavailable)\n",
process_get_name(&processes[i]));
break;
case 0:
- LOGF("Output from process `%s`: (no output)\n",
+ fprintf(stderr, "Output from process `%s`: (no output)\n",
process_get_name(&processes[i]));
break;
default:
- LOGF("Output from process `%s`:\n", process_get_name(&processes[i]));
+ fprintf(stderr, "Output from process `%s`:\n", process_get_name(&processes[i]));
process_copy_output(&processes[i], fileno(stderr));
break;
}
}
- LOG("=============================================================\n");
+ fprintf(stderr, "=============================================================\n");
/* In benchmark mode show concise output from the main process. */
} else if (benchmark_output) {
switch (process_output_size(main_proc)) {
case -1:
- LOGF("%s: (unavailable)\n", test);
+ fprintf(stderr, "%s: (unavailable)\n", test);
break;
case 0:
- LOGF("%s: (no output)\n", test);
+ fprintf(stderr, "%s: (no output)\n", test);
break;
default:
@@ -312,7 +312,7 @@ int run_test_part(const char* test, const char* part) {
}
}
- LOGF("No test part with that name: %s:%s\n", test, part);
+ fprintf(stderr, "No test part with that name: %s:%s\n", test, part);
return 255;
}
View
13 test/task.h
@@ -54,19 +54,6 @@ typedef enum {
PIPE
} stream_type;
-/* Log to stderr. */
-#define LOG(...) \
- do { \
- fprintf(stderr, "%s", __VA_ARGS__); \
- fflush(stderr); \
- } while (0)
-
-#define LOGF(...) \
- do { \
- fprintf(stderr, __VA_ARGS__); \
- fflush(stderr); \
- } while (0)
-
/* Die with fatal error. */
#define FATAL(msg) \
do { \
View
2 test/test-condvar-consumer-producer.c
@@ -127,7 +127,7 @@ TEST_IMPL(consumer_producer) {
ASSERT(0 == uv_thread_join(&pthread));
- LOGF("finished_consumers: %d\n", finished_consumers);
+ fprintf(stderr, "finished_consumers: %d\n", finished_consumers);
ASSERT(finished_consumers == MAX_CONSUMERS);
uv_cond_destroy(&empty);
View
4 test/test-idle.c
@@ -44,7 +44,7 @@ static void timer_cb(uv_timer_t* handle, int status) {
uv_close((uv_handle_t*) &timer_handle, close_cb);
timer_cb_called++;
- LOGF("timer_cb %d\n", timer_cb_called);
+ fprintf(stderr, "timer_cb %d\n", timer_cb_called);
}
@@ -53,7 +53,7 @@ static void idle_cb(uv_idle_t* handle, int status) {
ASSERT(status == 0);
idle_cb_called++;
- LOGF("idle_cb %d\n", idle_cb_called);
+ fprintf(stderr, "idle_cb %d\n", idle_cb_called);
}
View
20 test/test-loop-handles.c
@@ -114,7 +114,7 @@ static void timer_cb(uv_timer_t* handle, int status) {
static void idle_2_close_cb(uv_handle_t* handle) {
- LOG("IDLE_2_CLOSE_CB\n");
+ fprintf(stderr, "IDLE_2_CLOSE_CB\n");
ASSERT(handle == (uv_handle_t*)&idle_2_handle);
@@ -126,7 +126,7 @@ static void idle_2_close_cb(uv_handle_t* handle) {
static void idle_2_cb(uv_idle_t* handle, int status) {
- LOG("IDLE_2_CB\n");
+ fprintf(stderr, "IDLE_2_CB\n");
ASSERT(handle == &idle_2_handle);
ASSERT(status == 0);
@@ -140,7 +140,7 @@ static void idle_2_cb(uv_idle_t* handle, int status) {
static void idle_1_cb(uv_idle_t* handle, int status) {
int r;
- LOG("IDLE_1_CB\n");
+ fprintf(stderr, "IDLE_1_CB\n");
ASSERT(handle != NULL);
ASSERT(status == 0);
@@ -168,7 +168,7 @@ static void idle_1_cb(uv_idle_t* handle, int status) {
static void idle_1_close_cb(uv_handle_t* handle) {
- LOG("IDLE_1_CLOSE_CB\n");
+ fprintf(stderr, "IDLE_1_CLOSE_CB\n");
ASSERT(handle != NULL);
@@ -177,23 +177,23 @@ static void idle_1_close_cb(uv_handle_t* handle) {
static void prepare_1_close_cb(uv_handle_t* handle) {
- LOG("PREPARE_1_CLOSE_CB");
+ fprintf(stderr, "PREPARE_1_CLOSE_CB");
ASSERT(handle == (uv_handle_t*)&prepare_1_handle);
prepare_1_close_cb_called++;
}
static void check_close_cb(uv_handle_t* handle) {
- LOG("CHECK_CLOSE_CB\n");
+ fprintf(stderr, "CHECK_CLOSE_CB\n");
ASSERT(handle == (uv_handle_t*)&check_handle);
check_close_cb_called++;
}
static void prepare_2_close_cb(uv_handle_t* handle) {
- LOG("PREPARE_2_CLOSE_CB\n");
+ fprintf(stderr, "PREPARE_2_CLOSE_CB\n");
ASSERT(handle == (uv_handle_t*)&prepare_2_handle);
prepare_2_close_cb_called++;
@@ -203,7 +203,7 @@ static void prepare_2_close_cb(uv_handle_t* handle) {
static void check_cb(uv_check_t* handle, int status) {
int i, r;
- LOG("CHECK_CB\n");
+ fprintf(stderr, "CHECK_CB\n");
ASSERT(handle == &check_handle);
ASSERT(status == 0);
@@ -240,7 +240,7 @@ static void check_cb(uv_check_t* handle, int status) {
static void prepare_2_cb(uv_prepare_t* handle, int status) {
int r;
- LOG("PREPARE_2_CB\n");
+ fprintf(stderr, "PREPARE_2_CB\n");
ASSERT(handle == &prepare_2_handle);
ASSERT(status == 0);
@@ -261,7 +261,7 @@ static void prepare_2_cb(uv_prepare_t* handle, int status) {
static void prepare_1_cb(uv_prepare_t* handle, int status) {
int r;
- LOG("PREPARE_1_CB\n");
+ fprintf(stderr, "PREPARE_1_CB\n");
ASSERT(handle == &prepare_1_handle);
ASSERT(status == 0);
View
8 test/test-timer-again.c
@@ -49,7 +49,7 @@ static void repeat_1_cb(uv_timer_t* handle, int status) {
ASSERT(uv_timer_get_repeat((uv_timer_t*)handle) == 50);
- LOGF("repeat_1_cb called after %ld ms\n",
+ fprintf(stderr, "repeat_1_cb called after %ld ms\n",
(long int)(uv_now(uv_default_loop()) - start_time));
repeat_1_cb_called++;
@@ -72,7 +72,7 @@ static void repeat_2_cb(uv_timer_t* handle, int status) {
ASSERT(status == 0);
ASSERT(repeat_2_cb_allowed);
- LOGF("repeat_2_cb called after %ld ms\n",
+ fprintf(stderr, "repeat_2_cb called after %ld ms\n",
(long int)(uv_now(uv_default_loop()) - start_time));
repeat_2_cb_called++;
@@ -83,7 +83,7 @@ static void repeat_2_cb(uv_timer_t* handle, int status) {
return;
}
- LOGF("uv_timer_get_repeat %ld ms\n",
+ fprintf(stderr, "uv_timer_get_repeat %ld ms\n",
(long int)uv_timer_get_repeat(&repeat_2));
ASSERT(uv_timer_get_repeat(&repeat_2) == 100);
@@ -133,7 +133,7 @@ TEST_IMPL(timer_again) {
ASSERT(repeat_2_cb_called == 2);
ASSERT(close_cb_called == 2);
- LOGF("Test took %ld ms (expected ~700 ms)\n",
+ fprintf(stderr, "Test took %ld ms (expected ~700 ms)\n",
(long int)(uv_now(uv_default_loop()) - start_time));
ASSERT(700 <= uv_now(uv_default_loop()) - start_time);

0 comments on commit afc993c

Please sign in to comment.
Something went wrong with that request. Please try again.