diff mbox

[lttng-tools] Test add-context perf raw command

Message ID 1466536863-9729-1-git-send-email-jdesfossez@efficios.com
State Superseded, archived
Headers show

Commit Message

Julien Desfossez June 21, 2016, 7:21 p.m. UTC
Signed-off-by: Julien Desfossez <jdesfossez at efficios.com>
---
 tests/fast_regression              |   1 +
 tests/regression/ust/test_perf_raw | 103 +++++++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+)
 create mode 100755 tests/regression/ust/test_perf_raw

Comments

Mathieu Desnoyers June 21, 2016, 8:22 p.m. UTC | #1
What happens if we run this test on other architecture
than x86 ?

We should try to test this feature throughout the stack,
including tracing and looking at the result, but somehow
check that we are on the right architecture to do so.

Thanks,

Mathieu

----- On Jun 21, 2016, at 3:21 PM, Julien Desfossez jdesfossez at efficios.com wrote:

> Signed-off-by: Julien Desfossez <jdesfossez at efficios.com>
> ---
> tests/fast_regression              |   1 +
> tests/regression/ust/test_perf_raw | 103 +++++++++++++++++++++++++++++++++++++
> 2 files changed, 104 insertions(+)
> create mode 100755 tests/regression/ust/test_perf_raw
> 
> diff --git a/tests/fast_regression b/tests/fast_regression
> index 0c4f079..a3084d5 100644
> --- a/tests/fast_regression
> +++ b/tests/fast_regression
> @@ -30,3 +30,4 @@ regression/ust/clock-override/test_clock_override
> regression/ust/rotation-destroy-flush/test_rotation_destroy_flush
> regression/ust/test_event_basic
> regression/ust/test_event_tracef
> +regression/ust/test_perf_raw
> diff --git a/tests/regression/ust/test_perf_raw
> b/tests/regression/ust/test_perf_raw
> new file mode 100755
> index 0000000..00d7c52
> --- /dev/null
> +++ b/tests/regression/ust/test_perf_raw
> @@ -0,0 +1,103 @@
> +#!/bin/bash
> +#
> +# Copyright (C) - 2016 Julien Desfossez <jdesfossez at efficios.com>
> +#
> +# This program is free software; you can redistribute it and/or modify it
> +# under the terms of the GNU General Public License, version 2 only, as
> +# published by the Free Software Foundation.
> +#
> +# This program 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 General Public License for
> +# more details.
> +#
> +# You should have received a copy of the GNU General Public License along with
> +# this program; if not, write to the Free Software Foundation, Inc., 51
> +# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
> +
> +TEST_DESC="UST tracer - Perf counters"
> +
> +CURDIR=$(dirname $0)/
> +TESTDIR=$CURDIR/../..
> +LTTNG_BIN="lttng"
> +SESSION_NAME="perf_counters"
> +EVENT_NAME="tp:tptest"
> +NUM_TESTS=15
> +NR_ITER=1
> +NR_USEC_WAIT=1
> +TESTAPP_PATH="$TESTDIR/utils/testapp"
> +TESTAPP_NAME="gen-ust-events"
> +TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
> +
> +source $TESTDIR/utils/utils.sh
> +
> +function enable_ust_lttng_event_per_chan()
> +{
> +	sess_name="$1"
> +	event_name="$2"
> +	chan_name="$3"
> +
> +	$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name
> -c $chan_name -u >/dev/null 2>&1
> +	ok $? "Enable event $event_name for session $sess_name in channel $chan_name"
> +}
> +
> +function add_ust_lttng_context_ok()
> +{
> +	sess_name="$1"
> +	chan_name="$2"
> +	type="$3"
> +
> +	$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $sess_name -c $chan_name
> -t $type -u >/dev/null 2>&1
> +	ok $? "Add context $type for session $sess_name in channel $chan_name"
> +}
> +
> +function add_ust_lttng_context_fail()
> +{
> +	sess_name="$1"
> +	chan_name="$2"
> +	type="$3"
> +
> +	$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $sess_name -c $chan_name
> -t $type -u >/dev/null 2>&1
> +	test $? -ne "4"
> +	ok $? "Add context $type for session $sess_name in channel $chan_name failed
> as expected"
> +}
> +
> +# Only test parsing since this feature depends on the counters available on
> +# specifics processors and does not work in VM.
> +function test_parsing_raw()
> +{
> +	TRACE_PATH=$(mktemp -d)
> +	SESSION_NAME="ust_event_basic"
> +	CHAN_NAME="mychan"
> +
> +	create_lttng_session_ok $SESSION_NAME $TRACE_PATH
> +
> +	enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
> +
> +	enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
> +
> +	add_ust_lttng_context_ok $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test"
> +	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME
> "perf:thread:raw:b0110:test"
> +	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:"
> +	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110::"
> +	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r:test"
> +	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r::"
> +	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw::"
> +	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw"
> +	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME
> "perf:thread:raw:r0110:test:wrong"
> +
> +	destroy_lttng_session_ok $SESSION_NAME
> +
> +	rm -rf $TRACE_PATH
> +}
> +
> +# MUST set TESTDIR before calling those functions
> +plan_tests $NUM_TESTS
> +
> +print_test_banner "$TEST_DESC"
> +
> +start_lttng_sessiond
> +
> +test_parsing_raw
> +
> +stop_lttng_sessiond
> --
> 1.9.1
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
diff mbox

