Add UST test for n events using validation
authorDavid Goulet <dgoulet@efficios.com>
Mon, 16 Jan 2012 22:25:49 +0000 (17:25 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 16 Jan 2012 22:25:49 +0000 (17:25 -0500)
ust-nevents tests an instrumented application generating 100 events and
validating that those events are found using babeltrace (need to be
installed).

Adds the tests/utils.sh which is a family of function used to interact
with lttng cli. There is also a trace_matches function which uses
babeltrace to find string patterns.

Also, the session daemon is spawned at the beginning of runall.sh and
killed at the end. This means that all tests are done on a single
session daemon instance. Thus, session name across tests have to be
unique! From now on, each test should use the file name as a unique
identifier for the session name.

Finally, fixed the session name for all tests. At this commit, "make
check" or "sudo make check" should pass.

Signed-off-by: David Goulet <dgoulet@efficios.com>
17 files changed:
.gitignore
configure.ac
tests/Makefile.am
tests/lttng/kernel_all_events_basic.c
tests/lttng/kernel_event_basic.c
tests/lttng/run-kernel-tests.sh
tests/lttng/run-ust-global-tests.sh
tests/lttng/ust_global_all_events_basic.c
tests/lttng/ust_global_event_basic.c
tests/runall.sh
tests/test_ust_data_trace.c [new file with mode: 0644]
tests/ust-nevents/Makefile.am [new file with mode: 0644]
tests/ust-nevents/gen-nevents.c [new file with mode: 0644]
tests/ust-nevents/run [new file with mode: 0755]
tests/ust-nevents/tp.c [new file with mode: 0644]
tests/ust-nevents/ust_gen_nevents.h [new file with mode: 0644]
tests/utils.sh [new file with mode: 0644]

index d7e624f6a3bd1a50f9667fb44f1a98017a8d1289..9c70e0f58d4e01d7b8d01fb167789b08a3afc68d 100644 (file)
@@ -42,5 +42,6 @@ tests/kernel_all_events_basic
 tests/kernel_event_basic
 tests/ust_global_all_events_basic
 tests/ust_global_event_basic
+tests/ust-nevents/gen-nevents
 
 benchmark/
index 9abc477c59b7b2a6f47c69eb0b7df4f324361c42..af522eeb0677665d3d0899fc8f7a8c966927743e 100644 (file)
@@ -144,6 +144,7 @@ AC_CONFIG_FILES([
        lttng-sessiond/Makefile
        lttng/Makefile
        tests/Makefile
+       tests/ust-nevents/Makefile
        doc/Makefile
 ])
 
index 10db1bb6b636b16bde5644c711c36de09cb8b713..96d4f6403ec359d2e957a2d57fcea2e3c09e1aa3 100644 (file)
@@ -1,3 +1,5 @@
+SUBDIRS = . ust-nevents
+
 AM_CFLAGS=-I$(top_srcdir)/include -I$(top_srcdir)/libkernelctl \
                  -I$(top_srcdir)/liblttngctl -g -Wall -lurcu -lurcu-cds
 
index fd3926d1f87514d5809e2657ab43b64d94baa699..79c2b66ac3c1a9cd83654a7be70a580e18cfbd05 100644 (file)
@@ -35,6 +35,7 @@ int main(int argc, char **argv)
     struct lttng_domain dom;
        struct lttng_event event;
     char *channel_name = "channel0";
+       char *session_name = "kernel_all_events_basic";
     int ret = 0;
 
     dom.type = LTTNG_DOMAIN_KERNEL;
@@ -56,14 +57,14 @@ int main(int argc, char **argv)
        }
 
        printf("Creating tracing session (%s): ", argv[1]);
