test: move TEST-27-STDOUTFILE setup to static files
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 10 Dec 2019 08:19:13 +0000 (09:19 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 28 Mar 2020 10:46:47 +0000 (11:46 +0100)
test/TEST-27-STDOUTFILE/test.sh
test/TEST-27-STDOUTFILE/testsuite.sh [deleted file]
test/units/testsuite-27.service [new file with mode: 0644]
test/units/testsuite-27.sh [new file with mode: 0755]

index 66c98e5675a01fa82de921e8bde84b4ebf577f32..80c4b0920c84d4688ff0038afe504fb4cc75926d 100755 (executable)
@@ -13,22 +13,8 @@ test_setup() {
 
         setup_basic_environment
         mask_supporting_services
-        inst_binary cmp
-
-        # setup the testsuite service
-        cat >$initdir/etc/systemd/system/testsuite.service <<EOF
-[Unit]
-Description=Testsuite service
-
-[Service]
-ExecStart=/testsuite.sh
-Type=oneshot
-EOF
-        cp testsuite.sh $initdir/
-
-        setup_testsuite
     )
     setup_nspawn_root
 }
 
-do_test "$@"
+do_test "$@" 27
diff --git a/test/TEST-27-STDOUTFILE/testsuite.sh b/test/TEST-27-STDOUTFILE/testsuite.sh
deleted file mode 100755 (executable)
index c522f75..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/env bash
-set -ex
-set -o pipefail
-
-systemd-analyze log-level debug
-systemd-analyze log-target console
-
-systemd-run --wait --unit=one \
-            -p StandardOutput=file:/tmp/stdout \
-            -p StandardError=file:/tmp/stderr \
-            -p Type=exec \
-            sh -c 'echo x ; echo y >&2'
-cmp /tmp/stdout <<EOF
-x
-EOF
-cmp /tmp/stderr <<EOF
-y
-EOF
-
-systemd-run --wait --unit=two \
-            -p StandardOutput=file:/tmp/stdout \
-            -p StandardError=file:/tmp/stderr \
-            -p Type=exec \
-            sh -c 'echo z ; echo a >&2'
-cmp /tmp/stdout <<EOF
-z
-EOF
-cmp /tmp/stderr <<EOF
-a
-EOF
-
-systemd-run --wait --unit=three \
-            -p StandardOutput=append:/tmp/stdout \
-            -p StandardError=append:/tmp/stderr \
-            -p Type=exec \
-            sh -c 'echo b ; echo c >&2'
-cmp /tmp/stdout <<EOF
-z
-b
-EOF
-cmp /tmp/stderr <<EOF
-a
-c
-EOF
-
-systemd-analyze log-level info
-
-echo OK > /testok
-
-exit 0
diff --git a/test/units/testsuite-27.service b/test/units/testsuite-27.service
new file mode 100644 (file)
index 0000000..a1e8851
--- /dev/null
@@ -0,0 +1,6 @@
+[Unit]
+Description=TEST-27-STDOUTFILE
+
+[Service]
+ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
+Type=oneshot
diff --git a/test/units/testsuite-27.sh b/test/units/testsuite-27.sh
new file mode 100755 (executable)
index 0000000..9d92e6e
--- /dev/null
@@ -0,0 +1,50 @@
+#!/usr/bin/env bash
+set -ex
+set -o pipefail
+
+systemd-analyze log-level debug
+systemd-analyze log-target console
+
+systemd-run --wait --unit=test27-one \
+            -p StandardOutput=file:/tmp/stdout \
+            -p StandardError=file:/tmp/stderr \
+            -p Type=exec \
+            sh -c 'echo x ; echo y >&2'
+cmp /tmp/stdout <<EOF
+x
+EOF
+cmp /tmp/stderr <<EOF
+y
+EOF
+
+systemd-run --wait --unit=test27-two \
+            -p StandardOutput=file:/tmp/stdout \
+            -p StandardError=file:/tmp/stderr \
+            -p Type=exec \
+            sh -c 'echo z ; echo a >&2'
+cmp /tmp/stdout <<EOF
+z
+EOF
+cmp /tmp/stderr <<EOF
+a
+EOF
+
+systemd-run --wait --unit=test27-three \
+            -p StandardOutput=append:/tmp/stdout \
+            -p StandardError=append:/tmp/stderr \
+            -p Type=exec \
+            sh -c 'echo b ; echo c >&2'
+cmp /tmp/stdout <<EOF
+z
+b
+EOF
+cmp /tmp/stderr <<EOF
+a
+c
+EOF
+
+systemd-analyze log-level info
+
+echo OK >/testok
+
+exit 0