<div dir="ltr">Merged, thanks!<div><br></div><div>Jérémie</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 6, 2015 at 5:15 PM, Mathieu Desnoyers <span dir="ltr"><<a href="mailto:mathieu.desnoyers@efficios.com" target="_blank">mathieu.desnoyers@efficios.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Fix racy session/relayd wait-after-kill scheme.<br>
Fix racy live test where application may not have generated events yet<br>
when we attach to the live trace.<br>
<br>
Signed-off-by: Mathieu Desnoyers <<a href="mailto:mathieu.desnoyers@efficios.com">mathieu.desnoyers@efficios.com</a>><br>
---<br>
 tests/regression/tools/health/test_health.sh       |   4 +-<br>
 tests/regression/tools/live/test_kernel            |  47 +---------<br>
 tests/regression/tools/live/test_ust               |  60 ++++--------<br>
 .../regression/tools/live/test_ust_tracefile_count |  60 ++++--------<br>
 tests/regression/tools/save-load/test_load         |   6 +-<br>
 tests/utils/utils.sh                               | 103 ++++++++++++++++-----<br>
 6 files changed, 120 insertions(+), 160 deletions(-)<br>
<br>
diff --git a/tests/regression/tools/health/test_health.sh b/tests/regression/tools/health/test_health.sh<br>
index ade4b0e..40d2f9e 100644<br>
--- a/tests/regression/tools/health/test_health.sh<br>
+++ b/tests/regression/tools/health/test_health.sh<br>
@@ -146,7 +146,9 @@ function test_health<br>
        fi<br>
<br>
        if [ ${test_relayd} -eq 1 ]; then<br>
-               stop_lttng_relayd_nocheck<br>
+               # We may fail to stop relayd here, and this is OK, since<br>
+               # it may have been killed volountarily by testpoint.<br>
+               stop_lttng_relayd_notap<br>
        fi<br>
        stop_lttng_sessiond<br>
<br>
diff --git a/tests/regression/tools/live/test_kernel b/tests/regression/tools/live/test_kernel<br>
index 4b958df..0e542da 100755<br>
--- a/tests/regression/tools/live/test_kernel<br>
+++ b/tests/regression/tools/live/test_kernel<br>
@@ -62,22 +62,8 @@ else<br>
        exit 0<br>
 fi<br>
<br>
-if [ -z $(pidof lt-$SESSIOND_BIN) ]; then<br>
-       $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"<br>
-       if [ $? -eq 1 ]; then<br>
-               echo "Fail to start lttng-sessiond"<br>
-               exit 1<br>
-       fi<br>
-fi<br>
-<br>
-opt="--background -o $TRACE_PATH"<br>
-if [ -z $(pidof lt-$RELAYD_BIN) ]; then<br>
-       $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1<br>
-       if [ $? -eq 1 ]; then<br>
-               echo "Fail to start lttng-relayd (opt: $opt)"<br>
-               return 1<br>
-       fi<br>
-fi<br>
+start_lttng_sessiond_notap<br>
+start_lttng_relayd_notap "-o $TRACE_PATH"<br>
<br>
 setup_live_tracing<br>
<br>
@@ -86,30 +72,5 @@ $TESTDIR/regression/tools/live/live_test<br>
<br>
 clean_live_tracing<br>
<br>
-# Kill the relayd<br>
-PID_RELAYD=`pidof lt-$RELAYD_BIN`<br>
-kill $PID_RELAYD<br>
-if [ $? -eq 1 ]; then<br>
-       echo "Kill lttng-relayd (pid: $PID_RELAYD)"<br>
-       exit 1<br>
-else<br>
-       out=1<br>
-       while [ -n "$out" ]; do<br>
-               out=$(pidof lt-$RELAYD_BIN)<br>
-               sleep 0.5<br>
-       done<br>
-fi<br>
-<br>
-# Kill the sessiond<br>
-PID_SESSIOND=`pidof lt-$SESSIOND_BIN`<br>
-kill $PID_SESSIOND<br>
-if [ $? -eq 1 ]; then<br>
-       echo "Kill sessiond daemon"<br>
-       exit 1<br>
-else<br>
-       out=1<br>
-       while [ -n "$out" ]; do<br>
-               out=$(pidof lt-$SESSIOND_BIN)<br>
-               sleep 0.5<br>
-       done<br>
-fi<br>
+stop_lttng_relayd_notap<br>
+stop_lttng_sessiond_notap<br>
diff --git a/tests/regression/tools/live/test_ust b/tests/regression/tools/live/test_ust<br>
index ae69195..0b96858 100755<br>
--- a/tests/regression/tools/live/test_ust<br>
+++ b/tests/regression/tools/live/test_ust<br>
@@ -59,57 +59,29 @@ function clean_live_tracing()<br>
        rm -rf $TRACE_PATH<br>
 }<br>
