Skip to content

Commit

Permalink
added error handling to tests, now they wont stop when one test fails…
Browse files Browse the repository at this point in the history
…... unless its a super duper massive failure
  • Loading branch information
unknown authored and unknown committed Jul 13, 2016
1 parent 60ccf1d commit 631392f
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 33 deletions.
19 changes: 13 additions & 6 deletions TESTS/API/AnalogIn/AnalogIn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,21 @@ utest::v1::status_t test_setup(const size_t number_of_cases) {
return verbose_test_setup_handler(number_of_cases);
}

// Handle test failures, keep testing, dont stop
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
}

// Test cases
// TODO: take pin names from config file or generate from pinmap file
Case cases[] = {
Case("Test Analog Input on A0", AnalogInput_Test<A0,A1,A2,A3,A4,A5>),
Case("Test Analog Input on A1", AnalogInput_Test<A1,A2,A3,A4,A5,A0>),
Case("Test Analog Input on A2", AnalogInput_Test<A2,A3,A4,A5,A0,A1>),
Case("Test Analog Input on A3", AnalogInput_Test<A3,A4,A5,A0,A1,A2>),
Case("Test Analog Input on A4", AnalogInput_Test<A4,A5,A0,A1,A2,A3>),
Case("Test Analog Input on A5", AnalogInput_Test<A5,A0,A1,A2,A3,A4>),
Case("Test Analog Input on A0", AnalogInput_Test<A0,A1,A2,A3,A4,A5>,greentea_failure_handler),
Case("Test Analog Input on A1", AnalogInput_Test<A1,A2,A3,A4,A5,A0>,greentea_failure_handler),
Case("Test Analog Input on A2", AnalogInput_Test<A2,A3,A4,A5,A0,A1>,greentea_failure_handler),
Case("Test Analog Input on A3", AnalogInput_Test<A3,A4,A5,A0,A1,A2>,greentea_failure_handler),
Case("Test Analog Input on A4", AnalogInput_Test<A4,A5,A0,A1,A2,A3>,greentea_failure_handler),
Case("Test Analog Input on A5", AnalogInput_Test<A5,A0,A1,A2,A3,A4>,greentea_failure_handler),
};

Specification specification(test_setup, cases);
Expand Down
1 change: 1 addition & 0 deletions TESTS/API/AnalogOut/AnalogOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ utest::v1::status_t test_setup(const size_t number_of_cases) {
return verbose_test_setup_handler(number_of_cases);
}

// Handle test failures, keep testing, dont stop
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
Expand Down
27 changes: 17 additions & 10 deletions TESTS/API/DigitalIO/DigitalIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,25 @@ utest::v1::status_t test_setup(const size_t number_of_cases) {
return verbose_test_setup_handler(number_of_cases);
}

// Handle test failures, keep testing, dont stop
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
}

// Test cases
// TODO: take pinnames from config file
Case cases[] = {
Case("Testing Digital I/O on D2", DigitalIO_Test<D2,D3>),
Case("Testing Digital I/O on D3", DigitalIO_Test<D3,D2>),
Case("Testing Digital I/O on D4", DigitalIO_Test<D4,D5>),
Case("Testing Digital I/O on D5", DigitalIO_Test<D5,D4>),
Case("Testing Digital I/O on D6", DigitalIO_Test<D6,D7>),
Case("Testing Digital I/O on D7", DigitalIO_Test<D7,D6>),
Case("Testing Digital I/O on D8", DigitalIO_Test<D8,D9>),
Case("Testing Digital I/O on D9", DigitalIO_Test<D9,D8>),
Case("Testing Digital I/O on D0", DigitalIO_Test<D0,D1>),
Case("Testing Digital I/O on D1", DigitalIO_Test<D1,D0>),
Case("Testing Digital I/O on D2", DigitalIO_Test<D2,D3>,greentea_failure_handler),
Case("Testing Digital I/O on D3", DigitalIO_Test<D3,D2>,greentea_failure_handler),
Case("Testing Digital I/O on D4", DigitalIO_Test<D4,D5>,greentea_failure_handler),
Case("Testing Digital I/O on D5", DigitalIO_Test<D5,D4>,greentea_failure_handler),
Case("Testing Digital I/O on D6", DigitalIO_Test<D6,D7>,greentea_failure_handler),
Case("Testing Digital I/O on D7", DigitalIO_Test<D7,D6>,greentea_failure_handler),
Case("Testing Digital I/O on D8", DigitalIO_Test<D8,D9>,greentea_failure_handler),
Case("Testing Digital I/O on D9", DigitalIO_Test<D9,D8>,greentea_failure_handler),
Case("Testing Digital I/O on D0", DigitalIO_Test<D0,D1>,greentea_failure_handler),
Case("Testing Digital I/O on D1", DigitalIO_Test<D1,D0>,greentea_failure_handler),

};

