File 0009-test-functions-adapt-for-systemd-testsuite-package.patch of Package systemd-v234-testsuite

From 5f97306f5dc30fef0c8d979bbe22d95861a23170 Mon Sep 17 00:00:00 2001
From: Thomas Blume <thomas.blume@suse.com>
Date: Tue, 9 Apr 2019 09:58:58 +0200
Subject: [PATCH] test-functions: adapt for systemd-testsuite package

---
 test/test-functions | 127 +++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 95 insertions(+), 32 deletions(-)

diff --git a/test/test-functions b/test/test-functions
index b704d5be63..f68201c43a 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -20,10 +20,10 @@ if ! ROOTLIBDIR=$(pkg-config --variable=systemdutildir systemd); then
     ROOTLIBDIR=/usr/lib/systemd
 fi
 
-BASICTOOLS="sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm"
+BASICTOOLS="sh bash setsid loadkeys setfont login sulogin gzip sleep echo mount umount cryptsetup date dmsetup modprobe sed cmp tee rm passwd wc"
 DEBUGTOOLS="df free ls stty cat ps ln ip route dmesg dhclient mkdir cp ping dhclient strace less grep id tty touch du sort hostname find"
 
-STATEDIR="${BUILD_DIR:-.}/test/$(basename $(dirname $(realpath $0)))"
+STATEDIR="."
 STATEFILE="$STATEDIR/.testdir"
 TESTLOG="$STATEDIR/test.log"
 
@@ -34,9 +34,9 @@ function find_qemu_bin() {
 
     [ "$ARCH" ] || ARCH=$(uname -m)
     case $ARCH in
-    x86_64)
+    x86_64|s390x|aarch64)
         # QEMU's own build system calls it qemu-system-x86_64
-        [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a qemu-system-x86_64 2>/dev/null | grep '^/' -m1)
+        [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a qemu-system-$ARCH 2>/dev/null | grep '^/' -m1)
         ;;
     i*86)
         # new i386 version of QEMU
@@ -46,7 +46,7 @@ function find_qemu_bin() {
         [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a qemu 2>/dev/null | grep '^/' -m1)
         ;;
     ppc64*)
-        [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a qemu-system-$ARCH 2>/dev/null | grep '^/' -m1)
+        [ "$QEMU_BIN" ] || QEMU_BIN=$(which -a qemu-system-ppc64 2>/dev/null | grep '^/' -m1)
         ;;
     esac
 