<br>
-if [ -z $(pidof lt-$SESSIOND_BIN) ]; then<br>
-       $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"<br>
-       if [ $? -eq 1 ]; then<br>
-               echo "Fail to start lttng-sessiond"<br>
-               exit 1<br>
-       fi<br>
-fi<br>
-<br>
-opt="-o $TRACE_PATH --background"<br>
-if [ -z $(pidof lt-$RELAYD_BIN) ]; then<br>
-       $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1<br>
-       if [ $? -eq 1 ]; then<br>
-               echo "Fail to start lttng-relayd (opt: $opt)"<br>
-               return 1<br>
-       fi<br>
-fi<br>
+file_sync_after_first=$(mktemp -u)<br>
+<br>
+start_lttng_sessiond_notap<br>
+start_lttng_relayd_notap "-o $TRACE_PATH"<br>
<br>
 setup_live_tracing<br>
<br>
 # Run app in background<br>
-$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1<br>
+$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} >/dev/null 2>&1<br>
+<br>
+while [ ! -f "${file_sync_after_first}" ]; do<br>
+       sleep 0.5<br>
+done<br>
<br>
 # Start the live test<br>
 $TESTDIR/regression/tools/live/live_test<br>
<br>
+# Wait for the applications started in background<br>
+wait<br>
+<br>
 clean_live_tracing<br>
<br>
-# Kill the relayd<br>
-PID_RELAYD=`pidof lt-$RELAYD_BIN`<br>
-kill $PID_RELAYD<br>
-if [ $? -eq 1 ]; then<br>
-       echo "Kill lttng-relayd (pid: $PID_RELAYD)"<br>
-       exit 1<br>
-else<br>
-       out=1<br>
-       while [ -n "$out" ]; do<br>
-               out=$(pidof lt-$RELAYD_BIN)<br>
-               sleep 0.5<br>
-       done<br>
-fi<br>
-<br>
-# Kill the sessiond<br>
-PID_SESSIOND=`pidof lt-$SESSIOND_BIN`<br>
-kill $PID_SESSIOND<br>
-if [ $? -eq 1 ]; then<br>
-       echo "Kill sessiond daemon"<br>
-       exit 1<br>
-else<br>
-       out=1<br>
-       while [ -n "$out" ]; do<br>
-               out=$(pidof lt-$SESSIOND_BIN)<br>
-               sleep 0.5<br>
-       done<br>
-fi<br>
+rm -f ${file_sync_after_first}<br>
+<br>
+stop_lttng_relayd_notap<br>
+stop_lttng_sessiond_notap<br>
diff --git a/tests/regression/tools/live/test_ust_tracefile_count b/tests/regression/tools/live/test_ust_tracefile_count<br>
index 68e3722..54d6a52 100755<br>
--- a/tests/regression/tools/live/test_ust_tracefile_count<br>
+++ b/tests/regression/tools/live/test_ust_tracefile_count<br>
@@ -60,57 +60,29 @@ function clean_live_tracing()<br>
        rm -rf $TRACE_PATH<br>
 }<br>
<br>
-if [ -z $(pidof lt-$SESSIOND_BIN) ]; then<br>
-       $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --quiet --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"<br>
-       if [ $? -eq 1 ]; then<br>
-               echo "Fail to start lttng-sessiond"<br>
-               exit 1<br>
-       fi<br>
-fi<br>
-<br>
-opt="-o $TRACE_PATH --background"<br>
-if [ -z $(pidof lt-$RELAYD_BIN) ]; then<br>
-       $DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt >/dev/null 2>&1<br>
-       if [ $? -eq 1 ]; then<br>
-               echo "Fail to start lttng-relayd (opt: $opt)"<br>
-               return 1<br>
-       fi<br>
-fi<br>
+file_sync_after_first=$(mktemp -u)<br>
+<br>
+start_lttng_sessiond_notap<br>
+start_lttng_relayd_notap "-o $TRACE_PATH"<br>
<br>
 setup_live_tracing<br>
<br>
 # Run app in background<br>
-$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT >/dev/null 2>&1<br>
+$TESTAPP_BIN $NR_ITER $NR_USEC_WAIT ${file_sync_after_first} >/dev/null 2>&1<br>
+<br>
+while [ ! -f "${file_sync_after_first}" ]; do<br>
+       sleep 0.5<br>
+done<br>
<br>
 # Start the live test<br>
 $TESTDIR/regression/tools/live/live_test<br>
<br>
+# Wait for the applications started in background<br>
+wait<br>
+<br>
 clean_live_tracing<br>
