Commit Graph

46 Commits

Author SHA1 Message Date
Luca Boccassi bb64bec589 test: update test_create_image
Run mask_supporting_services, which was missing, and remove setup_nspawn_root which
is now already called outside test_create_image
2021-01-01 21:33:16 +00:00
Zbigniew Jędrzejewski-Szmek 9d84eb2053 test/TEST-01: allow running w/o -Dinstall-tests=true
This is useful for sanitizer builds under CI, see
https://github.com/systemd/systemd-centos-ci/pull/202#issuecomment-566476592.
2020-03-28 11:51:29 +01:00
Zbigniew Jędrzejewski-Szmek 8c3534b5db test: rework how images are created
Before, we'd create a separate image for each test, in
/var/tmp/systemd-test.XXXXX/rootdisk.img. Most of the images
where very similar, except that each one had some unit files installed
specifically for the test. The installation of those custom unit files
was removed in previous commits (all the unit files are always installed).

The new approach is to only create as few distinct images as possible.
We have:
default.img: the "normal" image suitable for almost all the tests
basic.img: the same as default image but doesn't mask any services
cryptsetup.img: p2 is used for encrypted /var
badid.img: /etc/machine-id is overwritten with stuff
selinux.img: with selinux added for fun and fun
and a few others:

ls -l build/test/*img
lrwxrwxrwx 1 root root 38 Mar 21 21:23 build/test/badid.img -> /var/tmp/systemd-test.PJFFeo/badid.img
lrwxrwxrwx 1 root root 38 Mar 21 21:17 build/test/basic.img -> /var/tmp/systemd-test.na0xOI/basic.img
lrwxrwxrwx 1 root root 43 Mar 21 21:18 build/test/cryptsetup.img -> /var/tmp/systemd-test.Tzjv06/cryptsetup.img
lrwxrwxrwx 1 root root 40 Mar 21 21:19 build/test/default.img -> /var/tmp/systemd-test.EscAsS/default.img
lrwxrwxrwx 1 root root 39 Mar 21 21:22 build/test/nspawn.img -> /var/tmp/systemd-test.HSebKo/nspawn.img
lrwxrwxrwx 1 root root 40 Mar 21 21:20 build/test/selinux.img -> /var/tmp/systemd-test.daBjbx/selinux.img
lrwxrwxrwx 1 root root 39 Mar 21 21:21 build/test/test08.img -> /var/tmp/systemd-test.OgnN8Z/test08.img

I considered trying to use the same image everywhere. It would probably be
possible, but it would be very brittle. By using separate images where it is
necessary we keep various orthogonal modifications independent.

The way that images are cached is complicated by the fact that we still
want to keep them in /var/tmp. Thus, an image is created on first use and
linked to from build/test/ so it can be found by other tests.

Tests cannot be run in parallel. I think that is an acceptable limitation.
Creation of the images was probably taking more resources then the actual
tests, so we should be better off anyway.
2020-03-28 11:51:29 +01:00
Zbigniew Jędrzejewski-Szmek 50b836518c test: drop cargo-cult line
p2 is only used in the cryptsetup test...
2020-03-28 11:51:13 +01:00
Zbigniew Jędrzejewski-Szmek fe85f2bb9c test: move TEST-01-BASIC setup to static files
After this commit, only tests that were converted will work, because the
interface to test_run() changed.
2020-03-28 11:46:47 +01:00
Jörg Thalheim ff12a7954c treewide: more portable bash shebangs
As in 2a5fcfae02
and in 3e67e5c992
using /usr/bin/env allows bash to be looked up in PATH
rather than being hard-coded.

As with the previous changes the same arguments apply
- distributions have scripts to rewrite shebangs on installation and
  they know what locations to rely on.
- For tests/compilation we should rather rely on the user to have setup
  there PATH correctly.

In particular this makes testing from git easier on NixOS where do not provide
/bin/bash to improve compose-ability.
2020-03-05 17:27:07 +01:00
Dan Streetman ec4cab49c9 test: add create_empty_image_rootdir() to simplify testcase setup
Almost all tests were manually mounting/unmounting $TESTDIR/root
from the loopback image; this moves all that into test-functions
so the test setup functions are simplier.

Also add test_setup_cleanup() function, to cleanup what is mounted
by create_empty_image_rootdir()
2019-07-16 18:05:15 -04:00
Frantisek Sumsal cc469c3dfc test: drop || return 1 expression which is incompatible with set -e
The `set -e` option is incompatible with a subshell/compound command,
which is followed by || <EXPR>. In such case, the -e option is ignored
in all affected subshells/functions (see man bash(1) for command `set`).
2019-07-08 21:11:32 +02:00
Frantisek Sumsal d0533a319b test: correctly fail when system is borked
In certain situations, the systemctl commands may fail (e.g. due to
missing shared libraries), but the 'script' continues and creates a
/testok file, marking the test incorrectly as passed. Let's fix this and
bail out immediately when a command exits with a non-zero exit code.
2019-05-27 22:31:55 +03:00
Zbigniew Jędrzejewski-Szmek cc5549ca12 scripts: use 4 space indentation
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)

Also remove the few vim config lines that were left. We should either have them
on all files, or none.

Also remove some strange stuff like '#!/bin/env bash', yikes.
2019-04-12 08:30:31 +02:00
Frantisek Sumsal e47df8232a test: drop service masking in TEST-01-BASIC
This test should ensure all systemd starts correctly, so masking them is
counter-productive in this case.
2019-01-11 13:45:08 +01:00
Evgeny Vereshchagin 7e11a95e41 tests: reproduce https://github.com/systemd/systemd/issues/11251 2018-12-29 19:14:28 +01:00
Evgeny Vereshchagin 9103671d7c test: don't run TEST-01-BASIC in unprivileged containers on Travis CI 2018-12-24 08:52:33 +01:00
Evgeny Vereshchagin 746fbd9c34 tests: also run TEST-01-BASIC in an unprivileged container (#9957)
This should make it much easier to catch regressions like
https://github.com/systemd/systemd/issues/9914 and
https://github.com/systemd/systemd/issues/8535.
2018-08-30 13:01:18 +09:00
Martin Pitt 818567fce6 test: Run qemu/nspawn tests with "set -e"
This catches errors like "ninja not found", missing programs etc. early,
instead of silently ignoring them and trying to boot a broken VM.

In install_config_files(), allow some distro specific files to be absent
(such as /etc/sysconfig/init).
2017-08-10 08:43:13 +02:00
Martin Pitt 054ee249a2 test: Factorize common integration test functions (#6540)
All test/TEST* but TEST-02-CRYPTSETUP share the same check_result_qemu()
and test_cleanup(), so move them into test_functions and only override
them in TEST-02-CRYPTSETUP.

Also provide a common test_run() which by default assumes that both QEMU
and nspawn tests are run. Particular tests which don't support either
need to explicitly opt out by setting $TEST_NO_{QEMU,NSPAWN}. Do it this
way around to avoid accidentally forgetting to opt in, and to encourage
test authors to at least always support nspawn.
2017-08-04 15:34:14 +03:00
Martin Pitt 7cad32bbde test: merge check_nspawn() into run_nspawn()
This makes nspawn tests symmetric with run_qemu() which also exits with 1 if
QEMU is not available.
2016-06-24 16:23:39 +02:00
Zbigniew Jędrzejewski-Szmek ed1190498f tree-wide: remove uses of --failed
It has been replaced by --state=failed.
2016-05-08 20:27:33 -04:00
Evgeny Vereshchagin cd949ee734 tests: don't run tests on incomplete setup 2015-11-25 17:51:17 +00:00
Lennart Poettering 8c191eecd4 Merge pull request #1957 from zonque/qemu-test
test: make QEMU tests work on Semaphore
2015-11-24 15:02:20 +01:00
Daniel Mack 6f9d3b08cf test: 01-basic: mask some services that currently don't run in qemu 2015-11-19 17:15:26 +01:00
Evgeny Vereshchagin 278d511547 tests: fix ls: cannot access /var/tmp/systemd-test.*/journal/*/*.journal
don't lose logs from the test machine too
2015-11-19 14:52:41 +00:00
Evgeny Vereshchagin 5c404f1ab8 tests: various fixes
* remove journal flushing (systemd-journal-flush.service runs journalctl --flush on boot)
* use sh -c and PATH instead of @SYSTEMCTL@ expansion
* remove unnecessary semicolons etc
2015-11-10 18:01:15 +00:00
Ronny Chevalier d31e109677 tests: do not use systemctl status --failed
since v212 calling systemctl status without arguments
will show a overall system state
2014-06-10 19:04:18 +02:00
Ronny Chevalier c6a77179a4 test: rework run_qemu
It tries to find a suitable QEMU binary and will use KVM if present.
We can now configure QEMU from outside with 4 variables :
  - $QEMU_BIN : path to QEMU's binary
  - $KERNEL_APPEND : arguments appended to kernel cmdline
  - $KERNEL_BIN : path to a kernel
    Default /boot/vmlinuz-$KERNEL_VER
  - $INITRD : path to an initramfs
    Default /boot/initramfs-${KERNEL_VER}.img
  - $QEMU_SMP : number of CPU simulated by QEMU.
    Default 1

(from Alexander Graf's script: http://www.spinics.net/lists/kvm/msg72389.html)
2013-12-10 07:46:21 -05:00
Ronny Chevalier 889a90422d test: remove duplicated code 2013-11-07 01:23:54 -05:00
Harald Hoyer 07ba977575 TEST-01-BASIC, TEST-02-CRYPTSETUP: fixed strip
also output more status about failed jobs
2013-09-17 15:19:17 -05:00
Zbigniew Jędrzejewski-Szmek fff87a35d9 test: make it easier to override kernel version 2013-04-24 00:25:04 -04:00
Zbigniew Jędrzejewski-Szmek 7bcd865d38 test: some trivial fixes to test scripts
- fix typo
- use compiled systemd-nspawn
- drop --capability=... from systemd-nspawn invocation, is is the default now
- simplify sudo make invocations
2013-01-29 19:01:41 -05:00
Michal Schmidt c90feab4ff test: factor out testsuite.target, end.service
Tests can use the same testsuite.target.
Add end.service to call poweroff instead of doing it from ExecStopPost
where it may be skipped on failure of ExecStart.
2013-01-25 22:29:56 +01:00
Michal Schmidt e8a66f4af2 test: use non-blocking systemctl calls in testsuite.service
"systemctl poweroff" called from testsuite.service will cause this unit
itself to stop. To avoid deadlock, the call must not be synchronous.
2013-01-25 22:29:55 +01:00
Lennart Poettering 71dc3ed1d9 test: split of cryptsetup into its own test 2012-09-13 23:19:05 +02:00
Lennart Poettering 5076f0ccfd nspawn: introduce new --capabilities= flag and make use of it in the nspawn test case 2012-06-28 14:05:16 +02:00
Lennart Poettering 5fa594df8d test: reenable nspawn, even if it fails for now 2012-06-28 12:18:04 +02:00
Harald Hoyer 0d6e798a78 test/TEST-01-BASIC: add /var on cryptoluks and wait for the journal 2012-05-29 09:23:37 +02:00
Harald Hoyer 6ea4364c7b test/TEST-01-BASIC: fail test, if qemu failed 2012-05-29 09:23:37 +02:00
Harald Hoyer f7c05f7de6 test/TEST-01-BASIC: make DEBUGTOOLS an environment variable 2012-05-29 09:23:31 +02:00
Harald Hoyer bd2b15138e test/TEST-01-BASIC: add missing "; then" 2012-05-24 16:07:35 +02:00
Harald Hoyer 7b17d413b1 test/TEST-01-BASIC: only test systemd-nspawn, if the test system uses systemd 2012-05-24 16:02:06 +02:00
Harald Hoyer d9890f4ed4 test/TEST-01-BASIC: add systemd-nspawn run with the root image 2012-05-24 15:52:31 +02:00
Harald Hoyer 6b197f2a03 test/TEST-01-BASIC: untabified 2012-05-24 15:33:58 +02:00
Harald Hoyer 3d3035e80c test/TEST-01-BASIC: add a defined rc.local 2012-05-24 15:32:51 +02:00
Harald Hoyer 7c1856aacd test/TEST-01-BASIC: add /etc/localtime to test image 2012-05-24 15:32:51 +02:00
Lennart Poettering 680705351d test: add touch to test machine 2012-05-24 15:21:43 +02:00
Lennart Poettering 32d965851d test: check systemctl --failed in test VM 2012-05-24 14:32:48 +02:00
Harald Hoyer 898720b7e9 test: introduce a basic testsuite framework
$ cd test
$ sudo make check

will run all tests in the TEST-* subdirectories

$ cd test/TEST-01-BASIC
$ sudo make clean setup run

will run the different stages of the test for debugging purposes
2012-05-22 16:54:54 +02:00