#!/bin/sh filter_output() { test_name="$1" debug_dir="" while read row; do echo "# $row" # Output is colorized; remove escape characters row_cleaned=`echo "$row" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"` # Transform "SETUP: PASS|FAIL" to "SETUP ($test_name): PASS|FAIL" row_cleaned=`echo "$row_cleaned" | sed "s/^SETUP:/SETUP ($test_name):/"` if echo "$row_cleaned" | grep -q '^[^:]*: \(PASS\|FAIL\|ERROR\)\( \[result=[^]]*\]\)\? ([0-9\.]\{1,\} s)$'; then # The row is a test result test_case=`echo "$row_cleaned" | grep -o '^\(SETUP\|([0-9]\{1,\}/[0-9]\{1,\})\)[^:]*' | sed 's|^([0-9]\{1,\}/[0-9]\{1,\}) ||'` status=`echo "$row_cleaned" | grep -o ': \(PASS\|FAIL\|ERROR\)' | sed -e 's/^: //' -e 's/ERROR/FAIL/'` echo -n "$status: $test_case" # Are there any textual results to be appended? keyval_file="$debug_dir/$test_case/keyval" if [ -n "$debug_dir" -a -e "$keyval_file" ]; then result=`grep '^result=' $keyval_file | sed 's/^result=//'` if [ -n "$result" ]; then echo -n " [result=$result]" fi fi echo "" elif echo "$row_cleaned" | grep -q '^DEBUG LOG: '; then # The row specifies the path to the debug log: Extract the debug directory and save it debug_dir=`echo "$row_cleaned" | sed -e 's,^DEBUG LOG: ,,' -e 's,/debug\.log$,,'` fi done } create_empty_image() { IMAGE_NAME="$1" COMPRESSION_TYPE="$2" COMPRESSED_IMAGE_NAME="${IMAGE_NAME}.${COMPRESSION_TYPE}" if [ -z "$COMPRESSION_TYPE" ]; then COMPRESSED_IMAGE_NAME="${IMAGE_NAME}" fi SHA1_NAME="${COMPRESSED_IMAGE_NAME}.sha1" pushd /opt/virt-test/shared/data/images/ &> /dev/null rm -f "$IMAGE_NAME" "$SHA1_NAME" "$COMPRESSED_IMAGE_NAME" rm -f "${IMAGE_NAME}.backup" echo "# Creating empty image ${IMAGE_NAME}" qemu-img create -f qcow2 ${IMAGE_NAME} 10M case "$COMPRESSION_TYPE" in bz2) bzip2 -c "$IMAGE_NAME" > "$COMPRESSED_IMAGE_NAME" ;; gz) gzip -c "$IMAGE_NAME" > "$COMPRESSED_IMAGE_NAME" ;; xz) xz -c "$IMAGE_NAME" > "$COMPRESSED_IMAGE_NAME" ;; *) echo "ERROR: Invalid compression type: $COMPRESSION_TYPE" popd exit 1 ;; esac sha1sum "$COMPRESSED_IMAGE_NAME" > "$SHA1_NAME" cp "$IMAGE_NAME" "${IMAGE_NAME}.backup" echo "# Empty image $IMAGE_NAME created" echo popd &> /dev/null } get_image() { URL_BASE="$1" IMAGE_NAME="$2" COMPRESSION_TYPE="$3" COMPRESSED_IMAGE_NAME="${IMAGE_NAME}.${COMPRESSION_TYPE}" if [ -z "$COMPRESSION_TYPE" ]; then COMPRESSED_IMAGE_NAME="${IMAGE_NAME}" fi SHA1_NAME="${COMPRESSED_IMAGE_NAME}.sha1" COMPRESSED_IMAGE_URL="${URL_BASE}/${COMPRESSED_IMAGE_NAME}" SHA1_URL="${URL_BASE}/${SHA1_NAME}" pushd /opt/virt-test/shared/data/images/ &> /dev/null rm -f "$IMAGE_NAME" "$SHA1_NAME" "$COMPRESSED_IMAGE_NAME" rm -f "${IMAGE_NAME}.backup" echo "# Downloading $COMPRESSED_IMAGE_URL" wget $COMPRESSED_IMAGE_URL wget $SHA1_URL if ! sha1sum -c "$SHA1_NAME" > /dev/null; then echo "ERROR: Invalid sha1 sum!" exit 1 fi echo "# Uncompressing $COMPRESSED_IMAGE_NAME -> $IMAGE_NAME" case "$COMPRESSION_TYPE" in bz2) bunzip2 -c "$COMPRESSED_IMAGE_NAME" > "$IMAGE_NAME" ;; gz) gunzip -c "$COMPRESSED_IMAGE_NAME" > "$IMAGE_NAME" ;; xz) unxz -c "$COMPRESSED_IMAGE_NAME" > "$IMAGE_NAME" ;; "") ;; *) echo "ERROR: Invalid compression type: $COMPRESSION_TYPE" popd exit 1 ;; esac cp "$IMAGE_NAME" "${IMAGE_NAME}.backup" echo "# Download of $IMAGE_NAME completed" echo popd &> /dev/null } # Verbose? VERBOSE= if [ "$1" = '-v' ]; then VERBOSE=1 set -x fi # Servers NTP_SERVER=ntp.enea.se # Architecture ARCH=`uname -m` # Needed by virt-test export AUTOTEST_PATH="/opt/autotest/" # Init LVM DEST_DIR=/opt/virt-test/shared/data if ! [ -e /dev/rootvg ]; then vgchange -ay udevadm settle # Wait for device nodes fi if [ -e /dev/rootvg ]; then if ! [ -e /dev/rootvg/virttestdatalv ]; then if ! lvcreate -L30G -n virttestdatalv /dev/rootvg; then echo "ERROR: Unable to create virttestdatalv!" >&2 exit 1 fi udevadm settle if ! mkfs.ext4 /dev/rootvg/virttestdatalv; then echo "ERROR: Unable to format virttestdatalv!" >&2 exit 1 fi fi # Mount the virttestdatalv mkdir -p $DEST_DIR if ! mountpoint -q $DEST_DIR; then if ! mount /dev/rootvg/virttestdatalv $DEST_DIR; then echo "ERROR: Unable to mount virttestdatalv!" >&2 exit 1 fi fi else echo "WARNING: No rootvg volume group! Continuing anyway" >&2 fi ( cd $DEST_DIR mkdir -p gpg images isos steps_data ) # Sync the clock before starting tests, as some tests will do this, and thereby # cause tests that run for a negative amount of time unless the time is synced # from the very beginning ntpdate $NTP_SERVER # Download/create images, kernel, initrd JEOS_VERSION="19-64" ENEA_VERSION="4.0" # virt-test will try to unpack the images for all architectures, even though # they are not used, so always create the (empty) images. create_empty_image "enea-${ENEA_VERSION}-x86_64.qcow2" "gz" create_empty_image "enea-${ENEA_VERSION}-ppc.qcow2" "gz" create_empty_image "enea-${ENEA_VERSION}-ppc64.qcow2" "gz" if [ "$ARCH" = "x86_64" ]; then #get_image "http://172.21.3.124/~jori/jeos/" "jeos-${JEOS_VERSION}.qcow2" "bz2" get_image "http://172.21.3.124/~jori/enea/" "enea-${ENEA_VERSION}-${ARCH}.qcow2" "gz" elif [ "$ARCH" = "ppc" -o "$ARCH" = "ppc64" ]; then get_image "http://172.21.3.124/~jori/enea/" "enea-${ENEA_VERSION}-${ARCH}.uImage" "" get_image "http://172.21.3.124/~jori/enea/" "enea-${ENEA_VERSION}-${ARCH}.cpio.gz" "" else echo "ERROR: Architecture '$ARCH' not supported" exit 1 fi # Create virbr0 if ! [ -e /sys/class/net/virbr0 ]; then ip link add virbr0 type bridge ip addr add dev virbr0 10.99.99.1/24 ip link set virbr0 up /etc/init.d/dnsmasq stop sleep 5 /etc/init.d/dnsmasq start fi # Run tests cd /opt/virt-test/ QEMU_BIN=`which qemu-system-$ARCH` OPTS="--qemu-bin=$QEMU_BIN --qemu_sandbox=off --no-downloads" if ! [ "$VERBOSE" = "" ]; then OPTS="$OPTS -v" fi declare -a TEST_SUITE TEST_SUITE_EXTRAOPTS TEST_CASES TEST_SUITE[0]="qemu" TEST_SUITE_EXTRAOPTS[0]="" TEST_CASES[0]="check_clock_offset.with_syscall,migrate.default.fd" TEST_SUITE[1]="libvirt" TEST_SUITE_EXTRAOPTS[1]="" if [ "$ARCH" = "x86_64" ]; then TEST_SUITE_EXTRAOPTS[1]="--machine-type=q35" fi TEST_CASES[1]="virsh.volume" for (( i=0; i<${#TEST_SUITE[@]}; i++ )); do # Update machine.cfg cp /opt/virt-test/shared/cfg/machines.cfg \ /opt/virt-test/backends/${TEST_SUITE[$i]}/cfg/ # Run tests echo "# Running ${TEST_SUITE[$i]} tests ${TEST_CASES[$i]}" ./run $OPTS ${TEST_SUITE_EXTRAOPTS[$i]} -g Enea -t "${TEST_SUITE[$i]}" \ --tests="${TEST_CASES[$i]}" --arch=$ARCH 2>&1 \ | filter_output "${TEST_SUITE[$i]}" done