test: register test as failed if setup failed
authorAnatoly Burakov <anatoly.burakov@intel.com>
Fri, 22 Dec 2017 10:21:51 +0000 (10:21 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 17 Jan 2018 23:13:28 +0000 (00:13 +0100)
If test set up couldn't be completed, the test was previously
shown as succeeding, even though setup failed. Fix this to report
test as failed, and count all tests that should've been executed,
as failed as well.

Fixes: ffac67b1f71b ("app/test: new assert macros and test suite runner")
Cc: stable@dpdk.org
Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
Acked-by: Declan Doherty <declan.doherty@intel.com>
test/test/test.c

index af1b1bf..44dfe20 100644 (file)
@@ -149,8 +149,20 @@ unit_test_suite_runner(struct unit_test_suite *suite)
        }
 
        if (suite->setup)
-               if (suite->setup() != 0)
+               if (suite->setup() != 0) {
+                       /*
+                        * setup failed, so count all enabled tests and mark
+                        * them as failed
+                        */
+                       while (suite->unit_test_cases[total].testcase) {
+                               if (!suite->unit_test_cases[total].enabled)
+                                       skipped++;
+                               else
+                                       failed++;
+                               total++;
+                       }
                        goto suite_summary;
+               }
 
        printf(" + ------------------------------------------------------- +\n");