From 974c88e8d9bf4b97f0f2a94f5c3327146eb92989 Mon Sep 17 00:00:00 2001 From: "Bruce A. Mah" Date: Tue, 18 Mar 2014 09:44:37 -0700 Subject: [PATCH] Include summary structures in JSON even if there's only one stream. This makes consuming the JSON easier and more consistent. Resolves #151. Submitted by: @i2aaron --- src/iperf_api.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/iperf_api.c b/src/iperf_api.c index 744e74c..50b9425 100644 --- a/src/iperf_api.c +++ b/src/iperf_api.c @@ -1920,7 +1920,7 @@ iperf_print_intermediate(struct iperf_test *test) } /* next build string with sum of all streams */ - if (test->num_streams > 1) { + if (test->num_streams > 1 || test->json_output) { sp = SLIST_FIRST(&test->streams); /* reset back to 1st stream */ irp = TAILQ_LAST(&sp->result->interval_results, irlisthead); /* use 1st stream for timing info */ @@ -2080,7 +2080,7 @@ iperf_print_results(struct iperf_test *test) } } - if (test->num_streams > 1) { + if (test->num_streams > 1 || test->json_output) { unit_snprintf(ubuf, UNIT_LEN, (double) total_sent, 'A'); bandwidth = (double) total_sent / (double) end_time; unit_snprintf(nbuf, UNIT_LEN, bandwidth, test->settings->unit_format);