Tests: Add debug output to getcpu_override
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 4 Nov 2015 23:45:04 +0000 (18:45 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 6 Nov 2015 23:24:16 +0000 (18:24 -0500)
Adds debug output to the getcpu_override test and split its
two tests into two distinct functions. This ensures that we
output two separate traces without overwriting the previous one.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/ust/getcpu-override/test_getcpu_override

index 2492c9c1133eb7b3bd170afd15b9e36d584676cc..fae33293dfd6be2d81eae9aa90972a052dba98ac 100755 (executable)
@@ -86,7 +86,7 @@ compare()
        local valid=0
 
        test ${#array_to_compare[*]} -eq ${#SEQUENCE_SEED[*]}
-       ok $? "Sequence seed and cpuid sequence are equal ${#SEQUENCE_SEED[*]}/${#array_to_compare[*]}"
+       ok $? "Sequence seed and cpuid sequence have the same size ${#SEQUENCE_SEED[*]}/${#array_to_compare[*]}"
 
        for (( i = 0; i < ${#SEQUENCE_SEED[*]}; i++ )); do
                if [ "${array_to_compare[$i]}" -ne "$(( ${SEQUENCE_SEED[$i]} % $NPROC))" ]; then
@@ -97,15 +97,26 @@ compare()
 
        if [[ $expected_to_fail -eq "1" ]]; then
                test $valid -ne "0"
-               ok $? "Cpuid extraction and seed sequence comparison fail as expected"
+               ok $? "Cpuid extraction and seed sequence comparison fails as expected"
        else
                ok $valid "Cpuid extraction and seed sequence comparison"
+               if [[ $valid -ne "0" ]]; then
+                       diag "Dumping arrays after failed comparison"
+                       for (( i = 0; i < ${#SEQUENCE_SEED[*]}; i++ )); do
+                               echo -n "# array value is "
+                               echo -n "${array_to_compare[$i]}"
+                               echo -n " expected "
+                               echo "$(( ${SEQUENCE_SEED[$i]} % $NPROC))"
+                       done
+                       diag "Dumping trace"
+                       $BABELTRACE_BIN $TRACE_PATH | awk '{print "# " $0}'
+               fi
        fi
 }
 
-test_getcpu_override()
+test_getcpu_override_fail()
 {
-       diag "Getcpu plugin"
+       diag "Getcpu plugin - no preloaded plugin"
 
        create_lttng_session_ok $SESSION_NAME $TRACE_PATH
        enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"
@@ -115,12 +126,19 @@ test_getcpu_override()
        destroy_lttng_session_ok $SESSION_NAME
 
        # Move output to an array by using =($())
-       cpuid_events=($($BABELTRACE_BIN $TRACE_PATH | sed -n 's/.*cpu_id = \([0-9]*\).*/\1/p'))
-       num_events=${#cpuid_events[*]}
+       local cpuid_events=($($BABELTRACE_BIN $TRACE_PATH | sed -n 's/.*cpu_id = \([0-9]*\).*/\1/p'))
+       local num_events=${#cpuid_events[*]}
        test $num_events -eq $NUM_EVENT
        ok $? "Extraction without getcpu plugin have $num_events/$NUM_EVENT"
        compare_fail cpuid_events[@]
 
+       return $?
+}
+
+test_getcpu_override()
+{
+       diag "Getcpu plugin - with plugin preloaded"
+
        create_lttng_session_ok $SESSION_NAME $TRACE_PATH
        enable_ust_lttng_event_ok $SESSION_NAME "$EVENT_NAME"
        start_lttng_tracing_ok $SESSION_NAME
@@ -128,10 +146,10 @@ test_getcpu_override()
        stop_lttng_tracing_ok $SESSION_NAME
        destroy_lttng_session_ok $SESSION_NAME
 
-       cpuid_events=($($BABELTRACE_BIN $TRACE_PATH | sed -n 's/.*cpu_id = \([0-9]*\).*/\1/p'))
-       num_events=${#cpuid_events[*]}
+       local cpuid_events=($($BABELTRACE_BIN $TRACE_PATH | sed -n 's/.*cpu_id = \([0-9]*\).*/\1/p'))
+       local num_events=${#cpuid_events[*]}
        test $num_events -eq $NUM_EVENT
-       ok $? "Extraction without getcpu plugin have $num_events/$NUM_EVENT"
+       ok $? "Extraction with getcpu plugin have $num_events/$NUM_EVENT"
 
        compare_ok cpuid_events[@]
 
@@ -143,7 +161,8 @@ plan_tests $NUM_TESTS
 print_test_banner "$TEST_DESC"
 
 TESTS=(
-       "test_getcpu_override"
+       test_getcpu_override_fail
+       test_getcpu_override
 )
 
 TEST_COUNT=${#TESTS[@]}
@@ -151,16 +170,16 @@ i=0
 
 start_lttng_sessiond
 
-while [ "$i" -lt "$TEST_COUNT" ]; do
-
+for fct_test in ${TESTS[@]};
+do
        TRACE_PATH=$(mktemp -d)
 
-       # Execute test
-       ${TESTS[$i]}
+       ${fct_test}
+       if [ $? -ne 0 ]; then
+               break;
+       fi
 
        rm -rf $TRACE_PATH
-
-       let "i++"
 done
 
 stop_lttng_sessiond
This page took 0.028805 seconds and 5 git commands to generate.