shared/tester: Fix divide by zero error 27/49527/1
authorGowtham Anandha Babu <gowtham.ab@samsung.com>
Wed, 14 Oct 2015 10:37:18 +0000 (16:07 +0530)
committerGowtham Anandha Babu <gowtham.ab@samsung.com>
Wed, 14 Oct 2015 10:42:59 +0000 (16:12 +0530)
Before adding a check - o/p:
Total: 0, Passed: 0 (-nan%), Failed: 0, Not Run: 0

After check - o/p:
Total: 0, Passed: 0 (0.0%), Failed: 0, Not Run: 0

Git repo link:
https://git.kernel.org/cgit/bluetooth/bluez.git/commit/?id=27f39bc20ef9c8eb7a60373700fbb2a62df20a79

Change-Id: If7363fd0d43040c88ea9b8d0dff7dc32f71fe0de

src/shared/tester.c

index ffcc2ea..a49fe04 100644 (file)
@@ -315,7 +315,8 @@ static int tester_summarize(void)
                COLOR_RED "Failed: %d" COLOR_OFF ", "
                COLOR_YELLOW "Not Run: %d" COLOR_OFF "\n",
                        not_run + passed + failed, passed,
-                       (float) passed * 100 / (not_run + passed + failed),
+                       (not_run + passed + failed) ?
+                       (float) passed * 100 / (not_run + passed + failed) : 0,
                        failed, not_run);
 
        execution_time = g_timer_elapsed(test_timer, NULL);