mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
test: move TEST-12-ISSUE-3171 setup to static files
This commit is contained in:
parent
3ac189d8aa
commit
d10029bba4
@ -15,75 +15,9 @@ test_setup() {
|
||||
|
||||
setup_basic_environment
|
||||
mask_supporting_services
|
||||
dracut_install cat mv stat nc
|
||||
|
||||
# setup the testsuite service
|
||||
cat >$initdir/etc/systemd/system/testsuite.service <<EOF
|
||||
[Unit]
|
||||
Description=Testsuite service
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/test-socket-group.sh
|
||||
Type=oneshot
|
||||
EOF
|
||||
|
||||
cat >$initdir/test-socket-group.sh <<'EOF'
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
U=/run/systemd/system/test.socket
|
||||
cat <<'EOL' >$U
|
||||
[Unit]
|
||||
Description=Test socket
|
||||
[Socket]
|
||||
Accept=yes
|
||||
ListenStream=/run/test.socket
|
||||
SocketGroup=adm
|
||||
SocketMode=0660
|
||||
EOL
|
||||
|
||||
cat <<'EOL' > /run/systemd/system/test@.service
|
||||
[Unit]
|
||||
Description=Test service
|
||||
[Service]
|
||||
StandardInput=socket
|
||||
ExecStart=/bin/sh -x -c cat
|
||||
EOL
|
||||
|
||||
systemctl start test.socket
|
||||
systemctl is-active test.socket
|
||||
[[ "$(stat --format='%G' /run/test.socket)" == adm ]]
|
||||
echo A | nc -w1 -U /run/test.socket
|
||||
|
||||
mv $U ${U}.disabled
|
||||
systemctl daemon-reload
|
||||
systemctl is-active test.socket
|
||||
[[ "$(stat --format='%G' /run/test.socket)" == adm ]]
|
||||
echo B | nc -w1 -U /run/test.socket && exit 1
|
||||
|
||||
mv ${U}.disabled $U
|
||||
systemctl daemon-reload
|
||||
systemctl is-active test.socket
|
||||
echo C | nc -w1 -U /run/test.socket && exit 1
|
||||
[[ "$(stat --format='%G' /run/test.socket)" == adm ]]
|
||||
|
||||
systemctl restart test.socket
|
||||
systemctl is-active test.socket
|
||||
echo D | nc -w1 -U /run/test.socket
|
||||
[[ "$(stat --format='%G' /run/test.socket)" == adm ]]
|
||||
|
||||
|
||||
touch /testok
|
||||
EOF
|
||||
|
||||
chmod 0755 $initdir/test-socket-group.sh
|
||||
setup_testsuite
|
||||
)
|
||||
|
||||
setup_nspawn_root
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
do_test "$@" 12
|
||||
|
@ -58,6 +58,8 @@ BASICTOOLS=(
|
||||
login
|
||||
modprobe
|
||||
mount
|
||||
mv
|
||||
nc
|
||||
rm
|
||||
sed
|
||||
setfont
|
||||
@ -65,6 +67,7 @@ BASICTOOLS=(
|
||||
sh
|
||||
sleep
|
||||
socat
|
||||
stat
|
||||
sulogin
|
||||
tail
|
||||
tee
|
||||
@ -91,7 +94,6 @@ DEBUGTOOLS=(
|
||||
ln
|
||||
ls
|
||||
mkdir
|
||||
mv
|
||||
ping
|
||||
ps
|
||||
route
|
||||
|
7
test/units/testsuite-12.service
Normal file
7
test/units/testsuite-12.service
Normal file
@ -0,0 +1,7 @@
|
||||
[Unit]
|
||||
Description=TEST-12-ISSUE-3171
|
||||
After=multi-user.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
|
||||
Type=oneshot
|
47
test/units/testsuite-12.sh
Executable file
47
test/units/testsuite-12.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
U=/run/systemd/system/test12.socket
|
||||
cat <<'EOF' >$U
|
||||
[Unit]
|
||||
Description=Test 12 socket
|
||||
[Socket]
|
||||
Accept=yes
|
||||
ListenStream=/run/test12.socket
|
||||
SocketGroup=adm
|
||||
SocketMode=0660
|
||||
EOF
|
||||
|
||||
cat <<'EOF' > /run/systemd/system/test12@.service
|
||||
[Unit]
|
||||
Description=Test service
|
||||
[Service]
|
||||
StandardInput=socket
|
||||
ExecStart=/bin/sh -x -c cat
|
||||
EOF
|
||||
|
||||
systemctl start test12.socket
|
||||
systemctl is-active test12.socket
|
||||
[[ "$(stat --format='%G' /run/test12.socket)" == adm ]]
|
||||
echo A | nc -w1 -U /run/test12.socket
|
||||
|
||||
mv $U ${U}.disabled
|
||||
systemctl daemon-reload
|
||||
systemctl is-active test12.socket
|
||||
[[ "$(stat --format='%G' /run/test12.socket)" == adm ]]
|
||||
echo B | nc -w1 -U /run/test12.socket && exit 1
|
||||
|
||||
mv ${U}.disabled $U
|
||||
systemctl daemon-reload
|
||||
systemctl is-active test12.socket
|
||||
echo C | nc -w1 -U /run/test12.socket && exit 1
|
||||
[[ "$(stat --format='%G' /run/test12.socket)" == adm ]]
|
||||
|
||||
systemctl restart test12.socket
|
||||
systemctl is-active test12.socket
|
||||
echo D | nc -w1 -U /run/test12.socket
|
||||
[[ "$(stat --format='%G' /run/test12.socket)" == adm ]]
|
||||
|
||||
touch /testok
|
Loading…
Reference in New Issue
Block a user