The C code is tested using Julia 1.5.1 (although any version >1.0 should work), and all tests can be run by executing include("runtests.jl")
in the Julia REPL. This compiles the C-code and calls it through Libdl using ccall
, and subsequently verifies that each function in the C-stack works as intended.
From the base directory, all tests can be run after activating the package, by
]activate .
include("test/runtests.jl")
This compiles the C-code as a shared library and proceeds to call individual functions, testing them against the same functions implemented in Julia. You can also run the tests individually to see exactly how specific functions have been implemented and their intended usage. Running all the tests produces the output below.
Compiling: Using LAPACK...
...
Testing math functions...
Testing the SO(3) maps...
Testing the SU(2) maps...
Testing FSF utilities...
Testing continuous FSF on SO(3)...
Testing robust FSF on SO(3)...
Testing continuous FSF on SU(2)...
Testing discontinuous FSF on SU(2)...
Testing robust FSF on SU(2)...
Testing continuous FOF on SO(3)...
Testing the power distribution...
Testing matrix addition (inplace)...
Testing matrix addition...
Testing matrix PSD solver...
Testing matrix multiplication...
Testing matrix PSD solver...
Testing matrix subtraction (inplace)...
Testing matrix subtraction...
Testing matrix transposition...
Test Summary: | Pass Total
All tests | 4121 4121
In addition, examples of C-implementations with complete control loops are given in the cont_main stack, and by first compiling the stack and then running the debug command from the bash shell, Valgrind will be run on the compiled stack to check for memory leaks. From the base directory, running
cd src && make clean && make && make debug
produces an output similar to that below
Allocate memory for the reference, state and controller structs...
Set some controller parameters, define dynamics and reference
Free allocated memory...
Allocate memory for the reference, state and controller structs...
Set some controller parameters, define dynamics and reference
Free allocated memory...
==69077==
==69077== HEAP SUMMARY:
==69077== in use at exit: 0 bytes in 0 blocks
==69077== total heap usage: 13,038 allocs, 13,038 frees, 964,080 bytes allocated
==69077==
==69077== All heap blocks were freed -- no leaks are possible
==69077==
==69077== For lists of detected and suppressed errors, rerun with: -s
==69077== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)