-
Notifications
You must be signed in to change notification settings - Fork 5
Self Test Mode
The Bist-Mode allows to perform a self-test without the GDBManipulator but disables the feature of mocking function. One use case is to perform a self-test of an embedded application while booting.
To enable the Self-Test mode the corresponding define “SELF_TEST_MODE” in “deUnit.c” must be set to “1”.
To enable the Mode is is also necessary to call the function ‘disableBreakMode()’ before invoking the tests. Otherwise the execution will block in the function ‘MessageToDebugger‘.
To get access to the test result is possible to register callBack functions which gets invoked by the deUnitFramework.
Is for example a callback function for a print function registered the Framework would print a GoogleTest like output. One example project can be found at “examples/HostWithSelfTest” To compile this example use:
gcc -o exampleSelfTest main.c testExample.c deUnit/*.c ./ exampleSelfTest
Example:
/**
* function that gets on each failed test invoked
*/
void fail(TestResult *res){
int *is = (res->is);
int *should = (res->should);
if(res->testTypeFlags & typeCompEqual){
printf("\t\texpected %d to be equal to %d \n",*is,*should);
}else{
printf("\t\texpected %d not to be equal to %d \n",*is,*should);
}
}
int main() {
addPrintFunction(printf);
addcallBackOnEachFail(fail);
disableBreakMode();
invokeAllTest();
return 0;
}