public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Anton Mikanovich <amikan@ilbers.de>
To: isar-users@googlegroups.com
Cc: Anton Mikanovich <amikan@ilbers.de>
Subject: [PATCH v3 11/11] vm_smoke_test: Migrate to Avocado
Date: Wed, 17 Mar 2021 17:52:25 +0300	[thread overview]
Message-ID: <20210317145225.88050-12-amikan@ilbers.de> (raw)
In-Reply-To: <20210317145225.88050-1-amikan@ilbers.de>

Call Avocado test cases instead of shell based.

Signed-off-by: Anton Mikanovich <amikan@ilbers.de>
---
 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


      parent reply	other threads:[~2021-03-17 14:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17 14:52 [PATCH v3 00/11] Update Avocado testsuite Anton Mikanovich
2021-03-17 14:52 ` [PATCH v3 01/11] start_vm.py: Fix target name handling Anton Mikanovich
2021-03-17 14:52 ` [PATCH v3 02/11] start_vm.py: Add output and PID file vm_start.py options Anton Mikanovich
2021-03-17 14:52 ` [PATCH v3 03/11] start_vm.py: Add MIPS support Anton Mikanovich
2021-03-17 14:52 ` [PATCH v3 04/11] vm_boot_test: Fix log file path in vm_boot_test Anton Mikanovich
2021-03-17 14:52 ` [PATCH v3 05/11] vm_boot_test: Remove external varianter Anton Mikanovich
2021-03-17 14:52 ` [PATCH v3 06/11] vm_boot_test: Improve QEMU images checking Anton Mikanovich
2021-03-17 14:52 ` [PATCH v3 07/11] build_test: Refactoring build tests cases Anton Mikanovich
2021-03-17 14:52 ` [PATCH v3 08/11] testsuite: Add Python generations for testsuite in gitignore Anton Mikanovich
2021-03-17 14:52 ` [PATCH v3 09/11] testsuite: Fix test suite prepare guide Anton Mikanovich
2021-03-17 14:52 ` [PATCH v3 10/11] ci_build: Migrate to Avocado Anton Mikanovich
2021-03-17 14:56   ` Jan Kiszka
2021-03-17 17:26     ` Anton Mikanovich
2021-03-17 17:36       ` Jan Kiszka
2021-03-17 14:52 ` Anton Mikanovich [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210317145225.88050-12-amikan@ilbers.de \
    --to=amikan@ilbers.de \
    --cc=isar-users@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox