| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright (C) - 2018 Anders Wallin <wallinux@gmail.com> |
| 4 | # |
| 5 | # This library is free software; you can redistribute it and/or modify it under |
| 6 | # the terms of the GNU Lesser General Public License as published by the Free |
| 7 | # Software Foundation; version 2.1 of the License. |
| 8 | # |
| 9 | # This library is distributed in the hope that it will be useful, but WITHOUT |
| 10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 11 | # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
| 12 | # details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU Lesser General Public License |
| 15 | # along with this library; if not, write to the Free Software Foundation, Inc., |
| 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | |
| 18 | TEST_DESC="Auto load session(s)" |
| 19 | |
| 20 | CURDIR=$(dirname $0)/ |
| 21 | CONFIG_DIR="${CURDIR}/configuration" |
| 22 | TESTDIR=$CURDIR/../../../ |
| 23 | SESSIOND_BIN="lttng-sessiond" |
| 24 | RELAYD_BIN="lttng-relayd" |
| 25 | LTTNG_BIN="lttng" |
| 26 | export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/config/) |
| 27 | |
| 28 | DIR=$(readlink -f $TESTDIR) |
| 29 | |
| 30 | NUM_TESTS=9 |
| 31 | |
| 32 | source $TESTDIR/utils/utils.sh |
| 33 | |
| 34 | # MUST set TESTDIR before calling those functions |
| 35 | plan_tests $NUM_TESTS |
| 36 | |
| 37 | print_test_banner "$TEST_DESC" |
| 38 | |
| 39 | function test_auto_load_file() |
| 40 | { |
| 41 | diag "Test auto load file" |
| 42 | |
| 43 | start_lttng_sessiond $CURDIR/load-42.lttng |
| 44 | list_lttng_with_opts load-42 |
| 45 | stop_lttng_sessiond |
| 46 | } |
| 47 | |
| 48 | function test_auto_load_dir() |
| 49 | { |
| 50 | diag "Test auto load directory" |
| 51 | |
| 52 | cp -f $CURDIR/load-42.lttng $LTTNG_DIR/ |
| 53 | |
| 54 | start_lttng_sessiond $LTTNG_DIR |
| 55 | list_lttng_with_opts load-42 |
| 56 | stop_lttng_sessiond |
| 57 | } |
| 58 | |
| 59 | function test_auto_load_lttng_home() |
| 60 | { |
| 61 | diag "Test auto load by setting LTTNG_HOME" |
| 62 | |
| 63 | mkdir -p $LTTNG_HOME/.lttng/sessions/auto |
| 64 | cp -f $CURDIR/load-42.lttng $LTTNG_HOME/.lttng/sessions/auto |
| 65 | |
| 66 | start_lttng_sessiond |
| 67 | list_lttng_with_opts load-42 |
| 68 | stop_lttng_sessiond |
| 69 | } |
| 70 | |
| 71 | TESTS=( |
| 72 | test_auto_load_file |
| 73 | test_auto_load_dir |
| 74 | test_auto_load_lttng_home |
| 75 | ) |
| 76 | |
| 77 | for fct_test in ${TESTS[@]}; |
| 78 | do |
| 79 | export LTTNG_HOME=$(mktemp -d) |
| 80 | export LTTNG_DIR=$(mktemp -d) |
| 81 | |
| 82 | ${fct_test} |
| 83 | rm -rf $LTTNG_DIR |
| 84 | rm -rf $LTTNG_HOME |
| 85 | if [ $? -ne 0 ]; then |
| 86 | break; |
| 87 | fi |
| 88 | done |