From: David Goulet Date: Wed, 17 Aug 2011 15:49:37 +0000 (-0400) Subject: Add lttng-modules detection for tests X-Git-Tag: v2.0-pre12~12 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=8e0dbb653e6872725775d640e2a64d4b08cceb3a;p=lttng-tools.git Add lttng-modules detection for tests Signed-off-by: David Goulet --- diff --git a/tests/lttng/run-kernel-tests.sh b/tests/lttng/run-kernel-tests.sh new file mode 100755 index 000000000..28ad6281b --- /dev/null +++ b/tests/lttng/run-kernel-tests.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +SESSIOND_BIN="ltt-sessiond" + +tmpdir=`mktemp -d` +tests=( kernel_event_basic kernel_all_events_basic ) +exit_code=0 + +function start_tests () +{ + for bin in ${tests[@]}; + do + ./$bin $tmpdir + # Test must return 0 to pass. + if [ $? -ne 0 ]; then + exit_code=1 + break + fi + # Cleaning up + rm -rf $tmpdir + done +} + +function check_lttng_modules () +{ + local out=`modprobe -l | grep lttng` + if [ -z "$out" ]; then + echo "LTTng modules not detected. Aborting kernel tests!" + echo "" + # Exit status 0 so the tests can continue + exit 0 + fi +} + +echo -e "\n--------------------------------------------------" +echo -e "Kernel tracer - Testing lttng client (liblttngctl)" +echo -e "--------------------------------------------------" + +# Detect lttng-modules installed + +check_lttng_modules + +if [ -z $(pidof $SESSIOND_BIN) ]; then + echo -n "Starting session daemon... " + ../ltt-sessiond/$SESSIOND_BIN --daemonize --quiet + if [ $? -eq 1 ]; then + echo -e '\e[1;31mFAILED\e[0m' + rm -rf $tmpdir + exit 1 + else + echo -e "\e[1;32mOK\e[0m" + fi +fi + +PID_SESSIOND=`pidof lt-$SESSIOND_BIN` + +# Simply wait for the session daemon bootstrap +sleep 1 + +start_tests + +echo -e -n "\nKilling session daemon... " +kill $PID_SESSIOND >/dev/null 2>&1 +if [ $? -eq 1 ]; then + echo -e '\e[1;31mFAILED\e[0m' +else + echo -e "\e[1;32mOK\e[0m" +fi + +exit $exit_code diff --git a/tests/lttng/runall.sh b/tests/lttng/runall.sh index 3d26bb172..0817f6813 100755 --- a/tests/lttng/runall.sh +++ b/tests/lttng/runall.sh @@ -1,55 +1,21 @@ #!/bin/bash -SESSIOND_BIN="ltt-sessiond" - -tmpdir=`mktemp -d` -tests=( kernel_event_basic kernel_all_events_basic ) +tests=( lttng/run-kernel-tests.sh ) exit_code=0 function start_tests () { for bin in ${tests[@]}; do - ./$bin $tmpdir + ./$bin # Test must return 0 to pass. if [ $? -ne 0 ]; then exit_code=1 break fi - # Cleaning up - rm -rf $tmpdir done } -echo -e "\n----------------------------------" -echo -e "Testing lttng client (liblttngctl)" -echo -e "----------------------------------" - -if [ -z $(pidof $SESSIOND_BIN) ]; then - echo -n "Starting session daemon... " - ../ltt-sessiond/$SESSIOND_BIN --daemonize --quiet - if [ $? -eq 1 ]; then - echo -e '\e[1;31mFAILED\e[0m' - rm -rf $tmpdir - exit 1 - else - echo -e "\e[1;32mOK\e[0m" - fi -fi - -PID_SESSIOND=`pidof lt-$SESSIOND_BIN` - -# Simply wait for the session daemon bootstrap -sleep 1 - start_tests -echo -e -n "\nKilling session daemon... " -kill $PID_SESSIOND >/dev/null 2>&1 -if [ $? -eq 1 ]; then - echo -e '\e[1;31mFAILED\e[0m' -else - echo -e "\e[1;32mOK\e[0m" -fi - exit $exit_code