diff --git a/tests/scripts/copy-from-image.sh b/tests/scripts/copy-from-image.sh new file mode 100755 index 0000000..9b71054 --- /dev/null +++ b/tests/scripts/copy-from-image.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +BASEDIR=$(realpath $(dirname "$0")) +. $BASEDIR/image-init-lib.sh + +# Base image to copy from +BOOT_IMAGE=$1 && shift +if [ ! -e "$BOOT_IMAGE" ]; then + perror_exit "Image '$BOOT_IMAGE' not found" +else + BOOT_IMAGE=$(realpath "$BOOT_IMAGE") +fi + +mount_image $BOOT_IMAGE + +IMAGE_MNT=$(get_image_mount_root $BOOT_IMAGE) + +SRC= +while [ $# -gt 1 ]; do + SRC="$SRC $IMAGE_MNT/$1" + shift +done +DST=$1 + +cp -rv $SRC $DST diff --git a/tests/scripts/image-init-lib.sh b/tests/scripts/image-init-lib.sh index 372e5e4..7be55d1 100644 --- a/tests/scripts/image-init-lib.sh +++ b/tests/scripts/image-init-lib.sh @@ -164,10 +164,20 @@ mount_image() { [ $? -ne 0 ] && perror_exit "failed to mount device '$mnt_dev'" } -shell_in_image() { - local image=$1 && shift +get_image_mount_root() { + local image=$1 local root=${MNTS[$image]} + echo $root + + if [ -z "$root" ]; then + return 1 + fi +} + +shell_in_image() { + local root=$(get_image_mount_root $1) && shift + pushd $root $SHELL @@ -176,8 +186,7 @@ shell_in_image() { } inst_pkg_in_image() { - local image=$1 && shift - local root=${MNTS[$image]} + local root=$(get_image_mount_root $1) && shift # LSB not available # release_info=$($SUDO chroot $root /bin/bash -c "lsb_release -a") @@ -193,10 +202,8 @@ inst_pkg_in_image() { } run_in_image() { - local image=$1 && shift - local root=${MNTS[$image]} + local root=$(get_image_mount_root $1) && shift - echo $SUDO chroot $root /bin/bash -c $@ > /dev/stderr $SUDO chroot $root /bin/bash -c "$@" } diff --git a/tests/scripts/kexec-kdump-test/init.sh b/tests/scripts/kexec-kdump-test/init.sh index bc2a642..5737810 100755 --- a/tests/scripts/kexec-kdump-test/init.sh +++ b/tests/scripts/kexec-kdump-test/init.sh @@ -92,6 +92,8 @@ has_valid_vmcore_dir() { fi test_output "Found a valid vmcore in \"$vmcore_dir\"" + test_output "VMCORE: $vmcore" + test_output "KERNEL VERSION: $(rpm -q kernel-core)" return 0 } diff --git a/tests/scripts/run-test.sh b/tests/scripts/run-test.sh index cdba7f4..ef628aa 100755 --- a/tests/scripts/run-test.sh +++ b/tests/scripts/run-test.sh @@ -88,6 +88,7 @@ for test_case in $testcases; do echo "-------- Console log: $(get_test_console_file $script)" echo "-------- Test log: $(get_test_output_file $script)" test_outputs+="$(get_test_output_file $script) " + rm -f $(get_test_console_file $script) rm -f $(get_test_output_file $script) @@ -104,6 +105,7 @@ for test_case in $testcases; do echo "-------- Console log: $(get_test_console_file $script)" echo "-------- Test log: $(get_test_output_file $script)" test_outputs+="$(get_test_output_file $script) " + rm -f $(get_test_console_file $script) rm -f $(get_test_output_file $script) @@ -116,10 +118,25 @@ for test_case in $testcases; do fi res="$(gather_test_result $test_outputs)" + [ $? -ne 0 ] && ret=$(expr $ret + 1) results[$test_case]="$res" echo -e "-------- Test finished: $test_case $res --------" + for script in $scripts; do + script="$testdir/$script" + output="$(get_test_output_file $script) " + image="$(get_test_image $script)" + vmcore="$(sed -n 's/^VMCORE: \(\S*\).*/\1/p' $output)" + kernel="$(sed -n 's/^KERNEL VERSION: \(\S*\).*/\1/p' $output)" + if [ -n "$vmcore" ]; then + echo "You can retrive the verify the vmcore file using following command:" + echo "./scripts/copy-from-image.sh \\" + echo " $image \\" + echo " $vmcore ./" + echo "Kernel package verion is: $kernel" + fi + done done echo "======== Test results ========"