Add a simple test case for TRACE_EVENT v2
authorNils Carlson <nils.carlson@ericsson.com>
Mon, 30 Aug 2010 08:23:04 +0000 (10:23 +0200)
committerPierre-Marc Fournier <pierre-marc.fournier@polymtl.ca>
Wed, 1 Sep 2010 04:17:07 +0000 (00:17 -0400)
The test case is useful for verifying compilation of the simplest
possible TRACE_EVENT.

Changes since version 1:
Added copyright notices
updated run with UST_AUTOCOLLECT per Davids comment.

configure.ac
tests/Makefile.am
tests/trace_event/Makefile.am [new file with mode: 0644]
tests/trace_event/run [new file with mode: 0755]
tests/trace_event/trace_event_test.c [new file with mode: 0644]
tests/trace_event/trace_event_test.h [new file with mode: 0644]

index 19ec6a7a809503ae2792b677fdedb988779aa46a..dee974fcc92e1af2c865ba7fff3fb44c1c0ddb19 100644 (file)
@@ -121,6 +121,7 @@ AC_CONFIG_FILES([
        tests/test-libustinstr-malloc/Makefile
        tests/dlopen/Makefile
        tests/same_line_marker/Makefile
+       tests/trace_event/Makefile
        libustinstr-malloc/Makefile
        libustfork/Makefile
        libustd/Makefile
index c1fc928b7a13d460d8ea837b0e3598e63ebf0cde..ab13cd73bb1b30c8cd1c51c777e915afd2d473ad 100644 (file)
@@ -1,3 +1,3 @@
-SUBDIRS = hello hello2 basic basic_long fork simple_include snprintf test-nevents test-libustinstr-malloc dlopen same_line_marker
+SUBDIRS = hello hello2 basic basic_long fork simple_include snprintf test-nevents test-libustinstr-malloc dlopen same_line_marker trace_event
 
 dist_noinst_SCRIPTS = test_loop runtests trace_matches
diff --git a/tests/trace_event/Makefile.am b/tests/trace_event/Makefile.am
new file mode 100644 (file)
index 0000000..6de9a12
--- /dev/null
@@ -0,0 +1,9 @@
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
+noinst_PROGRAMS = trace_event_test
+trace_event_test_SOURCES = trace_event_test.c
+trace_event_test_LDADD = $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
+
+CFLAGS_trace_event_test.o = -I$(src)
+noinst_SCRIPTS = run
+EXTRA_DIST = run
diff --git a/tests/trace_event/run b/tests/trace_event/run
new file mode 100755 (executable)
index 0000000..6a04341
--- /dev/null
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Run with nothing
+
+UST_AUTOCOLLECT=1 UST_AUTOPROBE=1 UST_TRACE=1 LD_LIBRARY_PATH=../../libust/.libs:../../../liburcu $1 .libs/trace_event_test
diff --git a/tests/trace_event/trace_event_test.c b/tests/trace_event/trace_event_test.c
new file mode 100644 (file)
index 0000000..9ed3d6c
--- /dev/null
@@ -0,0 +1,30 @@
+/* Copyright (C) 2010 Nils Carlson <nils.carlson@ericsson.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; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * 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 <stdio.h>
+#include <ust/clock.h>
+
+#define CREATE_TRACE_POINTS
+#include "trace_event_test.h"
+
+int main(int argc, char * argv[])
+{
+       static unsigned long time, i;
+       for (i=0; i<10; i++) {
+               time=trace_clock_read64();
+               trace_test(time, i);
+       }
+}
diff --git a/tests/trace_event/trace_event_test.h b/tests/trace_event/trace_event_test.h
new file mode 100644 (file)
index 0000000..b9843bf
--- /dev/null
@@ -0,0 +1,50 @@
+/* Copyright (C) 2010 Nils Carlson <nils.carlson@ericsson.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; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * 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
+ */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM trace_event_test
+
+#if !defined(_TRACE_EVENT_TEST_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_EVENT_TEST_H
+
+#include <ust/tracepoint.h>
+
+TRACE_EVENT(test,
+
+       TP_PROTO(unsigned long time, unsigned long count),
+
+       TP_ARGS(time, count),
+
+       TP_STRUCT__entry(
+               __field(        unsigned long,  time    )
+               __field(        unsigned long,  count   )
+       ),
+
+       TP_fast_assign(
+               __entry->time = time;
+               __entry->count = count;
+       ),
+
+       TP_printf("time=%lu count=%lu", __entry->time, __entry->count)
+);
+
+#endif /* _TRACE_EVENT_TEST_H */
+
+/* This part must be outside protection */
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#define TRACE_INCLUDE_FILE trace_event_test
+#include <ust/define_trace.h>
This page took 0.034079 seconds and 4 git commands to generate.