Patch

diff --git a/tests/fast_regression b/tests/fast_regression
index 0c4f079..a3084d5 100644
--- a/tests/fast_regression
+++ b/tests/fast_regression
@@ -30,3 +30,4 @@  regression/ust/clock-override/test_clock_override
 regression/ust/rotation-destroy-flush/test_rotation_destroy_flush
 regression/ust/test_event_basic
 regression/ust/test_event_tracef
+regression/ust/test_perf_raw
diff --git a/tests/regression/ust/test_perf_raw b/tests/regression/ust/test_perf_raw
new file mode 100755
index 0000000..00d7c52
--- /dev/null
+++ b/tests/regression/ust/test_perf_raw
@@ -0,0 +1,103 @@ 
+#!/bin/bash
+#
+# Copyright (C) - 2016 Julien Desfossez <jdesfossez at efficios.com>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License, version 2 only, as
+# published by the Free Software Foundation.
+#
+# This program 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 General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+TEST_DESC="UST tracer - Perf counters"
+
+CURDIR=$(dirname $0)/
+TESTDIR=$CURDIR/../..
+LTTNG_BIN="lttng"
+SESSION_NAME="perf_counters"
+EVENT_NAME="tp:tptest"
+NUM_TESTS=15
+NR_ITER=1
+NR_USEC_WAIT=1
+TESTAPP_PATH="$TESTDIR/utils/testapp"
+TESTAPP_NAME="gen-ust-events"
+TESTAPP_BIN="$TESTAPP_PATH/$TESTAPP_NAME/$TESTAPP_NAME"
+
+source $TESTDIR/utils/utils.sh
+
+function enable_ust_lttng_event_per_chan()
+{
+	sess_name="$1"
+	event_name="$2"
+	chan_name="$3"
+
+	$TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -c $chan_name -u >/dev/null 2>&1
+	ok $? "Enable event $event_name for session $sess_name in channel $chan_name"
+}
+
+function add_ust_lttng_context_ok()
+{
+	sess_name="$1"
+	chan_name="$2"
+	type="$3"
+
+	$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $sess_name -c $chan_name -t $type -u >/dev/null 2>&1
+	ok $? "Add context $type for session $sess_name in channel $chan_name"
+}
+
+function add_ust_lttng_context_fail()
+{
+	sess_name="$1"
+	chan_name="$2"
+	type="$3"
+
+	$TESTDIR/../src/bin/lttng/$LTTNG_BIN add-context -s $sess_name -c $chan_name -t $type -u >/dev/null 2>&1
+	test $? -ne "4"
+	ok $? "Add context $type for session $sess_name in channel $chan_name failed as expected"
+}
+
+# Only test parsing since this feature depends on the counters available on
+# specifics processors and does not work in VM.
+function test_parsing_raw()
+{
+	TRACE_PATH=$(mktemp -d)
+	SESSION_NAME="ust_event_basic"
+	CHAN_NAME="mychan"
+
+	create_lttng_session_ok $SESSION_NAME $TRACE_PATH
+
+	enable_ust_lttng_channel_ok $SESSION_NAME $CHAN_NAME
+
+	enable_ust_lttng_event_per_chan $SESSION_NAME $EVENT_NAME $CHAN_NAME
+
+	add_ust_lttng_context_ok $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test"
+	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:b0110:test"
+	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:"
+	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110::"
+	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r:test"
+	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r::"
+	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw::"
+	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw"
+	add_ust_lttng_context_fail $SESSION_NAME $CHAN_NAME "perf:thread:raw:r0110:test:wrong"
+
+	destroy_lttng_session_ok $SESSION_NAME
+
+	rm -rf $TRACE_PATH
+}
+
+# MUST set TESTDIR before calling those functions
+plan_tests $NUM_TESTS
+
+print_test_banner "$TEST_DESC"
+
+start_lttng_sessiond
+
+test_parsing_raw
+
+stop_lttng_sessiond