<br>
-# Kill the relayd<br>
-PID_RELAYD=`pidof lt-$RELAYD_BIN`<br>
-kill $PID_RELAYD<br>
-if [ $? -eq 1 ]; then<br>
-       echo "Kill lttng-relayd (pid: $PID_RELAYD)"<br>
-       exit 1<br>
-else<br>
-       out=1<br>
-       while [ -n "$out" ]; do<br>
-               out=$(pidof lt-$RELAYD_BIN)<br>
-               sleep 0.5<br>
-       done<br>
-fi<br>
-<br>
-# Kill the sessiond<br>
-PID_SESSIOND=`pidof lt-$SESSIOND_BIN`<br>
-kill $PID_SESSIOND<br>
-if [ $? -eq 1 ]; then<br>
-       echo "Kill sessiond daemon"<br>
-       exit 1<br>
-else<br>
-       out=1<br>
-       while [ -n "$out" ]; do<br>
-               out=$(pidof lt-$SESSIOND_BIN)<br>
-               sleep 0.5<br>
-       done<br>
-fi<br>
+rm -f ${file_sync_after_first}<br>
+<br>
+stop_lttng_relayd_notap<br>
+stop_lttng_sessiond_notap<br>
diff --git a/tests/regression/tools/save-load/test_load b/tests/regression/tools/save-load/test_load<br>
index c6234ef..0a7ee3a 100755<br>
--- a/tests/regression/tools/save-load/test_load<br>
+++ b/tests/regression/tools/save-load/test_load<br>
@@ -29,7 +29,7 @@ EVENT_NAME="tp:tptest"<br>
<br>
 DIR=$(readlink -f $TESTDIR)<br>
<br>
-NUM_TESTS=21<br>
+NUM_TESTS=23<br>
<br>
 source $TESTDIR/utils/utils.sh<br>
<br>
@@ -92,7 +92,7 @@ function test_complex_load()<br>
        fi<br>
        destroy_lttng_session_ok $sess<br>
<br>
-       stop_lttng_relayd_nocheck<br>
+       stop_lttng_relayd<br>
 }<br>
<br>
 function test_all_load()<br>
@@ -108,7 +108,7 @@ function test_all_load()<br>
        destroy_lttng_session_ok $SESSION_NAME<br>
        destroy_lttng_session_ok "$SESSION_NAME-complex"<br>
<br>
-       stop_lttng_relayd_nocheck<br>
+       stop_lttng_relayd<br>
 }<br>
<br>
 function test_overwrite()<br>
diff --git a/tests/utils/utils.sh b/tests/utils/utils.sh<br>
index 4282fbb..60adb4f 100644<br>
--- a/tests/utils/utils.sh<br>
+++ b/tests/utils/utils.sh<br>
@@ -238,9 +238,10 @@ function lttng_disable_kernel_channel_fail()<br>
        lttng_disable_kernel_channel 1 "$@"<br>
 }<br>
<br>
-function start_lttng_relayd<br>
+function start_lttng_relayd_opt()<br>
 {<br>
-       local opt=$1<br>
+       local withtap=$1<br>
+       local opt=$2<br>
<br>
        DIR=$(readlink -f $TESTDIR)<br>
<br>
@@ -248,52 +249,77 @@ function start_lttng_relayd<br>
                $DIR/../src/bin/lttng-relayd/$RELAYD_BIN -b $opt >$OUTPUT_DEST<br>
                #$DIR/../src/bin/lttng-relayd/$RELAYD_BIN $opt -vvv >>/tmp/relayd.log 2>&1 &<br>
                if [ $? -eq 1 ]; then<br>
-                       fail "Start lttng-relayd (opt: $opt)"<br>
+                       if [ $withtap -eq "1" ]; then<br>
+                               fail "Start lttng-relayd (opt: $opt)"<br>
+                       fi<br>
                        return 1<br>
                else<br>
-                       pass "Start lttng-relayd (opt: $opt)"<br>
+                       if [ $withtap -eq "1" ]; then<br>
+                               pass "Start lttng-relayd (opt: $opt)"<br>
+                       fi<br>
                fi<br>
        else<br>
                pass "Start lttng-relayd (opt: $opt)"<br>
        fi<br>
 }<br>
