public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH v2 0/3] Update scripts
@ 2018-05-04 12:27 Alexander Smirnov
  2018-05-04 12:27 ` [PATCH v2 1/3] scripts/vm_smoke_test: Add quite parameter Alexander Smirnov
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Alexander Smirnov @ 2018-05-04 12:27 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Hello all,

this is the second version of patches which update build and testing
scripts.

Changes since v1:
1. According to the Henning's suggestion, I set verbose output
enabled by default. In general, these scripts should be used for
CI and testing only, so for me it's OK to have verbosity by default.
2. Add debug option for bitbake.

Alex

Alexander Smirnov (3):
  scripts/vm_smoke_test: Add quite parameter
  scripts/vm_smoke_test: Check if QEMU didn't start
  scripts/ci_build: Make CI script more generic

 scripts/ci_build.sh   | 72 +++++++++++++++++++++++++++++++++-------
 scripts/vm_smoke_test | 91 +++++++++++++++++++++++++++++++++++++++++----------
 2 files changed, 134 insertions(+), 29 deletions(-)

-- 
2.1.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/3] scripts/vm_smoke_test: Add quite parameter
  2018-05-04 12:27 [PATCH v2 0/3] Update scripts Alexander Smirnov
@ 2018-05-04 12:27 ` Alexander Smirnov
  2018-05-04 12:27 ` [PATCH v2 2/3] scripts/vm_smoke_test: Check if QEMU didn't start Alexander Smirnov
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Smirnov @ 2018-05-04 12:27 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Due to this script is used for QA needs only, it's OK that it has verbose
output enabled by default. This patch adds option to supress excessive
output. But the boot log for specific configuration will be anyway shown
if respective test case failed.

Also this patch fixes an issue that the same boot log could be displayed
multiple times.

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

diff --git a/scripts/vm_smoke_test b/scripts/vm_smoke_test
index 274ec1d..76db97d 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=1
 
-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
 }
 
@@ -49,24 +55,62 @@ run_test () {
     echo "-------------------------------------------------"
     echo "Testing Isar [$DISTRO] image for [$ARCH] machine:"
 
-    # Start QEMU with Isar image
     start_vm -a $ARCH -d $DISTRO -o $CONSOLE_OUTPUT -p $PID_FILE > /dev/null 2>&1 &
     sleep 60
     kill `cat $PID_FILE`
 
-    # Check login prompt
+    FAIL=0
+
     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 "    -q, --quite           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 "    -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
+        ;;
+    -q|--quite)
+        VERBOSE=0
+        ;;
+    *)
+        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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 2/3] scripts/vm_smoke_test: Check if QEMU didn't start
  2018-05-04 12:27 [PATCH v2 0/3] Update scripts Alexander Smirnov
  2018-05-04 12:27 ` [PATCH v2 1/3] scripts/vm_smoke_test: Add quite parameter Alexander Smirnov
