run_tests: Nicer output, configurable verbosity.
authorbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 22 Aug 2008 11:08:10 +0000 (11:08 +0000)
committerbernie <bernie@38d2e660-2303-0410-9eaa-f027e97ec537>
Fri, 22 Aug 2008 11:08:10 +0000 (11:08 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1668 38d2e660-2303-0410-9eaa-f027e97ec537

bertos/run_tests.sh

index 22309ecadbe5c74346cb7747dc506144d414bfe2..c931da76f89cb0adbc3c56734e40c22d4c9c5568 100755 (executable)
@@ -1,16 +1,22 @@
 #!/bin/bash
 #
 # Copyright 2005 Develer S.r.l. (http://www.develer.com/)
-# All rights reserved.
+# Copyright 2008 Bernie Innocenti <bernie@codewiz.org>
 #
-# Author: Bernie Innocenti <bernie@codewiz.org>
-#
-# $Id$
+# Version: $Id$
+# Author:  Bernie Innocenti <bernie@codewiz.org>
 #
 
-VERBOSE=1
+# Testsuite output level:
+#  0 - quiet
+#  1 - progress output
+#  2 - build warnings
+#  3 - execution output
+#  4 - build commands
+VERBOSE=${VERBOSE:-1}
 
 CC=gcc
+#FIXME: -Ibertos/emul should not be needed
 CFLAGS="-W -Wall -Wextra -Ibertos -Ibertos/emul -std=gnu99 -fno-builtin -D_DEBUG -D_TEST -DARCH=ARCH_EMUL"
 
 CXX=g++
@@ -22,6 +28,16 @@ TESTS=${TESTS:-`find . \
 
 TESTOUT="testout"
 
+buildout='/dev/null'
+runout='/dev/null'
+[ "$VERBOSE" -ge 2 ] && buildout='/dev/stdout'
+[ "$VERBOSE" -ge 3 ] && runout='/dev/stdout'
+
+# Needed to get build/exec result code rather than tee's
+set -o pipefail
+
+rm -rf "${TESTOUT}.old"
+mv -f "${TESTOUT}" "$TESTOUT.old"
 mkdir -p "$TESTOUT"
 
 for src in $TESTS; do
@@ -34,10 +50,14 @@ for src in $TESTS; do
        esac
 
        [ $VERBOSE -gt 0 ] && echo "Building $name..."
-       $BUILDCMD 2>&1 | tee $name.build || echo "FAILED [BUILD]: $name"
-
-       [ $VERBOSE -gt 0 ] && echo "Running $name..."
-       $exe 2>&1 | tee $name.out || echo "FAILED [RUN]: $name"
-       #rm -f "$exe"
+       [ $VERBOSE -gt 4 ] && echo " $BUILDCMD"
+       if $BUILDCMD 2>&1 | tee >$buildout $TESTOUT/$name.build; then
+               [ $VERBOSE -gt 0 ] && echo "Running $name..."
+               if ! $exe 2>&1 | tee >$runout $TESTOUT/$name.out; then
+                       echo "FAILED [RUN]: $name"
+               fi
+       else
+               echo "FAILED [BUILD]: $name"
+       fi
 done