X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Futils.sh;h=24defc7f8d67c7172ef37c73cb4e60f673845623;hp=55bc9e9d5a41adf559840f41a0bab677c25894db;hb=b3e122872d4f6464ebcbc341b4fa4108c8a9d4a5;hpb=317eef9339f8620bf3d99972ba2a9196a36060db diff --git a/tests/utils.sh b/tests/utils.sh index 55bc9e9d5..24defc7f8 100644 --- a/tests/utils.sh +++ b/tests/utils.sh @@ -39,18 +39,20 @@ function validate_kernel_version () return 1 } -function start_sessiond () +function spawn_sessiond () { echo "" echo -n "Starting session daemon... " validate_kernel_version if [ $? -ne 0 ]; then - echo -e "\n*** Kernel to old for session daemon tests ***\n" + echo -e "\n*** Kernel too old for session daemon tests ***\n" 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 }