Instead of having to create files, and copying them in place for each
test, we move all static test files to a skeleton rootfs. This makes
it a lot easier to get an overview of how things and how they work.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Note: we need to add /usr/bin and /usr/sbin to the standard PATH
for tests and the test environment itself.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
- Add `type:forking` service option to trigger guessing pidfile to
watch for, instead of `pid:!foo` option, which is not intuitive.
This option may likely also survive into the new file format :)
- Update docs and add examples
- Update start-stop-serv.sh test case with this new variant
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
While without a working Internet connection today I ran into the issue
of not being able to run the tests. This adds a basic caching mechanism
to setup-root.sh which saves busybox-x86_64 in ~/.cache, if available.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
serv: add support for foregrounding, running with and without PID file,
including custom PID filename.
test: verify Finit can start & monitor services that:
1) Fork and creates a PID file in a known location
2) Don't fork and don't create a PID file, but Finit does
3) Don't fork but create a PID file
4) Don't fork and create custom named PID file
Note: Finit cannot support a service that forks and doesn't create a PID
file. This combination is impossible to support without tracking
all processes created in /proc -- which Finit does not do atm.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Coding style for shell scripts:
- Tabs for indent (change in Emacs needed)
- Braces on their own line, like C functions
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
I'll have to ask Jacques what this was for, because it doesn't seem to
be needed to run and monitor the test. Also, it lingers at shutdown,
causing some unintended side effects in Finit.
Commenting out for now, as a reminder to myself.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Install start-stop-daemon in test root. Add S01-service.sh, which uses
start-stop-daemon to start service.sh. Modify service.sh to respect
signals, and not exit immediately when sleep exits due to SIGTERM.
Remove PID file in signal callback and make sure to exit OK
The test itself is basically a copy of the start-stop-service.sh test.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The slay script checks for common errors and gives some logs and status
of Finit when something goes wrong. Helps detect issue #226 when the
start-kill-service.sh test runs at 100000 laps.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This trick can also be used by others who want to run Finit in an
unshare. Set the container environment variable to 'unshare',
like lxc and docker do for their products.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit implements a test for the signal feature of initctl. The
existing service used in tests (`common/service.sh`) has been extended
with a signal trap handler. When SIGUSR1 is received, it will write the
string `'USR1'` to `/tmp/usr1.log`. The test will run `initctl signal
service.sh SIGUSR1` and assert that the contents of the file
`/tmp/usr1.log` really is `USR1`.
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>
We extend the service.sh to emulate a well behaving service that creates
and removes its own PID file.
The new test emulates a crash by sending SIGKILL to service.sh. We then
verify that Finit restarts it, and eventually registers the new PID when
the services recreates the PID file.
Issue #226
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
- We need a working /var and /run for some features, e.g. PID
monitoring and status files for urandom.so
- Add empty fstab to silence mount errors from finit
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>