]> git.proxmox.com Git - systemd.git/blame - test/TEST-02-UNITTESTS/test.sh
New upstream version 249~rc1
[systemd.git] / test / TEST-02-UNITTESTS / test.sh
CommitLineData
46cdbd49 1#!/usr/bin/env bash
6e866b33 2set -e
8b3d4ff0 3
6e866b33
MB
4TEST_DESCRIPTION="Run unit tests under containers"
5RUN_IN_UNPRIVILEGED_CONTAINER=yes
6
a10f5d05
MB
7# embed some newlines in the kernel command line to stress our test suite
8KERNEL_APPEND="
9
10frobnicate!
11
12$KERNEL_APPEND
13"
14
8b3d4ff0
MB
15# shellcheck source=test/test-functions
16. "${TEST_BASE_DIR:?}/test-functions"
6e866b33
MB
17
18check_result_nspawn() {
8b3d4ff0
MB
19 local workspace="${1:?}"
20 local ret=1
21
22 [[ -e "$workspace/testok" ]] && ret=0
23
24 if [[ -s "$workspace/failed" ]]; then
25 ret=$((ret + 1))
6e866b33 26 echo "=== Failed test log ==="
8b3d4ff0 27 cat "$workspace/failed"
6e866b33 28 else
8b3d4ff0 29 if [[ -s "$workspace/skipped" ]]; then
6e866b33 30 echo "=== Skipped test log =="
8b3d4ff0 31 cat "$workspace/skipped"
6e866b33 32 fi
8b3d4ff0 33 if [[ -s "$workspace/testok" ]]; then
6e866b33 34 echo "=== Passed tests ==="
8b3d4ff0 35 cat "$workspace/testok"
6e866b33
MB
36 fi
37 fi
8b3d4ff0
MB
38
39 save_journal "$workspace/var/log/journal"
40 _umount_dir "${initdir:?}"
41
42 [[ -n "${TIMED_OUT:=}" ]] && ret=1
43 return $ret
6e866b33
MB
44}
45
46check_result_qemu() {
8b3d4ff0
MB
47 local ret=1
48
a10f5d05 49 mount_initdir
8b3d4ff0
MB
50 [[ -e "${initdir:?}/testok" ]] && ret=0
51
52 if [[ -s "$initdir/failed" ]]; then
53 ret=$((ret + 1))
6e866b33 54 echo "=== Failed test log ==="
8b3d4ff0 55 cat "$initdir/failed"
6e866b33 56 else
8b3d4ff0 57 if [[ -s "$initdir/skipped" ]]; then
6e866b33 58 echo "=== Skipped test log =="
8b3d4ff0 59 cat "$initdir/skipped"
6e866b33 60 fi
8b3d4ff0 61 if [[ -s "$initdir/testok" ]]; then
6e866b33 62 echo "=== Passed tests ==="
8b3d4ff0 63 cat "$initdir/testok"
6e866b33
MB
64 fi
65 fi
8b3d4ff0
MB
66
67 save_journal "$initdir/var/log/journal"
68 _umount_dir "$initdir"
69
70 [[ -n "${TIMED_OUT:=}" ]] && ret=1
71 return $ret
6e866b33
MB
72}
73
8b3d4ff0 74do_test "$@"