| 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 | echo -e "\n----------------------------------" |
| 25 | echo -e "Testing lttng client (liblttngctl)" |
| 26 | echo -e "----------------------------------" |
| 27 | |
| 28 | if [ -z $(pidof $SESSIOND_BIN) ]; then |
| 29 | echo -n "Starting session daemon... " |
| 30 | ../ltt-sessiond/$SESSIOND_BIN --daemonize --quiet |
| 31 | if [ $? -eq 1 ]; then |
| 32 | echo -e '\e[1;31mFAILED\e[0m' |
| 33 | rm -rf $tmpdir |
| 34 | exit 1 |
| 35 | else |
| 36 | echo -e "\e[1;32mOK\e[0m" |
| 37 | fi |
| 38 | fi |
| 39 | |
| 40 | PID_SESSIOND=`pidof lt-$SESSIOND_BIN` |
| 41 | |
| 42 | # Simply wait for the session daemon bootstrap |
| 43 | sleep 1 |
| 44 | |
| 45 | start_tests |
| 46 | |
| 47 | echo -e -n "\nKilling session daemon... " |
| 48 | kill $PID_SESSIOND >/dev/null 2>&1 |
| 49 | if [ $? -eq 1 ]; then |
| 50 | echo -e '\e[1;31mFAILED\e[0m' |
| 51 | else |
| 52 | echo -e "\e[1;32mOK\e[0m" |
| 53 | fi |
| 54 | |
| 55 | exit $exit_code |