X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=tests%2Futils.sh;h=9f2f629b49d6ec92a7b244e8e3a2c348e64ad8a2;hb=c0e668d09d6222ab3c792f70183f71eb5a18d8a7;hp=55bc9e9d5a41adf559840f41a0bab677c25894db;hpb=317eef9339f8620bf3d99972ba2a9196a36060db;p=lttng-tools.git diff --git a/tests/utils.sh b/tests/utils.sh index 55bc9e9d5..9f2f629b4 100644 --- a/tests/utils.sh +++ b/tests/utils.sh @@ -39,7 +39,7 @@ function validate_kernel_version () return 1 } -function start_sessiond () +function spawn_sessiond () { echo "" echo -n "Starting session daemon... " @@ -49,8 +49,10 @@ function start_sessiond () return 2 fi + DIR=$(readlink -f $TESTDIR) + if [ -z $(pidof lt-$SESSIOND_BIN) ]; then - $TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --daemonize --quiet --consumerd32-path="$(pwd)/../src/bin/lttng-consumerd/lttng-consumerd" --consumerd64-path="$(pwd)/../src/bin/lttng-consumerd/lttng-consumerd" + $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" if [ $? -eq 1 ]; then echo -e "\e[1;31mFAILED\e[0m" return 1 @@ -62,8 +64,35 @@ function start_sessiond () return 0 } +function start_sessiond() +{ + if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then + # Env variable requested no session daemon + return + fi + + spawn_sessiond + out=$? + if [ $out -eq 2 ]; then + # Kernel version is not compatible. + exit 0 + elif [ $out -ne 0 ]; then + echo "NOT bad $?" + exit 1 + fi + + # Simply wait for the session daemon bootstrap + echo "Waiting for the session daemon to bootstrap (2 secs)" + sleep 2 +} + function stop_sessiond () { + if [ -n $TEST_NO_SESSIOND ] && [ "$TEST_NO_SESSIOND" == "1" ]; then + # Env variable requested no session daemon + return + fi + PID_SESSIOND=`pidof lt-$SESSIOND_BIN` echo -e -n "Killing session daemon... " @@ -72,6 +101,11 @@ function stop_sessiond () echo -e "\e[1;31mFAILED\e[0m" return 1 else + out=1 + while [ -n "$out" ]; do + out=$(pidof lt-$SESSIOND_BIN) + sleep 0.5 + done echo -e "\e[1;32mOK\e[0m" fi } @@ -81,14 +115,43 @@ function create_lttng_session () sess_name=$1 trace_path=$2 - echo -n "Creating lttng session $SESSION_NAME in $TRACE_PATH " + 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" return 1 else echo -e "\e[1;32mOK\e[0m" - #echo $out | grep "written in" | cut -d' ' -f6 + fi +} + +function enable_lttng_channel() +{ + sess_name=$1 + channel_name=$2 + + 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" + return 1 + else + echo -e "\e[1;32mOK\e[0m" + fi +} + +function disable_lttng_channel() +{ + sess_name=$1 + channel_name=$2 + + 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" + return 1 + else + echo -e "\e[1;32mOK\e[0m" fi }