Expand Down
14 changes: 10 additions & 4 deletions TESTS/API/I2C/I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ utest::v1::status_t test_setup(const size_t number_of_cases) {
return verbose_test_setup_handler(number_of_cases);
}

// Handle test failures, keep testing, dont stop
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
}

// Test cases
Case cases[] = {
Case("Testing TMP102 Temperature Read",test_tmp102),
Case("Testing EEProm Write",test_eeprom_W),
Case("Testing EEProm Read",test_eeprom_R),
// Case("Testing EEProm WR",test_eeprom_WR),
Case("Testing TMP102 Temperature Read",test_tmp102,greentea_failure_handler),
Case("Testing EEProm Write",test_eeprom_W,greentea_failure_handler),
Case("Testing EEProm Read",test_eeprom_R,greentea_failure_handler),
// Case("Testing EEProm WR",test_eeprom_WR,greentea_failure_handler),
};

Specification specification(test_setup, cases);
Expand Down
27 changes: 17 additions & 10 deletions TESTS/API/InterruptIn/InterruptIn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,25 @@ utest::v1::status_t test_setup(const size_t number_of_cases) {
return verbose_test_setup_handler(number_of_cases);
}

// Handle test failures, keep testing, dont stop
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
}

// Test cases
// TODO: take pins from pinnames.h or from config file
Case cases[] = {
Case("Test InterruptIn on D0", InterruptInTest<D0,D1>),
Case("Test InterruptIn on D1", InterruptInTest<D1,D0>),
Case("Test InterruptIn on D2", InterruptInTest<D2,D3>),
Case("Test InterruptIn on D3", InterruptInTest<D3,D2>),
Case("Test InterruptIn on D4", InterruptInTest<D4,D5>),
Case("Test InterruptIn on D5", InterruptInTest<D5,D4>),
Case("Test InterruptIn on D6", InterruptInTest<D6,D7>),
Case("Test InterruptIn on D7", InterruptInTest<D7,D6>),
Case("Test InterruptIn on D8", InterruptInTest<D8,D9>),
Case("Test InterruptIn on D9", InterruptInTest<D9,D8>),
Case("Test InterruptIn on D0", InterruptInTest<D0,D1>,greentea_failure_handler),
Case("Test InterruptIn on D1", InterruptInTest<D1,D0>,greentea_failure_handler),
Case("Test InterruptIn on D2", InterruptInTest<D2,D3>,greentea_failure_handler),
Case("Test InterruptIn on D3", InterruptInTest<D3,D2>,greentea_failure_handler),
Case("Test InterruptIn on D4", InterruptInTest<D4,D5>,greentea_failure_handler),
Case("Test InterruptIn on D5", InterruptInTest<D5,D4>,greentea_failure_handler),
Case("Test InterruptIn on D6", InterruptInTest<D6,D7>,greentea_failure_handler),
Case("Test InterruptIn on D7", InterruptInTest<D7,D6>,greentea_failure_handler),
Case("Test InterruptIn on D8", InterruptInTest<D8,D9>,greentea_failure_handler),
Case("Test InterruptIn on D9", InterruptInTest<D9,D8>,greentea_failure_handler),
};

Specification specification(test_setup, cases);
Expand Down
10 changes: 8 additions & 2 deletions TESTS/API/SPI/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,15 @@ utest::v1::status_t test_setup(const size_t number_of_cases) {
return verbose_test_setup_handler(number_of_cases);
}

// // Test cases
// Handle test failures, keep testing, dont stop
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
}

// Test cases
Case cases[] = {
Case("Testing SPI via SD Write", test_sd_write),
Case("Testing SPI via SD Write", test_sd_write,greentea_failure_handler),
};

Specification specification(test_setup, cases);
Expand Down
17 changes: 16 additions & 1 deletion TESTS/API/UART/UART.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,30 @@ void test_uart_single(){
TEST_ASSERT(true);
}

// TODO: add more verbose tests
// - different speeds (9600 / 115200 / ...etc)
// - flush buffers
// - write longer strings
// - special characters
// - send break characters
// ...etc

utest::v1::status_t test_setup(const size_t number_of_cases) {
// Setup Greentea using a reasonable timeout in seconds
GREENTEA_SETUP(40, "default_auto");
return verbose_test_setup_handler(number_of_cases);
}

// Handle test failures, keep testing, dont stop
utest::v1::status_t greentea_failure_handler(const Case *const source, const failure_t reason) {
greentea_case_failure_abort_handler(source, reason);
return STATUS_CONTINUE;
}

// Test cases
// TODO: take pins from config file or from pinnames.h
Case cases[] = {
Case("Testing UART on D1/D0, single byte W/R ", test_uart_single),
Case("Testing UART on D1/D0, single byte W/R ", test_uart_single, greentea_failure_handler),
};

Specification specification(test_setup, cases);
Expand Down

0 comments on commit 631392f

Please sign in to comment.