-    if ((ret = lttng_create_session("test", argv[1])) < 0) {
+    if ((ret = lttng_create_session(session_name, argv[1])) < 0) {
         printf("error creating the session : %s\n", lttng_strerror(ret));
                goto create_fail;
     }
        PRINT_OK();
 
        printf("Creating session handle: ");
-       if ((handle = lttng_create_handle("test", &dom)) == NULL) {
+       if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
                printf("error creating handle: %s\n", lttng_strerror(ret));
                goto handle_fail;
        }
@@ -77,7 +78,7 @@ int main(int argc, char **argv)
        PRINT_OK();
 
        printf("Start tracing: ");
-    if ((ret = lttng_start_tracing("test")) < 0) {
+    if ((ret = lttng_start_tracing(session_name)) < 0) {
         printf("error starting tracing: %s\n", lttng_strerror(ret));
                goto start_fail;
     }
@@ -86,14 +87,14 @@ int main(int argc, char **argv)
     sleep(2);
 
        printf("Stop tracing: ");
-       if ((ret = lttng_stop_tracing("test")) < 0) {
+       if ((ret = lttng_stop_tracing(session_name)) < 0) {
                printf("error stopping tracing: %s\n", lttng_strerror(ret));
                goto stop_fail;
        }
        PRINT_OK();
 
        printf("Destroy tracing session: ");
-       if ((ret = lttng_destroy_session("test")) < 0) {
+       if ((ret = lttng_destroy_session(session_name)) < 0) {
                printf("error destroying session: %s\n", lttng_strerror(ret));
        }
        PRINT_OK();
@@ -108,7 +109,7 @@ handle_fail:
 stop_fail:
 start_fail:
 enable_fail:
-       lttng_destroy_session("test");
+       lttng_destroy_session(session_name);
        lttng_destroy_handle(handle);
 
     return 1;
index b33f691fdd4c0e41a99de151efda265722fac843..fb1cf42b0f4cc524d4dfcb777abdc085d37f41d1 100644 (file)
@@ -40,7 +40,7 @@ int main(int argc, char **argv)
 
     int ret = 0;
 
-       char *session_name = "kernel_event";
+       char *session_name = "kernel_event_basic";
 
     dom.type = LTTNG_DOMAIN_KERNEL;
 
index 04814fc9c55b4770c9754818478fa8cb38f3a1c9..d5a41382b010cd5dbc7b37142dc529af1bd1f9a5 100755 (executable)
@@ -1,6 +1,9 @@
 #!/bin/bash
 
 SESSIOND_BIN="lttng-sessiond"
+TESTDIR=$(dirname $0)/..
+
+source $TESTDIR/utils.sh
 
 tmpdir=`mktemp -d`
 tests=( kernel_event_basic kernel_all_events_basic )
@@ -16,9 +19,10 @@ function start_tests ()
             exit_code=1
             break
         fi
-               # Cleaning up
-               rm -rf $tmpdir
     done
+
+       # Cleaning up
+       rm -rf $tmpdir
 }
 
 function check_lttng_modules ()
@@ -40,31 +44,9 @@ echo -e "--------------------------------------------------"
 
 check_lttng_modules
 
-if [ -z $(pidof $SESSIOND_BIN) ]; then
-       echo -n "Starting session daemon... "
-       ../lttng-sessiond/$SESSIOND_BIN --daemonize --quiet
-       if [ $? -eq 1 ]; then
-               echo -e '\e[1;31mFAILED\e[0m'
-               rm -rf $tmpdir
-               exit 1
-       else
-               echo -e "\e[1;32mOK\e[0m"
-       fi
-fi
-
-PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
-
 # Simply wait for the session daemon bootstrap
 sleep 1
 
 start_tests
 
-echo -e -n "\nKilling session daemon... "
-kill $PID_SESSIOND >/dev/null 2>&1
-if [ $? -eq 1 ]; then
-    echo -e '\e[1;31mFAILED\e[0m'
-else
-    echo -e "\e[1;32mOK\e[0m"
-fi
-
 exit $exit_code
index bfcb974bf22c67566dd6d6ed7d1e712f39e167ba..135c8a2b4311f88c35f09e428ab1557a16eaa86c 100755 (executable)
@@ -1,6 +1,9 @@
 #!/bin/bash
 
 SESSIOND_BIN="lttng-sessiond"
+TESTDIR=$(dirname $0)/..
+
+source $TESTDIR/utils.sh
 
 tmpdir=`mktemp -d`
 tests=( ust_global_event_basic ust_global_all_events_basic )
@@ -16,27 +19,16 @@ function start_tests ()
             exit_code=1
             break
         fi
-               # Cleaning up
-               rm -rf $tmpdir
     done
+
+       # Cleaning up
+       rm -rf $tmpdir
 }
 
 echo -e "\n-------------------------------------------"
-echo -e "UST tracer - GLOBAL DOMAIN (LTTNG_DOMAIN_UST)"
+echo -e "UST tracer - Global domain (LTTNG_DOMAIN_UST)"
 echo -e "---------------------------------------------"
 
-if [ -z $(pidof $SESSIOND_BIN) ]; then
-       echo -n "Starting session daemon... "
-       ../lttng-sessiond/$SESSIOND_BIN --daemonize --quiet
-       if [ $? -eq 1 ]; then
-               echo -e '\e[1;31mFAILED\e[0m'
-               rm -rf $tmpdir
-               exit 1
-       else
-               echo -e "\e[1;32mOK\e[0m"
-       fi
-fi
-
 PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
 
 # Simply wait for the session daemon bootstrap
@@ -44,12 +36,4 @@ sleep 1
 
 start_tests
 
-echo -e -n "\nKilling session daemon... "
-kill $PID_SESSIOND >/dev/null 2>&1
-if [ $? -eq 1 ]; then
-    echo -e '\e[1;31mFAILED\e[0m'
-else
-    echo -e "\e[1;32mOK\e[0m"
-fi
-
 exit $exit_code
index 7c0a5624e54f516c5b3edbb9f0b9fd5a671912b7..32c39fb5e1cf2a58e66c646d07f974ee56fde2c1 100644 (file)
@@ -35,6 +35,7 @@ int main(int argc, char **argv)
     struct lttng_domain dom;
        struct lttng_event event;
     char *channel_name = "channel0";
+       char *session_name = "ust_global_all_events_basic";
     int ret = 0;
 
     dom.type = LTTNG_DOMAIN_UST;
@@ -51,14 +52,14 @@ int main(int argc, char **argv)
        }
 
        printf("Creating tracing session (%s): ", argv[1]);
-    if ((ret = lttng_create_session("test", argv[1])) < 0) {
+    if ((ret = lttng_create_session(session_name, argv[1])) < 0) {
         printf("error creating the session : %s\n", lttng_strerror(ret));
                goto create_fail;
     }
        PRINT_OK();
 
        printf("Creating session handle: ");
-       if ((handle = lttng_create_handle("test", &dom)) == NULL) {
+       if ((handle = lttng_create_handle(session_name, &dom)) == NULL) {
                printf("error creating handle: %s\n", lttng_strerror(ret));
                goto handle_fail;
        }
@@ -72,7 +73,7 @@ int main(int argc, char **argv)
        PRINT_OK();
 
        printf("Start tracing: ");
-    if ((ret = lttng_start_tracing("test")) < 0) {
+    if ((ret = lttng_start_tracing(session_name)) < 0) {
         printf("error starting tracing: %s\n", lttng_strerror(ret));
                goto start_fail;
     }
@@ -81,14 +82,14 @@ int main(int argc, char **argv)
     sleep(2);
 
        printf("Stop tracing: ");
-       if ((ret = lttng_stop_tracing("test")) < 0) {
+       if ((ret = lttng_stop_tracing(session_name)) < 0) {
                printf("error stopping tracing: %s\n", lttng_strerror(ret));
                goto stop_fail;
        }
        PRINT_OK();
 
        printf("Destroy tracing session: ");
-       if ((ret = lttng_destroy_session("test")) < 0) {
+       if ((ret = lttng_destroy_session(session_name)) < 0) {
                printf("error destroying session: %s\n", lttng_strerror(ret));
        }
        PRINT_OK();
@@ -103,7 +104,7 @@ handle_fail:
 stop_fail:
 start_fail:
 enable_fail:
-       lttng_destroy_session("test");
+       lttng_destroy_session(session_name);
        lttng_destroy_handle(handle);
 
     return 1;
index baa9ff836159eed17f113e42f5f994bc7202f0d0..d3a103033678bc5038a38ebcf1d5993cdee2db0c 100644 (file)
@@ -38,7 +38,7 @@ int main(int argc, char **argv)
 
     int ret = 0;
 
-       char *session_name = "ust_event_basic";
+       char *session_name = "ust_global_event_basic";
 
     dom.type = LTTNG_DOMAIN_UST;
 
index ec6fb3928262a491645baea9376458c87ff865bf..17be11817f31c69cfa53433835593f15bc1847ca 100755 (executable)
 
 #### ADD TESTS HERE ####
 
-test_suite=( test_sessions test_kernel_data_trace test_ust_data_trace lttng/runall.sh )
+test_suite=( test_sessions test_kernel_data_trace test_ust_data_trace
+                       lttng/runall.sh ust-nevents/run )
 
 #### END TESTS HERE ####
 
+TESTDIR=$(dirname $0)
+
+source $TESTDIR/utils.sh
+
+start_sessiond
+if [ $? -ne 0 ]; then
+       exit 1
+fi
+
 for bin in ${test_suite[@]};
 do
        ./$bin
@@ -30,9 +40,11 @@ do
        if [ $? -ne 0 ]; then
                echo -e '\e[1;31mFAIL\e[0m'
                echo ""
+               stop_sessiond
                exit 1
        fi
 done
 
 echo ""
+stop_sessiond
 exit 0
diff --git a/tests/test_ust_data_trace.c b/tests/test_ust_data_trace.c
new file mode 100644 (file)
index 0000000..4e4b29b
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * as published by the Free Software Foundation; only version 2
+ * of the License.
+ *
+ * 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.
+ */
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+
+#include "lttng/lttng.h"
+#include "lttng-sessiond/lttng-ust-abi.h"
+#include "lttng-share.h"
+#include "lttng-sessiond/trace-ust.h"
+#include "utils.h"
+
+/* This path will NEVER be created in this test */
+#define PATH1 "/tmp/.test-junk-lttng"
+
+/* For lttngerr.h */
+int opt_quiet = 1;
+int opt_verbose = 0;
+
+static const char alphanum[] =
+       "0123456789"
+       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+       "abcdefghijklmnopqrstuvwxyz";
+
+static struct ltt_ust_session *usess;
+static struct lttng_domain dom;
+
+/*
+ * Return random string of 10 characters.
+ */
+static char *get_random_string(void)
+{
+       int i;
+       char *str = malloc(11);
+
+       for (i = 0; i < 10; i++) {
+               str[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
+       }
+
+       str[10] = '\0';
+
+       return str;
+}
+
+static void create_one_ust_session(void)
+{
+       printf("Create UST session: ");
+
+       dom.type = LTTNG_DOMAIN_UST;
+
+       usess = trace_ust_create_session(PATH1, 42, &dom);
+       assert(usess != NULL);
+       PRINT_OK();
+
+       printf("Validating UST session: ");
+       assert(usess->id == 42);
+       assert(usess->start_trace == 0);
+       assert(usess->domain_global.channels != NULL);
+       assert(usess->domain_pid != NULL);
+       assert(usess->domain_exec != NULL);
+       assert(usess->uid == 0);
+       assert(usess->gid == 0);
+       PRINT_OK();
+
+       trace_ust_destroy_session(usess);
+}
+
+static void create_ust_metadata(void)
+{
+       struct ltt_ust_metadata *metadata;
+
+       assert(usess != NULL);
+
+       printf("Create UST metadata: ");
+       metadata = trace_ust_create_metadata(PATH1);
+       assert(metadata != NULL);
+       PRINT_OK();
+
+       printf("Validating UST session metadata: ");
+       assert(metadata->handle == -1);
+       assert(strlen(metadata->pathname));
+       assert(metadata->attr.overwrite
+                       == DEFAULT_CHANNEL_OVERWRITE);
+       assert(metadata->attr.subbuf_size
+                       == DEFAULT_METADATA_SUBBUF_SIZE);
+       assert(metadata->attr.num_subbuf
+                       == DEFAULT_METADATA_SUBBUF_NUM);
+       assert(metadata->attr.switch_timer_interval
+                       == DEFAULT_CHANNEL_SWITCH_TIMER);
+       assert(metadata->attr.read_timer_interval
+                       == DEFAULT_CHANNEL_READ_TIMER);
+       assert(metadata->attr.output == LTTNG_UST_MMAP);
+       PRINT_OK();
+
+       trace_ust_destroy_metadata(metadata);
+}
+
+static void create_ust_channel(void)
+{
+       struct ltt_ust_channel *uchan;
+       struct lttng_channel attr;
+
+       strncpy(attr.name, "channel0", 8);
+
+       printf("Creating UST channel: ");
+       uchan = trace_ust_create_channel(&attr, PATH1);
+       assert(uchan != NULL);
+       PRINT_OK();
+
+       printf("Validating UST channel: ");
+       assert(uchan->enabled == 0);
+       assert(strcmp(PATH1, uchan->pathname) == 0);
+       assert(strncmp(uchan->name, "channel0", 8) == 0);
+       assert(uchan->name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0');
+       assert(uchan->ctx != NULL);
+       assert(uchan->events != NULL);
+       assert(uchan->attr.overwrite  == attr.attr.overwrite);
+       PRINT_OK();
+
+       trace_ust_destroy_channel(uchan);
+}
+
+static void create_ust_event(void)
+{
+       struct ltt_ust_event *event;
+       struct lttng_event ev;
+
+       strncpy(ev.name, get_random_string(), LTTNG_SYMBOL_NAME_LEN);
+       ev.type = LTTNG_EVENT_TRACEPOINT;
+
+       printf("Creating UST event: ");
+       event = trace_ust_create_event(&ev);
+       assert(event != NULL);
+       PRINT_OK();
+
+       printf("Validating UST event: ");
+       assert(event->enabled == 0);
+       assert(event->ctx != NULL);
+       assert(event->attr.instrumentation == LTTNG_UST_TRACEPOINT);
+       assert(strcmp(event->attr.name, ev.name) == 0);
+       assert(event->attr.name[LTTNG_UST_SYM_NAME_LEN - 1] == '\0');
+       PRINT_OK();
+
+       trace_ust_destroy_event(event);
+}
+
+static void create_ust_context(void)
+{
+       struct lttng_event_context ctx;
+       struct ltt_ust_context *uctx;
+
+       printf("Creating UST context: ");
+       uctx = trace_ust_create_context(&ctx);
+       assert(uctx != NULL);
+       PRINT_OK();
+
+       printf("Validating UST context: ");
+       assert(ctx.ctx == uctx->ctx.ctx);
+       PRINT_OK();
+}
+
+int main(int argc, char **argv)
+{
+       printf("\nTesting UST data structures:\n-----------\n");
+
+       create_one_ust_session();
+       create_ust_metadata();
+       create_ust_channel();
+       create_ust_event();
+       create_ust_context();
+
+       /* Success */
+       return 0;
+}
diff --git a/tests/ust-nevents/Makefile.am b/tests/ust-nevents/Makefile.am
new file mode 100644 (file)
index 0000000..8007892
--- /dev/null
@@ -0,0 +1,8 @@
+AM_CPPFLAGS = -llttng-ust -ldl -I. -O2
+
+noinst_PROGRAMS = gen-nevents
+gen_nevents_SOURCES = gen-nevents.c tp.c ust_gen_nevents.h
+gen_nevents_LDADD = -llttng-ust
+
+noinst_SCRIPTS = run
+EXTRA_DIST = run
diff --git a/tests/ust-nevents/gen-nevents.c b/tests/ust-nevents/gen-nevents.c
new file mode 100644 (file)
index 0000000..03aa6c6
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) - 2009 Pierre-Marc Fournier
+ * Copyright (C) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * 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
+ */
+
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#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);
+       }
+
+       return 0;
+}
diff --git a/tests/ust-nevents/run b/tests/ust-nevents/run
new file mode 100755 (executable)
index 0000000..9fbc8d8
--- /dev/null
@@ -0,0 +1,45 @@
+#!/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
+
+TESTDIR=$(dirname $0)/..
+NR_ITER=100
+SESSION_NAME="ust-nevents"
+EVENT_NAME="ust_gen_nevents:tptest"
+TRACE_PATH=$(mktemp -d)
+
+source $TESTDIR/utils.sh
+
+echo -e "\n-----------------------------------"
+echo -e "UST tracer - Generate $NR_ITER events"
+echo -e "-------------------------------------"
+
+# MUST set TESTDIR before calling those functions
+
+create_lttng_session $SESSION_NAME $TRACE_PATH
+
+enable_ust_lttng_event $SESSION_NAME $EVENT_NAME
+start_tracing $SESSION_NAME
+
+# Start test
+./$(dirname $0)/gen-nevents $NR_ITER
+
+stop_tracing $SESSION_NAME
+destroy_lttng_session $SESSION_NAME
+
+trace_matches $EVENT_NAME $NR_ITER $TRACE_PATH
+
+rm -rf $TRACE_PATH
diff --git a/tests/ust-nevents/tp.c b/tests/ust-nevents/tp.c
new file mode 100644 (file)
index 0000000..e291924
--- /dev/null
@@ -0,0 +1,16 @@
+/*
+ * Copyright (c) - 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * Copyright (c) - 2012 David Goulet <dgoulet@efficios.com>
+ *
+ * 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/ust-nevents/ust_gen_nevents.h b/tests/ust-nevents/ust_gen_nevents.h
new file mode 100644 (file)
index 0000000..8d82ecb
--- /dev/null
@@ -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 <mathieu.desnoyers@efficios.com>
+ *
+ * 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 <lttng/tracepoint.h>
+
+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 <lttng/tracepoint-event.h>
+
+#ifdef __cplusplus 
+}
+#endif
diff --git a/tests/utils.sh b/tests/utils.sh
new file mode 100644 (file)
index 0000000..352a198
--- /dev/null
@@ -0,0 +1,139 @@
+#!/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
+
+SESSIOND_BIN="lttng-sessiond"
+LTTNG_BIN="lttng"
+BABELTRACE_BIN="babeltrace"
+
+function start_sessiond ()
+{
+       if [ -z $(pidof $SESSIOND_BIN) ]; then
+               echo -n "Starting session daemon... "
+               $TESTDIR/../lttng-sessiond/$SESSIOND_BIN --daemonize --quiet
+               if [ $? -eq 1 ]; then
+                       echo -e "\e[1;31mFAILED\e[0m"
+                       return 1
+               else
+                       echo -e "\e[1;32mOK\e[0m"
+               fi
+       fi
+}
+
+function stop_sessiond ()
+{
+       PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
+
+       echo -e -n "Killing session daemon... "
+       kill $PID_SESSIOND >/dev/null 2>&1
+       if [ $? -eq 1 ]; then
+               echo -e "\e[1;31mFAILED\e[0m"
+               return 1
+       else
+               echo -e "\e[1;32mOK\e[0m"
+       fi
+}
+
+function create_lttng_session ()
+{
+       sess_name=$1
+       trace_path=$2
+
+       echo -n "Creating lttng session $SESSION_NAME in $TRACE_PATH "
+       $TESTDIR/../lttng/$LTTNG_BIN create $sess_name -o $trace_path >/dev/null 2>&1
+       if [ $? -eq 1 ]; then
+               echo -e "\e[1;31mFAILED\e[0m"
+               return 1
+       else
+               echo -e "\e[1;32mOK\e[0m"
+               #echo $out | grep "written in" | cut -d' ' -f6
+       fi
+}
+
+function enable_ust_lttng_event ()
+{
+       sess_name=$1
+       event_name=$2
+
+       echo -n "Enabling lttng event $event_name for session $sess_name "
+       $TESTDIR/../lttng/$LTTNG_BIN enable-event $event_name -s $sess_name -u >/dev/null 2>&1
+       if [ $? -eq 1 ]; then
+               echo -e '\e[1;31mFAILED\e[0m'
+               return 1
+       else
+               echo -e "\e[1;32mOK\e[0m"
+       fi
+}
+
+function start_tracing ()
+{
+       sess_name=$1
+
+       echo -n "Start lttng tracing for session $sess_name "
+       $TESTDIR/../lttng/$LTTNG_BIN start $sess_name >/dev/null 2>&1
+       if [ $? -eq 1 ]; then
+               echo -e '\e[1;31mFAILED\e[0m'
+               return 1
+       else
+               echo -e "\e[1;32mOK\e[0m"
+       fi
+}
+
+function stop_tracing ()
+{
+       sess_name=$1
+
+       echo -n "Stop lttng tracing for session $sess_name "
+       $TESTDIR/../lttng/$LTTNG_BIN stop $sess_name >/dev/null 2>&1
+       if [ $? -eq 1 ]; then
+               echo -e '\e[1;31mFAILED\e[0m'
+               return 1
+       else
+               echo -e "\e[1;32mOK\e[0m"
+       fi
+}
+
+function destroy_lttng_session ()
+{
+       sess_name=$1
+
+       echo -n "Destroy lttng session $sess_name "
+       $TESTDIR/../lttng/$LTTNG_BIN destroy $sess_name >/dev/null 2>&1 
+       if [ $? -eq 1 ]; then
+               echo -e '\e[1;31mFAILED\e[0m'
+               return 1
+       else
+               echo -e "\e[1;32mOK\e[0m"
+       fi
+}
+
+function trace_matches ()
+{
+       event_name=$1
+       nr_iter=$2
+       trace_path=$3
+
+       echo -n "Looking for $nr_iter $event_name in $trace_path "
+
+       count=$($BABELTRACE_BIN $trace_path | grep $event_name | wc -l)
+       if [ "$count" -ne "$nr_iter" ]; then
+               echo -e "$count found in trace \e[1;31mFAILED\e[0m"
+               return 1
+       else
+               echo -e "Trace is coherent \e[1;32mOK\e[0m"
+               return 0
+       fi
+}
This page took 0.0395 seconds and 5 git commands to generate.