Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecated API calls in unit tests #290

Open
mfrey opened this issue Jul 16, 2018 · 5 comments
Open

deprecated API calls in unit tests #290

mfrey opened this issue Jul 16, 2018 · 5 comments
Labels

Comments

@mfrey
Copy link
Collaborator

mfrey commented Jul 16, 2018

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

@mfrey mfrey added the minor label Jul 16, 2018
@mfrey
Copy link
Collaborator Author

mfrey commented Jul 16, 2018

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.

@ericxiao77
Copy link

ericxiao77 commented Aug 8, 2018

[ 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!

@mfrey
Copy link
Collaborator Author

mfrey commented Aug 8, 2018

Your issue (compilation failure) is not related to this issue (compilation warning). I've opened a new issue #299

@ericxiao77
Copy link

I thought it was related, but I was wrong.Thanks for your help.

@mfrey
Copy link
Collaborator Author

mfrey commented Aug 8, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants