Tests: add session auto-loading test cases
authorAnders Wallin <wallinux@gmail.com>
Thu, 17 May 2018 20:50:41 +0000 (22:50 +0200)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 5 Jun 2018 19:35:01 +0000 (15:35 -0400)
lttng-sessiond can auto load sessions at startup;
- with "--load" option to lttng-sessiond, load one file
  or all sessions files in that directory
- from session files in $LTTNG_HOME/.lttng/sessions/auto/
- from session files in $sysconfdir/lttng/sessions/auto

This test case validates the two first scenarios.

Signed-off-by: Anders Wallin <wallinux@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/config/session-config.c
tests/fast_regression
tests/regression/tools/save-load/test_autoload [new file with mode: 0755]

index ed836f17e9d70e3d9cc5e0d3ea9eaf8d7e386b55..518fde70b5e63d1d244369ca634d0a647bb75f21 100644 (file)
@@ -3032,7 +3032,7 @@ int load_session_from_path(const char *path, const char *session_name,
                        errno = 0;
                        result = readdir(directory);
 
-                       /* Reached end of dir stream or error out */
+                       /* Reached end of dir stream or error out. */
                        if (!result) {
                                if (errno) {
                                        PERROR("Failed to enumerate the contents of path \"%s\" while loading session, readdir returned", path);
index f76b53dc2a5e1b22600c0841e7a331ebc9cc56ad..0c44c5a2318e881cd3936e8135b254d793f08f86 100644 (file)
@@ -13,6 +13,7 @@ regression/tools/snapshots/test_ust_fast
 regression/tools/snapshots/test_ust_streaming
 regression/tools/save-load/test_save
 regression/tools/save-load/test_load
+regression/tools/save-load/test_autoload
 regression/tools/mi/test_mi
 regression/tools/wildcard/test_event_wildcard
 regression/tools/crash/test_crash
diff --git a/tests/regression/tools/save-load/test_autoload b/tests/regression/tools/save-load/test_autoload
new file mode 100755 (executable)
index 0000000..35b5d7b
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/bash
+#
+# Copyright (C) - 2018 Anders Wallin <wallinux@gmail.com>
+#
+# This library is free software; you can redistribute it and/or modify it under
+# the terms of the GNU Lesser General Public License as published by the Free
+# Software Foundation; version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+# details.
+#
+# You should have received a copy of the GNU Lesser General Public License
+# along with this library; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+
+TEST_DESC="Auto load session(s)"
+
+CURDIR=$(dirname $0)/
+CONFIG_DIR="${CURDIR}/configuration"
+TESTDIR=$CURDIR/../../../
+SESSIOND_BIN="lttng-sessiond"
+RELAYD_BIN="lttng-relayd"
+LTTNG_BIN="lttng"
+export LTTNG_SESSION_CONFIG_XSD_PATH=$(readlink -m ${TESTDIR}../src/common/config/)
+
+DIR=$(readlink -f $TESTDIR)
+
+NUM_TESTS=9
+
+source $TESTDIR/utils/utils.sh
+
+# MUST set TESTDIR before calling those functions
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+function test_auto_load_file()
+{
+       diag "Test auto load file"
+
+       start_lttng_sessiond $CURDIR/load-42.lttng
+       list_lttng_with_opts load-42
+       stop_lttng_sessiond
+}
+
+function test_auto_load_dir()
+{
+       diag "Test auto load directory"
+
+       cp -f $CURDIR/load-42.lttng $LTTNG_DIR/
+
+       start_lttng_sessiond $LTTNG_DIR
+       list_lttng_with_opts load-42
+       stop_lttng_sessiond
+}
+
+function test_auto_load_lttng_home()
+{
+       diag "Test auto load by setting LTTNG_HOME"
+
+       mkdir -p $LTTNG_HOME/.lttng/sessions/auto
+       cp -f $CURDIR/load-42.lttng $LTTNG_HOME/.lttng/sessions/auto
+
+       start_lttng_sessiond
+       list_lttng_with_opts load-42
+       stop_lttng_sessiond
+}
+
+TESTS=(
+       test_auto_load_file
+       test_auto_load_dir
+       test_auto_load_lttng_home
+)
+
+for fct_test in ${TESTS[@]};
+do
+       export LTTNG_HOME=$(mktemp -d)
+       export LTTNG_DIR=$(mktemp -d)
+
+       ${fct_test}
+       rm -rf $LTTNG_DIR
+       rm -rf $LTTNG_HOME
+       if [ $? -ne 0 ]; then
+               break;
+       fi
+done
This page took 0.028902 seconds and 5 git commands to generate.