Commit c90feab4 authored by Michal Schmidt's avatar Michal Schmidt
Browse files

test: factor out testsuite.target, end.service

Tests can use the same testsuite.target.
Add end.service to call poweroff instead of doing it from ExecStopPost
where it may be skipped on failure of ExecStart.
parent e8a66f4a
...@@ -123,15 +123,8 @@ EOF ...@@ -123,15 +123,8 @@ EOF
LABEL=systemd / ext3 rw 0 1 LABEL=systemd / ext3 rw 0 1
EOF EOF
# setup the testsuite target # setup the testsuite target and the test ending service
cat >$initdir/etc/systemd/system/testsuite.target <<EOF cp $TEST_BASE_DIR/{testsuite.target,end.service} $initdir/etc/systemd/system/
[Unit]
Description=Testsuite target
Requires=multi-user.target
After=multi-user.target
Conflicts=rescue.target
AllowIsolate=yes
EOF
# setup the testsuite service # setup the testsuite service
cat >$initdir/etc/systemd/system/testsuite.service <<EOF cat >$initdir/etc/systemd/system/testsuite.service <<EOF
...@@ -141,11 +134,12 @@ After=multi-user.target ...@@ -141,11 +134,12 @@ After=multi-user.target
[Service] [Service]
ExecStart=/bin/bash -c 'set -x; systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok; while : ;do echo "testsuite service waiting for journal to move to /var/log/journal" > /dev/console ; for i in /var/log/journal/*;do [ -d "\$i" ] && echo "\$i" && break 2; done; sleep 1; done; sleep 1; exit 0;' ExecStart=/bin/bash -c 'set -x; systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok; while : ;do echo "testsuite service waiting for journal to move to /var/log/journal" > /dev/console ; for i in /var/log/journal/*;do [ -d "\$i" ] && echo "\$i" && break 2; done; sleep 1; done; sleep 1; exit 0;'
ExecStopPost=/usr/bin/systemctl poweroff --no-block
Type=oneshot Type=oneshot
EOF EOF
mkdir -p $initdir/etc/systemd/system/testsuite.target.wants mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
ln -fs ../end.service $initdir/etc/systemd/system/testsuite.target.wants/end.service
# make the testsuite the default target # make the testsuite the default target
ln -fs testsuite.target $initdir/etc/systemd/system/default.target ln -fs testsuite.target $initdir/etc/systemd/system/default.target
......
...@@ -122,15 +122,8 @@ LABEL=systemd / ext3 rw 0 1 ...@@ -122,15 +122,8 @@ LABEL=systemd / ext3 rw 0 1
/dev/mapper/varcrypt /var ext3 defaults 0 1 /dev/mapper/varcrypt /var ext3 defaults 0 1
EOF EOF
# setup the testsuite target # setup the testsuite target and the test ending service
cat >$initdir/etc/systemd/system/testsuite.target <<EOF cp $TEST_BASE_DIR/{testsuite.target,end.service} $initdir/etc/systemd/system/
[Unit]
Description=Testsuite target
Requires=multi-user.target
After=multi-user.target
Conflicts=rescue.target
AllowIsolate=yes
EOF
# setup the testsuite service # setup the testsuite service
cat >$initdir/etc/systemd/system/testsuite.service <<EOF cat >$initdir/etc/systemd/system/testsuite.service <<EOF
...@@ -140,11 +133,12 @@ After=multi-user.target ...@@ -140,11 +133,12 @@ After=multi-user.target
[Service] [Service]
ExecStart=/bin/bash -c 'set -x; systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok; while : ;do systemd-cat echo "testsuite service waiting for /var/log/journal" ; echo "testsuite service waiting for journal to move to /var/log/journal" > /dev/console ; for i in /var/log/journal/*;do [ -d "\$i" ] && echo "\$i" && break 2; done; sleep 1; done; sleep 1; exit 0;' ExecStart=/bin/bash -c 'set -x; systemctl --failed --no-legend --no-pager > /failed ; echo OK > /testok; while : ;do systemd-cat echo "testsuite service waiting for /var/log/journal" ; echo "testsuite service waiting for journal to move to /var/log/journal" > /dev/console ; for i in /var/log/journal/*;do [ -d "\$i" ] && echo "\$i" && break 2; done; sleep 1; done; sleep 1; exit 0;'
ExecStopPost=/usr/bin/systemctl poweroff --no-block
Type=oneshot Type=oneshot
EOF EOF
mkdir -p $initdir/etc/systemd/system/testsuite.target.wants mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
ln -fs ../end.service $initdir/etc/systemd/system/testsuite.target.wants/end.service
# make the testsuite the default target # make the testsuite the default target
ln -fs testsuite.target $initdir/etc/systemd/system/default.target ln -fs testsuite.target $initdir/etc/systemd/system/default.target
......
[Unit]
Description=End the test
After=testsuite.service
[Service]
ExecStart=/usr/bin/systemctl poweroff --no-block
[Unit]
Description=Testsuite target
Requires=multi-user.target
After=multi-user.target
Conflicts=rescue.target
AllowIsolate=yes
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment