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

Create automatic tests for sensord #10

Open
linuxianer99 opened this issue May 16, 2020 · 8 comments
Open

Create automatic tests for sensord #10

linuxianer99 opened this issue May 16, 2020 · 8 comments

Comments

@linuxianer99
Copy link
Member

No description provided.

@linuxianer99
Copy link
Member Author

@kedder: I added some unit tests using cmocka to sensord. For that reason i switched to cmake which makes things a lot easier ;-)
May you have a look on this ??
https://github.com/linuxianer99/sensord/tree/cmake

Thanks!

@kedder
Copy link
Member

kedder commented May 25, 2020

@linuxianer99 I think cmake is a move in right direction, but I'll need help building it. I checked out your branch and did

cmake .
make

And getting

Scanning dependencies of target test_AirDensity
[ 58%] Building C object tests/CMakeFiles/test_AirDensity.dir/test_AirDensity.c.o
/home/andrey/projects/openvario/sensord/tests/test_AirDensity.c:4:10: fatal error: cmocka.h: No such file or directory
    4 | #include <cmocka.h>
      |          ^~~~~~~~~~

How do you fetch the cmocka dependency with cmake?

@linuxianer99
Copy link
Member Author

cmocka is fetched automatically. Have a look in the CMakeLists.txt in tests subdir.
The problem is related to cmake paralell process.. There is problem with dependency resolution, so cmake builds test_AirDensity before cmocka is fetched.

If you call make a second time it should work. Also calling make -j1 should fix the problem for the moment. I am working on this ..

@kedder
Copy link
Member

kedder commented May 25, 2020

It doesn't look like it even makes an attempt at fetching it. make -j1 gives the same result, here is the full output:

$ make -j1 
[ 54%] Built target sensord
[ 58%] Building C object tests/CMakeFiles/test_AirDensity.dir/test_AirDensity.c.o
/home/andrey/projects/openvario/sensord/tests/test_AirDensity.c:4:10: fatal error: cmocka.h: No such file or directory
    4 | #include <cmocka.h>
      |          ^~~~~~~~~~
compilation terminated.
make[2]: *** [tests/CMakeFiles/test_AirDensity.dir/build.make:63: tests/CMakeFiles/test_AirDensity.dir/test_AirDensity.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:144: tests/CMakeFiles/test_AirDensity.dir/all] Error 2
make: *** [Makefile:95: all] Error 2

And no, calling it second time makes no difference. I'm clearly missing something obvious here...

@linuxianer99
Copy link
Member Author

linuxianer99 commented May 25, 2020

Hmmm ... that is strange.

can you try the following:

  • in sensord directory: mkdir build
    cd build
    cmake ..
    make -j8

Can you please post the complete output ?

@kedder
Copy link
Member

kedder commented May 25, 2020

Hm, interesting. When I do it in build dir, cmocka is actually fetched. The build still fails on the first try, but succeeds on second one. The full output is here: https://dpaste.org/oHGJ

@linuxianer99
Copy link
Member Author

@kedder: OK. Problem fixed :)

So we switch to cmake now ?
What so you think ?

@kedder
Copy link
Member

kedder commented May 27, 2020

Sure! Let's do that!

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

No branches or pull requests

2 participants