Open rugk opened 3 years ago
@rugk : That would be lovely!
A small historical background would be important:
make BOARD=qemu-coreboot-fbwhiptail run
) in board config doesn't take advantage of swtpm (same issue as above) while USB support is not in either (not passed at run either) Consequently, i'm not sure of what unit test we could really do here. Once qemu+swtpm+usb support is in, openqa could be applied to poke arount/make sure things are not breaking from one commit to the other on a functionality level. Otherwise, Heads is built in such a way that going into recovery is wiping the secret and extending PCRs so that measurements are made invalid.
But suggestions/PR welcome, as usual! What unit tests you would find useful here?
@rugk I thought the same but the issue is far more complex than it seems. It was not able to have the scripts shellcheck compliant without creating errors. There are global variables that are hard to track down, different coding styles, possibly dead code and functions do parse variables in different ways. As there are so many platforms that no one developer has access to I did not know how to approach that task by starting with unit tests.
I tried to create a list of steps to take to get to a point where unit testing would be viable in #885. I remember running into an issue with mocking in shunit2 I could not figure out and have used shellspec on other projects. The unit test framework is ultimately up to personal tastes.
I have wanted to get back to that but I fall into on rabbit hole after another with other projects and have yet to circle back.
https://shellspec.info/ looks great, thanks, did not know that. Anyway, that's off-topic. :smile:
@rugk Not really off topic as this is regarding unit testing the shell scripts in Heads. I suggested it as I had more success with shellspec than shunit2 and bats. Presumably as I am familiar with BDD style unit testing frameworks, but not everyone is. If you want to see some examples, here is where I used it before
I had a quick look at the code base and tried to find some unit tests for the biggest part of the used language (shell/bash). I could not find any, so I'm wondering whether you have any? Also looked at the CI script, but it just seems to build a whole lot of stuff.
If not, I'd suggest to add some, even starting with only some basic tests. For a security-relevant product at least some basic things may be tested.
To do this, I personally had a good experience with https://github.com/kward/shunit2/. Maybe this would be a good idea?