From 1a7d98249590850f66bc7dab36bb646c190958f4 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sun, 6 Dec 2015 11:46:07 +0000 Subject: [PATCH] change NAN markup to make tests work on mac For some unknown reason mac osx does not change NAN to negative in printout when asking to do so. To get rid of false positive test results change the sign of NAN to positive, that may break something for someone if there are people expecting -NAN when devision with zero happens. But that sort of breakage is pretty unlikely because it requires broken dhcpd.conf. Signed-off-by: Sami Kerola --- src/output.c | 34 +++++++++++++++++----------------- tests/expected/empty | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/output.c b/src/output.c index 4199473..e220243 100644 --- a/src/output.c +++ b/src/output.c @@ -148,10 +148,10 @@ int output_txt(void) shared_p->name, shared_p->available, shared_p->used, shared_p->available == - 0 ? -NAN : (float)(100 * shared_p->used) / shared_p->available, + 0 ? NAN : (float)(100 * shared_p->used) / shared_p->available, shared_p->touched, shared_p->touched + shared_p->used, shared_p->available == - 0 ? -NAN : ((float)(100 * (shared_p->touched + shared_p->used)) / + 0 ? NAN : ((float)(100 * (shared_p->touched + shared_p->used)) / shared_p->available)); if (config.backups_found == 1) { fprintf(outfile, "%7g %8.3f", @@ -181,17 +181,17 @@ int output_txt(void) shared_networks->available, shared_networks->used, shared_networks->available == - 0 ? -NAN : (float)(100 * shared_networks->used) / + 0 ? NAN : (float)(100 * shared_networks->used) / shared_networks->available, shared_networks->touched, shared_networks->touched + shared_networks->used, shared_networks->available == - 0 ? -NAN : (float)(100 * + 0 ? NAN : (float)(100 * (shared_networks->touched + shared_networks->used)) / shared_networks->available); if (config.backups_found == 1) { fprintf(outfile, "%7g %8.3f", - shared_networks->available == 0 ? -NAN : shared_networks->backups, + shared_networks->available == 0 ? NAN : shared_networks->backups, (float)(100 * shared_networks->backups) / shared_networks->available); } @@ -642,12 +642,12 @@ int output_html(void) output_double(outfile, "td", shared_networks->used); output_float(outfile, "td", shared_networks->available == - 0 ? -NAN : (float)(100 * shared_networks->used) / + 0 ? NAN : (float)(100 * shared_networks->used) / shared_networks->available); output_double(outfile, "td", shared_networks->touched); output_double(outfile, "td", shared_networks->touched + shared_networks->used); output_float(outfile, "td", - shared_networks->available == 0 ? -NAN : (float)(100 * + shared_networks->available == 0 ? NAN : (float)(100 * (shared_networks->touched + shared_networks->used)) @@ -655,7 +655,7 @@ int output_html(void) if (config.backups_found == 1) { output_double(outfile, "td", shared_networks->backups); output_float(outfile, "td", - shared_networks->available == 0 ? -NAN : (float)(100 * + shared_networks->available == 0 ? NAN : (float)(100 * shared_networks->backups) / shared_networks->available); } @@ -692,19 +692,19 @@ int output_html(void) output_double(outfile, "td", shared_p->used); output_float(outfile, "td", shared_p->available == - 0 ? -NAN : (float)(100 * shared_p->used) / + 0 ? NAN : (float)(100 * shared_p->used) / shared_p->available); output_double(outfile, "td", shared_p->touched); output_double(outfile, "td", shared_p->touched + shared_p->used); output_float(outfile, "td", - shared_p->available == 0 ? -NAN : (float)(100 * + shared_p->available == 0 ? NAN : (float)(100 * (shared_p->touched + shared_p->used)) / shared_p->available); if (config.backups_found == 1) { output_double(outfile, "td", shared_p->backups); output_float(outfile, "td", - shared_p->available == 0 ? -NAN : (float)(100 * + shared_p->available == 0 ? NAN : (float)(100 * shared_p->backups) / shared_p->available); } @@ -857,10 +857,10 @@ int output_csv(void) "\"%s\",\"%g\",\"%g\",\"%.3f\",\"%g\",\"%g\",\"%.3f\"", shared_p->name, shared_p->available, shared_p->used, - shared_p->available == 0 ? -NAN : (float)(100 * shared_p->used) / + shared_p->available == 0 ? NAN : (float)(100 * shared_p->used) / shared_p->available, shared_p->touched, shared_p->touched + shared_p->used, - shared_p->available == 0 ? -NAN : (float)(100 * + shared_p->available == 0 ? NAN : (float)(100 * (shared_p->touched + shared_p->used)) / shared_p->available); @@ -868,7 +868,7 @@ int output_csv(void) fprintf(outfile, ",\"%g\",\"%.3f\"", shared_p->backups, shared_p->available == - 0 ? -NAN : (float)(100 * shared_p->backups) / + 0 ? NAN : (float)(100 * shared_p->backups) / shared_p->available); } @@ -892,18 +892,18 @@ int output_csv(void) shared_networks->name, shared_networks->available, shared_networks->used, shared_networks->available == - 0 ? -NAN : (float)(100 * shared_networks->used) / + 0 ? NAN : (float)(100 * shared_networks->used) / shared_networks->available, shared_networks->touched, shared_networks->touched + shared_networks->used, shared_networks->available == - 0 ? -NAN : (float)(100 * + 0 ? NAN : (float)(100 * (shared_networks->touched + shared_networks->used)) / shared_networks->available); if (config.backups_found == 1) { fprintf(outfile, "%7g %8.3f", shared_networks->backups, shared_networks->available == - 0 ? -NAN : (float)(100 * shared_networks->backups) / + 0 ? NAN : (float)(100 * shared_networks->backups) / shared_networks->available); } fprintf(outfile, "\n"); diff --git a/tests/expected/empty b/tests/expected/empty index 96e71d1..0b12cd7 100644 --- a/tests/expected/empty +++ b/tests/expected/empty @@ -6,4 +6,4 @@ name max cur percent touch t+c t+c perc Sum of all ranges: name max cur percent touch t+c t+c perc -All networks 0 0 -nan 0 0 -nan +All networks 0 0 nan 0 0 nan