<br>
-function stop_lttng_relayd_nocheck<br>
+function start_lttng_relayd()<br>
 {<br>
+       start_lttng_relayd_opt 1 "$@"<br>
+}<br>
+<br>
+function start_lttng_relayd_notap()<br>
+{<br>
+       start_lttng_relayd_opt 0 "$@"<br>
+}<br>
+<br>
+function stop_lttng_relayd_opt()<br>
+{<br>
+       local withtap=$1<br>
+<br>
        PID_RELAYD=`pidof lt-$RELAYD_BIN`<br>
<br>
-       diag "Killing lttng-relayd (pid: $PID_RELAYD)"<br>
+       if [ $withtap -eq "1" ]; then<br>
+               diag "Killing lttng-relayd (pid: $PID_RELAYD)"<br>
+       fi<br>
        kill $PID_RELAYD >$OUTPUT_DEST<br>
        retval=$?<br>
<br>
-       if [ $retval -eq 1 ]; then<br>
+       if [ $? -eq 1 ]; then<br>
+               if [ $withtap -eq "1" ]; then<br>
+                       fail "Kill relay daemon"<br>
+               fi<br>
+               return 1<br>
+       else<br>
                out=1<br>
                while [ -n "$out" ]; do<br>
                        out=$(pidof lt-$RELAYD_BIN)<br>
                        sleep 0.5<br>
                done<br>
+               if [ $withtap -eq "1" ]; then<br>
+                       pass "Kill relay daemon"<br>
+               fi<br>
        fi<br>
        return $retval<br>
 }<br>
<br>
-function stop_lttng_relayd<br>
+function stop_lttng_relayd()<br>
 {<br>
-       stop_lttng_relayd_nocheck<br>
+       stop_lttng_relayd_opt 1 "$@"<br>
+}<br>
<br>
-       if [ $? -eq 1 ]; then<br>
-               fail "Killed lttng-relayd (pid: $PID_RELAYD)"<br>
-               return 1<br>
-       else<br>
-               pass "Killed lttng-relayd (pid: $PID_RELAYD)"<br>
-               return 0<br>
-       fi<br>
+function stop_lttng_relayd_notap()<br>
+{<br>
+       stop_lttng_relayd_opt 0 "$@"<br>
 }<br>
<br>
-#First argument: load path for automatic loading<br>
-function start_lttng_sessiond()<br>
+#First arg: show tap output<br>
+#Second argument: load path for automatic loading<br>
+function start_lttng_sessiond_opt()<br>
 {<br>
+       local withtap=$1<br>
+       local load_path=$2<br>
<br>
-       local load_path="$1"<br>
        if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then<br>
                # Env variable requested no session daemon<br>
                return<br>
@@ -311,19 +337,33 @@ function start_lttng_sessiond()<br>
<br>
        if [ -z $(pidof lt-$SESSIOND_BIN) ]; then<br>
                # Have a load path ?<br>
-               if [ -n "$1" ]; then<br>
+               if [ -n "$load_path" ]; then<br>
                        $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --load "$1" --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"<br>
                else<br>
                        $DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --consumerd32-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$DIR/../src/bin/lttng-consumerd/lttng-consumerd"<br>
                fi<br>
                #$DIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --background --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<br>
                status=$?<br>
-               ok $status "Start session daemon"<br>
+               if [ $withtap -eq "1" ]; then<br>
+                       ok $status "Start session daemon"<br>
+               fi<br>
        fi<br>
 }<br>
<br>
-function stop_lttng_sessiond ()<br>
+function start_lttng_sessiond()<br>
+{<br>
+       start_lttng_sessiond_opt 1 "$@"<br>
+}<br>
+<br>
+function start_lttng_sessiond_notap()<br>
 {<br>
+       start_lttng_sessiond_opt 0 "$@"<br>
+}<br>
+<br>
+function stop_lttng_sessiond_opt()<br>
+{<br>
+       local withtap=$1<br>
+<br>
        if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then<br>
                # Env variable requested no session daemon<br>
                return<br>
@@ -334,8 +374,9 @@ function stop_lttng_sessiond ()<br>
        kill $PID_SESSIOND >$OUTPUT_DEST<br>
<br>
        if [ $? -eq 1 ]; then<br>
-               fail "Kill sessions daemon"<br>
-               return 1<br>
+               if [ $withtap -eq "1" ]; then<br>
+                       fail "Kill sessions daemon"<br>
+               fi<br>
        else<br>
                out=1<br>
                while [ -n "$out" ]; do<br>
@@ -347,10 +388,22 @@ function stop_lttng_sessiond ()<br>
                        out=$(pidof $CONSUMERD_BIN)<br>
                        sleep 0.5<br>
                done<br>
-               pass "Kill session daemon"<br>
+               if [ $withtap -eq "1" ]; then<br>
+                       pass "Kill session daemon"<br>
+               fi<br>
        fi<br>
 }<br>
<br>
+function stop_lttng_sessiond()<br>
+{<br>
+       stop_lttng_sessiond_opt 1 "$@"<br>
+}<br>
+<br>
+function stop_lttng_sessiond_notap()<br>
+{<br>
+       stop_lttng_sessiond_opt 0 "$@"<br>
+}<br>
+<br>
 function list_lttng_with_opts ()<br>
 {<br>
        local opts=$1<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.4<br>
<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Jérémie Galarneau<br>EfficiOS Inc.<br><a href="http://www.efficios.com" target="_blank">http://www.efficios.com</a></div>
</div>