mirror of https://github.com/ARMmbed/mbed-os.git
Repeat: Allow repeat on timeout and validation at the same time.
parent
bc25003d41
commit
205233a6db
|
@ -128,11 +128,11 @@ void Harness::raise_failure(failure_t reason)
|
||||||
|
|
||||||
void Harness::schedule_next_case()
|
void Harness::schedule_next_case()
|
||||||
{
|
{
|
||||||
if (!(case_control.repeat & REPEAT_ON_TIMEOUT) && case_failed_before == case_failed) {
|
if ((case_control.repeat & REPEAT_ON_VALIDATE) && case_failed_before == case_failed) {
|
||||||
case_passed++;
|
case_passed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (case_control.repeat & REPEAT_ALL || case_control.repeat == REPEAT_NO_REPEAT) {
|
if (case_control.repeat & REPEAT_SETUP_TEARDOWN || case_control.repeat == REPEAT_NO_REPEAT) {
|
||||||
if (handlers.case_teardown &&
|
if (handlers.case_teardown &&
|
||||||
(handlers.case_teardown(case_current, case_passed, case_failed,
|
(handlers.case_teardown(case_current, case_passed, case_failed,
|
||||||
case_failed ? FAILURE_CASES : FAILURE_NONE) != STATUS_CONTINUE)) {
|
case_failed ? FAILURE_CASES : FAILURE_NONE) != STATUS_CONTINUE)) {
|
||||||
|
@ -180,7 +180,8 @@ void Harness::validate_callback()
|
||||||
{
|
{
|
||||||
minar::Scheduler::cancelCallback(case_timeout_handle);
|
minar::Scheduler::cancelCallback(case_timeout_handle);
|
||||||
case_timeout_handle = NULL;
|
case_timeout_handle = NULL;
|
||||||
if (case_control.repeat & REPEAT_ON_TIMEOUT) case_control = control_t();
|
if (case_control.repeat & REPEAT_ON_VALIDATE) case_control = control_t(REPEAT_ALL);
|
||||||
|
else if (case_control.repeat & REPEAT_ON_TIMEOUT) case_control = control_t();
|
||||||
minar::Scheduler::postCallback(schedule_next_case);
|
minar::Scheduler::postCallback(schedule_next_case);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,16 @@ namespace v1 {
|
||||||
|
|
||||||
enum repeat_t {
|
enum repeat_t {
|
||||||
REPEAT_NO_REPEAT = 0, ///< continue with the next test case
|
REPEAT_NO_REPEAT = 0, ///< continue with the next test case
|
||||||
REPEAT_CASE_ONLY = 1, ///< repeat the current test case without the setup and teardown handlers
|
|
||||||
REPEAT_ALL = 2, ///< repeat the current test case with the setup and teardown handlers
|
REPEAT_ON_TIMEOUT = 1,
|
||||||
REPEAT_ON_TIMEOUT = 4 ///< repeat the current on timeout only
|
REPEAT_ON_VALIDATE = 2,
|
||||||
|
REPEAT_CASE_ONLY = 4,
|
||||||
|
REPEAT_SETUP_TEARDOWN = 8,
|
||||||
|
|
||||||
|
REPEAT_ALL_ON_TIMEOUT = REPEAT_SETUP_TEARDOWN | REPEAT_ON_TIMEOUT, ///< repeat the handler with setup and teardown on timeout
|
||||||
|
REPEAT_HANDLER_ON_TIMEOUT = REPEAT_CASE_ONLY | REPEAT_ON_TIMEOUT, ///< repeat only the handler on timeout
|
||||||
|
REPEAT_ALL = REPEAT_SETUP_TEARDOWN | REPEAT_ON_VALIDATE, ///< repeat the handler with setup and teardown
|
||||||
|
REPEAT_HANDLER = REPEAT_CASE_ONLY | REPEAT_ON_VALIDATE ///< repeat only the handler
|
||||||
};
|
};
|
||||||
|
|
||||||
enum status_t {
|
enum status_t {
|
||||||
|
@ -99,7 +106,8 @@ namespace v1 {
|
||||||
|
|
||||||
control_t &
|
control_t &
|
||||||
operator+(const control_t &rhs) {
|
operator+(const control_t &rhs) {
|
||||||
if (repeat == 0 || repeat < rhs.repeat) repeat = rhs.repeat;
|
repeat = repeat_t(repeat | rhs.repeat);
|
||||||
|
if (repeat & REPEAT_SETUP_TEARDOWN) repeat = repeat_t(repeat & ~REPEAT_HANDLER);
|
||||||
if (timeout == uint32_t(-1) || timeout > rhs.timeout) timeout = rhs.timeout;
|
if (timeout == uint32_t(-1) || timeout > rhs.timeout) timeout = rhs.timeout;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -117,15 +125,15 @@ namespace v1 {
|
||||||
/// Alias class for asynchronous timeout control in milliseconds and
|
/// Alias class for asynchronous timeout control in milliseconds and
|
||||||
/// repeats the test case handler with calling teardown and setup handlers
|
/// repeats the test case handler with calling teardown and setup handlers
|
||||||
struct CaseRepeatAllOnTimeout : public control_t {
|
struct CaseRepeatAllOnTimeout : public control_t {
|
||||||
inline CaseRepeatAllOnTimeout(uint32_t ms) : control_t(repeat_t(REPEAT_ALL | REPEAT_ON_TIMEOUT), ms) {}
|
inline CaseRepeatAllOnTimeout(uint32_t ms) : control_t(REPEAT_ALL_ON_TIMEOUT, ms) {}
|
||||||
};
|
};
|
||||||
/// Alias class for asynchronous timeout control in milliseconds and
|
/// Alias class for asynchronous timeout control in milliseconds and
|
||||||
/// repeats only the test case handler without calling teardown and setup handlers
|
/// repeats only the test case handler without calling teardown and setup handlers
|
||||||
struct CaseRepeatHandlerOnTimeout : public control_t {
|
struct CaseRepeatHandlerOnTimeout : public control_t {
|
||||||
inline CaseRepeatHandlerOnTimeout(uint32_t ms) : control_t(repeat_t(REPEAT_CASE_ONLY | REPEAT_ON_TIMEOUT), ms) {}
|
inline CaseRepeatHandlerOnTimeout(uint32_t ms) : control_t(REPEAT_HANDLER_ON_TIMEOUT, ms) {}
|
||||||
};
|
};
|
||||||
/// repeats only the test case handler without calling teardown and setup handlers
|
/// repeats only the test case handler without calling teardown and setup handlers
|
||||||
const control_t CaseRepeatHandler = control_t(REPEAT_CASE_ONLY);
|
const control_t CaseRepeatHandler = control_t(REPEAT_HANDLER);
|
||||||
const control_t CaseRepeatHandlerOnly __deprecated = CaseRepeatHandler; // [[deprecated("use CaseRepeatHandler instead")]]
|
const control_t CaseRepeatHandlerOnly __deprecated = CaseRepeatHandler; // [[deprecated("use CaseRepeatHandler instead")]]
|
||||||
/// repeats the test case handler with calling teardown and setup handlers
|
/// repeats the test case handler with calling teardown and setup handlers
|
||||||
const control_t CaseRepeatAll = control_t(REPEAT_ALL);
|
const control_t CaseRepeatAll = control_t(REPEAT_ALL);
|
||||||
|
|
Loading…
Reference in New Issue