@@ -70,6 +70,15 @@ run_qemu() {
     if [[ ! "$KERNEL_BIN" ]]; then
         if [[ "$LOOKS_LIKE_ARCH" ]]; then
             KERNEL_BIN=/boot/vmlinuz-linux
+       elif [[ "$LOOKS_LIKE_SUSE" ]]; then
+            if [[ $(uname -m) == "aarch64" ]]; then
+                KERNEL_BIN=$(ls /boot/Image-$KERNEL_VER)
+            elif [[ $(uname -m) == "s390x" ]]; then
+                KERNEL_BIN=$(ls /boot/zipl/image-$KERNEL_VER)
+                default_suse_initrd=/boot/zipl/initrd-${KERNEL_VER}
+            else
+                KERNEL_BIN=$(ls /boot/vmlinu*-$KERNEL_VER)
+            fi
         else
             KERNEL_BIN=/boot/vmlinuz-$KERNEL_VER
         fi
@@ -78,7 +87,7 @@ run_qemu() {
     default_fedora_initrd=/boot/initramfs-${KERNEL_VER}.img
     default_debian_initrd=/boot/initrd.img-${KERNEL_VER}
     default_arch_initrd=/boot/initramfs-linux.img
-    default_suse_initrd=/boot/initrd-${KERNEL_VER}
+    [[ -e "$default_suse_initrd" ]] || default_suse_initrd=/boot/initrd-${KERNEL_VER}
     if [[ ! "$INITRD" ]]; then
         if [[ -e "$default_fedora_initrd" ]]; then
             INITRD="$default_fedora_initrd"
@@ -107,37 +116,65 @@ run_qemu() {
         exit 1
     fi
 
-if [[ "$LOOKS_LIKE_SUSE" ]]; then
-    PARAMS+="rd.hostonly=0"
-else
-    PARAMS+="ro"
-fi
+    DRIVEOPTS="file=${TESTDIR}/rootdisk.img,format=raw,cache=unsafe"
+    if [[ "$LOOKS_LIKE_SUSE" ]]; then
+        PARAMS="rd.hostonly=0 multipath=off systemd.mask=vboxdrv.service systemd.mask=vboxes.service systemd.mask=iscsiuio.socket systemd.mask=iscsid.socket console=ttyS0 rd.debug"
+        case $ARCH in
+        aarch64)
+            PARAMS+=" console=ttyAMA0"
+            DRIVEOPTS+=",if=none,id=hd0"
+            QEMUOPTS=" -cpu cortex-a57 -M virt"
+            DEVICEOPTS="-device ahci,id=ahci -device ide-hd,drive=hd0,bus=ahci.0 -device virtio-rng-pci"
+            ;;
+        ppc64*)
+            PARAMS+=" console=hvc0"
+            DRIVEOPTS+=",if=none,id=scsi0"
+            QEMUOPTS=" -M pseries"
+            DEVICEOPTS="-device virtio-rng-pci -device virtio-scsi-pci -device scsi-hd,drive=scsi0"
+            ;;
+        s390*)
+            DRIVEOPTS+=",if=none,id=scsi0"
+            QEMUOPTS=" -M s390-ccw-virtio"
+            S390ZIPLDEV=$(sed -n '/boot\/zipl/s/\([[:graph:]]*\).*/\1/p' /etc/fstab)
+            CHAN=$(echo $S390ZIPLDEV | sed -n 's/.*ccw-[0-9]\([[:graph:]]*\)-part.*/fe\1/p')
+	    DASDDEV=$(ls -l $S390ZIPLDEV | sed -n 's/.*\(vd[a-z]*\)[[:digit:]]*/\/dev\/\1/p')
+            DEVICEOPTS="-drive file=$DASDDEV,if=none,id=disk0,format=raw \
+		         -device virtio-blk-ccw,devno=$CHAN,drive=disk0 \
+			 -device virtio-scsi-ccw,id=scsi0 -device scsi-hd,drive=scsi0 \
+			 -device virtio-rng-ccw"
+	    ;;
+        *)
+            if [ -c /dev/kvm ]; then
+                QEMUOPTS="$QEMU_OPTIONS -accel kvm -enable-kvm"
+            fi
+	    ;;
+        esac
+    else
+        PARAMS+=" ro"
+    fi
 
 KERNEL_APPEND="$PARAMS \
 root=/dev/sda1 \
 raid=noautodetect \
 loglevel=2 \
 init=$ROOTLIBDIR/systemd \
-console=ttyS0 \
 selinux=0 \
 $_cgroup_args \
 $KERNEL_APPEND \
 "
 
-    QEMU_OPTIONS="-smp $QEMU_SMP \
+    QEMU_OPTIONS="$QEMUOPTS \
+-smp $QEMU_SMP \
 -net none \
 -m 512M \
 -nographic \
+-drive $DRIVEOPTS \
+$DEVICEOPTS \
 -kernel $KERNEL_BIN \
--drive format=raw,cache=unsafe,file=${TESTDIR}/rootdisk.img \
 "
 
     if [[ "$INITRD" && "$SKIP_INITRD" != "yes" ]]; then
-        QEMU_OPTIONS="$QEMU_OPTIONS -initrd $INITRD"
-    fi
-
-    if [ -c /dev/kvm ]; then
-        QEMU_OPTIONS="$QEMU_OPTIONS -machine accel=kvm -enable-kvm -cpu host"
+        QEMU_OPTIONS+=" -initrd $INITRD"
     fi
 
     if [[ "$QEMU_TIMEOUT" != "infinity" ]]; then
