diff mbox

[kvm-unit-tests,v2,11/12] wrappers: consolidate skip output

Message ID 1450374823-7648-12-git-send-email-rkrcmar@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Radim Krčmář Dec. 17, 2015, 5:53 p.m. UTC
Ugly helpers will get us yellow "SKIP" to stdout and 77 on exit.

Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
---
 v2: new
 
 scripts/mkstandalone.sh |  6 +++---
 scripts/run.bash        | 25 ++++++++++++++++---------
 2 files changed, 19 insertions(+), 12 deletions(-)

Comments

Andrew Jones Dec. 17, 2015, 7:59 p.m. UTC | #1
On Thu, Dec 17, 2015 at 06:53:42PM +0100, Radim Kr?má? wrote:
> Ugly helpers will get us yellow "SKIP" to stdout and 77 on exit.
> 
> Signed-off-by: Radim Kr?má? <rkrcmar@redhat.com>
> ---
>  v2: new
>  
>  scripts/mkstandalone.sh |  6 +++---
>  scripts/run.bash        | 25 ++++++++++++++++---------
>  2 files changed, 19 insertions(+), 12 deletions(-)
> 
> diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
> index c37f694398b8..adb11abf650c 100755
> --- a/scripts/mkstandalone.sh
> +++ b/scripts/mkstandalone.sh
> @@ -66,7 +66,7 @@ cat scripts/run.bash >> $standalone
>  
>  if [ ! -f $kernel ]; then
>  	cat <<EOF >> $standalone
> -echo "skip $testname (test kernel not present)" 1>&2
> +echo "\$(SKIP) $testname (test kernel not present)"
>  exit 1
>  EOF
>  else
> @@ -89,8 +89,8 @@ echo \$qemu $cmdline -smp $smp $opts
>  
>  cmdline="\`echo '$cmdline' | sed s%$kernel%_NO_FILE_4Uhere_%\`"
>  if \$qemu \$cmdline 2>&1 | grep 'No accelerator found' >/dev/null; then
> -	echo "skip $testname (QEMU doesn't support KVM)"
> -	exit 1
> +	echo "\$(SKIP) $testname (QEMU doesn't support KVM)"
> +	exit \$EXIT_SKIP
>  fi
>  
>  __run()
> diff --git a/scripts/run.bash b/scripts/run.bash
> index d3e8d37d315d..06a13b9aaf1a 100644
> --- a/scripts/run.bash
> +++ b/scripts/run.bash
> @@ -1,3 +1,10 @@
> +PASS() { echo -ne "\e[32mPASS\e[0m"; }
> +SKIP() { echo -ne "\e[33mSKIP\e[0m"; }
> +FAIL() { echo -ne "\e[31mFAIL\e[0m"; }

I definitely put these in functions.bash, but then I'd put run() in
functions.bash too, as I said earlier.

> +
> +EXIT_SUCCESS=0
> +EXIT_SKIP=77
> +
>  function run()
>  {
>      local testname="$1"
> @@ -10,22 +17,22 @@ function run()
>      local accel="$8"
>  
>      if [ -z "$testname" ]; then
> -        return
> +        return $EXIT_SKIP
>      fi
>  
>      if [ -n "$only_group" ] && ! grep -q "$only_group" <<<$groups; then
> -        return
> +        return $EXIT_SKIP
>      fi
>  
>      if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
> -        echo "skip $1 ($arch only)"
> -        return
> +        echo "`SKIP` $testname ($arch only)"
> +        return $EXIT_SKIP
>      fi
>  
>      __eval_log "$check" || {
>          __eval_log 'echo "skipped $testname (check returned $?)"'
> -        echo "skip $testname (failed check)"
> -        return
> +        echo "`SKIP` $testname (failed check)"
> +        return $EXIT_SKIP
>      }
>  
>      cmdline="TESTNAME=$testname ACCEL=$accel __run $kernel -smp $smp $opts"
> @@ -41,9 +48,9 @@ function run()
>      ret=$(($? >> 1))
>  
>      case $ret in
> -    0)  echo -ne "\e[32mPASS\e[0m" ;;
> -    77) echo -ne "\e[33mSKIP\e[0m" ;;
> -    *)  echo -ne "\e[31mFAIL\e[0m"
> +    $EXIT_SUCCESS) PASS ;;
> +    $EXIT_SKIP)    SKIP ;;
> +    *)             FAIL
>      esac
>  
>      echo -n " $testname"
> -- 
> 2.6.4

Otherwise
Reviewed-by: Andrew Jones <drjones@redhat.com>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/scripts/mkstandalone.sh b/scripts/mkstandalone.sh
index c37f694398b8..adb11abf650c 100755
--- a/scripts/mkstandalone.sh
+++ b/scripts/mkstandalone.sh
@@ -66,7 +66,7 @@  cat scripts/run.bash >> $standalone
 
 if [ ! -f $kernel ]; then
 	cat <<EOF >> $standalone
-echo "skip $testname (test kernel not present)" 1>&2
+echo "\$(SKIP) $testname (test kernel not present)"
 exit 1
 EOF
 else
@@ -89,8 +89,8 @@  echo \$qemu $cmdline -smp $smp $opts
 
 cmdline="\`echo '$cmdline' | sed s%$kernel%_NO_FILE_4Uhere_%\`"
 if \$qemu \$cmdline 2>&1 | grep 'No accelerator found' >/dev/null; then
-	echo "skip $testname (QEMU doesn't support KVM)"
-	exit 1
+	echo "\$(SKIP) $testname (QEMU doesn't support KVM)"
+	exit \$EXIT_SKIP
 fi
 
 __run()
diff --git a/scripts/run.bash b/scripts/run.bash
index d3e8d37d315d..06a13b9aaf1a 100644
--- a/scripts/run.bash
+++ b/scripts/run.bash
@@ -1,3 +1,10 @@ 
+PASS() { echo -ne "\e[32mPASS\e[0m"; }
+SKIP() { echo -ne "\e[33mSKIP\e[0m"; }
+FAIL() { echo -ne "\e[31mFAIL\e[0m"; }
+
+EXIT_SUCCESS=0
+EXIT_SKIP=77
+
 function run()
 {
     local testname="$1"
@@ -10,22 +17,22 @@  function run()
     local accel="$8"
 
     if [ -z "$testname" ]; then
-        return
+        return $EXIT_SKIP
     fi
 
     if [ -n "$only_group" ] && ! grep -q "$only_group" <<<$groups; then
-        return
+        return $EXIT_SKIP
     fi
 
     if [ -n "$arch" ] && [ "$arch" != "$ARCH" ]; then
-        echo "skip $1 ($arch only)"
-        return
+        echo "`SKIP` $testname ($arch only)"
+        return $EXIT_SKIP
     fi
 
     __eval_log "$check" || {
         __eval_log 'echo "skipped $testname (check returned $?)"'
-        echo "skip $testname (failed check)"
-        return
+        echo "`SKIP` $testname (failed check)"
+        return $EXIT_SKIP
     }
 
     cmdline="TESTNAME=$testname ACCEL=$accel __run $kernel -smp $smp $opts"
@@ -41,9 +48,9 @@  function run()
     ret=$(($? >> 1))
 
     case $ret in
-    0)  echo -ne "\e[32mPASS\e[0m" ;;
-    77) echo -ne "\e[33mSKIP\e[0m" ;;
-    *)  echo -ne "\e[31mFAIL\e[0m"
+    $EXIT_SUCCESS) PASS ;;
+    $EXIT_SKIP)    SKIP ;;
+    *)             FAIL
     esac
 
     echo -n " $testname"