Tests: Cleanup redundant code and use printing helper functions
authorChristian Babeux <christian.babeux@efficios.com>
Mon, 24 Sep 2012 16:11:46 +0000 (12:11 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 24 Sep 2012 20:36:18 +0000 (16:36 -0400)
Signed-off-by: Christian Babeux <christian.babeux@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
12 files changed:
tests/kernel/run-kernel-tests.sh
tests/tools/streaming/run-kernel
tests/tools/streaming/run-ust
tests/tools/streaming/uri_switch
tests/ust/before-after/run
tests/ust/high-throughput/run
tests/ust/low-throughput/run
tests/ust/multi-session/run
tests/ust/nprocesses/run
tests/ust/nprocesses/ust-nprocesses
tests/ust/run-ust-global-tests.sh
tests/utils.sh

index f872be5149ea0e50f6b778f7b6f0d9fe454e0480..f89cd7b260d2a1fccaf9669ae8eebbda6fda8dbb 100755 (executable)
@@ -46,9 +46,10 @@ function check_lttng_modules ()
        fi
 }
 
-echo -e "\n---------------------"
-echo -e "Testing Kernel tracer"
-echo -e "---------------------"
+
+TEST_DESC="Testing Kernel tracer"
+
+print_test_banner "$TEST_DESC"
 
 # Detect lttng-modules installed
 check_lttng_modules
index 73a99de158a070ccef6f95cbdb1b9d5953b260dd..b87be13c50f5b191da036cd8f033864c6955b53a 100755 (executable)
@@ -14,6 +14,7 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+TEST_DESC="Streaming - Kernel tracing"
 
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
@@ -25,9 +26,7 @@ TRACE_PATH=$(mktemp -d)
 
 source $TESTDIR/utils.sh
 
-echo -e "\n---------------------------"
-echo -e " Streaming - Kernel tracing "
-echo -e "----------------------------"
+print_test_banner "$TEST_DESC"
 
 if [ "$(id -u)" != "0" ]; then
        echo "This test must be running as root. Aborting"
@@ -50,10 +49,10 @@ function lttng_create_session
        # Create session with default path
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e '\e[1;31mFAILED\e[0m'
+               print_fail
                return 1
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
@@ -63,10 +62,10 @@ function lttng_enable_consumer_localhost
        # Create session with default path
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -k net://localhost >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e '\e[1;31mFAILED\e[0m'
+               print_fail
                return 1
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
index 0149918e22dff17f7489c27084c5fac5e2eb11cc..1c415cc70b44eb2f1436c6b7ce55f47b52b375b5 100755 (executable)
@@ -14,6 +14,7 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+TEST_DESC="Streaming - User space tracing"
 
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
@@ -26,9 +27,7 @@ TRACE_PATH=$(mktemp -d)
 
 source $TESTDIR/utils.sh
 
-echo -e "\n-------------------------------"
-echo -e " Streaming - User space tracing "
-echo -e "--------------------------------"
+print_test_banner "$TEST_DESC"
 
 if [ ! -x "$CURDIR/$BIN_NAME" ]; then
        echo -e "No UST nevents binary detected. Passing."
index a6b158230f4cb4cedd5793a413101508e8948812..cb0979e9a5a347cd0be7268d93c4460e9e2b2f47 100755 (executable)
@@ -15,6 +15,7 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+TEST_DESC="Streaming - URI switching"
 
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
@@ -27,10 +28,7 @@ TRACE_PATH=$(mktemp -d)
 
 source $TESTDIR/utils.sh
 
-echo -e "\n"
-echo -e "---------------------------"
-echo -e " Streaming - URI switching "
-echo -e "---------------------------"
+print_test_banner "$TEST_DESC"
 
 if [ ! -x "$CURDIR/$BIN_NAME" ]; then
        echo -e "No UST nevents binary detected. Skipping."
index 9b165282171a7bbb92fab9888a673170d6ff8873..5f6cc439b862cfb2b347db09f2e83209606a9264 100755 (executable)
@@ -14,6 +14,7 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+TEST_DESC="UST tracer - Start tracing before and after execution"
 
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
@@ -23,9 +24,7 @@ EVENT_NAME="ust_gen_nevents:tptest"
 
 source $TESTDIR/utils.sh
 