@@ -159,7 +196,7 @@ $KERNEL_APPEND \
 run_nspawn() {
     [[ -d /run/systemd/system ]] || return 1
 
-    local _nspawn_cmd="../../systemd-nspawn --register=no --kill-signal=SIGKILL --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND"
+    local _nspawn_cmd="/usr/bin/systemd-nspawn --register=no --kill-signal=SIGKILL --directory=$TESTDIR/nspawn-root $ROOTLIBDIR/systemd $KERNEL_APPEND"
     if [[ "$NSPAWN_TIMEOUT" != "infinity" ]]; then
         _nspawn_cmd="timeout --foreground $NSPAWN_TIMEOUT $_nspawn_cmd"
     fi
@@ -300,10 +337,10 @@ EOF
 
 install_fsck() {
     dracut_install /sbin/fsck*
-    dracut_install -o /bin/fsck*
-
-    # fskc.reiserfs calls reiserfsck. so, install it
-    dracut_install -o reiserfsck
+   
+    if rpm -q reiserfs; then 
+        dracut_install reiserfsck
+    fi 
 }
 
 install_dmevent() {
@@ -315,13 +352,36 @@ install_dmevent() {
         # see https://anonscm.debian.org/cgit/pkg-lvm/lvm2.git/tree/debian/patches/0007-udev.patch
         inst_rules 55-dm.rules 60-persistent-storage-dm.rules
     else
-        inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
+        inst_rules 10-dm.rules 13-dm-disk.rules 95-dm-notify.rules 60-persistent-storage.rules 61-persistent-storage-compat.rules 99-systemd.rules
     fi
 }
 
 install_systemd() {
-    # install compiled files
-    (cd $TEST_BASE_DIR/..; set -x; make DESTDIR=$initdir install)
+    ORIGDIR=$(pwd)
+    cd $TEST_BASE_DIR/..
+    for i in $(find /usr/lib/systemd -type f); do
+            inst_simple $i
+    done
+    for i in $(find /usr/lib/systemd -type l); do
+            inst_symlink $i
+    done
+    for i in $( find /usr/lib/systemd -type d); do
+            [[ -d $i ]] || mkdir $i
+            for j in $(find $i -type f); do
+                     inst_simple $j
+            done
+    done
+    for i in $(rpm -ql systemd | sed -n '/usr\/bin/p'); do
+            inst_simple $i
+    done
+    for i in /usr/lib/udev /lib/udev /etc/udev; do
+        for j in $(find $i -type f); do
+            inst_simple $j
+        done
+    done
+
+    cd $ORIGDIR
+
     # remove unneeded documentation
     rm -fr $initdir/usr/share/{man,doc}
     # we strip binaries since debug symbols increase binaries size a lot
@@ -349,12 +409,12 @@ install_missing_libraries() {
 create_empty_image() {
     rm -f "$TESTDIR/rootdisk.img"
     # Create the blank file to use as a root filesystem
-    dd if=/dev/null of="$TESTDIR/rootdisk.img" bs=1M seek=400
+    dd if=/dev/null of="$TESTDIR/rootdisk.img" bs=1M seek=600
     LOOPDEV=$(losetup --show -P -f $TESTDIR/rootdisk.img)
     [ -b "$LOOPDEV" ] || return 1
     echo "LOOPDEV=$LOOPDEV" >> $STATEFILE
     sfdisk "$LOOPDEV" <<EOF
-,390M
+,590M
 ,
 EOF
 
@@ -423,6 +483,11 @@ install_execs() {
          | while read i; do
          i=${i##Exec*=}; i=${i##-}
          # some {rc,halt}.local scripts and programs are okay to not exist, the rest should
+         # dracut binary are not present with the same name in the installed system
+	 [[ "$i" =~ "/bin/dracut-" ]] && i=$(find /usr/lib/dracut -name ${i#/*/*}.sh)
+	 [[ -z "$i" ]] && continue
+         # wicked service requires pppd which might not be installed
+         [[ "$i" == "/usr/sbin/pppd" ]] && continue
          inst $i || [ "${i%.local}" != "$i" ] || [ "${i%systemd-update-done}" != "$i" ]
      done
     )
@@ -488,9 +553,6 @@ EOF
 
 install_basic_tools() {
     [[ $BASICTOOLS ]] && dracut_install $BASICTOOLS
-    dracut_install -o sushell
-    # in Debian ldconfig is just a shell script wrapper around ldconfig.real
-    dracut_install -o ldconfig.real
 }
 
 install_debug_tools() {
@@ -1378,6 +1440,7 @@ setup_suse() {
     ln -s ../usr/bin/systemctl $initdir/bin/systemctl
     ln -s ../usr/lib/systemd $initdir/lib/systemd
     inst_simple "/usr/lib/systemd/system/haveged.service"
+    instmods ext4
 }
 
 # can be overridden in specific test
-- 
2.16.4

openSUSE Build Service is sponsored by