# ytest C library like `gtest / gmock` like, but works mainly with functions ## env linux ## install to create `libytest.so` ``` make ``` or ``` ./kreate_library_ytest.sh ``` ## install lib ytest ### include copy the headers in `include_ytest/include` to include directory, for example ``` cp -r include_ytest/include/* /usr/include/ ``` or ``` cp -r include_ytest/include/* ~/.local/include/ ``` if `/usr/include` or `~/.local/include` is in `CPATH` or execute ``` export CPATH=/Path_to_dir_ytest/include_ytest/include:$CPATH ``` or add the precedent line in `~/.bashrc`. We can avoid these copy or export to CPATH env by adding ``` -I/Path_to_dir_ytest/include_ytest/include ``` when compiling our test. ### library Also, we need to add `-L/Path_to_dir_ytest` when compiling our test, this `/Path_to_dir_ytest` contain `libytest.so`. Or we can copy `libytest.so` in a directory in `/usr/lib/` or other directory in ``` echo $LD_LIBRARY_PATH ``` 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` and `permutation_test/is_good.c` ## compile and run the example ``` cd test make ./launch_is_good_m ``` or ``` chmod +x compile.sh ./compile.sh "is_good.c" ./launch_is_good_c ``` ## error if we have ``` ./launch_is_good_m ./launch_is_good_m: error while loading shared libraries: libytest.so: cannot open shared object file: No such file or directory ```` we need to add LD_LIBRARY_PATH env permanantly or ``` LD_LIBRARY_PATH=/path_to/lib_ytest ./launch_is_good_m ``` it is th same if `./launch_is_good_c` do not find `libytest.so` ## some compile options ### if need debug print `./compile "is_good.c" "-D DEBUG=1"` ### if need gdb `./compile "is_good.c" "-g"` ### if need prompt googletest like `./compile "is_good.c" "-D HK"` We can combine these options, for example: `./compile "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 ### help `./launch_is_good_c -h` ``` usage: ./launch_is_good_c [OPTIONS] [] or : ./launch_is_good_c [OPTIONS]=[] OPTIONS -h, --help print help, options variables -p , --parallel , -p=, --parallel= by default the program ran in sequantial all test, if this option is set, the program run tests on NB threads. Each thread pull up one test out the list of all test not yet executed, and execute it, until the list is empty -t , --time , -t=, --time= by default unit is millisecons ms, the other of unit are choices are second (or s), and nanosecond (or ns) ex: -t ns or -t=nanosecond or --time=n to set nanosecond unit -u , --unicolour by default, the result is colored, if you choice this option, it prints with default color -r , --remove if the option parallel is choosen the result on each thread is record in separate files, this option remove the file logs of each thread after all tests. -s , --savelog , -s=file, --savelog=file this option save the global ordered result in 'file', -n=, ... ,--numtests=,... this option allow to execute only the selected numbers of tests (in the order in file test) ex: -n=0,6,3 8 to execute the tests 0,3,6,8 (if the number is less than the count of all tests) -l=, ... ,--listests=,... this option allow to execute only the selected name of tests. It allows empty name by using '-l=,' ex: -l=name0,,name2 : execute only (if they exist): TEST(name0),TEST(),TEST(name2) -b , --bar_progress , -b=BPRGSS, --bar_progress=BPRGSS. Example: -b="#_c" this option change progression bar if it is active. The first character ('#') fills the bar the second char ('_') fills the other part of bar. the bar is colored if the 3rd char is 'c' and not if different. by default the progress bar is active and the option is -b=" c", if need not colored, we can put -b=" n" option. -z=