BSP430
20141115
Board Support Package for MSP430 microcontrollers
|
A unit test facility. More...
Go to the source code of this file.
Functions | |
void | vBSP430unittestInitialize (void) |
void | vBSP430unittestResult_ (int line, int passp, const char *format,...) |
void | vBSP430unittestFinalize (void) |
A unit test facility.
This abstracts the unit-test specific portions of test430, since BSP430 itself replaces the platform support portions of that package.
It is not a full-featured xUnit style infrastructure, as there is no framework concept of test suites or setup/teardown functionality to restore a known configuration. Basically all it supports is verifying intermediate values and displaying unexpected results for further analysis.
#define BSP430_UNITTEST (configBSP430_UNITTEST - 0) |
Indicate that the unit test interface is available on the platform. This is normally set by <bsp430/utility/unittest.h> when configBSP430_UNITTEST is true.
#define BSP430_UNITTEST_ASSERT_EQUAL | ( | v1_, | |
v2_ | |||
) |
Validate that the expressions are equal
#define BSP430_UNITTEST_ASSERT_EQUAL_ASCIIZ | ( | v1_, | |
v2_ | |||
) |
Validate that the ASCIIZ contents are equal
#define BSP430_UNITTEST_ASSERT_EQUAL_FMT_ | ( | v1_, | |
v2_, | |||
type_, | |||
pri_ | |||
) |
Diagnose equality failures.
v1_ | an expression of some type |
v2_ | an expression of the same type as v1_ |
type_ | a type suitable for holding the values of v1_ and v2_ for equality comparison purposes |
pri_ | a print(3) format specifier, inclusive of the leading % , to be used to format the passed values of v1_ and v2_ in the case where the test fails |
#define BSP430_UNITTEST_ASSERT_EQUAL_FMTd | ( | v1_, | |
v2_ | |||
) | BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,int,"%" PRId16) |
Validate that the expressions are equal.
If they are not, emit a diagnostic showing both values formatted as signed 16-bit integers.
#define BSP430_UNITTEST_ASSERT_EQUAL_FMTld | ( | v1_, | |
v2_ | |||
) | BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,long,"%" PRId32) |
Validate that the expressions are equal.
If they are not, emit a diagnostic showing both values formatted as signed 32-bit decimal integers.
#define BSP430_UNITTEST_ASSERT_EQUAL_FMTlu | ( | v1_, | |
v2_ | |||
) | BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,unsigned long,"%" PRIu32) |
Validate that the expressions are equal.
If they are not, emit a diagnostic showing both values formatted as unsigned 32-bit decimal integers.
#define BSP430_UNITTEST_ASSERT_EQUAL_FMTlx | ( | v1_, | |
v2_ | |||
) | BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,unsigned long, "%#" PRIx32) |
Validate that the expressions are equal.
If they are not, emit a diagnostic showing both values formatted as unsigned 32-bit hexadecimal integers.
#define BSP430_UNITTEST_ASSERT_EQUAL_FMTp | ( | v1_, | |
v2_ | |||
) | BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,const void *,"%p") |
Validate that the pointer expressions are equal.
If they are not, emit a diagnostic showing both pointer values.
#define BSP430_UNITTEST_ASSERT_EQUAL_FMTu | ( | v1_, | |
v2_ | |||
) | BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,unsigned int,"%" PRIu16) |
Validate that the expressions are equal.
If they are not, emit a diagnostic showing both values formatted as unsigned 16-bit decimal integers.
#define BSP430_UNITTEST_ASSERT_EQUAL_FMTx | ( | v1_, | |
v2_ | |||
) | BSP430_UNITTEST_ASSERT_EQUAL_FMT_(v1_,v2_,unsigned int,"%#" PRIx16) |
Validate that the expressions are equal.
If they are not, emit a diagnostic showing both values formatted as unsigned 16-bit hexadecimal integers.
#define BSP430_UNITTEST_ASSERT_FALSE | ( | expr_ | ) |
Validate that the expression is false
#define BSP430_UNITTEST_ASSERT_TRUE | ( | expr_ | ) |
Validate that the expression is true
#define BSP430_UNITTEST_FAIL | ( | msg_ | ) |
Diagnose an unconditional failure
#define BSP430_UNITTEST_LED_FAILED BSP430_LED_RED |
The LED that is lit if the tests failed. This is normally the first red LED; if either the red or green LED is missing, it is the first available LED so that on a one-LED platform failure is indicated by a lit LED.
#define BSP430_UNITTEST_LED_PASSED BSP430_LED_GREEN |
The LED that is lit if the tests failed. This is normally the first green LED; if either the red or green LED is missing, it is the second available LED. On a one-LED platform, success is not visibly indicated.
#define configBSP430_UNITTEST 0 |
Define to a true value to enable the unit test infrastructure. In addition, the <bsp430/utility/unittest.h> header must be included, and the utility/unittest
module linked in.
#define configBSP430_UNITTEST_FAILFAST 0 |
Define to a true value to bypass subsequent tests after a failure. In this case, the internals of the unittest framework immediately execute the finalization routine on detection of a failure.
By default this is defined to a false value, and the framework continues to run the remaining tests in the application.
void vBSP430unittestFinalize | ( | void | ) |
Finalize the unittest framework.
This displays the results of the tests and emits a distinguished sequence (...done
) to the console for use in external monitor applications.
If tests pass, BSP430_UNITTEST_LED_PASSED is lit, and this function returns.
If at least one test failed, BSP430_UNITTEST_LED_FAILED flashes at 1Hz and this function does not return.
void vBSP430unittestInitialize | ( | void | ) |
Initialize the unittest framework.
This clears the history of previous tests and emits a distinguished sequence (sync...
) to the console for use in external monitor applications.
void vBSP430unittestResult_ | ( | int | line, |
int | passp, | ||
const char * | format, | ||
... | |||
) |
Display a unit test result.
line | the line number on which the test occurred. |
passp | a non-zero value if the test passed; a zero value indicates the test failed. |
format | a cprintf format statement for any diagnostic or status to be displayed for the test. A newline will be appended automatically. |