Openvario / variod

Daemon for autonomous e-vario
4 stars 8 forks source link

Create automatic software tests for variod #23

Open linuxianer99 opened 4 years ago

linuxianer99 commented 4 years ago

Maybe we can use a framework like Robot framework https://robotframework.org/

linuxianer99 commented 4 years ago

@kedder : How can we integrate these tests into Github CI ?

Think there should be a way to start the tools with one single command and got a result back after the test.

kedder commented 4 years ago

There is no tests yet, the tool I made so far is for "manual" testing - so I can squeeze some sound from the variod on my laptop (without real sensord). Once we have some automated tests, it should be pretty easy to integrate them with CI.

linuxianer99 commented 4 years ago

@kedder : What do you think about Mock testing ?? Think this solves our problem with I2C and the missing hardware. One method can be cmocka. Example is here: https://www.samlewis.me/2016/09/embedded-unit-testing-with-cmocka/

kedder commented 4 years ago

@linuxianer99, I think mocking i2c might only be relevant for testing sensord. Input for variod is NMEA stream, and output is NMEA too, so no harware mocking is really needed here.

linuxianer99 commented 4 years ago

@kedder : you are right regarding I2c. But i think we should use just one test framework for both apps.

kedder commented 4 years ago

I don't disagree. I don't have any experience with unit testing C programs, so I don't have a strong opinion here.

linuxianer99 commented 4 years ago

I also have less experience with testing C programs. But i did some test the last 2 hours:

https://www.wfbsoftware.de/2019/07/18/c-unit-testing-with-cmocka/ https://www.samlewis.me/2016/09/embedded-unit-testing-with-cmocka/

Have the first test running in sensord. (AirDensity functions):

`

include

include

include

include

include "../AirDensity.h"

static void test_AirDensity() { assert_float_equal(AirDensity(500.0), 1.1672, 0.005); }

int main(int argc, char **argv) { const UnitTest tests[] = { unit_test(test_AirDensity), }; return run_tests(tests); }`

It's without mock, but very simple to implement ..

The output look like:

`[build@localhost sensord]$ ./testmain [==========] Running 1 test(s). [ RUN ] test_AirDensity [ OK ] test_AirDensity [==========] 1 test(s) run. [ PASSED ] 1 test(s).

0 FAILED TEST(S) [build@localhost sensord]$`

I can prepare something the next days and push it in a branch. So you can have a look on it ...