Add api0 compile tests
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 29 Apr 2021 17:44:46 +0000 (13:44 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 6 May 2021 15:14:26 +0000 (11:14 -0400)
These compile tests will detect if we break the build of tracepoint
providers using the api0 of lttng-ust <= 2.12.

Change-Id: I208cfcbb624a799b3e32fc22bcbcfc03c547a466
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
30 files changed:
.gitignore
configure.ac
tests/compile/Makefile.am
tests/compile/api0/Makefile.am [new file with mode: 0644]
tests/compile/api0/ctf-types/Makefile.am [new file with mode: 0644]
tests/compile/api0/ctf-types/README [new file with mode: 0644]
tests/compile/api0/ctf-types/ctf-types.c [new file with mode: 0644]
tests/compile/api0/ctf-types/tp.c [new file with mode: 0644]
tests/compile/api0/ctf-types/ust_tests_ctf_types.h [new file with mode: 0644]
tests/compile/api0/hello-many/Makefile.am [new file with mode: 0644]
tests/compile/api0/hello-many/README [new file with mode: 0644]
tests/compile/api0/hello-many/hello-many.c [new file with mode: 0644]
tests/compile/api0/hello-many/tp.c [new file with mode: 0644]
tests/compile/api0/hello-many/ust_tests_hello_many.h [new file with mode: 0644]
tests/compile/api0/hello.cxx/Makefile.am [new file with mode: 0644]
tests/compile/api0/hello.cxx/README [new file with mode: 0644]
tests/compile/api0/hello.cxx/hello.cpp [new file with mode: 0644]
tests/compile/api0/hello.cxx/tp-cpp.cpp [new file with mode: 0644]
tests/compile/api0/hello.cxx/ust_tests_hello.h [new file with mode: 0644]
tests/compile/api0/hello/Makefile.am [new file with mode: 0644]
tests/compile/api0/hello/Makefile.example.bsd [new file with mode: 0644]
tests/compile/api0/hello/Makefile.example.linux [new file with mode: 0644]
tests/compile/api0/hello/README [new file with mode: 0644]
tests/compile/api0/hello/hello.c [new file with mode: 0644]
tests/compile/api0/hello/tp.c [new file with mode: 0644]
tests/compile/api0/hello/ust_tests_hello.h [new file with mode: 0644]
tests/compile/api0/same_line_tracepoint/Makefile.am [new file with mode: 0644]
tests/compile/api0/same_line_tracepoint/README [new file with mode: 0644]
tests/compile/api0/same_line_tracepoint/same_line_tracepoint.c [new file with mode: 0644]
tests/compile/api0/same_line_tracepoint/ust_tests_sameline.h [new file with mode: 0644]

index b7347e113b32b77e9f8ed3ee9cf4d509f9658303..12ec06c09df19ba79004781e8d5f2ed90911dba5 100644 (file)
@@ -76,6 +76,18 @@ cscope.*
 
 /tests/benchmark/bench1
 /tests/benchmark/bench2
+/tests/compile/api0/ctf-types/ctf-types
+/tests/compile/api0/ctf-types/ctf-types-api1
+/tests/compile/api0/hello.cxx/hello
+/tests/compile/api0/hello.cxx/hello-api1
+/tests/compile/api0/hello/hello
+/tests/compile/api0/hello/hello-api1
+/tests/compile/api0/hello-many/hello-many
+/tests/compile/api0/hello-many/hello-many-api1
+/tests/compile/api0/same_line_tracepoint/same_line_tracepoint
+/tests/compile/api0/same_line_tracepoint/same_line_tracepoint_api1
+/tests/compile/api0/test-app-ctx/hello
+/tests/compile/api0/test-app-ctx/hello-api1
 /tests/compile/api1/hello.cxx/hello
 /tests/compile/api1/hello.cxx/hello-compatapi1
 /tests/compile/api1/hello/hello
@@ -159,6 +171,12 @@ cscope.*
 /tests/Makefile
 /tests/benchmark/Makefile
 /tests/compile/Makefile
+/tests/compile/api0/Makefile
+/tests/compile/api0/ctf-types/Makefile
+/tests/compile/api0/hello-many/Makefile
+/tests/compile/api0/hello.cxx/Makefile
+/tests/compile/api0/hello/Makefile
+/tests/compile/api0/same_line_tracepoint/Makefile
 /tests/compile/api1/Makefile
 /tests/compile/api1/ust-fields/Makefile
 /tests/compile/api1/hello-many/Makefile
index a1a79eb2ff158139a344585ce4b12ba4de05e441..2e2fbb93264a072ed6f254d959aab5e115231e5d 100644 (file)
@@ -607,6 +607,12 @@ AC_CONFIG_FILES([
   src/python-lttngust/Makefile
   src/python-lttngust/setup.py
   tests/benchmark/Makefile
+  tests/compile/api0/ctf-types/Makefile
+  tests/compile/api0/hello.cxx/Makefile
+  tests/compile/api0/hello/Makefile
+  tests/compile/api0/hello-many/Makefile
+  tests/compile/api0/Makefile
+  tests/compile/api0/same_line_tracepoint/Makefile
   tests/compile/api1/ust-fields/Makefile
   tests/compile/api1/hello.cxx/Makefile
   tests/compile/api1/hello/Makefile
index 0ce13bea7a0e26f6a37200057599008df215bcf4..883a1ed8ad4f4366691a91a449d5247fa3fe8154 100644 (file)
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: LGPL-2.1-only
 
 SUBDIRS = \
+       api0 \
        api1
diff --git a/tests/compile/api0/Makefile.am b/tests/compile/api0/Makefile.am
new file mode 100644 (file)
index 0000000..56e327d
--- /dev/null
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: LGPL-2.1-only
+
+SUBDIRS = \
+       ctf-types \
+       hello \
+       hello-many \
+       same_line_tracepoint
+
+if HAVE_CXX
+SUBDIRS += hello.cxx
+endif
+
diff --git a/tests/compile/api0/ctf-types/Makefile.am b/tests/compile/api0/ctf-types/Makefile.am
new file mode 100644 (file)
index 0000000..d08395d
--- /dev/null
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: LGPL-2.1-only
+
+AM_CPPFLAGS += -I$(srcdir)
+
+noinst_PROGRAMS = ctf-types
+ctf_types_SOURCES = ctf-types.c tp.c ust_tests_ctf_types.h
+ctf_types_LDADD = $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la $(DL_LIBS)
+ctf_types_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
diff --git a/tests/compile/api0/ctf-types/README b/tests/compile/api0/ctf-types/README
new file mode 100644 (file)
index 0000000..0198653
--- /dev/null
@@ -0,0 +1,3 @@
+This is a "hello world" application used to verify that an instrumented program
+with tracepoints using type declarations in CTF metadata can be built
+successfully.
diff --git a/tests/compile/api0/ctf-types/ctf-types.c b/tests/compile/api0/ctf-types/ctf-types.c
new file mode 100644 (file)
index 0000000..c93c517
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2014 Geneviève Bastien <gbastien@versatic.net>
+ */
+
+#include <unistd.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_ctf_types.h"
+
+int main(int argc, char **argv)
+{
+       int i;
+       int delay = 0;
+
+       if (argc == 2)
+               delay = atoi(argv[1]);
+
+       fprintf(stderr, "Hello, World!\n");
+
+       sleep(delay);
+
+       fprintf(stderr, "Tracing... ");
+       for (i = 0; i < 100; i++) {
+               tracepoint(ust_tests_ctf_types, tptest, i, i % 6,
+                       i % 21);
+       }
+
+       for (i = 0; i < 10; i++) {
+               tracepoint(ust_tests_ctf_types, tptest_bis, i, i % 6);
+       }
+       fprintf(stderr, " done.\n");
+       return 0;
+}
diff --git a/tests/compile/api0/ctf-types/tp.c b/tests/compile/api0/ctf-types/tp.c
new file mode 100644 (file)
index 0000000..426854c
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2014 Geneviève Bastien <gbastien@versatic.net>
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_ctf_types.h"
diff --git a/tests/compile/api0/ctf-types/ust_tests_ctf_types.h b/tests/compile/api0/ctf-types/ust_tests_ctf_types.h
new file mode 100644 (file)
index 0000000..4ce4d98
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2014 Geneviève Bastien <gbastien@versatic.net>
+ */
+
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_ctf_types
+
+#if !defined(_TRACEPOINT_UST_TESTS_CTF_TYPES_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_CTF_TYPES_H
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_ENUM(ust_tests_ctf_types, testenum,
+       TP_ENUM_VALUES(
+               ctf_enum_value("even", 0)
+               ctf_enum_value("uneven", 1)
+               ctf_enum_range("twoto4", 2, 4)
+               ctf_enum_value("five\"extra\\test", 5)
+       )
+)
+
+TRACEPOINT_ENUM(ust_tests_ctf_types, testenum2,
+       TP_ENUM_VALUES(
+               ctf_enum_value("zero", 0)
+               ctf_enum_value("five", 5)
+               ctf_enum_range("ten_to_twenty", 10, 20)
+       )
+)
+
+/*
+ * Enumeration field is used twice to make sure the type declaration
+ * is entered only once in the metadata file.
+ */
+TRACEPOINT_EVENT(ust_tests_ctf_types, tptest,
+       TP_ARGS(int, anint, int, enumval, int, enumval2),
+       TP_FIELDS(
+               ctf_integer(int, intfield, anint)
+               ctf_enum(ust_tests_ctf_types, testenum, int, enumfield, enumval)
+               ctf_enum(ust_tests_ctf_types, testenum, long long,
+                               enumfield_bis, enumval)
+               ctf_enum(ust_tests_ctf_types, testenum2, unsigned int,
+                               enumfield_third, enumval2)
+       )
+)
+
+/*
+ * Another tracepoint using the types to make sure each type is entered
+ * only once in the metadata file.
+ */
+TRACEPOINT_EVENT(ust_tests_ctf_types, tptest_bis,
+       TP_ARGS(int, anint, int, enumval),
+       TP_FIELDS(
+               ctf_integer(int, intfield, anint)
+               ctf_enum(ust_tests_ctf_types, testenum, unsigned char,
+                       enumfield, enumval)
+       )
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_CTF_TYPES_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_ctf_types.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
diff --git a/tests/compile/api0/hello-many/Makefile.am b/tests/compile/api0/hello-many/Makefile.am
new file mode 100644 (file)
index 0000000..0235fc8
--- /dev/null
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: LGPL-2.1-only
+
+AM_CPPFLAGS += -I$(srcdir)
+
+noinst_PROGRAMS = hello-many
+hello_many_SOURCES = hello-many.c tp.c ust_tests_hello_many.h
+hello_many_LDADD = $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la $(DL_LIBS)
+hello_many_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
diff --git a/tests/compile/api0/hello-many/README b/tests/compile/api0/hello-many/README
new file mode 100644 (file)
index 0000000..a257254
--- /dev/null
@@ -0,0 +1,2 @@
+This is a "hello world" application used to verify that an instrumented
+program which contains more than 30 tracepoints can be built successfully.
diff --git a/tests/compile/api0/hello-many/hello-many.c b/tests/compile/api0/hello-many/hello-many.c
new file mode 100644 (file)
index 0000000..24736f6
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <string.h>
+#include <stdlib.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_hello_many.h"
+
+int main(int argc, char **argv)
+{
+       int delay = 0;
+
+       if (argc == 2)
+               delay = atoi(argv[1]);
+
+       fprintf(stderr, "Hello, World!\n");
+
+       sleep(delay);
+
+       fprintf(stderr, "Tracing... ");
+       tracepoint(ust_tests_hello_many, tptest_simple1);
+       tracepoint(ust_tests_hello_many, tptest_simple34);
+       fprintf(stderr, " done.\n");
+       return 0;
+}
diff --git a/tests/compile/api0/hello-many/tp.c b/tests/compile/api0/hello-many/tp.c
new file mode 100644 (file)
index 0000000..6c03264
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello_many.h"
diff --git a/tests/compile/api0/hello-many/ust_tests_hello_many.h b/tests/compile/api0/hello-many/ust_tests_hello_many.h
new file mode 100644 (file)
index 0000000..709e5bf
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_hello_many
+
+#if !defined(_TRACEPOINT_UST_TESTS_HELLO_MANY_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_HELLO_MANY_H
+
+#include <lttng/tracepoint.h>
+#include <stdbool.h>
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple1,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple2,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple3,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple4,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple5,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple6,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple7,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple8,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple9,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple10,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple11,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple12,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple13,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple14,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple15,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple16,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple17,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple18,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple19,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple20,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple21,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple22,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple23,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple24,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple25,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple26,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple27,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple28,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple29,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple30,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple31,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple32,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple33,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple34,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple35,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple36,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple37,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple38,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple39,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+TRACEPOINT_EVENT(ust_tests_hello_many, tptest_simple40,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_HELLO_MANY_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_hello_many.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
diff --git a/tests/compile/api0/hello.cxx/Makefile.am b/tests/compile/api0/hello.cxx/Makefile.am
new file mode 100644 (file)
index 0000000..282f921
--- /dev/null
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: LGPL-2.1-only
+
+AM_CPPFLAGS += -I$(srcdir)
+
+noinst_PROGRAMS = hello
+hello_SOURCES = hello.cpp tp-cpp.cpp ust_tests_hello.h
+hello_LDADD = $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la $(DL_LIBS)
diff --git a/tests/compile/api0/hello.cxx/README b/tests/compile/api0/hello.cxx/README
new file mode 100644 (file)
index 0000000..48cb0d8
--- /dev/null
@@ -0,0 +1,4 @@
+This is a "hello world" application used to verify that an instrumented
+program written in C++ can be built successfully.
+
+Only enabled if a C++ build environment is detected during configure.
diff --git a/tests/compile/api0/hello.cxx/hello.cpp b/tests/compile/api0/hello.cxx/hello.cpp
new file mode 100644 (file)
index 0000000..afbcf46
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <string.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_hello.h"
+
+static
+void inthandler(int sig __attribute__((unused)))
+{
+       printf("in SIGUSR1 handler\n");
+       tracepoint(ust_tests_hello, tptest_sighandler);
+}
+
+static
+int init_int_handler(void)
+{
+       int result;
+       struct sigaction act;
+
+       memset(&act, 0, sizeof(act));
+       result = sigemptyset(&act.sa_mask);
+       if (result == -1) {
+               perror("sigemptyset");
+               return -1;
+       }
+
+       act.sa_handler = inthandler;
+       act.sa_flags = SA_RESTART;
+
+       /* Only defer ourselves. Also, try to restart interrupted
+        * syscalls to disturb the traced program as little as possible.
+        */
+       result = sigaction(SIGUSR1, &act, NULL);
+       if (result == -1) {
+               perror("sigaction");
+               return -1;
+       }
+
+       return 0;
+}
+
+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;
+
+       init_int_handler();
+
+       if (argc == 2)
+               delay = atoi(argv[1]);
+
+       fprintf(stderr, "Hello, World!\n");
+
+       sleep(delay);
+
+       fprintf(stderr, "Tracing... ");
+       for (i = 0; i < 1000000; i++) {
+               netint = htonl(i);
+               tracepoint(ust_tests_hello, tptest, i, netint, values,
+                          text, strlen(text), dbl, flt, 15);
+               //usleep(100000);
+       }
+       fprintf(stderr, " done.\n");
+       return 0;
+}
diff --git a/tests/compile/api0/hello.cxx/tp-cpp.cpp b/tests/compile/api0/hello.cxx/tp-cpp.cpp
new file mode 100644 (file)
index 0000000..c7495dd
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello.h"
diff --git a/tests/compile/api0/hello.cxx/ust_tests_hello.h b/tests/compile/api0/hello.cxx/ust_tests_hello.h
new file mode 100644 (file)
index 0000000..1963e73
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_hello
+
+#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_HELLO_H
+
+#include <lttng/tracepoint.h>
+#include <stddef.h>
+
+TRACEPOINT_ENUM(ust_tests_hello, my_enum,
+       TP_ENUM_VALUES(
+               ctf_enum_value("zero", 0)
+               ctf_enum_value("one", 1)
+               ctf_enum_auto("two")
+               ctf_enum_value("three", 3)
+               ctf_enum_range("ten to twenty", 10, 20)
+               ctf_enum_auto("21!")
+       )
+)
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest,
+       TP_ARGS(int, anint, int, netint, long *, values,
+                char *, text, size_t, textlen,
+                double, doublearg, float, floatarg,
+                int, enumarg),
+       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)
+               ctf_enum(ust_tests_hello, my_enum, int, enumfield, enumarg)
+       )
+)
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_hello.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
diff --git a/tests/compile/api0/hello/Makefile.am b/tests/compile/api0/hello/Makefile.am
new file mode 100644 (file)
index 0000000..75ab9e1
--- /dev/null
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: LGPL-2.1-only
+
+AM_CPPFLAGS += -I$(srcdir)
+
+noinst_PROGRAMS = hello
+hello_SOURCES = hello.c tp.c ust_tests_hello.h
+hello_LDADD = $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la $(DL_LIBS)
+hello_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
diff --git a/tests/compile/api0/hello/Makefile.example.bsd b/tests/compile/api0/hello/Makefile.example.bsd
new file mode 100644 (file)
index 0000000..607171c
--- /dev/null
@@ -0,0 +1,8 @@
+# Example makefile for build outside of the LTTng-UST tree.
+
+hello:
+       ${CC} -O2 -I. -o hello -lc -llttng-ust hello.c tp.c
+
+.PHONY: clean
+clean:
+       rm -f hello
diff --git a/tests/compile/api0/hello/Makefile.example.linux b/tests/compile/api0/hello/Makefile.example.linux
new file mode 100644 (file)
index 0000000..c983f4c
--- /dev/null
@@ -0,0 +1,8 @@
+# Example makefile for build outside of the LTTng-UST tree.
+
+hello:
+       ${CC} -O2 -I. -o hello -ldl -llttng-ust hello.c tp.c
+
+.PHONY: clean
+clean:
+       rm -f hello
diff --git a/tests/compile/api0/hello/README b/tests/compile/api0/hello/README
new file mode 100644 (file)
index 0000000..5d5100d
--- /dev/null
@@ -0,0 +1,2 @@
+This is a "hello world" application used to verify that an instrumented
+program can be built successfully.
\ No newline at end of file
diff --git a/tests/compile/api0/hello/hello.c b/tests/compile/api0/hello/hello.c
new file mode 100644 (file)
index 0000000..87f2637
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2009 Pierre-Marc Fournier
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <string.h>
+/*
+ * Work-around inet.h missing struct mmsghdr forward declaration, with
+ * triggers a warning when system files warnings are enabled.
+ */
+struct mmsghdr;
+#include <arpa/inet.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_hello.h"
+
+static
+void inthandler(int sig __attribute__((unused)))
+{
+       printf("in SIGUSR1 handler\n");
+       tracepoint(ust_tests_hello, tptest_sighandler);
+}
+
+static
+int init_int_handler(void)
+{
+       int result;
+       struct sigaction act;
+
+       memset(&act, 0, sizeof(act));
+       result = sigemptyset(&act.sa_mask);
+       if (result == -1) {
+               perror("sigemptyset");
+               return -1;
+       }
+
+       act.sa_handler = inthandler;
+       act.sa_flags = SA_RESTART;
+
+       /* Only defer ourselves. Also, try to restart interrupted
+        * syscalls to disturb the traced program as little as possible.
+        */
+       result = sigaction(SIGUSR1, &act, NULL);
+       if (result == -1) {
+               perror("sigaction");
+               return -1;
+       }
+
+       return 0;
+}
+
+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;
+       bool mybool = 123;      /* should print "1" */
+
+       init_int_handler();
+
+       if (argc == 2)
+               delay = atoi(argv[1]);
+
+       fprintf(stderr, "Hello, World!\n");
+
+       sleep(delay);
+
+       fprintf(stderr, "Tracing... ");
+       for (i = 0; i < 1000000; i++) {
+               netint = htonl(i);
+               tracepoint(ust_tests_hello, tptest, i, netint, values,
+                          text, strlen(text), dbl, flt, mybool);
+               //usleep(100000);
+       }
+       fprintf(stderr, " done.\n");
+       return 0;
+}
diff --git a/tests/compile/api0/hello/tp.c b/tests/compile/api0/hello/tp.c
new file mode 100644 (file)
index 0000000..98669b6
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#define LTTNG_UST_TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello.h"
diff --git a/tests/compile/api0/hello/ust_tests_hello.h b/tests/compile/api0/hello/ust_tests_hello.h
new file mode 100644 (file)
index 0000000..2478a94
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_hello
+
+#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_HELLO_H
+
+#include <lttng/tracepoint.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest,
+       TP_ARGS(int, anint, int, netint, long *, values,
+               char *, text, size_t, textlen,
+               double, doublearg, float, floatarg,
+               bool, boolarg),
+       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_nowrite(long, arrfield1z, values, 3)
+               ctf_array(long, blah, values, 3)
+               ctf_array(long, arrfield1, values, 3)
+               ctf_array_hex(long, arrfield1_hex, values, 3)
+               ctf_array_network(long, arrfield1_network, values, 3)
+               ctf_array_network_hex(long, arrfield1_network_hex, values, 3)
+               ctf_array_text(char, arrfield2, text, 10)
+               ctf_sequence(char, seqfield1, text,
+                            size_t, textlen)
+               ctf_sequence_nowrite(char, seqfield1z, text,
+                            size_t, textlen)
+               ctf_sequence_hex(char, seqfield1_hex, text,
+                            size_t, textlen)
+               ctf_sequence_text(char, seqfield2, text,
+                            size_t, textlen)
+               ctf_sequence_network(long, seqfield_network_3, values,
+                            size_t, 3)
+               ctf_string(stringfield, text)
+               ctf_float(float, floatfield, floatarg)
+               ctf_float(double, doublefield, doublearg)
+               ctf_integer(bool, boolfield, boolarg)
+               ctf_integer_nowrite(int, filterfield, anint)
+       )
+)
+
+TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_hello.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
diff --git a/tests/compile/api0/same_line_tracepoint/Makefile.am b/tests/compile/api0/same_line_tracepoint/Makefile.am
new file mode 100644 (file)
index 0000000..f9e1ba6
--- /dev/null
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: LGPL-2.1-only
+
+AM_CPPFLAGS += -I$(srcdir)
+
+noinst_PROGRAMS = same_line_tracepoint
+same_line_tracepoint_SOURCES = same_line_tracepoint.c ust_tests_sameline.h
+same_line_tracepoint_LDADD = $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la $(DL_LIBS)
diff --git a/tests/compile/api0/same_line_tracepoint/README b/tests/compile/api0/same_line_tracepoint/README
new file mode 100644 (file)
index 0000000..55c2e08
--- /dev/null
@@ -0,0 +1,5 @@
+Same line tracepoint test
+-------------------------
+
+This is a build test that verifies multiple tracepoint can be placed on a single
+line.
diff --git a/tests/compile/api0/same_line_tracepoint/same_line_tracepoint.c b/tests/compile/api0/same_line_tracepoint/same_line_tracepoint.c
new file mode 100644 (file)
index 0000000..2f6f1ea
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ *
+ * Copyright (C) 2013 Jérémie Galarneau
+ */
+
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_sameline.h"
+
+int main(void)
+{
+       tracepoint(ust_tests_sameline, event1); tracepoint(ust_tests_sameline, event2);
+       return 0;
+}
diff --git a/tests/compile/api0/same_line_tracepoint/ust_tests_sameline.h b/tests/compile/api0/same_line_tracepoint/ust_tests_sameline.h
new file mode 100644 (file)
index 0000000..1894a95
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#undef TRACEPOINT_PROVIDER
+#define TRACEPOINT_PROVIDER ust_tests_sameline
+
+#if !defined(_TRACEPOINT_UST_TESTS_SAMELINE_H) || defined(TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_SAMELINE_H
+
+#include <lttng/tracepoint.h>
+
+TRACEPOINT_EVENT(ust_tests_sameline, event1,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+TRACEPOINT_LOGLEVEL(ust_tests_sameline, event1, TRACE_CRIT)
+
+TRACEPOINT_EVENT(ust_tests_sameline, event2,
+       TP_ARGS(),
+       TP_FIELDS()
+)
+TRACEPOINT_LOGLEVEL(ust_tests_sameline, event2, TRACE_CRIT)
+
+#endif /* _TRACEPOINT_UST_TESTS_SAMELINE_H */
+
+#undef TRACEPOINT_INCLUDE
+#define TRACEPOINT_INCLUDE "./ust_tests_sameline.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
This page took 0.038824 seconds and 4 git commands to generate.