@ 2018-05-04 12:27 ` Alexander Smirnov
  2018-05-04 12:27 ` [PATCH v2 3/3] scripts/ci_build: Make CI script more generic Alexander Smirnov
  2018-05-04 18:23 ` [PATCH v2 0/3] Update scripts Henning Schild
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Smirnov @ 2018-05-04 12:27 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Add check for QEMU start and display error message if it didn't start.

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

diff --git a/scripts/vm_smoke_test b/scripts/vm_smoke_test
index 76db97d..9c50508 100755
--- a/scripts/vm_smoke_test
+++ b/scripts/vm_smoke_test
@@ -1,7 +1,7 @@
 #!/bin/sh
 #
 # This software is a part of ISAR.
-# Copyright (C) 2015-2017 ilbers GmbH
+# Copyright (C) 2015-2018 ilbers GmbH
 
 CONSOLE_OUTPUT=/tmp/isar_console
 PID_FILE=/tmp/qemu.pid
@@ -56,18 +56,29 @@ run_test () {
     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 60
-    kill `cat $PID_FILE`
+    sleep 5
 
-    FAIL=0
+    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 60
+        kill `cat $PID_FILE`
+
+        FAIL=0
 
-    check_login_prompt
+        check_login_prompt
 
-    check_example_module
+        check_example_module
 
-    [ $VERBOSE -eq 1 -o $FAIL -eq 1 ] && dump_boot_log
+        [ $VERBOSE -eq 1 -o $FAIL -eq 1 ] && dump_boot_log
+
+        rm $CONSOLE_OUTPUT
+    fi
 
-    rm $CONSOLE_OUTPUT
     rm $PID_FILE
 }
 
-- 
2.1.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 3/3] scripts/ci_build: Make CI script more generic
  2018-05-04 12:27 [PATCH v2 0/3] Update scripts Alexander Smirnov
  2018-05-04 12:27 ` [PATCH v2 1/3] scripts/vm_smoke_test: Add quite parameter Alexander Smirnov
  2018-05-04 12:27 ` [PATCH v2 2/3] scripts/vm_smoke_test: Check if QEMU didn't start Alexander Smirnov
@ 2018-05-04 12:27 ` Alexander Smirnov
  2018-05-04 18:23 ` [PATCH v2 0/3] Update scripts Henning Schild
  3 siblings, 0 replies; 5+ messages in thread
From: Alexander Smirnov @ 2018-05-04 12:27 UTC (permalink / raw)
  To: isar-users; +Cc: Alexander Smirnov

Make this script more generic, so it could be used by any CI and by user
as well. Also add parameter to specify build folder.

Usage:
  ci_build [-q | -d] -b BUILD_DIR

And this command will build all the default Isar images.

Signed-off-by: Alexander Smirnov <asmirnov@ilbers.de>
---
 scripts/ci_build.sh | 72 +++++++++++++++++++++++++++++++++++++++++++++--------
 1 file changed, 61 insertions(+), 11 deletions(-)

diff --git a/scripts/ci_build.sh b/scripts/ci_build.sh
index e941f8c..fec0000 100755
--- a/scripts/ci_build.sh
+++ b/scripts/ci_build.sh
@@ -1,28 +1,78 @@
-# Script for Jenkins build
+# Script for CI system build
 #
 # Alexander Smirnov <asmirnov@ilbers.de>
-# Copyright (c) 2016-2017 ilbers GmbH
+# Copyright (c) 2016-2018 ilbers GmbH
 
 #!/bin/sh
 
+ES_BUG=3
+
 # Export $PATH to use 'parted' tool
 export PATH=$PATH:/sbin
 
-# Get parameters from the command line
-WORKSPACE=$1
-GIT_COMMIT=$2
-
 # Go to Isar root
 cd $(dirname $0)/..
 
-# Setup build folder for current revision
-if [ ! -d /build/$WORKSPACE/$GIT_COMMIT ]; then
-        mkdir -p /build/$WORKSPACE/$GIT_COMMIT
+# Start build in Isar tree by default
+BUILD_DIR=./build
+
+BB_ARGS="-v"
+
+show_help() {
+    echo "This script builds all the default Isar images."
+    echo
+    echo "Usage:"
+    echo "    $0 [params]"
+    echo
+    echo "Parameters:"
+    echo "    -b, --build BUILD_DIR set path to build directory. If not set,"
+    echo "                          the build will be started in current path."
+    echo "    -d, --debug           enable debug bitbake output."
+    echo "    -q, --quite           suppress verbose bitbake output."
+    echo "    --help                display this message and exit."
+    echo
+    echo "Exit status:"
+    echo " 0  if OK,"
+    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
+        ;;
+    -b|--build)
+        BUILD_DIR="$2"
+        shift
+        ;;
+    -d|--debug)
+        BB_ARGS="$BB_ARGS -d"
+        ;;
+    -q|--quite)
+        BB_ARGS=""
+        ;;
+    *)
+        echo "error: invalid parameter '$key', please try '--help' to get list of supported parameters"
+        exit $ES_BUG
+        ;;
+    esac
+
+    shift
+done
+
+# Setup build folder for the current build
+if [ ! -d $BUILD_DIR ]; then
+        mkdir -p $BUILD_DIR
 fi
-source isar-init-build-env /build/$WORKSPACE/$GIT_COMMIT
+source isar-init-build-env $BUILD_DIR
 
 # Start build for all possible configurations
-bitbake -v \
+bitbake $BB_ARGS \
         multiconfig:qemuarm-wheezy:isar-image-base \
         multiconfig:qemuarm-jessie:isar-image-base \
         multiconfig:qemuarm-stretch:isar-image-base \
-- 
2.1.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/3] Update scripts
  2018-05-04 12:27 [PATCH v2 0/3] Update scripts Alexander Smirnov
                   ` (2 preceding siblings ...)
  2018-05-04 12:27 ` [PATCH v2 3/3] scripts/ci_build: Make CI script more generic Alexander Smirnov
@ 2018-05-04 18:23 ` Henning Schild
  3 siblings, 0 replies; 5+ messages in thread
From: Henning Schild @ 2018-05-04 18:23 UTC (permalink / raw)
  To: Alexander Smirnov; +Cc: isar-users

LGTM

Am Fri, 4 May 2018 15:27:11 +0300
schrieb Alexander Smirnov <asmirnov@ilbers.de>:

> Hello all,
> 
> this is the second version of patches which update build and testing
> scripts.
> 
> Changes since v1:
> 1. According to the Henning's suggestion, I set verbose output
> enabled by default. In general, these scripts should be used for
> CI and testing only, so for me it's OK to have verbosity by default.
> 2. Add debug option for bitbake.
> 
> Alex
> 
> Alexander Smirnov (3):
>   scripts/vm_smoke_test: Add quite parameter
>   scripts/vm_smoke_test: Check if QEMU didn't start
>   scripts/ci_build: Make CI script more generic
> 
>  scripts/ci_build.sh   | 72 +++++++++++++++++++++++++++++++++-------
>  scripts/vm_smoke_test | 91
> +++++++++++++++++++++++++++++++++++++++++---------- 2 files changed,
> 134 insertions(+), 29 deletions(-)
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-05-04 18:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04 12:27 [PATCH v2 0/3] Update scripts Alexander Smirnov
2018-05-04 12:27 ` [PATCH v2 1/3] scripts/vm_smoke_test: Add quite parameter Alexander Smirnov
2018-05-04 12:27 ` [PATCH v2 2/3] scripts/vm_smoke_test: Check if QEMU didn't start Alexander Smirnov
2018-05-04 12:27 ` [PATCH v2 3/3] scripts/ci_build: Make CI script more generic Alexander Smirnov
2018-05-04 18:23 ` [PATCH v2 0/3] Update scripts Henning Schild

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox