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 software tests for variod #23

Open
linuxianer99 opened this issue May 16, 2020 · 7 comments · Fixed by #24
Open

Create automatic software tests for variod #23

linuxianer99 opened this issue May 16, 2020 · 7 comments · Fixed by #24

Comments

@linuxianer99
Copy link
Member

linuxianer99 commented May 16, 2020

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

@linuxianer99
Copy link
Member Author

@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
Copy link
Member

kedder commented May 18, 2020

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
Copy link
Member Author

@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
Copy link
Member

kedder commented May 18, 2020

@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
Copy link
Member Author

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

@kedder
Copy link
Member

kedder commented May 18, 2020

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
Copy link
Member Author

linuxianer99 commented May 18, 2020

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 <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>

#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 ...

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

Successfully merging a pull request may close this issue.

2 participants