restruct repository to ytest, create shared library for ytest

This commit is contained in:
2023-10-17 14:13:07 +02:00
parent d594aacd46
commit 09d4532e01
44 changed files with 1673 additions and 163 deletions
+64 -7
View File
@@ -4,29 +4,79 @@ C library like `gtest / gmock` like, but works mainly with functions
## env
linux
## install
```
make
```
or
```
./kreate_library_ytest.sh
```
### make options
```
make update_headers
```
it copy all headers of `ytest` in `include_ytest/include/`
## compile
if the code is in `test/is_good.c` we compile in the main directory by:
```
gcc -o launch_ex test/is_good.c -I./include_ytest -L. -lytest \
src/permutation/permutation.c src/set_theoric/set_theoric.c -I./src # this line is the library we need to test!
```
if we change the directory, we need to notice the /Path_to_dir_ytest, then change the option compile by
```
gcc -o launch_ex path_to_file/is_good.c -I/Path_to_dir_ytest/include_ytest -L/Path_to_dir_ytest -lytest \
/Path_tolib/src/permutation/permutation.c /Path_tolib/src/set_theoric/set_theoric.c -I./Path_tolib # this line is the library we need to test!
```
## install lib ytest
copy the headers in `include_ytest` to include directory, for example
```
cp include_ytest/include/* /usr/include/
```
or
```
cp include_ytest/include/* ~/.local/include/
```
if `/usr/include` or `~/.local/include` is in `CPATH`
or
add ```export CPATH=/Path_to_dir_ytest/include_ytest/include:$CPATH``` in `~/.bashrc`.
So, we do not need to add `-I/Path_to_dir_ytest/include_ytest/include` when compiling,
To avoid `-L/Path_to_dir_ytest` when compiling, we can copy `libytest.so` in a directory in `/usr/lib/` or copy `libytest.so` in `/path_to/lib_ytest/` and then
add ```export LD_LIBRARY_PATH=/path_to/lib_ytest:$LD_LIBRARY_PATH``` in `~/.bashrc`.
## test examples
`test/is_good.c`
## compile and run
## compile and run the example
```
make
cd test
make
./launch_is_good_m
```
or
```
chmod +x compile.sh
./compile.sh
./compile.sh "is_good.c"
./launch_is_good_c
```
## some compile options
### if need debug print
`./compile "-D DEBUG=1"`
`./compile "s_good.c" "-D DEBUG=1"`
### if need gdb
`./compile "-g"`
`./compile "test/is_good.c" "-g"`
### if need prompt googletest like
`./compile "-D HK"`
`./compile "test/is_good.c" "-D HK"`
We can combine these options, for example: `./compile "-D DEBUG=1 -D HK -g"`
We can combine these options, for example: `./compile "test/is_good.c" "-D DEBUG=1 -D HK -g"`
## launch options if using run_all_tests_args(argc, argv);
By default `./launch_is_good_{c,m}` is on 1 thread but we can add some options to run tests in parallel, or change colors, to disable progress bar, ..., to print help
@@ -89,6 +139,12 @@ For example, to launch tests (`test/is_good.c`) on 4 threads, using unicolor(bla
# How to create test
This need to add `path_to/include_ytest/include` in `CPATH` by `export CPATH=/path_to/include_ytest/include:$CPATH` in terminal or in `~/.bashrc` file for example, or add `-I/path_to/include_ytest/include` when compiling,
the others option when compiling are `-L/path_to/directorytest` this path must contain `libytest.so` generated by `make` or `./kreate_library_ytest` or we can put this path in `LD_LIBRARY_PATH`.
And we must add `lytest` to add the shared library in compilation.
## include
```
#include "ftest/ftest.h"
@@ -102,6 +158,7 @@ TEST(){
EXPECT_TRUE(true);
}
```
## in main func
### if using options:
```