]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: move TEST-15-DROPIN setup to static files
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 9 Dec 2019 22:29:18 +0000 (23:29 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 28 Mar 2020 10:46:47 +0000 (11:46 +0100)
Unfortunately the services needed to be renamed because of conflicts with other
services that exist in the shared dir.

test/TEST-15-DROPIN/test.sh
test/TEST-15-DROPIN/testsuite.service [deleted file]
test/units/testsuite-15.service [new file with mode: 0644]
test/units/testsuite-15.sh [moved from test/TEST-15-DROPIN/test-dropin.sh with 60% similarity]

index 63bbd3505174f4c7b1c1857bf803d4a4a0905f44..42d6c3dd79bb09664baac6bccc5604f843976588 100755 (executable)
@@ -10,13 +10,8 @@ test_setup() {
     setup_basic_environment
     mask_supporting_services
 
-    # import the test scripts in the rootfs and plug them in systemd
-    cp testsuite.service $initdir/etc/systemd/system/
-    cp test-dropin.sh    $initdir/
-    setup_testsuite
-
     # create dedicated rootfs for nspawn (located in $TESTDIR/nspawn-root)
     setup_nspawn_root
 }
 
-do_test "$@"
+do_test "$@" 15
diff --git a/test/TEST-15-DROPIN/testsuite.service b/test/TEST-15-DROPIN/testsuite.service
deleted file mode 100644 (file)
index 4c9f65e..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=Testsuite service
-
-[Service]
-ExecStart=/test-dropin.sh
-Type=oneshot
diff --git a/test/units/testsuite-15.service b/test/units/testsuite-15.service
new file mode 100644 (file)
index 0000000..2d07bd6
--- /dev/null
@@ -0,0 +1,6 @@
+[Unit]
+Description=TEST-15-DROPIN
+
+[Service]
+ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
+Type=oneshot
similarity index 60%
rename from test/TEST-15-DROPIN/test-dropin.sh
rename to test/units/testsuite-15.sh
index f80c9df1076a80c3535d24baf3b97980f639a316..c1d640a31c6a2983aa0388da13b5e447bf123a83 100755 (executable)
@@ -56,65 +56,65 @@ test_basic_dropins () {
     echo "Testing basic dropins..."
 
     echo "*** test a wants b wants c"
-    create_services a b c
-    ln -s ../b.service /etc/systemd/system/a.service.wants/
-    ln -s ../c.service /etc/systemd/system/b.service.wants/
-    check_ok a Wants b.service
-    check_ok b Wants c.service
+    create_services test15-a test15-b test15-c
+    ln -s ../test15-b.service /etc/systemd/system/test15-a.service.wants/
+    ln -s ../test15-c.service /etc/systemd/system/test15-b.service.wants/
+    check_ok test15-a Wants test15-b.service
+    check_ok test15-b Wants test15-c.service
 
     echo "*** test a wants,requires b"
-    create_services a b c
-    ln -s ../b.service /etc/systemd/system/a.service.wants/
-    ln -s ../b.service /etc/systemd/system/a.service.requires/
-    check_ok a Wants b.service
-    check_ok a Requires b.service
+    create_services test15-a test15-b test15-c
+    ln -s ../test15-b.service /etc/systemd/system/test15-a.service.wants/
+    ln -s ../test15-b.service /etc/systemd/system/test15-a.service.requires/
+    check_ok test15-a Wants test15-b.service
+    check_ok test15-a Requires test15-b.service
 
     echo "*** test a wants nonexistent"
-    create_service a
-    ln -s ../nonexistent.service /etc/systemd/system/a.service.wants/
-    check_ok a Wants nonexistent.service
-    systemctl start a
-    systemctl stop  a
+    create_service test15-a
+    ln -s ../nonexistent.service /etc/systemd/system/test15-a.service.wants/
+    check_ok test15-a Wants nonexistent.service
+    systemctl start test15-a
+    systemctl stop  test15-a
 
     echo "*** test a requires nonexistent"
-    ln -sf ../nonexistent.service /etc/systemd/system/a.service.requires/
+    ln -sf ../nonexistent.service /etc/systemd/system/test15-a.service.requires/
     systemctl daemon-reload
-    check_ok a Requires nonexistent.service
+    check_ok test15-a Requires nonexistent.service
 
     # 'b' is already loaded when 'c' pulls it in via a dropin.
     echo "*** test a,c require b"
-    create_services a b c
-    ln -sf ../b.service /etc/systemd/system/a.service.requires/
-    ln -sf ../b.service /etc/systemd/system/c.service.requires/
-    systemctl start a
-    check_ok c Requires b.service
-    systemctl stop b
+    create_services test15-a test15-b test15-c
+    ln -sf ../test15-b.service /etc/systemd/system/test15-a.service.requires/
+    ln -sf ../test15-b.service /etc/systemd/system/test15-c.service.requires/
+    systemctl start test15-a
+    check_ok test15-c Requires test15-b.service
+    systemctl stop test15-a test15-b
 
     # 'b'  is already loaded when 'c' pulls it in via an alias dropin.
     echo "*** test a wants alias"
-    create_services a b c
-    ln -sf c.service /etc/systemd/system/c1.service
-    ln -sf ../c.service  /etc/systemd/system/a.service.wants/
-    ln -sf ../c1.service /etc/systemd/system/b.service.wants/
-    systemctl start a
-    check_ok a Wants c.service
-    check_ok b Wants c.service
-    systemctl stop c
+    create_services test15-a test15-b test15-c
+    ln -sf test15-c.service /etc/systemd/system/test15-c1.service
+    ln -sf ../test15-c.service  /etc/systemd/system/test15-a.service.wants/
+    ln -sf ../test15-c1.service /etc/systemd/system/test15-b.service.wants/
+    systemctl start test15-a
+    check_ok test15-a Wants test15-c.service
+    check_ok test15-b Wants test15-c.service
+    systemctl stop test15-a test15-c
 
     echo "*** test service.d/ top level drop-in"
-    create_services b
-    check_ko a ExecCondition "/bin/echo a"
-    check_ko b ExecCondition "/bin/echo b"
+    create_services test15-a test15-b
+    check_ko test15-a ExecCondition "/bin/echo a"
+    check_ko test15-b ExecCondition "/bin/echo b"
     mkdir -p /usr/lib/systemd/system/service.d
     cat >/usr/lib/systemd/system/service.d/override.conf <<EOF
 [Service]
 ExecCondition=/bin/echo %n
 EOF
-    check_ok a ExecCondition "/bin/echo a"
-    check_ok b ExecCondition "/bin/echo b"
+    check_ok test15-a ExecCondition "/bin/echo test15-a"
+    check_ok test15-b ExecCondition "/bin/echo test15-b"
     rm -rf /usr/lib/systemd/system/service.d
 
-    clear_services a b c
+    clear_services test15-a test15-b test15-c
 }
 
 test_hierarchical_dropins () {
@@ -294,153 +294,153 @@ test_alias_dropins () {
     echo "Testing alias dropins..."
 
     echo "*** test a wants b1 alias of b"
-    create_services b
-    ln -sf b.service /etc/systemd/system/b1.service
-    ln -sf ../b1.service /etc/systemd/system/a.service.wants/
-    check_ok a Wants b.service
-    systemctl start a
-    systemctl --quiet is-active b
-    systemctl stop b
-    rm /etc/systemd/system/b1.service
-    clear_services b
+    create_services test15-a test15-b
+    ln -sf test15-b.service /etc/systemd/system/test15-b1.service
+    ln -sf ../test15-b1.service /etc/systemd/system/test15-a.service.wants/
+    check_ok test15-a Wants test15-b.service
+    systemctl start test15-a
+    systemctl --quiet is-active test15-b
+    systemctl stop test15-a test15-b
+    rm /etc/systemd/system/test15-b1.service
+    clear_services test15-a test15-b
 
     # Check that dependencies don't vary.
     echo "*** test 2"
-    create_services a x y
-    mkdir -p /etc/systemd/system/a1.service.wants/
-    ln -sf a.service /etc/systemd/system/a1.service
-    ln -sf ../x.service /etc/systemd/system/a.service.wants/
-    ln -sf ../y.service /etc/systemd/system/a1.service.wants/
-    check_ok a1 Wants x.service # see [1]
-    check_ok a1 Wants y.service
-    systemctl start a
-    check_ok a1 Wants x.service # see [2]
-    check_ok a1 Wants y.service
-    systemctl stop a x y
-    rm /etc/systemd/system/a1.service
-
-    clear_services a x y
+    create_services test15-a test15-x test15-y
+    mkdir -p /etc/systemd/system/test15-a1.service.wants/
+    ln -sf test15-a.service /etc/systemd/system/test15-a1.service
+    ln -sf ../test15-x.service /etc/systemd/system/test15-a.service.wants/
+    ln -sf ../test15-y.service /etc/systemd/system/test15-a1.service.wants/
+    check_ok test15-a1 Wants test15-x.service # see [1]
+    check_ok test15-a1 Wants test15-y.service
+    systemctl start test15-a
+    check_ok test15-a1 Wants test15-x.service # see [2]
+    check_ok test15-a1 Wants test15-y.service
+    systemctl stop test15-a test15-x test15-y
+    rm /etc/systemd/system/test15-a1.service
+
+    clear_services test15-a test15-x test15-y
 }
 
 test_masked_dropins () {
     echo "Testing masked dropins..."
 
-    create_services b
+    create_services test15-a test15-b
 
     # 'b' is masked for both deps
     echo "*** test a wants,requires b is masked"
-    ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
-    ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service
-    check_ko a Wants b.service
-    check_ko a Requires b.service
+    ln -sf /dev/null /etc/systemd/system/test15-a.service.wants/test15-b.service
+    ln -sf /dev/null /etc/systemd/system/test15-a.service.requires/test15-b.service
+    check_ko test15-a Wants test15-b.service
+    check_ko test15-a Requires test15-b.service
 
     # 'a' wants 'b' and 'b' is masked at a lower level
     echo "*** test a wants b, mask override"
-    ln -sf ../b.service /etc/systemd/system/a.service.wants/b.service
-    ln -sf /dev/null /usr/lib/systemd/system/a.service.wants/b.service
-    check_ok a Wants b.service
+    ln -sf ../test15-b.service /etc/systemd/system/test15-a.service.wants/test15-b.service
+    ln -sf /dev/null /usr/lib/systemd/system/test15-a.service.wants/test15-b.service
+    check_ok test15-a Wants test15-b.service
 
     # 'a' wants 'b' and 'b' is masked at a higher level
     echo "*** test a wants b, mask"
-    ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
-    ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service
-    check_ko a Wants b.service
+    ln -sf /dev/null /etc/systemd/system/test15-a.service.wants/test15-b.service
+    ln -sf ../test15-b.service /usr/lib/systemd/system/test15-a.service.wants/test15-b.service
+    check_ko test15-a Wants test15-b.service
 
     # 'a' is masked but has an override config file
     echo "*** test a is masked but has an override"
-    create_services b
-    ln -sf /dev/null /etc/systemd/system/a.service
-    cat >/usr/lib/systemd/system/a.service.d/override.conf <<EOF
+    create_services test15-a test15-b
+    ln -sf /dev/null /etc/systemd/system/test15-a.service
+    cat >/usr/lib/systemd/system/test15-a.service.d/override.conf <<EOF
 [Unit]
-After=b.service
+After=test15-b.service
 EOF
-    check_ok a UnitFileState masked
+    check_ok test15-a UnitFileState masked
 
     # 'b1' is an alias for 'b': masking 'b' dep should not influence 'b1' dep
     echo "*** test a wants b, b1, and one is masked"
-    create_services b
-    ln -sf b.service /etc/systemd/system/b1.service
-    ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
-    ln -sf ../b1.service /usr/lib/systemd/system/a.service.wants/b1.service
-    systemctl cat a
-    systemctl show -p Wants,Requires a
-    systemctl cat b1
-    systemctl show -p Wants,Requires b1
-    check_ok a Wants b.service
-    check_ko a Wants b1.service # the alias does not show up in the list of units
-    rm /etc/systemd/system/b1.service
+    create_services test15-a test15-b
+    ln -sf test15-b.service /etc/systemd/system/test15-b1.service
+    ln -sf /dev/null /etc/systemd/system/test15-a.service.wants/test15-b.service
+    ln -sf ../test15-b1.service /usr/lib/systemd/system/test15-a.service.wants/test15-b1.service
+    systemctl cat test15-a
+    systemctl show -p Wants,Requires test15-a
+    systemctl cat test15-b1
+    systemctl show -p Wants,Requires test15-b1
+    check_ok test15-a Wants test15-b.service
+    check_ko test15-a Wants test15-b1.service # the alias does not show up in the list of units
+    rm /etc/systemd/system/test15-b1.service
 
     # 'b1' is an alias for 'b': masking 'b1' should not influence 'b' dep
     echo "*** test a wants b, alias dep is masked"
-    create_services b
-    ln -sf b.service /etc/systemd/system/b1.service
-    ln -sf /dev/null /etc/systemd/system/a.service.wants/b1.service
-    ln -sf ../b.service /usr/lib/systemd/system/a.service.wants/b.service
-    check_ok a Wants b.service
-    check_ko a Wants b1.service # the alias does not show up in the list of units
-    rm /etc/systemd/system/b1.service
+    create_services test15-a test15-b
+    ln -sf test15-b.service /etc/systemd/system/test15-b1.service
+    ln -sf /dev/null /etc/systemd/system/test15-a.service.wants/test15-b1.service
+    ln -sf ../test15-b.service /usr/lib/systemd/system/test15-a.service.wants/test15-b.service
+    check_ok test15-a Wants test15-b.service
+    check_ko test15-a Wants test15-b1.service # the alias does not show up in the list of units
+    rm /etc/systemd/system/test15-b1.service
 
     # 'a' has Wants=b.service but also has a masking
     # dropin 'b': 'b' should still be pulled in.
     echo "*** test a wants b both ways"
-    create_services b
-    ln -sf /dev/null /etc/systemd/system/a.service.wants/b.service
-    cat >/usr/lib/systemd/system/a.service.d/wants-b.conf<<EOF
+    create_services test15-a test15-b
+    ln -sf /dev/null /etc/systemd/system/test15-a.service.wants/test15-b.service
+    cat >/usr/lib/systemd/system/test15-a.service.d/wants-b.conf<<EOF
 [Unit]
-Wants=b.service
+Wants=test15-b.service
 EOF
-    check_ok a Wants b.service
+    check_ok test15-a Wants test15-b.service
 
     # mask a dropin that points to an nonexistent unit.
     echo "*** test a wants nonexistent is masked"
-    create_services a
-    ln -sf /dev/null /etc/systemd/system/a.service.requires/nonexistent.service
-    ln -sf ../nonexistent.service /usr/lib/systemd/system/a.service.requires/
-    check_ko a Requires nonexistent.service
+    create_services test15-a
+    ln -sf /dev/null /etc/systemd/system/test15-a.service.requires/nonexistent.service
+    ln -sf ../nonexistent.service /usr/lib/systemd/system/test15-a.service.requires/
+    check_ko test15-a Requires nonexistent.service
 
     # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is
     # masked at a higher level.
     echo "*** test a wants b is masked"
-    create_services a b c
-    ln -sf ../b.service /etc/systemd/system/a.service.requires/
-    ln -sf ../b.service /run/systemd/system/c.service.requires/
-    ln -sf /dev/null /etc/systemd/system/c.service.requires/b.service
-    systemctl start a
-    check_ko c Requires b.service
-    systemctl stop b
+    create_services test15-a test15-b test15-c
+    ln -sf ../test15-b.service /etc/systemd/system/test15-a.service.requires/
+    ln -sf ../test15-b.service /run/systemd/system/test15-c.service.requires/
+    ln -sf /dev/null /etc/systemd/system/test15-c.service.requires/test15-b.service
+    systemctl start test15-a
+    check_ko test15-c Requires test15-b.service
+    systemctl stop test15-a test15-b
 
     # 'b' is already loaded when 'c' pulls it in via a dropin but 'b' is
     # masked at a lower level.
     echo "*** test a requires b is masked"
-    create_services a b c
-    ln -sf ../b.service /etc/systemd/system/a.service.requires/
-    ln -sf ../b.service /etc/systemd/system/c.service.requires/
-    ln -sf /dev/null /run/systemd/system/c.service.requires/b.service
-    systemctl start a
-    check_ok c Requires b.service
-    systemctl stop b
+    create_services test15-a test15-b test15-c
+    ln -sf ../test15-b.service /etc/systemd/system/test15-a.service.requires/
+    ln -sf ../test15-b.service /etc/systemd/system/test15-c.service.requires/
+    ln -sf /dev/null /run/systemd/system/test15-c.service.requires/test15-b.service
+    systemctl start test15-a
+    check_ok test15-c Requires test15-b.service
+    systemctl stop test15-a test15-b
 
     # 'a' requires 2 aliases of 'b' and one of them is a mask.
     echo "*** test a requires alias of b, other alias masked"
-    create_services b
-    ln -sf b.service /etc/systemd/system/b1.service
-    ln -sf b.service /etc/systemd/system/b2.service
-    ln -sf /dev/null /etc/systemd/system/a.service.requires/b1.service
-    ln -sf ../b1.service /run/systemd/system/a.service.requires/
-    ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/
-    check_ok a Requires b
+    create_services test15-a test15-b
+    ln -sf test15-b.service /etc/systemd/system/test15-b1.service
+    ln -sf test15-b.service /etc/systemd/system/test15-b2.service
+    ln -sf /dev/null /etc/systemd/system/test15-a.service.requires/test15-b1.service
+    ln -sf ../test15-b1.service /run/systemd/system/test15-a.service.requires/
+    ln -sf ../test15-b2.service /usr/lib/systemd/system/test15-a.service.requires/
+    check_ok test15-a Requires test15-b
 
     # Same as above but now 'b' is masked.
     echo "*** test a requires alias of b, b dep masked"
-    create_services b
-    ln -sf b.service /etc/systemd/system/b1.service
-    ln -sf b.service /etc/systemd/system/b2.service
-    ln -sf ../b1.service /run/systemd/system/a.service.requires/
-    ln -sf ../b2.service /usr/lib/systemd/system/a.service.requires/
-    ln -sf /dev/null /etc/systemd/system/a.service.requires/b.service
-    check_ok a Requires b
-
-    clear_services b
+    create_services test15-a test15-b
+    ln -sf test15-b.service /etc/systemd/system/test15-b1.service
+    ln -sf test15-b.service /etc/systemd/system/test15-b2.service
+    ln -sf ../test15-b1.service /run/systemd/system/test15-a.service.requires/
+    ln -sf ../test15-b2.service /usr/lib/systemd/system/test15-a.service.requires/
+    ln -sf /dev/null /etc/systemd/system/test15-a.service.requires/test15-b.service
+    check_ok test15-a Requires test15-b
+
+    clear_services test15-a test15-b
 }
 
 test_invalid_dropins () {