From 4e5996ceeab7c134a16eb39e7f03da84087bd3c3 Mon Sep 17 00:00:00 2001 From: Niklas Hauser Date: Fri, 4 Dec 2015 17:38:40 +0000 Subject: [PATCH] Allow starting a specification at a different case. This can be used to skip failing test cases with external support from a test runner like greentea. It would reset the device and execute the specification again, but start at the next test case. --- "frameworks\\utest/source/harness.cpp" | 11 ++++++++++- "frameworks\\utest/utest/harness.h" | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git "a/frameworks\\utest/source/harness.cpp" "b/frameworks\\utest/source/harness.cpp" index 094fba640b..fe6dd62c63 100644 --- "a/frameworks\\utest/source/harness.cpp" +++ "b/frameworks\\utest/source/harness.cpp" @@ -52,9 +52,18 @@ static void die() { } void Harness::run(const Specification specification) +{ + run(specification, 0); +} + +void Harness::run(const Specification specification, std::size_t start_case) { mbed::util::CriticalSectionLock lock; + // ignore any invalid start index + if (start_case >= specification.length) + return; + test_cases = specification.cases; test_length = specification.length; defaults = specification.defaults; @@ -68,7 +77,7 @@ void Harness::run(const Specification specification) case_passed = 0; case_failed = 0; case_failed_before = 0; - case_current = test_cases; + case_current = &test_cases[start_case]; if (handlers.test_setup && (handlers.test_setup(test_length) != STATUS_CONTINUE)) { if (handlers.test_teardown) handlers.test_teardown(0, 0, FAILURE_SETUP); diff --git "a/frameworks\\utest/utest/harness.h" "b/frameworks\\utest/utest/harness.h" index bb6769ba8e..f2c228b6ff 100644 --- "a/frameworks\\utest/utest/harness.h" +++ "b/frameworks\\utest/utest/harness.h" @@ -43,9 +43,13 @@ namespace v1 { class Harness { public: - /// Starts running a test specification + /// Runs a test specification static void run(const Specification specification); + /// Runs a test specification starting at the specified case index + /// @warning if the start index is out of bounds, the call has no effect! + static void run(const Specification specification, size_t start_case); + /// @returns `true` if a test specification is being executed, `false` otherwise static bool is_busy();