Add UST and kernel streaming tests
[lttng-tools.git] / tests / tools / streaming / run-ust
diff --git a/tests/tools/streaming/run-ust b/tests/tools/streaming/run-ust
new file mode 100755 (executable)
index 0000000..0689201
--- /dev/null
@@ -0,0 +1,118 @@
+#!/bin/bash
+#
+# Copyright (C) - 2012 David Goulet <dgoulet@efficios.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
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../..
+BIN_NAME="gen-ust-events"
+SESSION_NAME="stream"
+EVENT_NAME="tp:tptest"
+PID_RELAYD=0
+
+source $TESTDIR/utils.sh
+
+echo -e "\n-------------------------------"
+echo -e " Streaming - User space tracing "
+echo -e "--------------------------------"
+
+if [ ! -x "$CURDIR/$BIN_NAME" ]; then
+       echo -e "No UST nevents binary detected. Passing."
+       exit 0
+fi
+
+function lttng_create_session
+{
+       # Create session with default path
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN create $SESSION_NAME >/dev/null 2>&1
+}
+
+function lttng_enable_consumer
+{
+       # Create session with default path
+       $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-consumer -u net://localhost/test >/dev/null 2>&1
+}
+
+function wait_apps
+{
+       echo -n "Waiting for applications to end"
+       while [ -n "$(pidof $BIN_NAME)" ]; do
+               echo -n "."
+               sleep 0.5
+       done
+       echo ""
+}
+
+# MUST set TESTDIR before calling those functions
+
+function test_ust_before_start ()
+{
+       echo -e "\n=== Testing UST streaming BEFORE tracing starts\n"
+       lttng_create_session
+       lttng_enable_consumer
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+
+       # Run 5 times with a 1 second delay
+       ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
+
+       start_tracing $SESSION_NAME
+
+       wait_apps
+       stop_tracing $SESSION_NAME
+       destroy_lttng_session $SESSION_NAME
+}
+
+function test_ust_after_start ()
+{
+       echo -e "\n=== Testing UST streaming AFTER tracing starts\n"
+       lttng_create_session
+       lttng_enable_consumer
+       enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+       start_tracing $SESSION_NAME
+
+       # Run 5 times with a 1 second delay
+       ./$CURDIR/$BIN_NAME 5 1000000 >/dev/null 2>&1 &
+
+       wait_apps
+       stop_tracing $SESSION_NAME
+       destroy_lttng_session $SESSION_NAME
+}
+
+start_sessiond
+lttng_start_relayd
+
+tests=( test_ust_before_start test_ust_after_start )
+
+for fct_test in ${tests[@]};
+do
+       SESSION_NAME=$(randstring 16 0)
+       ${fct_test}
+
+       # Validate test
+       validate_trace $EVENT_NAME ~/lttng-traces/$HOSTNAME/$SESSION_NAME*
+       if [ $? -eq 0 ]; then
+               # Only delete if successful
+               rm -rf ~/lttng-traces/$HOSTNAME/$SESSION_NAME*
+               rm -rf ~/lttng-traces/$SESSION_NAME*
+       else
+               break
+       fi
+done
+
+echo ""
+stop_sessiond
+lttng_stop_relayd
+
+exit $out
This page took 0.02527 seconds and 4 git commands to generate.