diff options
Diffstat (limited to 'test/test-functions')
-rw-r--r-- | test/test-functions | 49 |
1 files changed, 22 insertions, 27 deletions
diff --git a/test/test-functions b/test/test-functions index f76d930..b664fb0 100644 --- a/test/test-functions +++ b/test/test-functions @@ -20,14 +20,20 @@ DRACUT=${DRACUT-${basedir}/dracut.sh} PKGLIBDIR=${PKGLIBDIR-$basedir} test_dracut() { - TEST_DRACUT_ARGS+=" --local --no-hostonly --no-early-microcode --add test --kver $KVERSION" + TEST_DRACUT_ARGS+=" --local --no-hostonly --no-hostonly-cmdline --no-early-microcode --add test --force --kver $KVERSION" + + # include $TESTDIR"/overlay if exists + if [ -d "$TESTDIR"/overlay ]; then + TEST_DRACUT_ARGS+=" --include $TESTDIR/overlay /" + fi # shellcheck disable=SC2162 IFS=' ' read -a TEST_DRACUT_ARGS_ARRAY <<< "$TEST_DRACUT_ARGS" - "$DRACUT" "$@" \ - --kernel-cmdline "panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot selinux=0 console=ttyS0,115200n81 $DEBUGFAIL" \ - "${TEST_DRACUT_ARGS_ARRAY[@]}" || return 1 + "$DRACUT" \ + --kernel-cmdline "panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot quiet rd.retry=10 rd.info rd.shell=0 selinux=0 console=ttyS0,115200n81 $DEBUGFAIL" \ + "${TEST_DRACUT_ARGS_ARRAY[@]}" \ + "$@" || return 1 } command -v test_check &> /dev/null || test_check() { @@ -52,23 +58,14 @@ COLOR_FAILURE='\033[0;31m' COLOR_WARNING='\033[0;33m' COLOR_NORMAL='\033[0;39m' -check_root() { - if ((EUID != 0)); then - SETCOLOR_FAILURE - echo "Tests must be run as root! Please use 'sudo'." - SETCOLOR_NORMAL - exit 1 - fi -} - # generate qemu arguments for named raw disks # -# qemu_add_drive_args <index> <args> <filename> <id-name> [<bootindex>] +# qemu_add_drive <index> <args> <filename> <id-name> [<bootindex>] # # index: name of the index variable (set to 0 at start) # args: name of the argument array variable (set to () at start) # filename: filename of the raw disk image -# id-name: name of the disk in /dev/disk/by-id -> /dev/disk/by-id/ata-disk_$name +# id-name: name of the disk in /dev/disk/by-id -> /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_$name # size: optional file size in MiB (0 implies size is not set) # bootindex: optional bootindex number # @@ -81,13 +78,13 @@ check_root() { # ``` # declare -a disk_args=() # declare -i disk_index=0 -# qemu_add_drive_args disk_index disk_args "$TESTDIR"/root.ext3 root 0 1 -# qemu_add_drive_args disk_index disk_args "$TESTDIR"/client.img client -# qemu_add_drive_args disk_index disk_args "$TESTDIR"/iscsidisk2.img iscsidisk2 -# qemu_add_drive_args disk_index disk_args "$TESTDIR"/iscsidisk3.img iscsidisk3 +# qemu_add_drive disk_index disk_args "$TESTDIR"/root.ext3 root 0 1 +# qemu_add_drive disk_index disk_args "$TESTDIR"/client.img client +# qemu_add_drive disk_index disk_args "$TESTDIR"/iscsidisk2.img iscsidisk2 +# qemu_add_drive disk_index disk_args "$TESTDIR"/iscsidisk3.img iscsidisk3 # qemu "${disk_args[@]}" # ``` -qemu_add_drive_args() { +qemu_add_drive() { local index=${!1} local file=$3 local name=${4:-$index} @@ -95,12 +92,13 @@ qemu_add_drive_args() { local bootindex=$6 if [ "${size}" -ne 0 ]; then - dd if=/dev/zero of="${file}" bs=1MiB count="${size}" + dd if=/dev/zero of="${file}" bs=1MiB count="${size}" status=none fi eval "${2}"'+=(' \ - -drive "if=none,format=raw,file=${file},id=drive-sata${index}" \ - -device "ide-hd,bus=ide.${index},drive=drive-sata${index},id=sata${index},${bootindex:+bootindex=$bootindex,}model=disk,serial=${name}" \ + -device "virtio-scsi-pci,id=scsi${index}" \ + -drive "if=none,format=raw,file=${file},id=drive-data${index}" \ + -device "scsi-hd,bus=scsi${index}.0,drive=drive-data${index},id=data${index},${bootindex:+bootindex=$bootindex,}serial=${name}" \ ')' # shellcheck disable=SC2219 @@ -108,7 +106,7 @@ qemu_add_drive_args() { } test_marker_reset() { - dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1 + dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1 status=none } test_marker_check() { @@ -122,13 +120,11 @@ test_marker_check() { while (($# > 0)); do case $1 in --run) - check_root echo "TEST RUN: $TEST_DESCRIPTION" test_check && test_run exit $? ;; --setup) - check_root echo "TEST SETUP: $TEST_DESCRIPTION" test_check && test_setup exit $? @@ -141,7 +137,6 @@ while (($# > 0)); do exit $? ;; --all) - check_root if ! test_check 2 &> test${TEST_RUN_ID:+-$TEST_RUN_ID}.log; then echo -e "TEST: $TEST_DESCRIPTION " "$COLOR_WARNING" "[SKIPPED]" "$COLOR_NORMAL" exit 0 |