mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-03 13:47:04 +03:00
d0533a319b
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.
40 lines
932 B
Bash
Executable File
40 lines
932 B
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
TEST_DESCRIPTION="Basic systemd setup"
|
|
RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes}
|
|
|
|
. $TEST_BASE_DIR/test-functions
|
|
|
|
test_setup() {
|
|
create_empty_image
|
|
mkdir -p $TESTDIR/root
|
|
mount ${LOOPDEV}p1 $TESTDIR/root
|
|
|
|
# Create what will eventually be our root filesystem onto an overlay
|
|
(
|
|
LOG_LEVEL=5
|
|
eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
|
|
|
|
setup_basic_environment
|
|
|
|
# setup the testsuite service
|
|
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
|
[Unit]
|
|
Description=Testsuite service
|
|
After=multi-user.target
|
|
|
|
[Service]
|
|
ExecStart=/bin/sh -e -x -c 'systemctl --state=failed --no-legend --no-pager > /failed ; systemctl daemon-reload ; echo OK > /testok'
|
|
Type=oneshot
|
|
EOF
|
|
|
|
setup_testsuite
|
|
) || return 1
|
|
setup_nspawn_root
|
|
|
|
ddebug "umount $TESTDIR/root"
|
|
umount $TESTDIR/root
|
|
}
|
|
|
|
do_test "$@"
|