16 Commits
V1.1 ... master

Author SHA1 Message Date
stubbfel
163455cd00 add Readme 2018-09-06 22:40:54 +02:00
stubbfel
0278a185e4 squash! refactor output function to test_session_control_block 2018-04-05 22:39:57 +02:00
stubbfel
30c7c93ef4 refactor output function to test_session_control_block 2018-03-31 01:05:27 +02:00
stubbfel
98ffa6508d mv BuildKernelModule and refactor run_unity_printk_test 2018-03-09 00:02:07 +01:00
stubbfel
a0bddbbda3 enable colors 2018-03-09 00:00:02 +01:00
stubbfel
a25162238b show now correct file path, test name and line number 2018-03-09 00:00:02 +01:00
stubbfel
1a37404f5e update fff und Unity 2018-03-09 00:00:02 +01:00
stubbfel
c04badcf5a add get_directory_definitions and get_directory_includes 2018-03-08 23:59:48 +01:00
stubbfel
695403d014 fix shell interpreter 2018-03-08 23:59:48 +01:00
stubbfel
52faaaff69 update kunity 2018-03-08 23:59:48 +01:00
stubbfel
66f19afb8c fix costum commant output path 2018-03-08 23:59:48 +01:00
stubbfel
7c4a1d6fe8 add stringifycation of prefix macro 2018-03-08 23:59:48 +01:00
stubbfel
80f56f28f3 add macro for prefixing test function names 2018-03-08 23:59:48 +01:00
stubbfel
cc125783a9 replace b execute process by custom command, so that we can copy files at build time 2018-03-08 23:59:48 +01:00
stubbfel
d549077c78 fix copy failure and double includes 2018-03-08 23:59:48 +01:00
stubbfel
3632dd5c39 add submodules 2018-03-08 23:43:26 +01:00
2 changed files with 52 additions and 1 deletions

2
.gitmodules vendored
View File

@@ -1,3 +1,3 @@
[submodule "lib/Unity"]
path = lib/Unity
url = https://github.com/ThrowTheSwitch/Unity.git
url = gitea@gitea.stubbe.rocks:3rd-party/Unity.git

51
README.md Normal file
View File

@@ -0,0 +1,51 @@
# KUnity
KUnity configure the c unit test framework Unity (http://www.throwtheswitch.org/unity) so that it can use in kernel space. The test results will be "shown" by `printk`.
## Add KUnity to a kernel module
```Makefile
# add KUnity and Unity source files
module-objs += lib/KUnity/src/kunity.o
module-objs += lib/KUnity/lib/Unity/src/unity.o
# include KUnity and Unity header
ccflags-y += -I<lib_path>/KUnity/src
ccflags-y += -I<lib_path>/KUnity/lib/Unity/src
# set the unity config by header file flag, which is provided by KUnity
ccflags-y += -DUNITY_INCLUDE_CONFIG_H
```
## Write and Running test cases
Test can be written like Unity tests, but for the definition of the test function you have to use the ```KUNITY_TEST``` makro.
When a kunity test should run, its necessary to add the prefix ```kunity_test_``` to the test function name.
```c
#include <kunity.h>
// ... application includes
KUNITY_TEST(first_simple_test)
{
TEST_ASSERT_EQUAL(1, 0);
}
// add more tests
// run tests
int module_init(void) {
int result = 0;
UNITY_BEGIN();
RUN_TEST(kunity_test_first_simple_test);
// ... call the other tests
result = UNITY_END();
if ( < 1) {
// all tests was successful, startup module
// ...
}
return -result;
}
```
For running tests it can also use the [KUnity-Test-Runner-Module](/kttd/KUnity-Test-Runner-Module)