-
Notifications
You must be signed in to change notification settings - Fork 4
Test Syntax and Test creation
To write the test-cases direct you have to create an InvoceAll function which calls all test-cases. It is advisable to divide the test-cases into groups. So that the invoceAll function do the setup and calls each test-group. Test-Setup
Before any test could be executed the function MessageToDebugger(startTesting) must be called. This function establishes the connection to the GDB-Server and blocks until an test-mode gets configured by the GDB-Manipulator. Test-Execution
Program execution plan :
Asserts
Supported Asserts are defined in assets.h :
ASSERT_EQ(should, is)
Check if “should” is equals to “is” For : uint8_t , int, uint32_t
ASSERT_NEQ(should, is)
Check if “should” is not equals to “is” For : uint8_t , int, uint32_t
Assert_EQ_Mem(is*, sizeIs, should* , sizeShould)
Check of the “is” memory is equals to the “should” memory. Tests-Teardown
The GDB-Manipulator has to be informed about the executing of all test-cases. This is done by the calling the Function “MessageToDebugger(finishAllTest)”
Please see the corresponding wiki entry for further information’s
Mocks and Stubs are active until function deleteAllMocks() gets called. Automatically Test-code Generation
To simplify the test generation (test setup, invokeAll test cases, test teardown) a test file parser has been built with “awk” with this parser it is possible to generate googleTest like tests.
An test-case has following setup:
TEST(<testGroup>,<testName>){ … <Asserts etc.> }
e.g. test.c
#include "testSuite/asserts.h"
#include "testSuite/testSuite.h"
TEST(classSuccess,NEQ_SUCCESS){
uint8_t u1 = 1;
uint32_t u2 = -1;
ASSERT_NEQ(0,1);
ASSERT_NEQ(1,0);
ASSERT_NEQ(-1,0);
ASSERT_NEQ(-1,1);
ASSERT_NEQ(u1,u2);
}
To generate “c”-compatible Code call the awk script: “parseSingleFile.awk” e.g.
awk -f awk/parseSingleFile.awk test.c
This prints the generated test-code to the cli.
It is possible to filter test Groups on compile time out by setting the variable: testFilter with
awk -v testFilter="<group>" -f awk/parseSingleFile.awk test.c
stands for the start of each group to be filtered.
To filter several groups it is possible to to separate the groups with ,
awk -v testFilter="<group1>,<group2>,<group3>" -f awk/parseSingleFile.awk test.c
For further information’s see Test Filter Invoke All Tests
With the script “generateInvokeAll.awk” it possible to generate an function that calls all test groups. e.g.
ls targetExamples/testexamples/withParser/*.c | awk -f awk/generateInvokeAll.awk