In the test framework for finit, a set of shell scripts are used to setup a test harness, run tests, and finalize tests. In the setup, a file system is created for the virtualized/containerized environment in which all tests are run, located at `$FINIT_SRC/test/tenv-root`. In the tear down phase of each test, the file `/var/lock` is made readable using `chmod +r`. It is not clear _why_ the teardown code does this, as there are no references in the test framework to this path anywhere else. It is conceivable that the teardown phase attempted to "reset the state" for next test. The code that that this commit removes does not always work. When `/var/lock` is a symlink, and resolves to an absolute path, the test framework does not function properly. The teardown code is run in the context of the host computer, and touching files outside of the virtualized environment is not ok. The removal of the offending code does not seem to affect tests: all tests pass without it, so its existence is questionable. Signed-off-by: Jörgen Sigvardsson <jorgen.sigvardsson@gmail.com>
Tests
Finit comes with a set of tests and a small framework for running them. Contributors are encouraged to write new tests when implementing features, or fixing bugs.
Each test is run in isolation, in it's own namespace. Finit will therefore be able to be launched as PID 1. Since it's also running with it's own root directory it will be able to function properly without having any super user privileges in the host environment.
Running tests
To run the test suite, first build Finit, e.g:
./configure --prefix=/usr --exec-prefix= --sysconfdir=/etc --localstatedir=/var
make -j9 clean all
Then run (parallel does not work atm):
make check
make check will set up the required assets for the test environment, and then
run the full set of tests. The environment is not removed afterwards so at
this point individual tests can be executed without having to run the entire
test suite, which is handy when developing new tests or debugging existing
test. To execute an individual test, simply invoke the script containing it:
./test/name-of-the-test.sh