From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6940636076695355392 X-Received: by 2002:a05:6000:1545:: with SMTP id 5mr4867021wry.90.1615992802050; Wed, 17 Mar 2021 07:53:22 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:600c:1546:: with SMTP id f6ls1504306wmg.3.canary-gmail; Wed, 17 Mar 2021 07:53:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1mgJxC1lRA3AKQlz5VEmxG6p2RRoJkQKSiXuvmGdXAGaU5BWqAe45g6oQOL1C1W4Df21/ X-Received: by 2002:a1c:7715:: with SMTP id t21mr4043576wmi.132.1615992801249; Wed, 17 Mar 2021 07:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615992801; cv=none; d=google.com; s=arc-20160816; b=vJ0r1jjLdqH96QsXmP8KVnrdGz5OAWZlYZLEDoqy4Geo1x5MTgpeVm7BVVpoo3qxJz ZVPHAv+sQ60tQsCucON/vCy710uaQKKqQxKZBpPuQneEooaYZKIHFWWyOkjXK6Mrys2k PUGZpMm2IQv/D7M6ot67RCrTM2do7B7xjrw8BDRghBHvNeuqMZvKMTUqNAlEV8NuU8zV TZedI026sjyJAhRSBBxjfjZSUSGlgRFq6VMNduwvl7SaTVa7nr5zHsyocqujwFBtXmA0 9YGD9gg2a4HvWZ+hEriHtqU0C1fMWso2Z1wbNj0phdjPMRJBVT7fnTtOgVvetbk+OSHw HgcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=jB9L046epci06pgtsa6cilBK5YeaDnceeaSWjoXAJcg=; b=SvX8sg9D1K+4v69+UlL9x5zat1yxFwjgloDwwinfVNSBHmolUd1aHByD8iHXjHOFKj u2eQFh6gs/rBy1h7M0KY+pB9v3GbF5I0ct9ruIUkz59uUKw/zkxuRlmk0VCDAahW3+ig xNseRalHUrRzupFG7D9l2KMGrEOcRHHAgEZSZWXYaX5FyC366u+RtUi2C+zrplh/f+qw G2wRLXURXJU1cbAfcqhaQ+guvhkugLl9kduxpEvc9aHPxLT6XHlNVb89K5J/eZ58NSBW 1KYKUOuXpK76hNCow8p9vxpsZhkD+0N31QeZR1bi5F6IsYMqLn2jd/FrEhUK02A7Zy8S 56zg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=amikan@ilbers.de Return-Path: Received: from shymkent.ilbers.de (shymkent.ilbers.de. [85.214.156.166]) by gmr-mx.google.com with ESMTPS id w2si59195wmb.4.2021.03.17.07.53.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 17 Mar 2021 07:53:21 -0700 (PDT) Received-SPF: pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) client-ip=85.214.156.166; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of amikan@ilbers.de designates 85.214.156.166 as permitted sender) smtp.mailfrom=amikan@ilbers.de Received: from localhost.localdomain (mm-117-75-121-178.mgts.dynamic.pppoe.byfly.by [178.121.75.117] (may be forged)) (authenticated bits=0) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8) with ESMTPSA id 12HEqhaK032071 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 17 Mar 2021 15:53:20 +0100 From: Anton Mikanovich To: isar-users@googlegroups.com Cc: Anton Mikanovich Subject: [PATCH v3 11/11] vm_smoke_test: Migrate to Avocado Date: Wed, 17 Mar 2021 17:52:25 +0300 Message-Id: <20210317145225.88050-12-amikan@ilbers.de> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210317145225.88050-1-amikan@ilbers.de> References: <20210317145225.88050-1-amikan@ilbers.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-TUID: at/fucAz3v5h Call Avocado test cases instead of shell based. Signed-off-by: Anton Mikanovich --- scripts/vm_smoke_test | 110 ++++------------------- scripts/vm_smoke_test_legacy | 168 +++++++++++++++++++++++++++++++++++ 2 files changed, 185 insertions(+), 93 deletions(-) create mode 100755 scripts/vm_smoke_test_legacy diff --git a/scripts/vm_smoke_test b/scripts/vm_smoke_test index ce08213..0ef3caf 100755 --- a/scripts/vm_smoke_test +++ b/scripts/vm_smoke_test @@ -3,9 +3,7 @@ # This software is a part of ISAR. # Copyright (C) 2015-2018 ilbers GmbH -CONSOLE_OUTPUT=/tmp/isar_console -PID_FILE=/tmp/qemu.pid -VERBOSE=1 +VERBOSE="--show-job-log" TIMEOUT=300 # Error codes: @@ -13,75 +11,12 @@ ES_OK=0 ES_FAIL=1 ES_BUG=3 -RET=$ES_OK +RET=$ES_FAIL -dump_boot_log() { - echo "Boot log:\n8<--" - cat $CONSOLE_OUTPUT - echo "\n8<--" -} - -check_login_prompt() { - echo -n "Check login prompt: " - - str=$(grep "isar login: " $CONSOLE_OUTPUT) - - if [ -n "$str" ]; then - echo "PASSED" - else - echo "FAIL" - RET=$ES_FAIL - FAIL=1 - fi -} - -check_example_module() { - echo -n "Check example module: " - - str=$(grep "Just an example" $CONSOLE_OUTPUT) - - if [ -n "$str" ]; then - echo "PASSED" - else - echo "FAIL" - RET=$ES_FAIL - FAIL=1 - fi -} - -run_test () { - ARCH=$1 - DISTRO=$2 - - echo "-------------------------------------------------" - echo "Testing Isar [$DISTRO] image for [$ARCH] machine:" +# Get Avocado QEMU tests path +VM_TEST_DIR="$(dirname "$0")/../testsuite/vm_boot_test" - start_vm -a $ARCH -d $DISTRO -o $CONSOLE_OUTPUT -p $PID_FILE > /dev/null 2>&1 & - sleep 5 - - if [ -z `ps -p $! -o pid=` ]; then - echo "QEMU start: FAILED" - RET=$ES_FAIL - echo "Command output:\n8<--" - start_vm -a $ARCH -d $DISTRO -o $CONSOLE_OUTPUT -p $PID_FILE - echo "\n8<--" - else - sleep $TIMEOUT - kill `cat $PID_FILE` - - FAIL=0 - - check_login_prompt - - check_example_module - - [ $VERBOSE -eq 1 -o $FAIL -eq 1 ] && dump_boot_log - - rm $CONSOLE_OUTPUT - fi - - rm $PID_FILE -} +BUILD_DIR=$PWD show_help() { echo "This script tests the Isar images for default targets in QEMU." @@ -91,10 +26,6 @@ show_help() { echo echo "Parameters:" echo " -f,--fast test reduced set of supported targets." - echo " -o,--output FILE specify file to store console output." - echo " The default is: /tmp/isar_console" - echo " -p,--pid-file FILE specify file to store QEMU process PID." - echo " The default is: /tmp/qemu.pid" echo " -q, --quiet do not display boot logs for all the targets." echo " If test failed for the specific configuration," echo " the respective boot log will be printed anyway." @@ -119,18 +50,18 @@ do exit 0 ;; -o|--output) - CONSOLE_OUTPUT=$2 + # Deprecated option shift ;; -p|--pid-file) - PID_FILE=$2 + # Deprecated option shift ;; -f|--fast) FAST_BUILD="1" ;; -q|--quiet) - VERBOSE=0 + VERBOSE="" ;; -t|--timeout) TIMEOUT=$2 @@ -145,24 +76,17 @@ do shift done -# ARM machine -run_test arm stretch -run_test arm buster - -# AMD64 machine -if [ -z "$FAST_BUILD" ]; then - run_test amd64 buster - run_test amd64 focal +TAGS="full" +if [ -n "$FAST_BUILD" ]; then + TAGS="fast" fi -run_test amd64 stretch -# i386 machine -if [ -z "$FAST_BUILD" ]; then - run_test i386 stretch - run_test i386 buster -fi +# Provide working path +export VIRTUAL_ENV="./" -# ARM64 machine -run_test arm64 stretch +if avocado run "$VM_TEST_DIR/vm_boot_test.py" -t $TAGS \ + -p build_dir="$BUILD_DIR" -p time_to_wait=$TIMEOUT $VERBOSE; then + RET=$ES_OK +fi exit $RET diff --git a/scripts/vm_smoke_test_legacy b/scripts/vm_smoke_test_legacy new file mode 100755 index 0000000..ce08213 --- /dev/null +++ b/scripts/vm_smoke_test_legacy @@ -0,0 +1,168 @@ +#!/bin/sh +# +# This software is a part of ISAR. +# Copyright (C) 2015-2018 ilbers GmbH + +CONSOLE_OUTPUT=/tmp/isar_console +PID_FILE=/tmp/qemu.pid +VERBOSE=1 +TIMEOUT=300 + +# Error codes: +ES_OK=0 +ES_FAIL=1 +ES_BUG=3 + +RET=$ES_OK + +dump_boot_log() { + echo "Boot log:\n8<--" + cat $CONSOLE_OUTPUT + echo "\n8<--" +} + +check_login_prompt() { + echo -n "Check login prompt: " + + str=$(grep "isar login: " $CONSOLE_OUTPUT) + + if [ -n "$str" ]; then + echo "PASSED" + else + echo "FAIL" + RET=$ES_FAIL + FAIL=1 + fi +} + +check_example_module() { + echo -n "Check example module: " + + str=$(grep "Just an example" $CONSOLE_OUTPUT) + + if [ -n "$str" ]; then + echo "PASSED" + else + echo "FAIL" + RET=$ES_FAIL + FAIL=1 + fi +} + +run_test () { + ARCH=$1 + DISTRO=$2 + + echo "-------------------------------------------------" + echo "Testing Isar [$DISTRO] image for [$ARCH] machine:" + + start_vm -a $ARCH -d $DISTRO -o $CONSOLE_OUTPUT -p $PID_FILE > /dev/null 2>&1 & + sleep 5 + + if [ -z `ps -p $! -o pid=` ]; then + echo "QEMU start: FAILED" + RET=$ES_FAIL + echo "Command output:\n8<--" + start_vm -a $ARCH -d $DISTRO -o $CONSOLE_OUTPUT -p $PID_FILE + echo "\n8<--" + else + sleep $TIMEOUT + kill `cat $PID_FILE` + + FAIL=0 + + check_login_prompt + + check_example_module + + [ $VERBOSE -eq 1 -o $FAIL -eq 1 ] && dump_boot_log + + rm $CONSOLE_OUTPUT + fi + + rm $PID_FILE +} + +show_help() { + echo "This script tests the Isar images for default targets in QEMU." + echo + echo "Usage:" + echo " $0 [params]" + echo + echo "Parameters:" + echo " -f,--fast test reduced set of supported targets." + echo " -o,--output FILE specify file to store console output." + echo " The default is: /tmp/isar_console" + echo " -p,--pid-file FILE specify file to store QEMU process PID." + echo " The default is: /tmp/qemu.pid" + echo " -q, --quiet do not display boot logs for all the targets." + echo " If test failed for the specific configuration," + echo " the respective boot log will be printed anyway." + echo " -t,--timeout SEC specify time in seconds to wait before stop QEMU." + echo " The default is: 300" + echo " -h, --help display this message and exit." + echo + echo "Exit status:" + echo " 0 if OK," + echo " 1 if test failed," + echo " 3 if invalid parameters are passed." +} + +# Parse command line to get user configuration +while [ $# -gt 0 ] +do + key="$1" + + case $key in + -h|--help) + show_help + exit 0 + ;; + -o|--output) + CONSOLE_OUTPUT=$2 + shift + ;; + -p|--pid-file) + PID_FILE=$2 + shift + ;; + -f|--fast) + FAST_BUILD="1" + ;; + -q|--quiet) + VERBOSE=0 + ;; + -t|--timeout) + TIMEOUT=$2 + shift + ;; + *) + echo "error: invalid parameter '$key', please try '--help' to get list of supported parameters" + exit $ES_BUG + ;; + esac + + shift +done + +# ARM machine +run_test arm stretch +run_test arm buster + +# AMD64 machine +if [ -z "$FAST_BUILD" ]; then + run_test amd64 buster + run_test amd64 focal +fi +run_test amd64 stretch + +# i386 machine +if [ -z "$FAST_BUILD" ]; then + run_test i386 stretch + run_test i386 buster +fi + +# ARM64 machine +run_test arm64 stretch + +exit $RET -- 2.25.1