public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Alexander Smirnov <asmirnov@ilbers.de>
To: isar-users@googlegroups.com
Cc: Alexander Smirnov <asmirnov@ilbers.de>
Subject: [PATCH 1/3] scripts/vm_smoke_test: Add verbosity parameter
Date: Tue,  1 May 2018 20:55:09 +0300	[thread overview]
Message-ID: <20180501175511.26145-2-asmirnov@ilbers.de> (raw)
In-Reply-To: <20180501175511.26145-1-asmirnov@ilbers.de>

Issues:
1. Currently this script displays boot log for all the images. This could
   bring some inconviniences for users, who want to perform quick test and
   get just messages FAILED/PASSED.
2. Also the boot log is displayed if test case failed. So in the worst case
   when all cases for current image failed, the boot log will be displayed
   3 times.

Solution:
1. If at least one test case failed for current image, the boot log will be
   displayed (only one time, despite on number of cases failed).
2. Boot log is disabled by default. It could be enabled for all the images
   by '-v' option passed to this script.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 scripts/vm_smoke_test | 62 ++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 54 insertions(+), 8 deletions(-)

diff --git a/scripts/vm_smoke_test b/scripts/vm_smoke_test
index 274ec1d..92fda2d 100755
--- a/scripts/vm_smoke_test
+++ b/scripts/vm_smoke_test
@@ -5,13 +5,19 @@
 
 CONSOLE_OUTPUT=/tmp/isar_console
 PID_FILE=/tmp/qemu.pid
+VERBOSE=0
 
-RET=0
+# Error codes:
+ES_OK=0
+ES_FAIL=1
+ES_BUG=3
+
+RET=$ES_OK
 
 dump_boot_log() {
-    echo "Boot log: 8<--"
+    echo "Boot log:\n8<--"
     cat $CONSOLE_OUTPUT
-    echo -e "\n8<--"
+    echo "\n8<--"
 }
 
 check_login_prompt() {
@@ -23,8 +29,8 @@ check_login_prompt() {
         echo "PASSED"
     else
         echo "FAIL"
-        dump_boot_log
-        RET=1
+        RET=$ES_FAIL
+        FAIL=1
     fi
 }
 
@@ -37,8 +43,8 @@ check_example_module() {
         echo "PASSED"
     else
         echo "FAIL"
-        dump_boot_log
-        RET=1
+        RET=$ES_FAIL
+        FAIL=1
     fi
 }
 
@@ -54,19 +60,59 @@ run_test () {
     sleep 60
     kill `cat $PID_FILE`
 
+    FAIL=0
+
     # Check login prompt
     check_login_prompt
 
     # Check kernel module
     check_example_module
 
-    dump_boot_log
+    [ $VERBOSE -eq 1 -o $FAIL -eq 1 ] && dump_boot_log
 
     # Clean up test artifacts
     rm $CONSOLE_OUTPUT
     rm $PID_FILE
 }
 
+show_help() {
+    echo "This script tests all the default Isar images in QEMU."
+    echo
+    echo "Usage:"
+    echo "    $0 [params]"
+    echo
+    echo "Parameters:"
+    echo "    -v, --verbose         display boot logs for all the targets."
+    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
+        ;;
+    -v|--verbose)
+        VERBOSE=1
+        ;;
+    *)
+        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 wheezy
 run_test arm jessie
-- 
2.1.4


  reply	other threads:[~2018-05-01 17:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-01 17:55 [PATCH 0/3] Update scripts Alexander Smirnov
2018-05-01 17:55 ` Alexander Smirnov [this message]
2018-05-02  8:30   ` [PATCH 1/3] scripts/vm_smoke_test: Add verbosity parameter Henning Schild
2018-05-01 17:55 ` [PATCH 2/3] scripts/vm_smoke_test: Check if QEMU didn't start Alexander Smirnov
2018-05-02  8:36   ` Henning Schild
2018-05-01 17:55 ` [PATCH 3/3] scripts/ci_build: Make CI script more generic Alexander Smirnov
2018-05-02  8:39   ` Henning Schild
2018-05-02  8:42 ` [PATCH 0/3] Update scripts Henning Schild

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=20180501175511.26145-2-asmirnov@ilbers.de \
    --to=asmirnov@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