ztest_run_all() with predicates marks previously passed tests as skipped

I am trying to set up unit tests with the ZTEST Framework to run directly on my nrf5340 board. The test code is similar to this custom test_main example from the documentation:

#include <zephyr/ztest.h>

#include "my_test.h"

void test_main(void)
{
     struct power_sequence_state state;

     /* Only suites that use a predicate checking for phase == PWR_PHASE_0 will run. */
     state.phase = PWR_PHASE_0;
     ztest_run_all(&state);

     /* Only suites that use a predicate checking for phase == PWR_PHASE_1 will run. */
     state.phase = PWR_PHASE_1;
     ztest_run_all(&state);

     /* Only suites that use a predicate checking for phase == PWR_PHASE_2 will run. */
     state.phase = PWR_PHASE_2;
     ztest_run_all(&state);

     /* Check that all the suites in this binary ran at least once. */
     ztest_verify_all_test_suites_ran();
}

The issue I am having is that tests that run at PWR_PHASE_0 and pass (or fail for that matter) are subsequently marked as skipped when the following ztest_run_all() for the next power phase is ran.

I understand that they were technically skipped for the following phases, but it seems odd to have that override the previous valid test result in the test suite summary.

Is there any way around this interaction, so that the test summary properly shows the results, instead of all but the last phase of tests showing skipped?

Thanks,

- BrettG

Parents Reply Children
No Data
Related