1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-02 13:47:27 +03:00
systemd/test/units/TEST-29-PORTABLE.sh

71 lines
2.3 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
2021-03-05 18:36:04 +09:00
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -eux
set -o pipefail
# shellcheck source=test/units/test-control.sh
. "$(dirname "$0")"/test-control.sh
# shellcheck source=test/units/util.sh
. "$(dirname "$0")"/util.sh
install_extension_images
# Set longer timeout for slower machines, e.g. non-KVM vm.
mkdir -p /run/systemd/system.conf.d
cat >/run/systemd/system.conf.d/10-timeout.conf <<EOF
[Manager]
DefaultEnvironment=SYSTEMD_DISSECT_VERITY_TIMEOUT_SEC=30
ManagerEnvironment=SYSTEMD_DISSECT_VERITY_TIMEOUT_SEC=30
EOF
mkdir -p /run/systemd/system/systemd-portabled.service.d/
cat <<EOF >/run/systemd/system/systemd-portabled.service.d/override.conf
[Service]
Environment=SYSTEMD_LOG_LEVEL=debug
EOF
systemctl daemon-reexec
udevadm control --log-level debug
ARGS=()
test: bump the `reattach` timeout when running w/ plain QEMU As it might sometimes take slightly longer without the acceleration: ``` [ 176.805681] testsuite-29.sh[534]: + cp /usr/share/app1.raw /tmp/app1_2.raw [ 176.885365] testsuite-29.sh[534]: + timeout 30 portablectl reattach --now --runtime --extension /tmp/app1_2.raw /usr/share/minimal_1.raw app1 [ 177.053358] portablectl[993]: (Matching unit files with prefixes 'app1'.) [ 177.138770] kernel: loop0: detected capacity change from 0 to 2965504 [ 177.343137] kernel: loop1: detected capacity change from 0 to 4096 ... [ 201.932062] systemd[1]: app1.service: Deactivated successfully. [ 202.009310] systemd[1]: Stopped app1.service. [ 202.053776] systemd[1]: app1.service: Consumed 2.183s CPU time. [ 202.125061] systemd[1]: Stopping app1.service... [ 202.611760] systemd[1]: Starting modprobe@dm_mod.service... [ 202.851031] systemd[1]: Starting modprobe@dm_verity.service... [ 202.909352] systemd[1]: Starting modprobe@loop.service... [ 203.198918] systemd[1]: Starting app1.service... [ 207.145494] kernel: audit: type=1130 audit(1663770336.105:428): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=testsuite-29 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed' [ 207.652545] systemd[1]: testsuite-29.service: Main process exited, code=exited, status=124/n/a [ 207.665088] systemd[1]: testsuite-29.service: Failed with result 'exit-code'. [ 207.830522] systemd[1]: Failed to start testsuite-29.service. ... [ 208.889449] script1.sh[1035]: ID="centos" [ 208.889449] script1.sh[1035]: VERSION_ID="8" [ 208.889449] script1.sh[1035]: SYSEXT_SCOPE=portable [ 208.889449] script1.sh[1035]: PORTABLE_PREFIXES=app1 ... [ 214.155097] systemd[1]: app1.service: Deactivated successfully. ``` Spotted in Ubuntu CI and CentOS CI. Follow-up to 706c9a30ac.
2022-09-29 14:23:11 +02:00
STATE_DIRECTORY=/var/lib/private/
if [[ -v ASAN_OPTIONS || -v UBSAN_OPTIONS ]]; then
# If we're running under sanitizers, we need to use a less restrictive
# profile, otherwise LSan syscall would get blocked by seccomp
ARGS+=(--profile=trusted)
# With the trusted profile DynamicUser is disabled, so the storage is not in private/
test: bump the `reattach` timeout when running w/ plain QEMU As it might sometimes take slightly longer without the acceleration: ``` [ 176.805681] testsuite-29.sh[534]: + cp /usr/share/app1.raw /tmp/app1_2.raw [ 176.885365] testsuite-29.sh[534]: + timeout 30 portablectl reattach --now --runtime --extension /tmp/app1_2.raw /usr/share/minimal_1.raw app1 [ 177.053358] portablectl[993]: (Matching unit files with prefixes 'app1'.) [ 177.138770] kernel: loop0: detected capacity change from 0 to 2965504 [ 177.343137] kernel: loop1: detected capacity change from 0 to 4096 ... [ 201.932062] systemd[1]: app1.service: Deactivated successfully. [ 202.009310] systemd[1]: Stopped app1.service. [ 202.053776] systemd[1]: app1.service: Consumed 2.183s CPU time. [ 202.125061] systemd[1]: Stopping app1.service... [ 202.611760] systemd[1]: Starting modprobe@dm_mod.service... [ 202.851031] systemd[1]: Starting modprobe@dm_verity.service... [ 202.909352] systemd[1]: Starting modprobe@loop.service... [ 203.198918] systemd[1]: Starting app1.service... [ 207.145494] kernel: audit: type=1130 audit(1663770336.105:428): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=testsuite-29 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=failed' [ 207.652545] systemd[1]: testsuite-29.service: Main process exited, code=exited, status=124/n/a [ 207.665088] systemd[1]: testsuite-29.service: Failed with result 'exit-code'. [ 207.830522] systemd[1]: Failed to start testsuite-29.service. ... [ 208.889449] script1.sh[1035]: ID="centos" [ 208.889449] script1.sh[1035]: VERSION_ID="8" [ 208.889449] script1.sh[1035]: SYSEXT_SCOPE=portable [ 208.889449] script1.sh[1035]: PORTABLE_PREFIXES=app1 ... [ 214.155097] systemd[1]: app1.service: Deactivated successfully. ``` Spotted in Ubuntu CI and CentOS CI. Follow-up to 706c9a30ac.
2022-09-29 14:23:11 +02:00
STATE_DIRECTORY=/var/lib/
fi
export STATE_DIRECTORY
export SYSTEMD_LOG_LEVEL=debug
export SYSTEMD_DISSECT_VERITY_TIMEOUT_SEC=30
# Quick smoke tests
systemd-dissect --no-pager /usr/share/minimal_0.raw | grep -q '✓ portable service'
systemd-dissect --no-pager /usr/share/minimal_1.raw | grep -q '✓ portable service'
systemd-dissect --no-pager /tmp/app0.raw | grep -q '✓ sysext for portable service'
systemd-dissect --no-pager /tmp/app1.raw | grep -q '✓ sysext for portable service'
systemd-dissect --no-pager /tmp/conf0.raw | grep -q '✓ confext for portable service'
# Lack of ID field in os-release should be rejected, but it caused a crash in the past instead
mkdir -p /tmp/emptyroot/usr/lib
mkdir -p /tmp/emptyext/usr/lib/extension-release.d
touch /tmp/emptyroot/usr/lib/os-release
touch /tmp/emptyext/usr/lib/extension-release.d/extension-release.emptyext
# Remote peer disconnected -> portabled crashed
res="$(! portablectl attach --extension /tmp/emptyext /tmp/emptyroot 2> >(grep "Remote peer disconnected"))"
test -z "${res}"
: "Run subtests"
run_subtests
touch /testok