Openvario / sensord

Daemon to poll air data from Openvario sensorboard
6 stars 11 forks source link

Create automatic tests for sensord #10

Open linuxianer99 opened 4 years ago

linuxianer99 commented 4 years ago

@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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Hmmm ... that is strange.

can you try the following:

Can you please post the complete output ?

kedder commented 4 years ago

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 commented 4 years ago

@kedder: OK. Problem fixed :)

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

kedder commented 4 years ago

Sure! Let's do that!