mirror of
https://github.com/systemd/systemd.git
synced 2025-03-08 08:58:27 +03:00
Merge pull request #28835 from mrc0mmand/more-tests
test: add coverage for #27953
This commit is contained in:
commit
e158e17299
7
test/testsuite-07.units/issue27953.service
Normal file
7
test/testsuite-07.units/issue27953.service
Normal file
@ -0,0 +1,7 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Unit]
|
||||
Description=This unit should not remain active once the shell process exits
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=sh -c 'sleep infinity & exit 0'
|
@ -13,8 +13,6 @@ if [[ -n "${ASAN_OPTIONS:-}" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
systemd-analyze log-level debug
|
||||
|
||||
systemctl start issue14566-repro
|
||||
sleep 4
|
||||
systemctl status issue14566-repro
|
||||
@ -28,4 +26,4 @@ sleep 4
|
||||
# I personally prefer to see 42.
|
||||
ps -p "$leaked_pid" && exit 42
|
||||
|
||||
systemd-analyze log-level info
|
||||
exit 0
|
||||
|
11
test/units/testsuite-07.issue-27953.sh
Executable file
11
test/units/testsuite-07.issue-27953.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
set -eux
|
||||
set -o pipefail
|
||||
|
||||
# Check if the unit doesn't remain in active state after the main PID exits
|
||||
# Issue: https://github.com/systemd/systemd/issues/27953
|
||||
|
||||
systemctl start issue27953.service
|
||||
timeout 10 sh -c 'while systemctl is-active issue27953.service; do sleep .5; done'
|
||||
[[ "$(systemctl show -P ExitType issue27953.service)" == main ]]
|
@ -8,8 +8,6 @@ set -o pipefail
|
||||
# shellcheck source=test/units/util.sh
|
||||
. "$(dirname "$0")"/util.sh
|
||||
|
||||
systemd-analyze log-level debug
|
||||
|
||||
# The main service PID should be the parent bash process
|
||||
MAINPID="${PPID:?}"
|
||||
test "$(systemctl show -P MainPID testsuite-07.service)" -eq "$MAINPID"
|
||||
@ -172,5 +170,3 @@ test "$(systemctl show -P Result test-true.scope)" = success
|
||||
systemctl start user@4711.service
|
||||
runas testuser systemd-run --scope --user --unit test-true.scope /bin/true
|
||||
test "$(systemctl show -P Result test-true.scope)" = success
|
||||
|
||||
systemd-analyze log-level info
|
||||
|
@ -23,7 +23,7 @@ TMP_MOUNTINFO="$(mktemp)"
|
||||
|
||||
cp /proc/1/mountinfo "$TMP_MOUNTINFO"
|
||||
# Add a mount entry with a "Unicode non-character" in it
|
||||
echo -ne '69 1 252:2 / /foo/mountinfo rw,relatime shared:1 - cifs //foo\ufffebar rw,seclabel\n' >>"$TMP_MOUNTINFO"
|
||||
LANG="C.UTF-8" printf '69 1 252:2 / /foo/mountinfo rw,relatime shared:1 - cifs //foo\ufffebar rw,seclabel\n' >>"$TMP_MOUNTINFO"
|
||||
mount --bind "$TMP_MOUNTINFO" /proc/1/mountinfo
|
||||
systemctl daemon-reload
|
||||
# On affected versions this would throw an error:
|
||||
@ -42,12 +42,12 @@ rm -f "$TMP_MOUNTINFO"
|
||||
# a) Unit generated from /etc/fstab
|
||||
[[ -e /etc/fstab ]] && cp -f /etc/fstab /tmp/fstab.bak
|
||||
|
||||
echo -ne '//localhost/foo\ufffebar /foo/fstab cifs defaults 0 0\n' >/etc/fstab
|
||||
LANG="C.UTF-8" printf '//localhost/foo\ufffebar /foo/fstab cifs defaults 0 0\n' >/etc/fstab
|
||||
systemctl daemon-reload
|
||||
[[ "$(systemctl show -P UnitFileState foo-fstab.mount)" == bad ]]
|
||||
|
||||
# b) Unit generated from /etc/fstab (but the invalid character is in options)
|
||||
echo -ne '//localhost/foobar /foo/fstab/opt cifs nosuid,a\ufffeb,noexec 0 0\n' >/etc/fstab
|
||||
LANG="C.UTF-8" printf '//localhost/foobar /foo/fstab/opt cifs nosuid,a\ufffeb,noexec 0 0\n' >/etc/fstab
|
||||
systemctl daemon-reload
|
||||
[[ "$(systemctl show -P UnitFileState foo-fstab-opt.mount)" == bad ]]
|
||||
rm -f /etc/fstab
|
||||
@ -57,14 +57,14 @@ systemctl daemon-reload
|
||||
|
||||
# c) Mount unit
|
||||
mkdir -p /run/systemd/system
|
||||
echo -ne '[Mount]\nWhat=//localhost/foo\ufffebar\nWhere=/foo/unit\nType=cifs\nOptions=noexec\n' >/run/systemd/system/foo-unit.mount
|
||||
LANG="C.UTF-8" printf '[Mount]\nWhat=//localhost/foo\ufffebar\nWhere=/foo/unit\nType=cifs\nOptions=noexec\n' >/run/systemd/system/foo-unit.mount
|
||||
systemctl daemon-reload
|
||||
[[ "$(systemctl show -P UnitFileState foo-unit.mount)" == bad ]]
|
||||
rm -f /run/systemd/system/foo-unit.mount
|
||||
|
||||
# d) Mount unit (but the invalid character is in Options=)
|
||||
mkdir -p /run/systemd/system
|
||||
echo -ne '[Mount]\nWhat=//localhost/foobar\nWhere=/foo/unit/opt\nType=cifs\nOptions=noexec,a\ufffeb,nosuid\n' >/run/systemd/system/foo-unit-opt.mount
|
||||
LANG="C.UTF-8" printf '[Mount]\nWhat=//localhost/foobar\nWhere=/foo/unit/opt\nType=cifs\nOptions=noexec,a\ufffeb,nosuid\n' >/run/systemd/system/foo-unit-opt.mount
|
||||
systemctl daemon-reload
|
||||
[[ "$(systemctl show -P UnitFileState foo-unit-opt.mount)" == bad ]]
|
||||
rm -f /run/systemd/system/foo-unit-opt.mount
|
||||
|
Loading…
x
Reference in New Issue
Block a user