-echo -e "\n----------------------------------------------------"
-echo -e "UST tracer - Star tracing before and after execution"
-echo -e "----------------------------------------------------"
+print_test_banner "$TEST_DESC"
 
 if [ ! -x "$CURDIR/gen-nevents" ]; then
        echo -e "No UST nevents binary detected. Passing."
@@ -44,7 +43,8 @@ test_before_apps() {
        # Start test
        echo -n "Starting application... "
        ./$CURDIR/gen-nevents $NR_ITER
-       echo -e "Ended \e[1;32mOK\e[0m"
+       echo -n "Ended "
+       print_ok
        stop_tracing $SESSION_NAME
        destroy_lttng_session $SESSION_NAME
 
@@ -58,7 +58,7 @@ test_after_apps() {
 
        echo -n "Starting application... "
        ./$CURDIR/gen-nevents 100 &
-       echo -e "\e[1;32mOK\e[0m"
+       print_ok
 
        # BEFORE application is spawned
        create_lttng_session $SESSION_NAME $TRACE_PATH
@@ -74,11 +74,11 @@ test_after_apps() {
        out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l)
        if [ $out -eq 0 ]; then
                echo -n "No event found. Suppose to have at least one... "
-               echo -e "\e[1;31mFAILED\e[0m"
+               print_fail
                out=1
        else
                echo -n "Found $out event(s). Coherent... "
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
                out=0
        fi
 
index de3111ddde8b95540600cb796e43fd2ef8a18fa2..f86a17a14f8fd1e6015a07c6bbe00dc0fdc35ab4 100755 (executable)
@@ -14,6 +14,7 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+TEST_DESC="UST tracer - Testing high events throughput"
 
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
@@ -24,9 +25,7 @@ EVENT_NAME="tp:tptest"
 
 source $TESTDIR/utils.sh
 
-echo -e "\n-------------------------------------------"
-echo -e "UST tracer - Testing high events throughput"
-echo -e "-------------------------------------------"
+print_test_banner "$TEST_DESC"
 
 if [ ! -x "$CURDIR/$BIN_NAME" ]; then
        echo -e "No UST nevents binary detected. Passing."
@@ -81,11 +80,11 @@ let wanted=$NR_ITER*1000000
 
 if [ $wanted -ne $total ]; then
        echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
-       echo -e "\e[1;31mFAILED\e[0m"
+       print_fail
        out=1
 else
        echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... "
-       echo -e "\e[1;32mOK\e[0m"
+       print_ok
        out=0
 fi
 
index 3f2d1b72cfb8fe2b7f3ef1b1dfd53233e575e42b..219a6417e38c3e9193339e91f17b2479df79a8a5 100755 (executable)
@@ -14,6 +14,7 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+TEST_DESC="UST tracer - Testing low events throughput"
 
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
@@ -23,9 +24,7 @@ EVENT_NAME="tp:slow"
 
 source $TESTDIR/utils.sh
 
-echo -e "\n-------------------------------------------"
-echo -e "UST tracer - Testing low events throughput"
-echo -e "-------------------------------------------"
+print_test_banner "$TEST_DESC"
 
 if [ ! -x "$CURDIR/$BIN_NAME" ]; then
        echo -e "No UST nevents binary detected. Passing."
@@ -92,9 +91,9 @@ done
 
 if [ $out -eq 0 ]; then
        echo -n "Trace is coherent... "
-       echo -e "\e[1;32mOK\e[0m"
+       print_ok
 else
-       echo -e "\e[1;31mFAILED\e[0m"
+       print_fail
 fi
 
 rm -rf $TRACE_PATH
index f6dab7c65a3b5142c1028a56c99a29f3d908e777..ce3d12bcad735777da25bcead1c9e12ec016a1d9 100755 (executable)
@@ -14,6 +14,7 @@
 # You should have received a copy of the GNU Lesser General Public License
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+TEST_DESC="UST tracer - Multi-session"
 
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
@@ -23,9 +24,7 @@ EVENT_NAME="ust_gen_nevents:tptest"
 
 source $TESTDIR/utils.sh
 
-echo -e "\n--------------------------"
-echo -e "UST tracer - Multi-session"
-echo -e "--------------------------"
+print_test_banner "$TEST_DESC"
 
 if [ ! -x "$CURDIR/gen-nevents" ]; then
        echo -e "No UST nevents binary detected. Passing."
@@ -46,7 +45,7 @@ test_multi_session() {
 
        echo -n "Starting application generating $NR_ITER events... "
        ./$CURDIR/gen-nevents $NR_ITER &
-       echo -e "\e[1;32mOK\e[0m"
+       print_ok
 
        # At least hit one event
        echo -n "Waiting for events to record "
@@ -54,7 +53,7 @@ test_multi_session() {
                echo -n "."
                sleep 0.1
        done
-       echo -e "\e[1;32m OK\e[0m"
+       print_ok
 
        for i in `seq 0 3`; do
                stop_tracing "$SESSION_NAME-$i"
@@ -62,11 +61,11 @@ test_multi_session() {
                out=$(babeltrace "$TRACE_PATH/$i" | grep "$EVENT_NAMEi$i" | wc -l)
                if [ $out -ne $NR_ITER ]; then
                        echo -n "No event found. Suppose to have at least one... "
-                       echo -e "\e[1;31mFAILED\e[0m"
+                       print_fail
                        out=1
                else
                        echo -n "Found $out event(s) for $SESSION_NAME-$i. Coherent... "
-                       echo -e "\e[1;32mOK\e[0m"
+                       print_ok
                        out=0
                fi
        done
index 7513fe138c0b6a2bc8724a9e9670ea8ee413ef28..25ca413125a9dc429aaaa0dd6aab68b7ae2f95f4 100755 (executable)
 # You should have received a copy of the GNU Lesser General Public License
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+NR_ITER=100
+TEST_DESC="UST tracer - Generate $NR_ITER process"
 
 CURDIR=$(dirname $0)/
 TESTDIR=$CURDIR/../..
-NR_ITER=100
 TEST_BIN_NAME="gen-events-time"
 
 source $TESTDIR/utils.sh
 
-echo -e "\n-------------------------------------"
-echo -e "UST tracer - Generate $NR_ITER process"
-echo -e "---------------------------------------"
+print_test_banner "$TEST_DESC"
 
 if [ ! -x "$CURDIR/$TEST_BIN_NAME" ]; then
        echo -e "No UST $TEST_BIN_NAME binary detected. Passing."
index eab6d3965354718c497ee78b152c1d89a4364a95..7355057178501e5ee934ea1e77d93dbbe2cba127 100755 (executable)
@@ -41,9 +41,10 @@ sleep 3
 listing=$($TESTDIR/../src/bin/lttng/$LTTNG_BIN list -u)
 reg_app_count=$(echo -n $listing | sed "s/$TEST_BIN_NAME/$TEST_BIN_NAME\n/g" | grep "$TEST_BIN_NAME" | wc -l)
 if [ "$reg_app_count" -ne "$NR_ITER" ]; then
-       echo -e "$reg_app_count apps listed. Expected $NR_ITER \e[1;31mFAILED\e[0m"
+       echo -e "$reg_app_count apps listed. Expected $NR_ITER "
+       print_fail
 else
-       echo -e "\e[1;32mOK\e[0m"
+       print_ok
 fi
 
 TRACE_PATH=$(mktemp -d)
@@ -64,5 +65,5 @@ rm -rf $TRACE_PATH
 
 echo -e -n "Killing all spawned applications..."
 killall -q $TEST_BIN_NAME >/dev/null 2>&1 &
-echo -e "\e[1;32mOK\e[0m"
+print_ok
 exit 0
index 969e217332fe2eafd2b27e51ea754870dafe8c2c..57c517050095b8cf68ff3bee02c372a7406ce796 100755 (executable)
@@ -35,9 +35,9 @@ function start_tests ()
        rm -rf $tmpdir
 }
 
-echo -e "\n-------------------------------------------"
-echo -e "UST tracer - Global domain (LTTNG_DOMAIN_UST)"
-echo -e "---------------------------------------------"
+TEST_DESC="UST tracer - Global domain (LTTNG_DOMAIN_UST)"
+
+print_test_banner "$TEST_DESC"
 
 start_tests
 
index 8fcb0da38c2a8f4a3f9ca8af0484edf8b8aa4ee3..b4b2451018dc6e05764a16dbfd9bd130c4780468 100644 (file)
@@ -98,10 +98,10 @@ function spawn_sessiond ()
                $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"
                #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --verbose-consumer >>/tmp/sessiond.log 2>&1 &
                if [ $? -eq 1 ]; then
-                       echo -e "\e[1;31mFAILED\e[0m"
+                       print_fail
                        return 1
                else
-                       echo -e "\e[1;32mOK\e[0m"
+                       print_ok
                fi
        fi
 
@@ -121,10 +121,10 @@ function lttng_enable_kernel_event
        echo -n "Enabling kernel event $event_name for session $sess_name"
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -k >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e '\e[1;31mFAILED\e[0m'
+               print_fail
                return 1
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
@@ -140,13 +140,13 @@ function lttng_start_relayd
                $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1 &
                #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &
                if [ $? -eq 1 ]; then
-                       echo -e "\e[1;31mFAILED\e[0m"
+                       print_fail
                        return 1
                else
-                       echo -e "\e[1;32mOK\e[0m"
+                       print_ok
                fi
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
@@ -157,7 +157,7 @@ function lttng_stop_relayd
        echo -e -n "Killing lttng-relayd (pid: $PID_RELAYD)... "
        kill $PID_RELAYD >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e "\e[1;31mFAILED\e[0m"
+               print_fail
                return 1
        else
                out=1
@@ -165,7 +165,7 @@ function lttng_stop_relayd
                        out=$(pidof lt-$RELAYD_BIN)
                        sleep 0.5
                done
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
                return 0
        fi
 }
@@ -204,7 +204,7 @@ function stop_sessiond ()
        echo -e -n "Killing session daemon... "
        kill $PID_SESSIOND >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e "\e[1;31mFAILED\e[0m"
+               print_fail
                return 1
        else
                out=1
@@ -212,7 +212,7 @@ function stop_sessiond ()
                        out=$(pidof lt-$SESSIOND_BIN)
                        sleep 0.5
                done
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
@@ -224,10 +224,10 @@ function create_lttng_session ()
        echo -n "Creating lttng session $sess_name in $trace_path "
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $sess_name -o $trace_path >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e "\e[1;31mFAILED\e[0m"
+               print_fail
                return 1
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
@@ -239,10 +239,10 @@ function enable_lttng_channel()
        echo -n "Enabling lttng channel $channel_name for session $sess_name"
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel $channel_name -s $sess_name >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e "\e[1;31mFAILED\e[0m"
+               print_fail
                return 1
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
@@ -254,10 +254,10 @@ function disable_lttng_channel()
        echo -n "Disabling lttng channel $channel_name for session $sess_name"
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-channel $channel_name -s $sess_name >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e "\e[1;31mFAILED\e[0m"
+               print_fail
                return 1
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
@@ -269,10 +269,10 @@ function enable_ust_lttng_event ()
        echo -n "Enabling lttng event $event_name for session $sess_name "
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e '\e[1;31mFAILED\e[0m'
+               print_fail
                return 1
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
@@ -283,10 +283,10 @@ function start_tracing ()
        echo -n "Start lttng tracing for session $sess_name "
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN start $sess_name >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e '\e[1;31mFAILED\e[0m'
+               print_fail
                return 1
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
@@ -297,10 +297,10 @@ function stop_tracing ()
        echo -n "Stop lttng tracing for session $sess_name "
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN stop $sess_name >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e '\e[1;31mFAILED\e[0m'
+               print_fail
                return 1
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
@@ -311,10 +311,10 @@ function destroy_lttng_session ()
        echo -n "Destroy lttng session $sess_name "
        $TESTDIR/../src/bin/lttng/$LTTNG_BIN destroy $sess_name >/dev/null 2>&1
        if [ $? -eq 1 ]; then
-               echo -e '\e[1;31mFAILED\e[0m'
+               print_fail
                return 1
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
        fi
 }
 
@@ -334,10 +334,12 @@ function trace_matches ()
 
        count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
        if [ "$count" -ne "$nr_iter" ]; then
-               echo -e "$count found in trace \e[1;31mFAILED\e[0m"
+               echo -n "$count found in trace "
+               print_fail
                return 1
        else
-               echo -e "Trace is coherent \e[1;32mOK\e[0m"
+               echo -n "Trace is coherent "
+               print_ok
                return 0
        fi
 }
@@ -356,10 +358,10 @@ function validate_trace
        echo -n "Validating trace for event $event_name... "
        traced=$($BABELTRACE_BIN $trace_path 2>/dev/null | grep $event_name | wc -l)
        if [ $traced -eq 0 ]; then
-               echo -e "\e[1;31mFAILED\e[0m"
+               print_fail
                return 1
        else
-               echo -e "\e[1;32mOK\e[0m"
+               print_ok
                return 0
        fi
 }
This page took 0.050582 seconds and 4 git commands to generate.