fpagliughi / rust-industrial-io

Rust interface to the Linux Industrial I/O subsystem
MIT License
44 stars 21 forks source link

Tests for the library #13

Closed Funky185540 closed 2 years ago

Funky185540 commented 3 years ago

Currently there aren't any tests yet. I'd really like to add some, but I'm uncertain about how to test an embedded library that's as close to the metal as this one... Do you happen to have any suggestions? Or have you made some thoughts on it that you may want to share?

My best guess was to use the XML backend, although I have no clue how that works (yet). It seems that one can't rely on the iio_dummy kernel-module to be available, at least I couldn't find it anywhere on my Fedora host... But then again XML would possibly allow for the tests to be run in a CI environment?

Just throwing some thoughts in here. If you have a pointer for me, I'll happily go invest that!

fpagliughi commented 3 years ago

Well certainly there are some unit tests, but the coverage isn't great yet. Oh, and they're currently broken (not compiling) by the changes from #12, but I'll have that fixed in 5 min.

But Pull Requests for more unit tests are always welcome!

The expectation is that the tests will run against iio_dummy, specifically the configuration set up by the load_dummy.sh script at the top of the repository. This also creates a Linux hrtimer and makes sure the config filesystem is mounted.

Perhaps the dummy isn't pre-compiled for every distribution, but it can be... as opposed to any specific piece of hardware which is probably not available to most users. Luckily it's available on Debian/Ubuntu/Mint, but it's not too crazy to compile. I'm not going to even try to describe that in this repo since it's so distro-dependent.

I'm not sure of any other integration tests that we might do (i.e. start a 'tests/' directory). I'm happy with more unit tests for the time being.

But I'd also be open to some more examples that target specific hardware if there are things that might not fit into a more generic example.

fpagliughi commented 2 years ago

Closing from inactivity. Feel free to -open if something new comes up.