ccn-lite
ccn-lite copied to clipboard
deprecated API calls in unit tests
Description
If you build the unit tests with a recent version of cmocka, the compiler will produce warnings about deprecated calls to _run_tests
.
Steps to reproduce the issue
You have to follow the standard build instructions
$ mkdir build ; cd build
$ cmake ..
$ make
Expected results
Unit tests compile without warnings.
Actual results
Compiling unit tests result in warnings on deprecated API calls to _run_tests
The actual fix is relatively easy. You have to replace the deprecated API call in your return statement in a unit test with cmocka_run_group_tests
and subsequently replace the unit_test
calls with cmocka_unit_test
calls. Also the type of the array needs to be CMUnitTest
over UnitTest
128 int main(void)
129 {
130 const struct CMUnitTest tests[] = {
131 cmocka_unit_test(test_prefix_to_path),
132 cmocka_unit_test(test_uri_to_prefix),
133 cmocka_unit_test(test_append_to_prefix),
134 cmocka_unit_test(test_prefix_exact_match),
135 cmocka_unit_test(test_prefix_no_exact_match),
136 cmocka_unit_test(test_prefix_longest_match),
137 cmocka_unit_test(test_prefix_no_longest_match),
138 };
139
140 return cmocka_run_group_tests_name("core: prefix tests", tests, NULL, NULL);
141 }
I've started to write a fix for our existing unit tests which can be found here. Unfortunately, the cmocka version on semaphore CI uses the package with the old API. We can either wait for an upgrade or think about using backports or other mechanisms to get a recent version of cmocka running.
[ 95%] Building C object test/ccnl-core/CMakeFiles/test_interest.dir/test_interest.c.o /home/pi0/ccn-lite/test/ccnl-core/test_interest.c:4:20: fatal error: cmocka.h: No such file or directory compilation terminated. test/ccnl-core/CMakeFiles/test_interest.dir/build.make:62: recipe for target 'test/ccnl-core/CMakeFiles/test_interest.dir/test_interest.c.o' failed make[2]: *** [test/ccnl-core/CMakeFiles/test_interest.dir/test_interest.c.o] Error 1 CMakeFiles/Makefile2:985: recipe for target 'test/ccnl-core/CMakeFiles/test_interest.dir/all' failed make[1]: *** [test/ccnl-core/CMakeFiles/test_interest.dir/all] Error 2 Makefile:94: recipe for target 'all' failed make: *** [all] Error 2
Can you give me some suggestions for this problem?This messge show in the terminal after using "$build"(the last step in the standard build instructions).Thank you!
Your issue (compilation failure) is not related to this issue (compilation warning). I've opened a new issue #299
I thought it was related, but I was wrong.Thanks for your help.
I thought it was related, but I was wrong.Thanks for your help.
The "problem" we are facing in this issue is that the cmocka version we run on our own (developer) machines is newer than what semaphore (the CI system we use) provides. This results in this deprecated API warnings on machines with recent cmocka versions.