2020-03-04 09:35:06 +00:00
#!/usr/bin/env bash
2021-10-17 18:13:06 +02:00
# 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
2021-04-09 19:39:41 +02:00
set -eux
2019-03-07 14:47:43 +09:00
set -o pipefail
2024-09-14 21:46:38 +02:00
# shellcheck source=test/units/test-control.sh
. " $( dirname " $0 " ) " /test-control.sh
2024-04-24 21:21:34 +02:00
# shellcheck source=test/units/util.sh
. " $( dirname " $0 " ) " /util.sh
install_extension_images
2022-08-31 23:10:43 +09:00
# 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
2022-09-03 18:51:56 +02:00
[ Manager]
2022-08-31 23:10:43 +09:00
DefaultEnvironment = SYSTEMD_DISSECT_VERITY_TIMEOUT_SEC = 30
ManagerEnvironment = SYSTEMD_DISSECT_VERITY_TIMEOUT_SEC = 30
EOF
2024-09-14 21:46:38 +02:00
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
2022-08-31 23:10:43 +09:00
systemctl daemon-reexec
2022-08-31 23:12:26 +09:00
udevadm control --log-level debug
2021-09-30 14:14:19 +02:00
ARGS = ( )
2022-09-29 14:23:11 +02:00
STATE_DIRECTORY = /var/lib/private/
2021-09-30 14:14:19 +02:00
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)
2022-01-27 14:10:34 +00:00
# With the trusted profile DynamicUser is disabled, so the storage is not in private/
2022-09-29 14:23:11 +02:00
STATE_DIRECTORY = /var/lib/
2021-09-30 14:14:19 +02:00
fi
2024-09-14 21:46:38 +02:00
export STATE_DIRECTORY
export SYSTEMD_LOG_LEVEL = debug
2024-09-15 16:19:57 +02:00
export SYSTEMD_DISSECT_VERITY_TIMEOUT_SEC = 30
2024-09-14 21:46:38 +02:00
# Quick smoke tests
2021-09-30 14:14:19 +02:00
2021-11-23 16:34:40 +01:00
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'
2024-04-24 21:21:34 +02:00
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'
2021-11-23 16:34:40 +01:00
2022-05-20 12:24:45 +01:00
# 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 } "
2024-09-14 21:46:38 +02:00
: "Run subtests"
run_subtests
2023-07-12 15:49:55 +02:00
touch /testok