Check kernel version for tests
authorDavid Goulet <dgoulet@efficios.com>
Tue, 24 Jan 2012 16:49:49 +0000 (11:49 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Tue, 24 Jan 2012 16:49:49 +0000 (11:49 -0500)
Test using the session daemon must be done on a kernel version 2.6.27 or
higher for lttng-tools and lttng-ust requirements. Before starting a
session daemon, tests validate the kernel version and stop them if the
kernel is too old.

This is *really* important for launchpad build system which compile and
run our tests on 2.6.24 kernel.

Signed-off-by: David Goulet <dgoulet@efficios.com>
tests/runall.sh
tests/utils.sh

index 08b3904838d1408e54a7c2474cc952be27349e9d..5e1c0f537a8113a337237513e3977710b7a66760 100755 (executable)
 
 #### ADD TESTS HERE ####
 
-test_suite=( test_sessions test_kernel_data_trace test_ust_data_trace
-                       lttng/runall.sh ust-nevents/run ust-nprocesses/run )
+# A spawned session daemon is needed for those tests
+test_with_sessiond=( lttng/runall.sh ust-nevents/run ust-nprocesses/run )
+
+# No session daemon needed
+test_no_sessiond=( test_sessions test_kernel_data_trace test_ust_data_trace )
 
 #### END TESTS HERE ####
 
@@ -28,12 +31,35 @@ TESTDIR=$(dirname $0)
 
 source $TESTDIR/utils.sh
 
+## NO Session daemon ##
+for bin in ${test_no_sessiond[@]};
+do
+       if [ ! -e $bin ]; then
+               echo -e "$bin not found, passing"
+               continue
+       fi
+
+       ./$bin
+       # Test must return 0 to pass.
+       if [ $? -ne 0 ]; then
+               echo -e '\e[1;31mFAIL\e[0m'
+               echo ""
+               exit 1
+       fi
+done
+
+# With session daemon
 start_sessiond
-if [ $? -ne 0 ]; then
+out=$?
+if [ $out -eq 2 ]; then
+       # Kernel version is not compatible.
+       exit 0
+elif [ $out -ne 0 ]; then
+       echo "NOT bad $?"
        exit 1
 fi
 
-for bin in ${test_suite[@]};
+for bin in ${test_with_sessiond[@]};
 do
        if [ ! -e $bin ]; then
                echo -e "$bin not found, passing"
index 1d8f2ebd0b73b823ecc9884aba202616780af3b8..01e8eae21b3886c0bd532f0e438610e94e74c8cf 100644 (file)
@@ -19,8 +19,34 @@ SESSIOND_BIN="lttng-sessiond"
 LTTNG_BIN="lttng"
 BABELTRACE_BIN="babeltrace"
 
+# Minimal kernel version supported for session daemon tests
+KERNEL_MAJOR_VERSION=2
+KERNEL_MINOR_VERSION=6
+KERNEL_PATCHLEVEL_VERSION=27
+
+function validate_kernel_version ()
+{
+       kern_version=($(uname -r | awk -F. '{ printf("%d.%d.%d\n",$1,$2,$3); }' | tr '.' '\n'))
+       if [ ${kern_version[0]} -gt $KERNEL_MAJOR_VERSION ]; then
+               return 0
+       fi
+       if [ ${kern_version[1]} -gt $KERNEL_MINOR_VERSION ]; then
+               return 0
+       fi
+       if [ ${kern_version[2]} -ge $KERNEL_PATCHLEVEL_VERSION ]; then
+               return 0
+       fi
+       return 1
+}
+
 function start_sessiond ()
 {
+       validate_kernel_version
+       if [ $? -ne 0 ]; then
+               echo -e "\n*** Kernel to old for session daemon tests ***\n"
+               return 2
+       fi
+
        if [ -z $(pidof $SESSIOND_BIN) ]; then
                echo -n "Starting session daemon... "
                $TESTDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN --daemonize --quiet
@@ -31,6 +57,8 @@ function start_sessiond ()
                        echo -e "\e[1;32mOK\e[0m"
                fi
        fi
+
+       return 0
 }
 
 function stop_sessiond ()
This page took 0.026025 seconds and 4 git commands to generate.