From: David Goulet Date: Mon, 2 Apr 2012 15:57:23 +0000 (-0400) Subject: Add low-throughput test X-Git-Tag: v2.1.0-rc1~173 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=4d5b973e8e468bf99fc9229b9b7a67bfdfe09924 Add low-throughput test Test during 20 minutes events at each minute, 10 minutes and 20 minutes. It validates the event order with an incremental counter. Signed-off-by: David Goulet --- diff --git a/configure.ac b/configure.ac index b2dbe4268..d28dab876 100644 --- a/configure.ac +++ b/configure.ac @@ -200,6 +200,7 @@ AC_CONFIG_FILES([ tests/ust/nevents/Makefile tests/ust/nprocesses/Makefile tests/ust/high-throughput/Makefile + tests/ust/low-throughput/Makefile ]) AC_OUTPUT diff --git a/tests/test_list.py b/tests/test_list.py index 80e76491d..375e07320 100644 --- a/tests/test_list.py +++ b/tests/test_list.py @@ -52,4 +52,11 @@ Tests = \ 'desc': "Test multiple large number of events with concurrent application", 'success': 0, 'enabled': True }, + { + 'bin': "ust/low-throughput/run", 'daemon': True, 'kern': False, + 'name': "UST tracer - Testing high events throughput", + 'desc': "Test low throughput of events", + 'success': 0, 'enabled': False + # Deactivated. This test last 20 minutes... + }, ] diff --git a/tests/ust/low-throughput/Makefile.am b/tests/ust/low-throughput/Makefile.am new file mode 100644 index 000000000..aefdf5318 --- /dev/null +++ b/tests/ust/low-throughput/Makefile.am @@ -0,0 +1,16 @@ +AM_CFLAGS = -I. -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-events +gen_events_SOURCES = main.c tp.c tp.h +gen_events_LDADD = -llttng-ust -lurcu + +noinst_SCRIPTS = run +EXTRA_DIST = run diff --git a/tests/ust/low-throughput/main.c b/tests/ust/low-throughput/main.c new file mode 100644 index 000000000..c8802e7df --- /dev/null +++ b/tests/ust/low-throughput/main.c @@ -0,0 +1,84 @@ +/* + * 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 + +#define TRACEPOINT_DEFINE +#include "tp.h" + +/* + * Thread recording a tracepoint every minute for 20 minutes. + */ +static void *th_event_minute(void *data) +{ + int i; + + /* Loop for 20 minutes */ + for (i = 1; i < 21; i++) { + /* Sleep 60 seconds */ + poll(NULL, 0, 60000); + + /* 20 minutes tracepoint */ + if ((i % 20) == 0) { + tracepoint(tp, slow, i, "twenty"); + printf("Twenty: %d\n", i); + } + + /* 10 minutes tracepoint */ + if ((i % 10) == 0) { + tracepoint(tp, slow, i, "ten"); + printf("Ten: %d\n", i); + } + + /* 1 minute tracepoint */ + tracepoint(tp, slow, i, "one"); + printf("One: %d\n", i); + } + + return NULL; +} + +/* + * main + */ +int main(int argc, char **argv) +{ + int ret; + void *status; + pthread_t thread; + + ret = pthread_create(&thread, NULL, th_event_minute, NULL); + if (ret != 0) { + perror("pthread_create event minute"); + goto error; + } + + ret = pthread_join(thread, &status); + if (ret != 0) { + perror("pthread_join"); + goto error; + } + + return 0; + +error: + return 1; +} diff --git a/tests/ust/low-throughput/run b/tests/ust/low-throughput/run new file mode 100755 index 000000000..8beaf60a5 --- /dev/null +++ b/tests/ust/low-throughput/run @@ -0,0 +1,102 @@ +#!/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 + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../.. +BIN_NAME="gen-events" +SESSION_NAME="low-throughput" +EVENT_NAME="tp:slow" + +source $TESTDIR/utils.sh + +echo -e "\n-------------------------------------------" +echo -e "UST tracer - Testing low events throughput" +echo -e "-------------------------------------------" + +if [ ! -e "$CURDIR/$BIN_NAME" ]; then + echo -e "No UST nevents binary detected. Passing." + exit 0 +fi + +TRACE_PATH=$(mktemp -d) + +# MUST set TESTDIR before calling those functions + +start_sessiond + +create_lttng_session $SESSION_NAME $TRACE_PATH + +enable_ust_lttng_event $SESSION_NAME $EVENT_NAME +start_tracing $SESSION_NAME + +# This is going to take 20 minutes +./$CURDIR/$BIN_NAME >/dev/null 2>&1 + +stop_tracing $SESSION_NAME +destroy_lttng_session $SESSION_NAME + +stop_sessiond + +# Validate test + +last_val=0 +out=0 + +babeltrace $TRACE_PATH | while read event; +do + val=$(echo $event | cut -f10 -d" ") + val=${val%?} + th=$(echo $event | cut -f13 -d " ") + + if [ $th = '"one"' ]; then + ((last_val++)) + # We expect here a continous value from 1 to 20 + if [ $last_val -ne $val ]; then + echo -n "[-] One minute event failed ($val) " + out=1 + break + fi + elif [ $th = '"ten"' ]; then + # Test 10 minutes counter + if [ $val -ne 10 ]; then + # Test 20 minutes counter + if [ $val -ne 20 ]; then + echo -n "[-] Ten minutes event failed ($val) " + out=1 + break + fi + fi + elif [ $th = '"twenty"' ]; then + # Test 20 minutes counter + if [ $val -ne 20 ]; then + echo -n "[-] Twenty minutes event failed ($val) " + out=1 + break + fi + fi +done + +if [ $out -eq 0 ]; then + echo -n "Trace is coherent... " + echo -e "\e[1;32mOK\e[0m" +else + echo -e "\e[1;31mFAILED\e[0m" +fi + +rm -rf $TRACE_PATH + +exit $out diff --git a/tests/ust/low-throughput/tp.c b/tests/ust/low-throughput/tp.c new file mode 100644 index 000000000..1d6cbdaab --- /dev/null +++ b/tests/ust/low-throughput/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 "tp.h" diff --git a/tests/ust/low-throughput/tp.h b/tests/ust/low-throughput/tp.h new file mode 100644 index 000000000..74b908b56 --- /dev/null +++ b/tests/ust/low-throughput/tp.h @@ -0,0 +1,45 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER tp + +#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_TP_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(tp, slow, + TP_ARGS(unsigned int, c, char *, thread_name), + TP_FIELDS( + ctf_integer(unsigned int, counter, c) + ctf_string(th_name, thread_name) + ) +) + +#endif /* _TRACEPOINT_TP_H */ + +#undef TRACEPOINT_INCLUDE_FILE +#define TRACEPOINT_INCLUDE_FILE ./tp.h + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif diff --git a/tests/ust/runall.sh b/tests/ust/runall.sh index 514680b7a..f47246fce 100755 --- a/tests/ust/runall.sh +++ b/tests/ust/runall.sh @@ -4,6 +4,10 @@ DIR=$(dirname $0) tests=( $DIR/run-ust-global-tests.sh $DIR/nevents/run $DIR/nprocesses/run \ $DIR/high-throughput/run ) + +# $DIR/low-throughput/run --> DEACTIVATED. +# Use only for release. This test last 20 minutes + exit_code=0 function start_tests ()