Add lttng-modules detection for tests
[lttng-tools.git] / tests / lttng / run-kernel-tests.sh
1 #!/bin/bash
2
3 SESSIOND_BIN="ltt-sessiond"
4
5 tmpdir=`mktemp -d`
6 tests=( kernel_event_basic kernel_all_events_basic )
7 exit_code=0
8
9 function start_tests ()
10 {
11 for bin in ${tests[@]};
12 do
13 ./$bin $tmpdir
14 # Test must return 0 to pass.
15 if [ $? -ne 0 ]; then
16 exit_code=1
17 break
18 fi
19 # Cleaning up
20 rm -rf $tmpdir
21 done
22 }
23
24 function check_lttng_modules ()
25 {
26 local out=`modprobe -l | grep lttng`
27 if [ -z "$out" ]; then
28 echo "LTTng modules not detected. Aborting kernel tests!"
29 echo ""
30 # Exit status 0 so the tests can continue
31 exit 0
32 fi
33 }
34
35 echo -e "\n--------------------------------------------------"
36 echo -e "Kernel tracer - Testing lttng client (liblttngctl)"
37 echo -e "--------------------------------------------------"
38
39 # Detect lttng-modules installed
40
41 check_lttng_modules
42
43 if [ -z $(pidof $SESSIOND_BIN) ]; then
44 echo -n "Starting session daemon... "
45 ../ltt-sessiond/$SESSIOND_BIN --daemonize --quiet
46 if [ $? -eq 1 ]; then
47 echo -e '\e[1;31mFAILED\e[0m'
48 rm -rf $tmpdir
49 exit 1
50 else
51 echo -e "\e[1;32mOK\e[0m"
52 fi
53 fi
54
55 PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
56
57 # Simply wait for the session daemon bootstrap
58 sleep 1
59
60 start_tests
61
62 echo -e -n "\nKilling session daemon... "
63 kill $PID_SESSIOND >/dev/null 2>&1
64 if [ $? -eq 1 ]; then
65 echo -e '\e[1;31mFAILED\e[0m'
66 else
67 echo -e "\e[1;32mOK\e[0m"
68 fi
69
70 exit $exit_code
This page took 0.042333 seconds and 4 git commands to generate.