From: David Goulet Date: Wed, 27 Mar 2013 16:25:35 +0000 (-0400) Subject: Tests: Add periodical flush fast regression test X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=a788a3ed13e6caf984c88796b045727b820fdbc0 Tests: Add periodical flush fast regression test Signed-off-by: David Goulet --- diff --git a/configure.ac b/configure.ac index e2c2a4ffd..e49aebedf 100644 --- a/configure.ac +++ b/configure.ac @@ -329,6 +329,7 @@ AC_CONFIG_FILES([ tests/regression/ust/low-throughput/Makefile tests/regression/ust/before-after/Makefile tests/regression/ust/buffers-uid/Makefile + tests/regression/ust/periodical-metadata-flush/Makefile tests/regression/ust/multi-session/Makefile tests/regression/ust/overlap/Makefile tests/regression/ust/overlap/demo/Makefile diff --git a/tests/fast_regression b/tests/fast_regression index fb4ac6037..e6a883be7 100644 --- a/tests/fast_regression +++ b/tests/fast_regression @@ -7,6 +7,7 @@ regression/tools/health/test_tp_fail regression/tools/streaming/test_ust regression/ust/before-after/test_before_after regression/ust/buffers-uid/test_buffers_uid +regression/ust/periodical-metadata-flush/test_periodical_metadata_flush regression/ust/multi-session/test_multi_session regression/ust/nprocesses/test_nprocesses regression/ust/overlap/test_overlap diff --git a/tests/regression/ust/Makefile.am b/tests/regression/ust/Makefile.am index e6225440b..dbc9a17c1 100644 --- a/tests/regression/ust/Makefile.am +++ b/tests/regression/ust/Makefile.am @@ -1,6 +1,7 @@ if HAVE_LIBLTTNG_UST_CTL SUBDIRS = nprocesses high-throughput low-throughput before-after multi-session \ - overlap buffers-uid linking daemon exit-fast fork libc-wrapper + overlap buffers-uid linking daemon exit-fast fork libc-wrapper \ + periodical-metadata-flush EXTRA_DIST = test_event_basic test_event_wildcard diff --git a/tests/regression/ust/periodical-metadata-flush/Makefile.am b/tests/regression/ust/periodical-metadata-flush/Makefile.am new file mode 100644 index 000000000..72013e8ea --- /dev/null +++ b/tests/regression/ust/periodical-metadata-flush/Makefile.am @@ -0,0 +1,16 @@ +AM_CFLAGS = -I$(srcdir) -O2 +AM_LDFLAGS = -llttng-ust + +if LTTNG_TOOLS_BUILD_WITH_LIBDL +AM_LDFLAGS += -ldl +endif +if LTTNG_TOOLS_BUILD_WITH_LIBC_DL +AM_LDFLAGS += -lc +endif + +noinst_PROGRAMS = gen-nevents +gen_nevents_SOURCES = gen-nevents.c tp.c ust_gen_nevents.h +gen_nevents_LDADD = -llttng-ust + +noinst_SCRIPTS = test_periodical_metadata_flush +EXTRA_DIST = test_periodical_metadata_flush diff --git a/tests/regression/ust/periodical-metadata-flush/gen-nevents.c b/tests/regression/ust/periodical-metadata-flush/gen-nevents.c new file mode 100644 index 000000000..b2c19927f --- /dev/null +++ b/tests/regression/ust/periodical-metadata-flush/gen-nevents.c @@ -0,0 +1,56 @@ +/* + * Copyright (C) - 2009 Pierre-Marc Fournier + * Copyright (C) - 2011 Mathieu Desnoyers + * 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 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TRACEPOINT_DEFINE +#include "ust_gen_nevents.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; + unsigned int nr_iter = 100; + + if (argc == 2) { + nr_iter = atoi(argv[1]); + } + + for (i = 0; i < nr_iter; i++) { + netint = htonl(i); + tracepoint(ust_gen_nevents, tptest, i, netint, values, text, + strlen(text), dbl, flt); + usleep(100000); + } + + return 0; +} diff --git a/tests/regression/ust/periodical-metadata-flush/test_periodical_metadata_flush b/tests/regression/ust/periodical-metadata-flush/test_periodical_metadata_flush new file mode 100755 index 000000000..2d984d522 --- /dev/null +++ b/tests/regression/ust/periodical-metadata-flush/test_periodical_metadata_flush @@ -0,0 +1,214 @@ +#!/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 tracer - Tracing with per UID buffers and periodical flush" + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../../.. +NR_ITER=100 +SESSION_NAME="periodical-flush" +EVENT_NAME="ust_gen_nevents:tptest" +BIN_NAME="gen-nevents" +NUM_TESTS=38 + +source $TESTDIR/utils/utils.sh + +if [ ! -x "$CURDIR/gen-nevents" ]; then + BAIL_OUT "No UST nevents binary detected." +fi + +# MUST set TESTDIR before calling those functions + +function enable_channel_per_uid() +{ + local sess_name=$1 + local channel_name=$2 + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name >/dev/null 2>&1 + ok $? "Enable channel $channel_name per UID for session $sess_name" +} + +function enable_metadata_per_uid() +{ + local sess_name=$1 + local channel_name="metadata" + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-uid -u $channel_name -s $sess_name --switch-timer 200000 >/dev/null 2>&1 + ok $? "Enable channel $channel_name per UID for session $sess_name" +} + +function enable_metadata_per_pid() +{ + local sess_name=$1 + local channel_name="metadata" + + $TESTDIR/../src/bin/lttng/$LTTNG_BIN enable-channel --buffers-pid -u $channel_name -s $sess_name --switch-timer 200000 >/dev/null 2>&1 + ok $? "Enable channel $channel_name per PID for session $sess_name" +} + +function wait_apps +{ + diag "Waiting for applications to end..." + while [ -n "$(pidof $BIN_NAME)" ]; do + sleep 1 + done +} + +test_after_app_pid() { + local out + + diag "Start application AFTER tracing is started" + + # BEFORE application is spawned + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_metadata_per_pid $SESSION_NAME + enable_ust_lttng_channel $SESSION_NAME "channel0" + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + + ./$CURDIR/$BIN_NAME $NR_ITER + ok $? "Start application to trace" + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH + + return $? +} + +test_before_app_pid() { + local out + + diag "Start application BEFORE tracing is started" + + ./$CURDIR/$BIN_NAME $NR_ITER & + ok $? "Start application to trace" + + # BEFORE application is spawned + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_metadata_per_pid $SESSION_NAME + enable_ust_lttng_channel $SESSION_NAME "channel0" + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + + # At least hit one event + sleep 2 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l) + if [ $out -eq 0 ]; then + fail "Trace validation" + diag "No event(s) found. We are supposed to have at least one." + out=1 + else + pass "Trace validation" + diag "Found $out event(s). Coherent." + out=0 + fi + + wait_apps + + return $out +} + +test_after_app_uid() { + local out + + diag "Start application AFTER tracing is started" + + # BEFORE application is spawned + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_metadata_per_uid $SESSION_NAME + enable_channel_per_uid $SESSION_NAME "channel0" + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + + ./$CURDIR/$BIN_NAME $NR_ITER + ok $? "Start application to trace" + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH + + return $? +} + +test_before_app_uid() { + local out + + diag "Start application BEFORE tracing is started" + + ./$CURDIR/$BIN_NAME $NR_ITER & + ok $? "Start application to trace" + + # BEFORE application is spawned + create_lttng_session $SESSION_NAME $TRACE_PATH + enable_metadata_per_uid $SESSION_NAME + enable_channel_per_uid $SESSION_NAME "channel0" + enable_ust_lttng_event $SESSION_NAME $EVENT_NAME + start_lttng_tracing $SESSION_NAME + + # At least hit one event + sleep 2 + + stop_lttng_tracing $SESSION_NAME + destroy_lttng_session $SESSION_NAME + + out=$(babeltrace $TRACE_PATH | grep $EVENT_NAME | wc -l) + if [ $out -eq 0 ]; then + fail "Trace validation" + diag "No event(s) found. We are supposed to have at least one." + out=1 + else + pass "Trace validation" + diag "Found $out event(s). Coherent." + out=0 + fi + + wait_apps + + return $out +} + +# MUST set TESTDIR before calling those functions +plan_tests $NUM_TESTS + +print_test_banner "$TEST_DESC" + +TESTS=( + "test_before_app_uid" + "test_after_app_uid" + "test_before_app_pid" + "test_after_app_pid" +) + +TEST_COUNT=${#TESTS[@]} +i=0 + +start_lttng_sessiond + +while [ $i -lt $TEST_COUNT ]; do + TRACE_PATH=$(mktemp -d) + ${TESTS[$i]} + #rm -rf $TRACE_PATH + let "i++" +done + +stop_lttng_sessiond diff --git a/tests/regression/ust/periodical-metadata-flush/tp.c b/tests/regression/ust/periodical-metadata-flush/tp.c new file mode 100644 index 000000000..e291924a3 --- /dev/null +++ b/tests/regression/ust/periodical-metadata-flush/tp.c @@ -0,0 +1,16 @@ +/* + * Copyright (c) - 2011 Mathieu Desnoyers + * Copyright (c) - 2012 David Goulet + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED OR + * IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program for any purpose, + * provided the above notices are retained on all copies. Permission to modify + * the code and to distribute modified code is granted, provided the above + * notices are retained, and a notice that the code was modified is included + * with the above copyright notice. + */ + +#define TRACEPOINT_CREATE_PROBES +#include "ust_gen_nevents.h" diff --git a/tests/regression/ust/periodical-metadata-flush/ust_gen_nevents.h b/tests/regression/ust/periodical-metadata-flush/ust_gen_nevents.h new file mode 100644 index 000000000..bc09c4497 --- /dev/null +++ b/tests/regression/ust/periodical-metadata-flush/ust_gen_nevents.h @@ -0,0 +1,56 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER ust_gen_nevents + +#if !defined(_TRACEPOINT_UST_GEN_NEVENTS_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_UST_GEN_NEVENTS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED + * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. + * + * Permission is hereby granted to use or copy this program + * for any purpose, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + */ + +#include + +TRACEPOINT_EVENT(ust_gen_nevents, tptest, + 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) + ) +) + +#endif /* _TRACEPOINT_UST_GEN_NEVENTS_H */ + +#undef TRACEPOINT_INCLUDE_FILE +#define TRACEPOINT_INCLUDE_FILE ./ust_gen_nevents.h + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif