From 26b53d3b7ce1812a2ebc2c7153a50d35bba2a270 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Fri, 16 Nov 2012 13:38:11 -0500 Subject: [PATCH] Add UST overlap tests Tests the overlap of event names, wildcards, loglevels and filters. Not added yet to the make check since this depends on lttng-ust 2.1 not yet released. Acked-by: Mathieu Desnoyers Signed-off-by: David Goulet --- .gitignore | 1 + configure.ac | 2 + tests/ust/Makefile.am | 3 +- tests/ust/overlap/Makefile.am | 4 + tests/ust/overlap/demo/Makefile.am | 29 + tests/ust/overlap/demo/demo-trace | 3 + tests/ust/overlap/demo/demo.c | 65 +++ tests/ust/overlap/demo/tp.c | 18 + tests/ust/overlap/demo/tp2.c | 18 + tests/ust/overlap/demo/tp3.c | 18 + tests/ust/overlap/demo/ust_tests_demo.h | 63 +++ tests/ust/overlap/demo/ust_tests_demo2.h | 60 ++ tests/ust/overlap/demo/ust_tests_demo3.h | 45 ++ tests/ust/overlap/overlap.sh | 689 +++++++++++++++++++++++ tests/ust/overlap/run | 24 + tests/utils.sh | 70 ++- 16 files changed, 1109 insertions(+), 3 deletions(-) create mode 100644 tests/ust/overlap/Makefile.am create mode 100644 tests/ust/overlap/demo/Makefile.am create mode 100755 tests/ust/overlap/demo/demo-trace create mode 100644 tests/ust/overlap/demo/demo.c create mode 100644 tests/ust/overlap/demo/tp.c create mode 100644 tests/ust/overlap/demo/tp2.c create mode 100644 tests/ust/overlap/demo/tp3.c create mode 100644 tests/ust/overlap/demo/ust_tests_demo.h create mode 100644 tests/ust/overlap/demo/ust_tests_demo2.h create mode 100644 tests/ust/overlap/demo/ust_tests_demo3.h create mode 100755 tests/ust/overlap/overlap.sh create mode 100755 tests/ust/overlap/run diff --git a/.gitignore b/.gitignore index 8e5fc9c44..383dbf960 100644 --- a/.gitignore +++ b/.gitignore @@ -61,5 +61,6 @@ gen-events gen-ust-events unit_tests health_check +tests/ust/overlap/demo/demo benchmark/ diff --git a/configure.ac b/configure.ac index 71b394d76..61946db91 100644 --- a/configure.ac +++ b/configure.ac @@ -298,6 +298,8 @@ AC_CONFIG_FILES([ tests/ust/low-throughput/Makefile tests/ust/before-after/Makefile tests/ust/multi-session/Makefile + tests/ust/overlap/Makefile + tests/ust/overlap/demo/Makefile ]) AC_OUTPUT diff --git a/tests/ust/Makefile.am b/tests/ust/Makefile.am index 387842d11..c59829051 100644 --- a/tests/ust/Makefile.am +++ b/tests/ust/Makefile.am @@ -1,5 +1,6 @@ if HAVE_LIBLTTNG_UST_CTL -SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session +SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ + overlap AM_CFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/tests -I$(top_srcdir)/src -g -Wall AM_LDFLAGS = -lurcu -lurcu-cds diff --git a/tests/ust/overlap/Makefile.am b/tests/ust/overlap/Makefile.am new file mode 100644 index 000000000..803f1ed90 --- /dev/null +++ b/tests/ust/overlap/Makefile.am @@ -0,0 +1,4 @@ +SUBDIRS = demo + +noinst_SCRIPTS = run +EXTRA_DIST = run diff --git a/tests/ust/overlap/demo/Makefile.am b/tests/ust/overlap/demo/Makefile.am new file mode 100644 index 000000000..1532ecd7a --- /dev/null +++ b/tests/ust/overlap/demo/Makefile.am @@ -0,0 +1,29 @@ +AM_CFLAGS=-I$(srcdir) + +FORCE_SHARED_LIB_OPTIONS = -module -shared -avoid-version \ + -rpath $(abs_builddir) + +#contains ust_tests_demo.h and ust_tests_demo2.h provider probes +liblttng_ust_provider_ust_tests_demo_la_SOURCES = \ + tp.c ust_tests_demo.h \ + tp2.c ust_tests_demo2.h +liblttng_ust_provider_ust_tests_demo_la_LIBADD = -llttng-ust +liblttng_ust_provider_ust_tests_demo_la_LDFLAGS = $(FORCE_SHARED_LIB_OPTIONS) + +#contains ust_tests_demo3.h provider probes +liblttng_ust_provider_ust_tests_demo3_la_SOURCES = tp3.c ust_tests_demo3.h +liblttng_ust_provider_ust_tests_demo3_la_LIBADD = -llttng-ust +liblttng_ust_provider_ust_tests_demo3_la_LDFLAGS = $(FORCE_SHARED_LIB_OPTIONS) + +noinst_LTLIBRARIES = liblttng-ust-provider-ust-tests-demo.la \ + liblttng-ust-provider-ust-tests-demo3.la + +noinst_PROGRAMS = demo +demo_SOURCES = demo.c ust_tests_demo.h +# The demo program only depends on libdl/libc for dlopen(). +if LTTNG_TOOLS_BUILD_WITH_LIBDL +demo_LDADD = -ldl +endif +if LTTNG_TOOLS_BUILD_WITH_LIBC_DL +demo_LDADD = -lc +endif diff --git a/tests/ust/overlap/demo/demo-trace b/tests/ust/overlap/demo/demo-trace new file mode 100755 index 000000000..88a1be73c --- /dev/null +++ b/tests/ust/overlap/demo/demo-trace @@ -0,0 +1,3 @@ +#!/bin/sh + +LD_PRELOAD=.libs/liblttng-ust-provider-ust-tests-demo.so:.libs/liblttng-ust-provider-ust-tests-demo3.so ./demo ${*} diff --git a/tests/ust/overlap/demo/demo.c b/tests/ust/overlap/demo/demo.c new file mode 100644 index 000000000..e2b61c2e4 --- /dev/null +++ b/tests/ust/overlap/demo/demo.c @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2009 Pierre-Marc Fournier + * Copyright (C) 2011 Mathieu Desnoyers + * + * 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 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TRACEPOINT_DEFINE +#define TRACEPOINT_PROBE_DYNAMIC_LINKAGE +#include "ust_tests_demo.h" +#include "ust_tests_demo2.h" +#include "ust_tests_demo3.h" + +int main(int argc, char **argv) +{ + int i, netint; + long values[] = { 1, 2, 3 }; + char text[10] = "test"; + double dbl = 2.0; + float flt = 2222.0; + int delay = 0; + + if (argc == 2) + delay = atoi(argv[1]); + + fprintf(stderr, "Demo program starting.\n"); + + sleep(delay); + + fprintf(stderr, "Tracing... "); + tracepoint(ust_tests_demo, starting, 123); + for (i = 0; i < 5; i++) { + netint = htonl(i); + tracepoint(ust_tests_demo2, loop, i, netint, values, + text, strlen(text), dbl, flt); + } + tracepoint(ust_tests_demo, done, 456); + tracepoint(ust_tests_demo3, done, 42); + fprintf(stderr, " done.\n"); + return 0; +} diff --git a/tests/ust/overlap/demo/tp.c b/tests/ust/overlap/demo/tp.c new file mode 100644 index 000000000..288ce6146 --- /dev/null +++ b/tests/ust/overlap/demo/tp.c @@ -0,0 +1,18 @@ +/* + * tp.c + * + * Copyright (c) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_demo.h" diff --git a/tests/ust/overlap/demo/tp2.c b/tests/ust/overlap/demo/tp2.c new file mode 100644 index 000000000..718c9db26 --- /dev/null +++ b/tests/ust/overlap/demo/tp2.c @@ -0,0 +1,18 @@ +/* + * tp2.c + * + * Copyright (c) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_demo2.h" diff --git a/tests/ust/overlap/demo/tp3.c b/tests/ust/overlap/demo/tp3.c new file mode 100644 index 000000000..b1babc735 --- /dev/null +++ b/tests/ust/overlap/demo/tp3.c @@ -0,0 +1,18 @@ +/* + * tp3.c + * + * Copyright (c) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_tests_demo3.h" diff --git a/tests/ust/overlap/demo/ust_tests_demo.h b/tests/ust/overlap/demo/ust_tests_demo.h new file mode 100644 index 000000000..3e024b44e --- /dev/null +++ b/tests/ust/overlap/demo/ust_tests_demo.h @@ -0,0 +1,63 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + +#include + +TRACEPOINT_EVENT(ust_tests_demo, starting, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo, starting, TRACE_CRIT) + +/* + * Dummy model information, just for example. TODO: we should check if + * EMF model URI have some standard format we should follow. + */ +TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, starting, + "http://example.com/path_to_model?q=ust_tests_demo:starting") + +TRACEPOINT_EVENT(ust_tests_demo, done, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo, done, TRACE_CRIT) + +TRACEPOINT_MODEL_EMF_URI(ust_tests_demo, done, + "http://example.com/path_to_model?q=ust_tests_demo:done") + +#endif /* _TRACEPOINT_UST_TESTS_DEMO_H */ + +#undef TRACEPOINT_INCLUDE_FILE +#define TRACEPOINT_INCLUDE_FILE ./ust_tests_demo.h + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif diff --git a/tests/ust/overlap/demo/ust_tests_demo2.h b/tests/ust/overlap/demo/ust_tests_demo2.h new file mode 100644 index 000000000..cf4424b61 --- /dev/null +++ b/tests/ust/overlap/demo/ust_tests_demo2.h @@ -0,0 +1,60 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo2 + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO2_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO2_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + +#include + +TRACEPOINT_EVENT(ust_tests_demo2, loop, + TP_ARGS(int, anint, int, netint, long *, values, + char *, text, size_t, textlen, + double, doublearg, float, floatarg), + TP_FIELDS( + ctf_integer(int, intfield, anint) + ctf_integer_hex(int, intfield2, anint) + ctf_integer(long, longfield, anint) + ctf_integer_network(int, netintfield, netint) + ctf_integer_network_hex(int, netintfieldhex, netint) + ctf_array(long, arrfield1, values, 3) + ctf_array_text(char, arrfield2, text, 10) + ctf_sequence(char, seqfield1, text, + size_t, textlen) + ctf_sequence_text(char, seqfield2, text, + size_t, textlen) + ctf_string(stringfield, text) + ctf_float(float, floatfield, floatarg) + ctf_float(double, doublefield, doublearg) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo2, loop, TRACE_WARNING) + +#endif /* _TRACEPOINT_UST_TESTS_DEMO2_H */ + +#undef TRACEPOINT_INCLUDE_FILE +#define TRACEPOINT_INCLUDE_FILE ./ust_tests_demo2.h + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif diff --git a/tests/ust/overlap/demo/ust_tests_demo3.h b/tests/ust/overlap/demo/ust_tests_demo3.h new file mode 100644 index 000000000..e58ee86f7 --- /dev/null +++ b/tests/ust/overlap/demo/ust_tests_demo3.h @@ -0,0 +1,45 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_tests_demo3 + +#if !defined(_TRACEPOINT_UST_TESTS_DEMO3_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_TESTS_DEMO3_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + +#include + +TRACEPOINT_EVENT(ust_tests_demo3, done, + TP_ARGS(int, value), + TP_FIELDS( + ctf_integer(int, value, value) + ) +) +TRACEPOINT_LOGLEVEL(ust_tests_demo3, done, TRACE_WARNING) + +#endif /* _TRACEPOINT_UST_TESTS_DEMO3_H */ + +#undef TRACEPOINT_INCLUDE_FILE +#define TRACEPOINT_INCLUDE_FILE ./ust_tests_demo3.h + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif diff --git a/tests/ust/overlap/overlap.sh b/tests/ust/overlap/overlap.sh new file mode 100755 index 000000000..eed949d2c --- /dev/null +++ b/tests/ust/overlap/overlap.sh @@ -0,0 +1,689 @@ +#!/bin/bash +# +# Copyright (C) - 2012 David Goulet +# +# 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="UST - Wildcard overlap" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../.. +SESSION_NAME="wildcard-overlap" + +DEMO_EVENT1="ust_tests_demo:starting" +DEMO_EVENT1_2="ust_tests_demo:done" +DEMO_EVENT2="ust_tests_demo2:loop" +DEMO_EVENT3="ust_tests_demo3:done" + +NUM_DEMO1_EVENT=1 +NUM_DEMO1_2_EVENT=1 +NUM_DEMO2_EVENT=5 +NUM_DEMO3_EVENT=1 + +source $TESTDIR/utils.sh + +print_test_banner "$TEST_DESC" + +if [ ! -x "$CURDIR/demo/demo" ]; then + echo -e "No UST nevents binary detected. Passing." + exit 0 +fi + +# MUST set TESTDIR before calling those functions + +run_demo_app() +{ + local dir=`pwd` + + cd demo + + # Start test + echo -n "Starting application... " + ./$CURDIR/demo-trace >/dev/null 2>&1 + echo -n "Ended " + print_ok + + cd $dir +} + +# Ease our life a bit ;) +trace_match_demo1_events() +{ + trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH + trace_matches $DEMO_EVENT1_2 $NUM_DEMO1_EVENT $TRACE_PATH +} + +# Ease our life a bit ;) +trace_match_all_demo_events() +{ + trace_match_demo1_events + trace_matches $DEMO_EVENT2 $NUM_DEMO2_EVENT $TRACE_PATH + trace_matches $DEMO_EVENT3 $NUM_DEMO3_EVENT $TRACE_PATH +} + +# Ease our life a bit ;) +trace_match_no_demo_events() +{ + trace_matches $DEMO_EVENT1 0 $TRACE_PATH + trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH + trace_matches $DEMO_EVENT2 0 $TRACE_PATH + trace_matches $DEMO_EVENT3 0 $TRACE_PATH +} + +# Expect all "demo" events, no duplicate. +test_enable_simple_wildcard() +{ + local event_wild1="us*" + local event_wild2="ust*" + + echo "" + echo "=== Simple wildcard overlap" + + enable_ust_lttng_event $SESSION_NAME $event_wild1 + enable_ust_lttng_event $SESSION_NAME $event_wild2 + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + + return $? +} + +# Expect all "demo" events, no duplicate. +test_enable_wildcard_filter() +{ + local event_wild1="us*" + local event_wild2="ust*" + + echo "" + echo "=== Wildcard overlap with filter" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==1" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==0" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expect all "demo" events, no duplicate. +test_enable_wildcard_filter_2() +{ + local event_wild1="us*" + local event_wild2="ust*" + + echo "" + echo "=== Wildcard overlap with filter 2" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==0" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==1" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expect all "demo" events, no duplicate. +test_enable_wildcard_filter_3() +{ + local event_wild1="us*" + local event_wild2="ust*" + + echo "" + echo "=== Wildcard overlap with filter 3" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==1" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==1" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expected: No events. +test_enable_wildcard_filter_4() +{ + local event_wild1="us*" + local event_wild2="ust*" + + echo "" + echo "=== Wildcard overlap with filter 4" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==0" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==0" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_no_demo_events + return $? +} + +# Expect all "demo" events, no duplicate. +test_enable_wildcard_filter_5() +{ + local event_wild1="us*" + local event_wild2="$DEMO_EVENT1" + + echo "" + echo "=== Wildcard overlap with filter 5" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==1" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==0" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expect all $DEMO_EVENT1 events, no duplicate. +test_enable_wildcard_filter_6() +{ + local event_wild1="us*" + local event_wild2="$DEMO_EVENT1" + + echo "" + echo "=== Wildcard overlap with filter 6" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==0" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==1" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH + trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH + trace_matches $DEMO_EVENT2 0 $TRACE_PATH + trace_matches $DEMO_EVENT3 0 $TRACE_PATH + return $? +} + +# Expect all events, no duplicate. +test_enable_wildcard_filter_7() +{ + local event_wild1="us*" + local event_wild2="$DEMO_EVENT1" + + echo "" + echo "=== Wildcard overlap with filter 7" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==1" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==1" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expected: No events. +test_enable_wildcard_filter_8() +{ + local event_wild1="us*" + local event_wild2="$DEMO_EVENT1" + + echo "" + echo "=== Wildcard overlap with filter 8" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==0" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==0" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_no_demo_events + return $? +} + +# Expect all events. +test_enable_same_wildcard_filter() +{ + local event_wild1="ust*" + local event_wild2="ust*" + + echo "" + echo "=== Same wildcard overlap with filter" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==1&&1==1" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==1" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expect all events. +test_enable_same_wildcard_filter_2() +{ + local event_wild1="ust*" + local event_wild2="ust*" + + echo "" + echo "=== Same wildcard overlap with filter 2" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==1" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==1" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expect all events. +test_enable_same_wildcard_filter_3() +{ + local event_wild1="ust*" + local event_wild2="ust*" + + echo "" + echo "=== Same wildcard overlap with filter 3" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==1" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==0" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expected: No events. +test_enable_same_wildcard_filter_4() +{ + local event_wild1="ust*" + local event_wild2="ust*" + + echo "" + echo "=== Same wildcard overlap with filter 4" + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==0&&1==0" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==0" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_no_demo_events + return $? +} + +# Expected: Only $DEMO_EVENT1 +test_enable_same_event_filter() +{ + local event_wild1="$DEMO_EVENT1" + local event_wild2="$DEMO_EVENT1" + + echo "" + echo "=== Enable same event with filter." + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==1&&1==1" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==1" + + disable_ust_lttng_event $SESSION_NAME "ust*" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH + trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH + trace_matches $DEMO_EVENT2 0 $TRACE_PATH + trace_matches $DEMO_EVENT3 0 $TRACE_PATH + return $? +} + +# Expected: No events. +test_disable_same_wildcard_filter() +{ + local event_wild1="ust*" + local event_wild2="ust*" + + echo "" + echo "=== Disable same wildcard with filter." + + enable_ust_lttng_event_filter $SESSION_NAME $event_wild1 "1==1&&1==1" + enable_ust_lttng_event_filter $SESSION_NAME $event_wild2 "1==1" + + disable_ust_lttng_event $SESSION_NAME "ust*" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_no_demo_events + return $? +} + +# Expect no events +test_enable_bad_wildcard() +{ + # Invalid event + local event_wild1="ust_tests_demo" + local event_wild2="ust_tests_demo2" + local event_wild3="ust_tests_demo3" + + echo "" + echo "=== Enable bad wildcard" + + enable_ust_lttng_event $SESSION_NAME $event_wild1 + enable_ust_lttng_event $SESSION_NAME $event_wild2 + enable_ust_lttng_event $SESSION_NAME $event_wild3 + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_no_demo_events + return $? +} + +# Expect all "demo" events, no duplicate. +test_enable_simple_wildcard_2() +{ + local event_wild1="us*" + local event_wild2="$DEMO_EVENT1" + + echo "" + echo "=== Simple wildcard 2" + + enable_ust_lttng_event $SESSION_NAME $event_wild1 + enable_ust_lttng_event $SESSION_NAME $event_wild2 + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expected: all CRIT events, + all warning events. +test_enable_loglevel_overlap() +{ + local event_wild1="us*" + local event_wild2="ust*" + + echo "" + echo "=== Enable loglevel overlap" + + enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING" + enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expected: all CRIT events, + all warning events. +test_enable_loglevel_only_overlap() +{ + local event_wild1="us*" + local event_wild2="ust*" + + echo "" + echo "=== Enable loglevel only overlap" + + enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING" + enable_ust_lttng_event_loglevel_only $SESSION_NAME "$event_wild2" "TRACE_CRIT" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expected: all events +test_enable_loglevel_overlap_2() +{ + local event_wild1="us*" + local event_wild2="$DEMO_EVENT2" + + echo "" + echo "=== Enable loglevel overlap 2" + + enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_WARNING" + enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_CRIT" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expected only ust_tests_demo* events. +test_enable_same_wildcard_loglevels() +{ + local event_wild1="ust*" + local event_wild2="ust*" + + echo "" + echo "=== Enable same wildcard with different loglevels" + + enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT" + enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_match_all_demo_events + return $? +} + +# Expected only ust_tests_demo:starting events. +test_enable_same_event_loglevels() +{ + local event_wild1="$DEMO_EVENT1" + local event_wild2="$DEMO_EVENT1" + + echo "" + echo "=== Enable same event with different loglevels" + + enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild1" "TRACE_CRIT" + enable_ust_lttng_event_loglevel $SESSION_NAME "$event_wild2" "TRACE_WARNING" + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH + trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH + trace_matches $DEMO_EVENT2 0 $TRACE_PATH + trace_matches $DEMO_EVENT3 0 $TRACE_PATH + return $? +} + +# Expect 0 event +test_disable_simple_wildcard() +{ + local event_wild1="us*" + local event_wild2="$DEMO_EVENT1" + + echo "" + echo "=== Disable simple wildcard" + + enable_ust_lttng_event $SESSION_NAME $event_wild1 + enable_ust_lttng_event $SESSION_NAME $event_wild2 + + disable_ust_lttng_event $SESSION_NAME $event_wild1 + disable_ust_lttng_event $SESSION_NAME $event_wild2 + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + # No events are expected. + trace_match_no_demo_events + return $? +} + +# Expect only "ust_tests_demo" events. +test_disable_wildcard_overlap() +{ + local event_wild1="us*" + local event_wild2="$DEMO_EVENT1" + + echo "" + echo "=== Disable wildcard overlap" + + enable_ust_lttng_event $SESSION_NAME $event_wild1 + enable_ust_lttng_event $SESSION_NAME $event_wild2 + + disable_ust_lttng_event $SESSION_NAME $event_wild1 + + start_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + run_demo_app + + stop_lttng_tracing $SESSION_NAME >/dev/null 2>&1 + + # Expect only "ust_tests_demo" events. + trace_matches $DEMO_EVENT1 $NUM_DEMO1_EVENT $TRACE_PATH + trace_matches $DEMO_EVENT1_2 0 $TRACE_PATH + trace_matches $DEMO_EVENT2 0 $TRACE_PATH + trace_matches $DEMO_EVENT3 0 $TRACE_PATH + return $? +} + +TESTS=( + "test_enable_wildcard_filter" + "test_enable_wildcard_filter_2" + "test_enable_wildcard_filter_3" + "test_enable_wildcard_filter_4" + "test_enable_wildcard_filter_5" + "test_enable_wildcard_filter_6" + "test_enable_wildcard_filter_7" + "test_enable_wildcard_filter_8" + "test_enable_same_wildcard_filter" + "test_enable_same_wildcard_filter_2" + "test_enable_same_wildcard_filter_3" + "test_enable_same_wildcard_filter_4" + "test_enable_same_event_filter" + "test_enable_loglevel_only_overlap" + "test_enable_same_event_loglevels" + "test_enable_same_wildcard_loglevels" + "test_enable_bad_wildcard" + "test_enable_loglevel_overlap_2" + "test_enable_simple_wildcard" + "test_enable_simple_wildcard_2" + "test_enable_loglevel_overlap" + "test_disable_simple_wildcard" + "test_disable_wildcard_overlap" +) + +TEST_COUNT=${#TESTS[@]} +i=0 + +start_lttng_sessiond + +while [ "$i" -lt "$TEST_COUNT" ]; do + + TRACE_PATH=$(mktemp -d) + + create_lttng_session $SESSION_NAME $TRACE_PATH >/dev/null 2>&1 + + # Execute test + ${TESTS[$i]} + if [ $? -ne 0 ]; then + stop_lttng_sessiond + exit 1 + fi + + destroy_lttng_session $SESSION_NAME >/dev/null 2>&1 + + rm -rf $TRACE_PATH + + let "i++" +done + +stop_lttng_sessiond diff --git a/tests/ust/overlap/run b/tests/ust/overlap/run new file mode 100755 index 000000000..ca8efb34f --- /dev/null +++ b/tests/ust/overlap/run @@ -0,0 +1,24 @@ +#!/bin/bash + +DIR=$(dirname $0) + +tests=( $DIR/overlap.sh) + +exit_code=0 + +function start_tests () +{ + for bin in ${tests[@]}; + do + ./$bin + # Test must return 0 to pass. + if [ $? -ne 0 ]; then + exit_code=1 + break + fi + done +} + +start_tests + +exit $exit_code diff --git a/tests/utils.sh b/tests/utils.sh index 5e32e78f0..23b2dfd07 100644 --- a/tests/utils.sh +++ b/tests/utils.sh @@ -264,10 +264,76 @@ function disable_lttng_channel() function enable_ust_lttng_event () { sess_name=$1 - event_name=$2 + event_name="$2" echo -n "Enabling lttng event $event_name for session $sess_name " - $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u >/dev/null 2>&1 + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event "$event_name" -s $sess_name -u >/dev/null 2>&1 + if [ $? -eq 1 ]; then + print_fail + return 1 + else + print_ok + fi +} + +function enable_ust_lttng_event_filter() +{ + sess_name="$1" + event_name="$2" + filter="$3" + echo -n "Enabling lttng event with filtering " + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u --filter "$filter" 2>&1 >/dev/null + if [ $? -eq 0 ]; then + print_ok + return 0 + else + print_fail + return 1 + fi +} + +function enable_ust_lttng_event_loglevel() +{ + sess_name="$1" + event_name="$2" + loglevel="$3" + echo -n "Enabling lttng event $event_name with loglevel $loglevel" + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u --loglevel $loglevel 2>&1 >/dev/null + if [ $? -eq 0 ]; then + print_ok + return 0 + else + print_fail + return 1 + fi +} + +function enable_ust_lttng_event_loglevel_only() +{ + sess_name="$1" + event_name="$2" + loglevel="$3" + echo -n "Enabling lttng event $event_name with loglevel-only $loglevel" + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u --loglevel-only $loglevel 2>&1 >/dev/null + if [ $? -eq 0 ]; then + print_ok + return 0 + else + print_fail + return 1 + fi +} + +function disable_ust_lttng_event () +{ + sess_name=$1 + event_name=$2 + + echo -n "Disabling lttng event $event_name for session $sess_name " + $TESTDIR/../src/bin/lttng/$LTTNG_BIN disable-event $event_name -s $sess_name -u >/dev/null 2>&1 if [ $? -eq 1 ]; then print_fail return 1 -- 2.34.1