]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: move TEST-24-UNIT-TESTS setup to static files
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 10 Dec 2019 14:31:09 +0000 (15:31 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 28 Mar 2020 10:46:47 +0000 (11:46 +0100)
I picked the list of zone files to install by grepping through the code. This
is is a bit brittle, but installing all of them takes a while, and more
importantly, writes a lot of lines to the log.

test/TEST-24-UNIT-TESTS/test.sh
test/test-functions
test/units/testsuite-24.service [new file with mode: 0644]
test/units/testsuite-24.sh [moved from test/TEST-24-UNIT-TESTS/testsuite.sh with 92% similarity]

index c9198fb6c7157bf8beeeda255e591585342b1881..7b07a9ee5cb76ad0f906e33c7bdee579ee30bc05 100755 (executable)
@@ -65,37 +65,10 @@ test_setup() {
         LOG_LEVEL=5
         eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
 
-        for i in getfacl dirname basename capsh cut rev stat mktemp rmdir ionice unshare uname tr awk getent diff xzcat lz4cat; do
-            inst_binary $i
-        done
-
-        inst /etc/hosts
-
         setup_basic_environment
-        install_keymaps yes
-        install_zoneinfo
-        # Install nproc to determine # of CPUs for correct parallelization
-        inst_binary nproc
-
-        # 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
+        mask_supporting_services
     )
     setup_nspawn_root
-
-    # mask some services that we do not want to run in these tests
-    ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.service
-    ln -fs /dev/null $initdir/etc/systemd/system/systemd-networkd.socket
-    ln -fs /dev/null $initdir/etc/systemd/system/systemd-resolved.service
 }
 
-do_test "$@"
+do_test "$@" 24
index 9eef9a63fbf699be0cb71234fd94191617f4c49d..70e3e75be3d1222898406539b8b2c279f3207d8d 100644 (file)
@@ -40,37 +40,51 @@ PATH_TO_INIT=$ROOTLIBDIR/systemd
 [ "$JOURNALCTL" ] || JOURNALCTL=$(which -a $BUILD_DIR/journalctl journalctl 2>/dev/null | grep '^/' -m1)
 
 BASICTOOLS=(
+    awk
+    basename
     bash
     busybox
+    capsh
     cat
     chmod
     chown
     cmp
     cryptsetup
+    cut
     date
+    dd
+    diff
+    dirname
     dmsetup
     echo
     env
     false
+    getent
+    getfacl
+    gunzip
     gzip
     head
+    ionice
     ip
     ln
     loadkeys
     login
+    lz4cat
     mkfifo
     mktemp
     modprobe
     mount
     mv
     nc
+    nproc
     readlink
+    rev
     rm
     rmdir
     sed
+    seq
     setfont
     setsid
-    seq
     sh
     sleep
     socat
@@ -81,10 +95,13 @@ BASICTOOLS=(
     tee
     test
     touch
+    tr
     true
     umount
+    uname
     unshare
     xargs
+    xzcat
 )
 
 DEBUGTOOLS=(
@@ -385,6 +402,7 @@ setup_basic_environment() {
     install_systemd
     install_missing_libraries
     install_config_files
+    install_zoneinfo
     create_rc_local
     install_basic_tools
     install_libnss
@@ -964,10 +982,16 @@ install_keymaps() {
 }
 
 install_zoneinfo() {
-    for i in /usr/share/zoneinfo/{,*/,*/*/}*; do
-        [[ -f $i ]] || continue
-        inst $i
-    done
+    inst_any /usr/share/zoneinfo/Asia/Seoul
+    inst_any /usr/share/zoneinfo/Asia/Vladivostok
+    inst_any /usr/share/zoneinfo/Australia/Sydney
+    inst_any /usr/share/zoneinfo/Europe/Berlin
+    inst_any /usr/share/zoneinfo/Europe/Kiev
+    inst_any /usr/share/zoneinfo/Pacific/Auckland
+    inst_any /usr/share/zoneinfo/Pacific/Honolulu
+    inst_any /usr/share/zoneinfo/CET
+    inst_any /usr/share/zoneinfo/EET
+    inst_any /usr/share/zoneinfo/UTC
 }
 
 install_fonts() {
diff --git a/test/units/testsuite-24.service b/test/units/testsuite-24.service
new file mode 100644 (file)
index 0000000..de53f03
--- /dev/null
@@ -0,0 +1,6 @@
+[Unit]
+Description=TEST-24-UNIT-TESTS
+
+[Service]
+ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
+Type=oneshot
similarity index 92%
rename from test/TEST-24-UNIT-TESTS/testsuite.sh
rename to test/units/testsuite-24.sh
index cc78adbbe94226ee3fa5d9d1b674b9b9154ab714..0e3cb154777a1b4bf218e66fb0d48cbacd1f4759 100755 (executable)
@@ -21,23 +21,23 @@ function report_result() {
 
     if [[ $ret -ne 0 && $ret != 77 ]]; then
         echo "$name failed with $ret"
-        echo "$name" >> /failed-tests
+        echo "$name" >>/failed-tests
         {
             echo "--- $name begin ---"
             cat "/$name.log"
             echo "--- $name end ---"
-        } >> /failed
+        } >>/failed
     elif [[ $ret == 77 ]]; then
         echo "$name skipped"
-        echo "$name" >> /skipped-tests
+        echo "$name" >>/skipped-tests
         {
             echo "--- $name begin ---"
             cat "/$name.log"
             echo "--- $name end ---"
-        } >> /skipped
+        } >>/skipped
     else
         echo "$name OK"
-        echo "$name" >> /testok
+        echo "$name" >>/testok
     fi
 
     systemd-cat echo "--- $name ---"
@@ -69,7 +69,7 @@ for task in "${TEST_LIST[@]}"; do
 
     if [[ -x $task ]]; then
         log_file="/${task##*/}.log"
-        $task &> "$log_file" &
+        $task &>"$log_file" &
         running[$task]=$!
     fi
 done