Cleanup: separate tests between 'unit' and 'compile'
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 16 Jul 2020 19:09:45 +0000 (15:09 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 20 Oct 2020 19:29:34 +0000 (15:29 -0400)
Change-Id: Ib4326540609dc464b9a89ba9b891cf9c410d902b
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
121 files changed:
.gitignore
configure.ac
tests/Makefile.am
tests/compile/Makefile.am [new file with mode: 0644]
tests/compile/ctf-types/Makefile.am [new file with mode: 0644]
tests/compile/ctf-types/README [new file with mode: 0644]
tests/compile/ctf-types/ctf-types.c [new file with mode: 0644]
tests/compile/ctf-types/tp.c [new file with mode: 0644]
tests/compile/ctf-types/ust_tests_ctf_types.h [new file with mode: 0644]
tests/compile/hello-many/Makefile.am [new file with mode: 0644]
tests/compile/hello-many/README [new file with mode: 0644]
tests/compile/hello-many/hello-many.c [new file with mode: 0644]
tests/compile/hello-many/tp.c [new file with mode: 0644]
tests/compile/hello-many/ust_tests_hello_many.h [new file with mode: 0644]
tests/compile/hello.cxx/Makefile.am [new file with mode: 0644]
tests/compile/hello.cxx/README [new file with mode: 0644]
tests/compile/hello.cxx/hello.cpp [new file with mode: 0644]
tests/compile/hello.cxx/tp-cpp.cpp [new file with mode: 0644]
tests/compile/hello.cxx/ust_tests_hello.h [new file with mode: 0644]
tests/compile/hello/Makefile.am [new file with mode: 0644]
tests/compile/hello/Makefile.example.bsd [new file with mode: 0644]
tests/compile/hello/Makefile.example.linux [new file with mode: 0644]
tests/compile/hello/README [new file with mode: 0644]
tests/compile/hello/hello.c [new file with mode: 0644]
tests/compile/hello/tp.c [new file with mode: 0644]
tests/compile/hello/ust_tests_hello.h [new file with mode: 0644]
tests/compile/same_line_tracepoint/Makefile.am [new file with mode: 0644]
tests/compile/same_line_tracepoint/README [new file with mode: 0644]
tests/compile/same_line_tracepoint/same_line_tracepoint.c [new file with mode: 0644]
tests/compile/same_line_tracepoint/ust_tests_sameline.h [new file with mode: 0644]
tests/compile/test-app-ctx/Makefile.am [new file with mode: 0644]
tests/compile/test-app-ctx/hello.c [new file with mode: 0644]
tests/compile/test-app-ctx/tp.c [new file with mode: 0644]
tests/compile/test-app-ctx/ust_tests_hello.h [new file with mode: 0644]
tests/ctf-types/Makefile.am [deleted file]
tests/ctf-types/README [deleted file]
tests/ctf-types/ctf-types.c [deleted file]
tests/ctf-types/tp.c [deleted file]
tests/ctf-types/ust_tests_ctf_types.h [deleted file]
tests/gcc-weak-hidden/Makefile.am [deleted file]
tests/gcc-weak-hidden/b.c [deleted file]
tests/gcc-weak-hidden/c.c [deleted file]
tests/gcc-weak-hidden/d.c [deleted file]
tests/gcc-weak-hidden/main.c [deleted file]
tests/hello-many/Makefile.am [deleted file]
tests/hello-many/README [deleted file]
tests/hello-many/hello-many.c [deleted file]
tests/hello-many/tp.c [deleted file]
tests/hello-many/ust_tests_hello_many.h [deleted file]
tests/hello.cxx/Makefile.am [deleted file]
tests/hello.cxx/README [deleted file]
tests/hello.cxx/hello.cpp [deleted file]
tests/hello.cxx/tp-cpp.cpp [deleted file]
tests/hello.cxx/ust_tests_hello.h [deleted file]
tests/hello/Makefile.am [deleted file]
tests/hello/Makefile.example.bsd [deleted file]
tests/hello/Makefile.example.linux [deleted file]
tests/hello/README [deleted file]
tests/hello/hello.c [deleted file]
tests/hello/tp.c [deleted file]
tests/hello/ust_tests_hello.h [deleted file]
tests/pthread_name/Makefile.am [deleted file]
tests/pthread_name/pthread_name.c [deleted file]
tests/same_line_tracepoint/Makefile.am [deleted file]
tests/same_line_tracepoint/README [deleted file]
tests/same_line_tracepoint/same_line_tracepoint.c [deleted file]
tests/same_line_tracepoint/ust_tests_sameline.h [deleted file]
tests/snprintf/Makefile.am [deleted file]
tests/snprintf/README [deleted file]
tests/snprintf/snprintf.c [deleted file]
tests/test-app-ctx/Makefile.am [deleted file]
tests/test-app-ctx/hello.c [deleted file]
tests/test-app-ctx/tp.c [deleted file]
tests/test-app-ctx/ust_tests_hello.h [deleted file]
tests/unit/Makefile.am [new file with mode: 0644]
tests/unit/gcc-weak-hidden/Makefile.am [new file with mode: 0644]
tests/unit/gcc-weak-hidden/b.c [new file with mode: 0644]
tests/unit/gcc-weak-hidden/c.c [new file with mode: 0644]
tests/unit/gcc-weak-hidden/d.c [new file with mode: 0644]
tests/unit/gcc-weak-hidden/main.c [new file with mode: 0644]
tests/unit/pthread_name/Makefile.am [new file with mode: 0644]
tests/unit/pthread_name/pthread_name.c [new file with mode: 0644]
tests/unit/snprintf/Makefile.am [new file with mode: 0644]
tests/unit/snprintf/README [new file with mode: 0644]
tests/unit/snprintf/snprintf.c [new file with mode: 0644]
tests/unit/ust-elf/Makefile.am [new file with mode: 0644]
tests/unit/ust-elf/README.md [new file with mode: 0644]
tests/unit/ust-elf/data/aarch64_be/main.elf [new file with mode: 0644]
tests/unit/ust-elf/data/aarch64_be/main.elf.debug [new file with mode: 0755]
tests/unit/ust-elf/data/armeb/main.elf [new file with mode: 0644]
tests/unit/ust-elf/data/armeb/main.elf.debug [new file with mode: 0755]
tests/unit/ust-elf/data/main.c [new file with mode: 0644]
tests/unit/ust-elf/data/pic/hello.c [new file with mode: 0644]
tests/unit/ust-elf/data/pic/hello.exec [new file with mode: 0644]
tests/unit/ust-elf/data/pic/hello.pic [new file with mode: 0644]
tests/unit/ust-elf/data/pic/hello.pie [new file with mode: 0644]
tests/unit/ust-elf/data/pic/libhello.c [new file with mode: 0644]
tests/unit/ust-elf/data/x86/main.elf [new file with mode: 0644]
tests/unit/ust-elf/data/x86/main.elf.debug [new file with mode: 0755]
tests/unit/ust-elf/data/x86_64/main.elf [new file with mode: 0644]
tests/unit/ust-elf/data/x86_64/main.elf.debug [new file with mode: 0755]
tests/unit/ust-elf/test_ust_elf.in [new file with mode: 0644]
tests/unit/ust-elf/ust-elf.c [new file with mode: 0644]
tests/ust-elf/Makefile.am [deleted file]
tests/ust-elf/README.md [deleted file]
tests/ust-elf/data/aarch64_be/main.elf [deleted file]
tests/ust-elf/data/aarch64_be/main.elf.debug [deleted file]
tests/ust-elf/data/armeb/main.elf [deleted file]
tests/ust-elf/data/armeb/main.elf.debug [deleted file]
tests/ust-elf/data/main.c [deleted file]
tests/ust-elf/data/pic/hello.c [deleted file]
tests/ust-elf/data/pic/hello.exec [deleted file]
tests/ust-elf/data/pic/hello.pic [deleted file]
tests/ust-elf/data/pic/hello.pie [deleted file]
tests/ust-elf/data/pic/libhello.c [deleted file]
tests/ust-elf/data/x86/main.elf [deleted file]
tests/ust-elf/data/x86/main.elf.debug [deleted file]
tests/ust-elf/data/x86_64/main.elf [deleted file]
tests/ust-elf/data/x86_64/main.elf.debug [deleted file]
tests/ust-elf/test_ust_elf.in [deleted file]
tests/ust-elf/ust-elf.c [deleted file]

index c81a6ca123fd7b57cb2ab0d05384e87bc9ddf40e..f34fd0509744c09f7e5d23d701b57c6298e3eded 100644 (file)
@@ -70,19 +70,19 @@ doc/man/tracef.3
 doc/man/tracelog.3
 doc/man/vtracef.3
 
-tests/hello/hello
-tests/hello-many/hello-many
-tests/hello.cxx/hello
-tests/same_line_tracepoint/same_line_tracepoint
-tests/snprintf/test_snprintf
-tests/ust-elf/ust-elf
-tests/ust-elf/test_ust_elf
 tests/benchmark/bench1
 tests/benchmark/bench2
-tests/ctf-types/ctf-types
-tests/test-app-ctx/hello
-tests/gcc-weak-hidden/test_gcc_weak_hidden
-tests/pthread_name/test_pthread_name
+tests/compile/ctf-types/ctf-types
+tests/compile/hello.cxx/hello
+tests/compile/hello/hello
+tests/compile/hello-many/hello-many
+tests/compile/same_line_tracepoint/same_line_tracepoint
+tests/compile/test-app-ctx/hello
+tests/unit/gcc-weak-hidden/test_gcc_weak_hidden
+tests/unit/pthread_name/test_pthread_name
+tests/unit/snprintf/test_snprintf
+tests/unit/ust-elf/test_ust_elf
+tests/unit/ust-elf/ust-elf
 
 # Java agent library
 *.class
index 586affc9499515f4101e9d0ddd79e744f5d797c1..d409072a51b64075ef349b206c9a6650c17181ef 100644 (file)
@@ -566,18 +566,20 @@ AC_CONFIG_FILES([
        python-lttngust/lttngust/__init__.py
        tools/Makefile
        tests/Makefile
-       tests/ctf-types/Makefile
-       tests/hello/Makefile
-       tests/hello-many/Makefile
-       tests/hello.cxx/Makefile
-       tests/same_line_tracepoint/Makefile
-       tests/snprintf/Makefile
-       tests/ust-elf/Makefile
+       tests/compile/Makefile
+       tests/compile/ctf-types/Makefile
+       tests/compile/hello.cxx/Makefile
+       tests/compile/hello/Makefile
+       tests/compile/hello-many/Makefile
+       tests/compile/same_line_tracepoint/Makefile
+       tests/compile/test-app-ctx/Makefile
        tests/benchmark/Makefile
-       tests/pthread_name/Makefile
+       tests/unit/gcc-weak-hidden/Makefile
+       tests/unit/Makefile
+       tests/unit/pthread_name/Makefile
+       tests/unit/snprintf/Makefile
+       tests/unit/ust-elf/Makefile
        tests/utils/Makefile
-       tests/test-app-ctx/Makefile
-       tests/gcc-weak-hidden/Makefile
        lttng-ust.pc
        lttng-ust-ctl.pc
 ])
@@ -591,7 +593,7 @@ AC_CONFIG_LINKS([
        python-lttngust/lttngust/loghandler.py:python-lttngust/lttngust/loghandler.py
 ])
 
-AC_CONFIG_FILES([tests/ust-elf/test_ust_elf],[chmod +x tests/ust-elf/test_ust_elf])
+AC_CONFIG_FILES([tests/unit/ust-elf/test_ust_elf],[chmod +x tests/unit/ust-elf/test_ust_elf])
 
 AC_OUTPUT
 
index d46c94a58fe293e51a84d3dd456d292ebef73bbc..204925c1762435f5886f1a162b791a868cf6b92c 100644 (file)
@@ -1,18 +1,14 @@
-SUBDIRS = utils hello same_line_tracepoint snprintf benchmark ust-elf \
-               ctf-types test-app-ctx gcc-weak-hidden hello-many pthread_name
-
-if CXX_WORKS
-SUBDIRS += hello.cxx
-endif
+SUBDIRS = utils unit compile benchmark
 
 LOG_DRIVER_FLAGS='--merge'
 LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
        $(top_srcdir)/config/tap-driver.sh
 
-TESTS = snprintf/test_snprintf \
-       ust-elf/test_ust_elf \
-       gcc-weak-hidden/test_gcc_weak_hidden \
-       pthread_name/test_pthread_name
+TESTS = \
+       unit/gcc-weak-hidden/test_gcc_weak_hidden \
+       unit/pthread_name/test_pthread_name \
+       unit/snprintf/test_snprintf \
+       unit/ust-elf/test_ust_elf
 
 EXTRA_DIST = README
 
diff --git a/tests/compile/Makefile.am b/tests/compile/Makefile.am
new file mode 100644 (file)
index 0000000..04f4443
--- /dev/null
@@ -0,0 +1,11 @@
+SUBDIRS = \
+       ctf-types \
+       hello \
+       hello-many \
+       same_line_tracepoint \
+       test-app-ctx
+
+if CXX_WORKS
+SUBDIRS += hello.cxx
+endif
+
diff --git a/tests/compile/ctf-types/Makefile.am b/tests/compile/ctf-types/Makefile.am
new file mode 100644 (file)
index 0000000..8fcb1a2
--- /dev/null
@@ -0,0 +1,8 @@
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = ctf-types
+ctf_types_SOURCES = ctf-types.c tp.c ust_tests_ctf_types.h
+ctf_types_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+ctf_types_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
+
+EXTRA_DIST = README
diff --git a/tests/compile/ctf-types/README b/tests/compile/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/ctf-types/ctf-types.c b/tests/compile/ctf-types/ctf-types.c
new file mode 100644 (file)
index 0000000..006976a
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2014  Geneviève Bastien <gbastien@versatic.net>
+ *
+ * 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 <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/ctf-types/tp.c b/tests/compile/ctf-types/tp.c
new file mode 100644 (file)
index 0000000..6a33fca
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * tp.c
+ *
+ * Copyright (c) 2014 Geneviève Bastien <gbastien@versatic.net>
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_ctf_types.h"
diff --git a/tests/compile/ctf-types/ust_tests_ctf_types.h b/tests/compile/ctf-types/ust_tests_ctf_types.h
new file mode 100644 (file)
index 0000000..e789cbe
--- /dev/null
@@ -0,0 +1,83 @@
+#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
+
+/*
+ * Copyright (C) 2014 Geneviève Bastien <gbastien@versatic.net>
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#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/hello-many/Makefile.am b/tests/compile/hello-many/Makefile.am
new file mode 100644 (file)
index 0000000..d8f140b
--- /dev/null
@@ -0,0 +1,8 @@
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = hello-many
+hello_many_SOURCES = hello-many.c tp.c ust_tests_hello_many.h
+hello_many_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+hello_many_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
+
+EXTRA_DIST = README
diff --git a/tests/compile/hello-many/README b/tests/compile/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/hello-many/hello-many.c b/tests/compile/hello-many/hello-many.c
new file mode 100644 (file)
index 0000000..eb1e471
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2009  Pierre-Marc Fournier
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@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 <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/hello-many/tp.c b/tests/compile/hello-many/tp.c
new file mode 100644 (file)
index 0000000..ed5e8ce
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * tp.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello_many.h"
diff --git a/tests/compile/hello-many/ust_tests_hello_many.h b/tests/compile/hello-many/ust_tests_hello_many.h
new file mode 100644 (file)
index 0000000..c5f82b6
--- /dev/null
@@ -0,0 +1,239 @@
+#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
+
+/*
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#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/hello.cxx/Makefile.am b/tests/compile/hello.cxx/Makefile.am
new file mode 100644 (file)
index 0000000..9d80913
--- /dev/null
@@ -0,0 +1,7 @@
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = hello
+hello_SOURCES = hello.cpp tp-cpp.cpp ust_tests_hello.h
+hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+
+EXTRA_DIST = README
diff --git a/tests/compile/hello.cxx/README b/tests/compile/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/hello.cxx/hello.cpp b/tests/compile/hello.cxx/hello.cpp
new file mode 100644 (file)
index 0000000..9af2bf8
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2009  Pierre-Marc Fournier
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@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 <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"
+
+void inthandler(int sig)
+{
+       printf("in SIGUSR1 handler\n");
+       tracepoint(ust_tests_hello, tptest_sighandler);
+}
+
+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/hello.cxx/tp-cpp.cpp b/tests/compile/hello.cxx/tp-cpp.cpp
new file mode 100644 (file)
index 0000000..a2099ab
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * tp.cpp
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello.h"
diff --git a/tests/compile/hello.cxx/ust_tests_hello.h b/tests/compile/hello.cxx/ust_tests_hello.h
new file mode 100644 (file)
index 0000000..22914ee
--- /dev/null
@@ -0,0 +1,78 @@
+#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
+
+/*
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#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/hello/Makefile.am b/tests/compile/hello/Makefile.am
new file mode 100644 (file)
index 0000000..04fb9be
--- /dev/null
@@ -0,0 +1,8 @@
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = hello
+hello_SOURCES = hello.c tp.c ust_tests_hello.h
+hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+hello_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
+
+EXTRA_DIST = README
diff --git a/tests/compile/hello/Makefile.example.bsd b/tests/compile/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/hello/Makefile.example.linux b/tests/compile/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/hello/README b/tests/compile/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/hello/hello.c b/tests/compile/hello/hello.c
new file mode 100644 (file)
index 0000000..058f7fa
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2009  Pierre-Marc Fournier
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@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 <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"
+
+void inthandler(int sig)
+{
+       printf("in SIGUSR1 handler\n");
+       tracepoint(ust_tests_hello, tptest_sighandler);
+}
+
+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;
+}
+
+void test_inc_count(void);
+
+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/hello/tp.c b/tests/compile/hello/tp.c
new file mode 100644 (file)
index 0000000..4790965
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * tp.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello.h"
diff --git a/tests/compile/hello/ust_tests_hello.h b/tests/compile/hello/ust_tests_hello.h
new file mode 100644 (file)
index 0000000..a140ca8
--- /dev/null
@@ -0,0 +1,80 @@
+#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
+
+/*
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#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/same_line_tracepoint/Makefile.am b/tests/compile/same_line_tracepoint/Makefile.am
new file mode 100644 (file)
index 0000000..598dbec
--- /dev/null
@@ -0,0 +1,7 @@
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = same_line_tracepoint
+same_line_tracepoint_SOURCES = same_line_tracepoint.c ust_tests_sameline.h
+same_line_tracepoint_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+
+EXTRA_DIST = README
diff --git a/tests/compile/same_line_tracepoint/README b/tests/compile/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/same_line_tracepoint/same_line_tracepoint.c b/tests/compile/same_line_tracepoint/same_line_tracepoint.c
new file mode 100644 (file)
index 0000000..60f8a75
--- /dev/null
@@ -0,0 +1,26 @@
+/* Copyright (C) 2013 Jérémie Galarneau
+ *
+ * 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
+ */
+
+#define TRACEPOINT_DEFINE
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_sameline.h"
+
+int main()
+{
+       tracepoint(ust_tests_sameline, event1); tracepoint(ust_tests_sameline, event2);
+       return 0;
+}
diff --git a/tests/compile/same_line_tracepoint/ust_tests_sameline.h b/tests/compile/same_line_tracepoint/ust_tests_sameline.h
new file mode 100644 (file)
index 0000000..6425db7
--- /dev/null
@@ -0,0 +1,49 @@
+#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
+
+/*
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#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>
diff --git a/tests/compile/test-app-ctx/Makefile.am b/tests/compile/test-app-ctx/Makefile.am
new file mode 100644 (file)
index 0000000..699165b
--- /dev/null
@@ -0,0 +1,6 @@
+AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
+
+noinst_PROGRAMS = hello
+hello_SOURCES = hello.c tp.c ust_tests_hello.h
+hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
+hello_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
diff --git a/tests/compile/test-app-ctx/hello.c b/tests/compile/test-app-ctx/hello.c
new file mode 100644 (file)
index 0000000..e9e45ec
--- /dev/null
@@ -0,0 +1,343 @@
+/*
+ * Copyright (C) 2009  Pierre-Marc Fournier
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@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 <fcntl.h>
+#include <signal.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.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 <stddef.h>
+#include <stdlib.h>
+#include <stdbool.h>
+
+#define TRACEPOINT_DEFINE
+#include "ust_tests_hello.h"
+
+/* Internal header. */
+#include <lttng/ust-events.h>
+#include <lttng/ringbuffer-config.h>
+#include <lttng/ust-context-provider.h>
+
+static __thread unsigned int test_count;
+
+void test_inc_count(void)
+{
+       test_count++;
+}
+
+static
+size_t test_get_size(struct lttng_ctx_field *field, size_t offset)
+{
+       int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
+       size_t size = 0;
+
+       size += lib_ring_buffer_align(offset, lttng_alignof(char));
+       size += sizeof(char);           /* tag */
+       switch (sel) {
+       case LTTNG_UST_DYNAMIC_TYPE_NONE:
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_S8:
+               size += lib_ring_buffer_align(offset, lttng_alignof(int8_t));
+               size += sizeof(int8_t);         /* variant */
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_S16:
+               size += lib_ring_buffer_align(offset, lttng_alignof(int16_t));
+               size += sizeof(int16_t);        /* variant */
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_S32:
+               size += lib_ring_buffer_align(offset, lttng_alignof(int32_t));
+               size += sizeof(int32_t);        /* variant */
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_S64:
+               size += lib_ring_buffer_align(offset, lttng_alignof(int64_t));
+               size += sizeof(int64_t);        /* variant */
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_U8:
+               size += lib_ring_buffer_align(offset, lttng_alignof(uint8_t));
+               size += sizeof(uint8_t);                /* variant */
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_U16:
+               size += lib_ring_buffer_align(offset, lttng_alignof(uint16_t));
+               size += sizeof(uint16_t);       /* variant */
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_U32:
+               size += lib_ring_buffer_align(offset, lttng_alignof(uint32_t));
+               size += sizeof(uint32_t);       /* variant */
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_U64:
+               size += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
+               size += sizeof(uint64_t);       /* variant */
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
+               size += lib_ring_buffer_align(offset, lttng_alignof(float));
+               size += sizeof(float);          /* variant */
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
+               size += lib_ring_buffer_align(offset, lttng_alignof(double));
+               size += sizeof(double);         /* variant */
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_STRING:
+               size += strlen("teststr") + 1;
+               break;
+       default:
+               abort();
+       }
+
+       return size;
+}
+
+static
+void test_record(struct lttng_ctx_field *field,
+                struct lttng_ust_lib_ring_buffer_ctx *ctx,
+                struct lttng_channel *chan)
+{
+       int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
+       char sel_char = (char) sel;
+
+       lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
+       chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
+       switch (sel) {
+       case LTTNG_UST_DYNAMIC_TYPE_NONE:
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_S8:
+       {
+               int8_t v = -8;
+
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+               chan->ops->event_write(ctx, &v, sizeof(v));
+               break;
+       }
+       case LTTNG_UST_DYNAMIC_TYPE_S16:
+       {
+               int16_t v = -16;
+
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+               chan->ops->event_write(ctx, &v, sizeof(v));
+               break;
+       }
+       case LTTNG_UST_DYNAMIC_TYPE_S32:
+       {
+               int32_t v = -32;
+
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+               chan->ops->event_write(ctx, &v, sizeof(v));
+               break;
+       }
+       case LTTNG_UST_DYNAMIC_TYPE_S64:
+       {
+               int64_t v = -64;
+
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+               chan->ops->event_write(ctx, &v, sizeof(v));
+               break;
+       }
+       case LTTNG_UST_DYNAMIC_TYPE_U8:
+       {
+               uint8_t v = 8;
+
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+               chan->ops->event_write(ctx, &v, sizeof(v));
+               break;
+       }
+       case LTTNG_UST_DYNAMIC_TYPE_U16:
+       {
+               uint16_t v = 16;
+
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+               chan->ops->event_write(ctx, &v, sizeof(v));
+               break;
+       }
+       case LTTNG_UST_DYNAMIC_TYPE_U32:
+       {
+               uint32_t v = 32;
+
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+               chan->ops->event_write(ctx, &v, sizeof(v));
+               break;
+       }
+       case LTTNG_UST_DYNAMIC_TYPE_U64:
+       {
+               uint64_t v = 64;
+
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
+               chan->ops->event_write(ctx, &v, sizeof(v));
+               break;
+       }
+       case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
+       {
+               float f = 22322.0;
+
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(f));
+               chan->ops->event_write(ctx, &f, sizeof(f));
+               break;
+       }
+       case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
+       {
+               double d = 2.0;
+
+               lib_ring_buffer_align_ctx(ctx, lttng_alignof(d));
+               chan->ops->event_write(ctx, &d, sizeof(d));
+               break;
+       }
+       case LTTNG_UST_DYNAMIC_TYPE_STRING:
+       {
+               const char *str = "teststr";
+               chan->ops->event_write(ctx, str, strlen(str) + 1);
+               break;
+       }
+       default:
+               abort();
+       }
+}
+
+static
+void test_get_value(struct lttng_ctx_field *field,
+               struct lttng_ctx_value *value)
+{
+       int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
+
+       value->sel = sel;
+       switch (sel) {
+       case LTTNG_UST_DYNAMIC_TYPE_NONE:
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_S8:
+               value->u.s64 = -8;
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_S16:
+               value->u.s64 = -16;
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_S32:
+               value->u.s64 = -32;
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_S64:
+               value->u.s64 = -64;
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_U8:
+               value->u.s64 = 8;
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_U16:
+               value->u.s64 = 16;
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_U32:
+               value->u.s64 = 32;
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_U64:
+               value->u.s64 = 64;
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
+               value->u.d = 22322.0;
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
+               value->u.d = 2.0;
+               break;
+       case LTTNG_UST_DYNAMIC_TYPE_STRING:
+               value->u.str = "teststr";
+               break;
+       default:
+               abort();
+       }
+}
+
+struct lttng_ust_context_provider myprovider = {
+       .name = "$app.myprovider",
+       .get_size = test_get_size,
+       .record = test_record,
+       .get_value = test_get_value,
+};
+
+void inthandler(int sig)
+{
+       printf("in SIGUSR1 handler\n");
+       tracepoint(ust_tests_hello, tptest_sighandler);
+}
+
+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;
+}
+
+void test_inc_count(void);
+
+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]);
+
+       if (lttng_ust_context_provider_register(&myprovider))
+               abort();
+
+       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);
+               test_inc_count();
+               //usleep(100000);
+       }
+       lttng_ust_context_provider_unregister(&myprovider);
+       fprintf(stderr, " done.\n");
+       return 0;
+}
diff --git a/tests/compile/test-app-ctx/tp.c b/tests/compile/test-app-ctx/tp.c
new file mode 100644 (file)
index 0000000..4790965
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * tp.c
+ *
+ * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#define TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello.h"
diff --git a/tests/compile/test-app-ctx/ust_tests_hello.h b/tests/compile/test-app-ctx/ust_tests_hello.h
new file mode 100644 (file)
index 0000000..f16a75d
--- /dev/null
@@ -0,0 +1,69 @@
+#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
+
+/*
+ * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * 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.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <lttng/tracepoint.h>
+#include <stddef.h>
+#include <stdbool.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(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_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/ctf-types/Makefile.am b/tests/ctf-types/Makefile.am
deleted file mode 100644 (file)
index 8fcb1a2..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = ctf-types
-ctf_types_SOURCES = ctf-types.c tp.c ust_tests_ctf_types.h
-ctf_types_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-ctf_types_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
-
-EXTRA_DIST = README
diff --git a/tests/ctf-types/README b/tests/ctf-types/README
deleted file mode 100644 (file)
index 0198653..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-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/ctf-types/ctf-types.c b/tests/ctf-types/ctf-types.c
deleted file mode 100644 (file)
index 006976a..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2014  Geneviève Bastien <gbastien@versatic.net>
- *
- * 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 <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/ctf-types/tp.c b/tests/ctf-types/tp.c
deleted file mode 100644 (file)
index 6a33fca..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * tp.c
- *
- * Copyright (c) 2014 Geneviève Bastien <gbastien@versatic.net>
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_ctf_types.h"
diff --git a/tests/ctf-types/ust_tests_ctf_types.h b/tests/ctf-types/ust_tests_ctf_types.h
deleted file mode 100644 (file)
index e789cbe..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-#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
-
-/*
- * Copyright (C) 2014 Geneviève Bastien <gbastien@versatic.net>
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#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/gcc-weak-hidden/Makefile.am b/tests/gcc-weak-hidden/Makefile.am
deleted file mode 100644 (file)
index da3d301..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
-
-noinst_LTLIBRARIES = libgcc-wh.la
-libgcc_wh_la_SOURCES = c.c d.c
-
-noinst_PROGRAMS = test_gcc_weak_hidden
-test_gcc_weak_hidden_SOURCES = main.c b.c
-test_gcc_weak_hidden_LDADD = $(top_builddir)/tests/utils/libtap.a \
-       $(builddir)/libgcc-wh.la
diff --git a/tests/gcc-weak-hidden/b.c b/tests/gcc-weak-hidden/b.c
deleted file mode 100644 (file)
index 218a154..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-int testint __attribute__((weak, visibility("hidden")));
-void *testptr __attribute__((weak, visibility("hidden")));
-struct {
-       char a[24];
-} testsym_24_bytes __attribute__((weak, visibility("hidden")));
-
-void *testfct_int(void)
-{
-       return &testint;
-}
-
-void *testfct_ptr(void)
-{
-       return &testptr;
-}
-
-void *testfct_24_bytes(void)
-{
-       return &testsym_24_bytes;
-}
diff --git a/tests/gcc-weak-hidden/c.c b/tests/gcc-weak-hidden/c.c
deleted file mode 100644 (file)
index 1a744e2..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-int testint __attribute__((weak, visibility("hidden")));
-void *testptr __attribute__((weak, visibility("hidden")));
-struct {
-       char a[24];
-} testsym_24_bytes __attribute__((weak, visibility("hidden")));
-
-void *testlibfct1_int(void)
-{
-       return &testint;
-}
-
-void *testlibfct1_ptr(void)
-{
-       return &testptr;
-}
-
-void *testlibfct1_24_bytes(void)
-{
-       return &testsym_24_bytes;
-}
diff --git a/tests/gcc-weak-hidden/d.c b/tests/gcc-weak-hidden/d.c
deleted file mode 100644 (file)
index 05e10b4..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-int testint __attribute__((weak, visibility("hidden")));
-void *testptr __attribute__((weak, visibility("hidden")));
-struct {
-       char a[24];
-} testsym_24_bytes __attribute__((weak, visibility("hidden")));
-
-void *testlibfct2_int(void)
-{
-       return &testint;
-}
-
-void *testlibfct2_ptr(void)
-{
-       return &testptr;
-}
-
-void *testlibfct2_24_bytes(void)
-{
-       return &testsym_24_bytes;
-}
diff --git a/tests/gcc-weak-hidden/main.c b/tests/gcc-weak-hidden/main.c
deleted file mode 100644 (file)
index 0a80c05..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2016 - 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 <stdbool.h>
-#include "tap.h"
-
-#define NUM_TESTS 2
-
-int testint __attribute__((weak, visibility("hidden")));
-void *testptr __attribute__((weak, visibility("hidden")));
-struct {
-       char a[24];
-} testsym_24_bytes __attribute__((weak, visibility("hidden")));
-
-void *testfct_int(void);
-void *testfct_ptr(void);
-void *testfct_24_bytes(void);
-
-void *testlibfct1_int(void);
-void *testlibfct1_ptr(void);
-void *testlibfct1_24_bytes(void);
-
-void *testlibfct2_int(void);
-void *testlibfct2_ptr(void);
-void *testlibfct2_24_bytes(void);
-
-enum {
-       MATCH_PROGRAM_INT,
-       MATCH_PROGRAM_PTR,
-       MATCH_PROGRAM_24_BYTES,
-       MATCH_LIB_INT,
-       MATCH_LIB_PTR,
-       MATCH_LIB_24_BYTES,
-       NR_MATCH,
-};
-
-static bool match_matrix[NR_MATCH];
-
-int main()
-{
-       plan_tests(NUM_TESTS);
-
-       if (testfct_int() == &testint)
-               match_matrix[MATCH_PROGRAM_INT] = true;
-       if (testfct_ptr() == &testptr)
-               match_matrix[MATCH_PROGRAM_PTR] = true;
-       if (testfct_24_bytes() == &testsym_24_bytes)
-               match_matrix[MATCH_PROGRAM_24_BYTES] = true;
-
-       if (testlibfct1_int() == testlibfct2_int())
-               match_matrix[MATCH_LIB_INT] = true;
-       if (testlibfct1_ptr() == testlibfct2_ptr())
-               match_matrix[MATCH_LIB_PTR] = true;
-       if (testlibfct1_24_bytes() == testlibfct2_24_bytes())
-               match_matrix[MATCH_LIB_24_BYTES] = true;
-
-       diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (4 bytes integer object)",
-               match_matrix[MATCH_PROGRAM_INT] ? "match" : "MISMATCH");
-       diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (pointer object)",
-               match_matrix[MATCH_PROGRAM_PTR] ? "match" : "MISMATCH");
-       diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (24 bytes structure object)",
-               match_matrix[MATCH_PROGRAM_24_BYTES] ? "match" : "MISMATCH");
-
-       diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (4 bytes integer object)",
-               match_matrix[MATCH_LIB_INT] ? "match" : "MISMATCH");
-       diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (pointer object)",
-               match_matrix[MATCH_LIB_PTR] ? "match" : "MISMATCH");
-       diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (24 bytes structure object)",
-               match_matrix[MATCH_LIB_24_BYTES] ? "match" : "MISMATCH");
-
-       ok(match_matrix[MATCH_PROGRAM_INT] == match_matrix[MATCH_PROGRAM_PTR],
-               "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within main program");
-       ok(match_matrix[MATCH_LIB_INT] == match_matrix[MATCH_LIB_PTR],
-               "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within shared library");
-
-       return exit_status();
-}
diff --git a/tests/hello-many/Makefile.am b/tests/hello-many/Makefile.am
deleted file mode 100644 (file)
index d8f140b..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = hello-many
-hello_many_SOURCES = hello-many.c tp.c ust_tests_hello_many.h
-hello_many_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-hello_many_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
-
-EXTRA_DIST = README
diff --git a/tests/hello-many/README b/tests/hello-many/README
deleted file mode 100644 (file)
index a257254..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-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/hello-many/hello-many.c b/tests/hello-many/hello-many.c
deleted file mode 100644 (file)
index eb1e471..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2009  Pierre-Marc Fournier
- * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@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 <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/hello-many/tp.c b/tests/hello-many/tp.c
deleted file mode 100644 (file)
index ed5e8ce..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * tp.c
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_hello_many.h"
diff --git a/tests/hello-many/ust_tests_hello_many.h b/tests/hello-many/ust_tests_hello_many.h
deleted file mode 100644 (file)
index c5f82b6..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-#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
-
-/*
- * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#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/hello.cxx/Makefile.am b/tests/hello.cxx/Makefile.am
deleted file mode 100644 (file)
index 9d80913..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = hello
-hello_SOURCES = hello.cpp tp-cpp.cpp ust_tests_hello.h
-hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-
-EXTRA_DIST = README
diff --git a/tests/hello.cxx/README b/tests/hello.cxx/README
deleted file mode 100644 (file)
index 48cb0d8..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-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/hello.cxx/hello.cpp b/tests/hello.cxx/hello.cpp
deleted file mode 100644 (file)
index 9af2bf8..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2009  Pierre-Marc Fournier
- * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@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 <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"
-
-void inthandler(int sig)
-{
-       printf("in SIGUSR1 handler\n");
-       tracepoint(ust_tests_hello, tptest_sighandler);
-}
-
-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/hello.cxx/tp-cpp.cpp b/tests/hello.cxx/tp-cpp.cpp
deleted file mode 100644 (file)
index a2099ab..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * tp.cpp
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_hello.h"
diff --git a/tests/hello.cxx/ust_tests_hello.h b/tests/hello.cxx/ust_tests_hello.h
deleted file mode 100644 (file)
index 22914ee..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#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
-
-/*
- * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#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/hello/Makefile.am b/tests/hello/Makefile.am
deleted file mode 100644 (file)
index 04fb9be..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = hello
-hello_SOURCES = hello.c tp.c ust_tests_hello.h
-hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-hello_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
-
-EXTRA_DIST = README
diff --git a/tests/hello/Makefile.example.bsd b/tests/hello/Makefile.example.bsd
deleted file mode 100644 (file)
index 607171c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# 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/hello/Makefile.example.linux b/tests/hello/Makefile.example.linux
deleted file mode 100644 (file)
index c983f4c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-# 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/hello/README b/tests/hello/README
deleted file mode 100644 (file)
index 5d5100d..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-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/hello/hello.c b/tests/hello/hello.c
deleted file mode 100644 (file)
index 058f7fa..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2009  Pierre-Marc Fournier
- * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@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 <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"
-
-void inthandler(int sig)
-{
-       printf("in SIGUSR1 handler\n");
-       tracepoint(ust_tests_hello, tptest_sighandler);
-}
-
-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;
-}
-
-void test_inc_count(void);
-
-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/hello/tp.c b/tests/hello/tp.c
deleted file mode 100644 (file)
index 4790965..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * tp.c
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_hello.h"
diff --git a/tests/hello/ust_tests_hello.h b/tests/hello/ust_tests_hello.h
deleted file mode 100644 (file)
index a140ca8..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#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
-
-/*
- * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#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/pthread_name/Makefile.am b/tests/pthread_name/Makefile.am
deleted file mode 100644 (file)
index 173191d..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/liblttng-ust -I$(top_srcdir)/tests/utils
-
-noinst_PROGRAMS = test_pthread_name
-test_pthread_name_SOURCES = pthread_name.c
-test_pthread_name_LDADD = $(top_builddir)/tests/utils/libtap.a
diff --git a/tests/pthread_name/pthread_name.c b/tests/pthread_name/pthread_name.c
deleted file mode 100644 (file)
index b6c7831..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Copyright (C) 2020 Michael Jeanson <mjeanson@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; only
- * 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 <stdio.h>
-#include <string.h>
-#include "compat.h"
-
-#include "tap.h"
-
-#define TEST_NAME_PROPER_LEN 16
-
-int main()
-{
-       int ret;
-       char name1[TEST_NAME_PROPER_LEN];
-       char name2[TEST_NAME_PROPER_LEN];
-       char too_long_name[] = "thisnameistoolong";
-       char short_name[] = "labatt50";
-       char short_name_ust[] = "labatt50-ust";
-       char long_name[] = "procrastinating";
-       char long_name_ust[] = "procrastina-ust";
-
-       plan_tests(12);
-
-       /* Get the initial thread name */
-       ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
-       ok(ret == 0, "Get the thread name: '%s'", name1);
-
-       /* Set a thread name of more than 16 bytes, should fail */
-       ret = lttng_pthread_setname_np(too_long_name);
-       ok(ret == ERANGE, "Set a too long thread name: '%s'", too_long_name);
-
-       /* Get the thread name again, shouldn't have changed */
-       ret = lttng_pthread_getname_np(name2, TEST_NAME_PROPER_LEN);
-       ok(ret == 0, "Get the thread name: '%s'", name2);
-       ok(strcmp(name1, name2) == 0, "Compare the initial thread name: '%s' == '%s'", name1, name2);
-
-       /* Set a thread name of less than 16 bytes */
-       ret = lttng_pthread_setname_np(short_name);
-       ok(ret == 0, "Set a short thread name: '%s'", short_name);
-
-       /* Get the thread name again, should be the one we set */
-       ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
-       ok(ret == 0, "Get a short thread name: '%s'", name1);
-       ok(strcmp(short_name, name1) == 0, "Compare the short thread name: '%s' == '%s'", short_name, name1);
-
-       /* Append "-ust" to the thread name */
-       lttng_ust_setustprocname();
-       ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
-       ok(strcmp(short_name_ust, name1) == 0, "Compare the short UST thread name: '%s' == '%s'", short_name_ust, name1);
-
-
-       /* Set a thread name of 16 bytes */
-       ret = lttng_pthread_setname_np(long_name);
-       ok(ret == 0, "Set a long thread name: '%s'", long_name);
-
-       /* Get the thread name again, should be the one we set */
-       ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
-       ok(ret == 0, "Get a long thread name: '%s'", name1);
-       ok(strncmp(long_name, name1, TEST_NAME_PROPER_LEN - 1) == 0, "Compare the long thread name: '%s' == '%s'", long_name, name1);
-
-       /* Append "-ust" to the thread name which will truncate its end */
-       lttng_ust_setustprocname();
-       ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
-       ok(strcmp(long_name_ust, name1) == 0, "Compare the long UST thread name: '%s' == '%s'", long_name_ust, name1);
-
-       return exit_status();
-}
diff --git a/tests/same_line_tracepoint/Makefile.am b/tests/same_line_tracepoint/Makefile.am
deleted file mode 100644 (file)
index 598dbec..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = same_line_tracepoint
-same_line_tracepoint_SOURCES = same_line_tracepoint.c ust_tests_sameline.h
-same_line_tracepoint_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-
-EXTRA_DIST = README
diff --git a/tests/same_line_tracepoint/README b/tests/same_line_tracepoint/README
deleted file mode 100644 (file)
index 55c2e08..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-Same line tracepoint test
--------------------------
-
-This is a build test that verifies multiple tracepoint can be placed on a single
-line.
diff --git a/tests/same_line_tracepoint/same_line_tracepoint.c b/tests/same_line_tracepoint/same_line_tracepoint.c
deleted file mode 100644 (file)
index 60f8a75..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/* Copyright (C) 2013 Jérémie Galarneau
- *
- * 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
- */
-
-#define TRACEPOINT_DEFINE
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_sameline.h"
-
-int main()
-{
-       tracepoint(ust_tests_sameline, event1); tracepoint(ust_tests_sameline, event2);
-       return 0;
-}
diff --git a/tests/same_line_tracepoint/ust_tests_sameline.h b/tests/same_line_tracepoint/ust_tests_sameline.h
deleted file mode 100644 (file)
index 6425db7..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#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
-
-/*
- * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#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>
diff --git a/tests/snprintf/Makefile.am b/tests/snprintf/Makefile.am
deleted file mode 100644 (file)
index db0aca9..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
-
-noinst_PROGRAMS = test_snprintf
-test_snprintf_SOURCES = snprintf.c
-test_snprintf_LDADD = $(top_builddir)/snprintf/libustsnprintf.la \
-       $(top_builddir)/tests/utils/libtap.a
-
-EXTRA_DIST = README
diff --git a/tests/snprintf/README b/tests/snprintf/README
deleted file mode 100644 (file)
index 1321fad..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-ust_safe_snprintf test
--------------------
-
-Basic functionality test of the ust snprintf() implementation.
-
-DESCRIPTION
------------
-
-The ust_safe_snprintf() is tested against a known output string.
diff --git a/tests/snprintf/snprintf.c b/tests/snprintf/snprintf.c
deleted file mode 100644 (file)
index c108740..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright (C) 2009  Pierre-Marc Fournier
- *
- * 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 <string.h>
-#include "ust_snprintf.h"
-
-#include "tap.h"
-
-int main()
-{
-       char buf[100];
-       char *expected;
-       char test_fmt_str[] = "header %d, %s, %03d, '%3$*d'";
-       char escaped_test_fmt_str[] = "header %%d, %%s, %%03d, '%%3$*d'";
-
-       plan_tests(1);
-
-       expected = "header 9999, hello, 005, '    9'";
-       ust_safe_snprintf(buf, 99, test_fmt_str, 9999, "hello", 5, 9);
-
-       char test_desc_fmt_str[] = "Got expected output string with format string \"%s\"";
-       char test_desc[sizeof(escaped_test_fmt_str) + sizeof(test_desc_fmt_str) - 1];
-       sprintf(test_desc, test_desc_fmt_str, escaped_test_fmt_str);
-       ok(strcmp(buf, expected) == 0, test_desc);
-
-       return exit_status();
-}
diff --git a/tests/test-app-ctx/Makefile.am b/tests/test-app-ctx/Makefile.am
deleted file mode 100644 (file)
index 699165b..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-AM_CPPFLAGS += -I$(srcdir) -Wsystem-headers
-
-noinst_PROGRAMS = hello
-hello_SOURCES = hello.c tp.c ust_tests_hello.h
-hello_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la $(DL_LIBS)
-hello_CFLAGS = -Werror=old-style-definition $(AM_CFLAGS)
diff --git a/tests/test-app-ctx/hello.c b/tests/test-app-ctx/hello.c
deleted file mode 100644 (file)
index e9e45ec..0000000
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright (C) 2009  Pierre-Marc Fournier
- * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@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 <fcntl.h>
-#include <signal.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.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 <stddef.h>
-#include <stdlib.h>
-#include <stdbool.h>
-
-#define TRACEPOINT_DEFINE
-#include "ust_tests_hello.h"
-
-/* Internal header. */
-#include <lttng/ust-events.h>
-#include <lttng/ringbuffer-config.h>
-#include <lttng/ust-context-provider.h>
-
-static __thread unsigned int test_count;
-
-void test_inc_count(void)
-{
-       test_count++;
-}
-
-static
-size_t test_get_size(struct lttng_ctx_field *field, size_t offset)
-{
-       int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
-       size_t size = 0;
-
-       size += lib_ring_buffer_align(offset, lttng_alignof(char));
-       size += sizeof(char);           /* tag */
-       switch (sel) {
-       case LTTNG_UST_DYNAMIC_TYPE_NONE:
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_S8:
-               size += lib_ring_buffer_align(offset, lttng_alignof(int8_t));
-               size += sizeof(int8_t);         /* variant */
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_S16:
-               size += lib_ring_buffer_align(offset, lttng_alignof(int16_t));
-               size += sizeof(int16_t);        /* variant */
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_S32:
-               size += lib_ring_buffer_align(offset, lttng_alignof(int32_t));
-               size += sizeof(int32_t);        /* variant */
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_S64:
-               size += lib_ring_buffer_align(offset, lttng_alignof(int64_t));
-               size += sizeof(int64_t);        /* variant */
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_U8:
-               size += lib_ring_buffer_align(offset, lttng_alignof(uint8_t));
-               size += sizeof(uint8_t);                /* variant */
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_U16:
-               size += lib_ring_buffer_align(offset, lttng_alignof(uint16_t));
-               size += sizeof(uint16_t);       /* variant */
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_U32:
-               size += lib_ring_buffer_align(offset, lttng_alignof(uint32_t));
-               size += sizeof(uint32_t);       /* variant */
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_U64:
-               size += lib_ring_buffer_align(offset, lttng_alignof(uint64_t));
-               size += sizeof(uint64_t);       /* variant */
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
-               size += lib_ring_buffer_align(offset, lttng_alignof(float));
-               size += sizeof(float);          /* variant */
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
-               size += lib_ring_buffer_align(offset, lttng_alignof(double));
-               size += sizeof(double);         /* variant */
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_STRING:
-               size += strlen("teststr") + 1;
-               break;
-       default:
-               abort();
-       }
-
-       return size;
-}
-
-static
-void test_record(struct lttng_ctx_field *field,
-                struct lttng_ust_lib_ring_buffer_ctx *ctx,
-                struct lttng_channel *chan)
-{
-       int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
-       char sel_char = (char) sel;
-
-       lib_ring_buffer_align_ctx(ctx, lttng_alignof(char));
-       chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
-       switch (sel) {
-       case LTTNG_UST_DYNAMIC_TYPE_NONE:
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_S8:
-       {
-               int8_t v = -8;
-
-               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
-               chan->ops->event_write(ctx, &v, sizeof(v));
-               break;
-       }
-       case LTTNG_UST_DYNAMIC_TYPE_S16:
-       {
-               int16_t v = -16;
-
-               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
-               chan->ops->event_write(ctx, &v, sizeof(v));
-               break;
-       }
-       case LTTNG_UST_DYNAMIC_TYPE_S32:
-       {
-               int32_t v = -32;
-
-               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
-               chan->ops->event_write(ctx, &v, sizeof(v));
-               break;
-       }
-       case LTTNG_UST_DYNAMIC_TYPE_S64:
-       {
-               int64_t v = -64;
-
-               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
-               chan->ops->event_write(ctx, &v, sizeof(v));
-               break;
-       }
-       case LTTNG_UST_DYNAMIC_TYPE_U8:
-       {
-               uint8_t v = 8;
-
-               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
-               chan->ops->event_write(ctx, &v, sizeof(v));
-               break;
-       }
-       case LTTNG_UST_DYNAMIC_TYPE_U16:
-       {
-               uint16_t v = 16;
-
-               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
-               chan->ops->event_write(ctx, &v, sizeof(v));
-               break;
-       }
-       case LTTNG_UST_DYNAMIC_TYPE_U32:
-       {
-               uint32_t v = 32;
-
-               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
-               chan->ops->event_write(ctx, &v, sizeof(v));
-               break;
-       }
-       case LTTNG_UST_DYNAMIC_TYPE_U64:
-       {
-               uint64_t v = 64;
-
-               lib_ring_buffer_align_ctx(ctx, lttng_alignof(v));
-               chan->ops->event_write(ctx, &v, sizeof(v));
-               break;
-       }
-       case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
-       {
-               float f = 22322.0;
-
-               lib_ring_buffer_align_ctx(ctx, lttng_alignof(f));
-               chan->ops->event_write(ctx, &f, sizeof(f));
-               break;
-       }
-       case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
-       {
-               double d = 2.0;
-
-               lib_ring_buffer_align_ctx(ctx, lttng_alignof(d));
-               chan->ops->event_write(ctx, &d, sizeof(d));
-               break;
-       }
-       case LTTNG_UST_DYNAMIC_TYPE_STRING:
-       {
-               const char *str = "teststr";
-               chan->ops->event_write(ctx, str, strlen(str) + 1);
-               break;
-       }
-       default:
-               abort();
-       }
-}
-
-static
-void test_get_value(struct lttng_ctx_field *field,
-               struct lttng_ctx_value *value)
-{
-       int sel = test_count % _NR_LTTNG_UST_DYNAMIC_TYPES;
-
-       value->sel = sel;
-       switch (sel) {
-       case LTTNG_UST_DYNAMIC_TYPE_NONE:
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_S8:
-               value->u.s64 = -8;
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_S16:
-               value->u.s64 = -16;
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_S32:
-               value->u.s64 = -32;
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_S64:
-               value->u.s64 = -64;
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_U8:
-               value->u.s64 = 8;
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_U16:
-               value->u.s64 = 16;
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_U32:
-               value->u.s64 = 32;
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_U64:
-               value->u.s64 = 64;
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_FLOAT:
-               value->u.d = 22322.0;
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_DOUBLE:
-               value->u.d = 2.0;
-               break;
-       case LTTNG_UST_DYNAMIC_TYPE_STRING:
-               value->u.str = "teststr";
-               break;
-       default:
-               abort();
-       }
-}
-
-struct lttng_ust_context_provider myprovider = {
-       .name = "$app.myprovider",
-       .get_size = test_get_size,
-       .record = test_record,
-       .get_value = test_get_value,
-};
-
-void inthandler(int sig)
-{
-       printf("in SIGUSR1 handler\n");
-       tracepoint(ust_tests_hello, tptest_sighandler);
-}
-
-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;
-}
-
-void test_inc_count(void);
-
-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]);
-
-       if (lttng_ust_context_provider_register(&myprovider))
-               abort();
-
-       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);
-               test_inc_count();
-               //usleep(100000);
-       }
-       lttng_ust_context_provider_unregister(&myprovider);
-       fprintf(stderr, " done.\n");
-       return 0;
-}
diff --git a/tests/test-app-ctx/tp.c b/tests/test-app-ctx/tp.c
deleted file mode 100644 (file)
index 4790965..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * tp.c
- *
- * Copyright (c) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#define TRACEPOINT_CREATE_PROBES
-#include "ust_tests_hello.h"
diff --git a/tests/test-app-ctx/ust_tests_hello.h b/tests/test-app-ctx/ust_tests_hello.h
deleted file mode 100644 (file)
index f16a75d..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-#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
-
-/*
- * Copyright (C) 2011  Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-#include <lttng/tracepoint.h>
-#include <stddef.h>
-#include <stdbool.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(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_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/unit/Makefile.am b/tests/unit/Makefile.am
new file mode 100644 (file)
index 0000000..8c14ffb
--- /dev/null
@@ -0,0 +1,5 @@
+SUBDIRS = \
+       gcc-weak-hidden \
+       pthread_name \
+       snprintf \
+       ust-elf
diff --git a/tests/unit/gcc-weak-hidden/Makefile.am b/tests/unit/gcc-weak-hidden/Makefile.am
new file mode 100644 (file)
index 0000000..da3d301
--- /dev/null
@@ -0,0 +1,9 @@
+AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
+
+noinst_LTLIBRARIES = libgcc-wh.la
+libgcc_wh_la_SOURCES = c.c d.c
+
+noinst_PROGRAMS = test_gcc_weak_hidden
+test_gcc_weak_hidden_SOURCES = main.c b.c
+test_gcc_weak_hidden_LDADD = $(top_builddir)/tests/utils/libtap.a \
+       $(builddir)/libgcc-wh.la
diff --git a/tests/unit/gcc-weak-hidden/b.c b/tests/unit/gcc-weak-hidden/b.c
new file mode 100644 (file)
index 0000000..218a154
--- /dev/null
@@ -0,0 +1,20 @@
+int testint __attribute__((weak, visibility("hidden")));
+void *testptr __attribute__((weak, visibility("hidden")));
+struct {
+       char a[24];
+} testsym_24_bytes __attribute__((weak, visibility("hidden")));
+
+void *testfct_int(void)
+{
+       return &testint;
+}
+
+void *testfct_ptr(void)
+{
+       return &testptr;
+}
+
+void *testfct_24_bytes(void)
+{
+       return &testsym_24_bytes;
+}
diff --git a/tests/unit/gcc-weak-hidden/c.c b/tests/unit/gcc-weak-hidden/c.c
new file mode 100644 (file)
index 0000000..1a744e2
--- /dev/null
@@ -0,0 +1,20 @@
+int testint __attribute__((weak, visibility("hidden")));
+void *testptr __attribute__((weak, visibility("hidden")));
+struct {
+       char a[24];
+} testsym_24_bytes __attribute__((weak, visibility("hidden")));
+
+void *testlibfct1_int(void)
+{
+       return &testint;
+}
+
+void *testlibfct1_ptr(void)
+{
+       return &testptr;
+}
+
+void *testlibfct1_24_bytes(void)
+{
+       return &testsym_24_bytes;
+}
diff --git a/tests/unit/gcc-weak-hidden/d.c b/tests/unit/gcc-weak-hidden/d.c
new file mode 100644 (file)
index 0000000..05e10b4
--- /dev/null
@@ -0,0 +1,20 @@
+int testint __attribute__((weak, visibility("hidden")));
+void *testptr __attribute__((weak, visibility("hidden")));
+struct {
+       char a[24];
+} testsym_24_bytes __attribute__((weak, visibility("hidden")));
+
+void *testlibfct2_int(void)
+{
+       return &testint;
+}
+
+void *testlibfct2_ptr(void)
+{
+       return &testptr;
+}
+
+void *testlibfct2_24_bytes(void)
+{
+       return &testsym_24_bytes;
+}
diff --git a/tests/unit/gcc-weak-hidden/main.c b/tests/unit/gcc-weak-hidden/main.c
new file mode 100644 (file)
index 0000000..0a80c05
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2016 - 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 <stdbool.h>
+#include "tap.h"
+
+#define NUM_TESTS 2
+
+int testint __attribute__((weak, visibility("hidden")));
+void *testptr __attribute__((weak, visibility("hidden")));
+struct {
+       char a[24];
+} testsym_24_bytes __attribute__((weak, visibility("hidden")));
+
+void *testfct_int(void);
+void *testfct_ptr(void);
+void *testfct_24_bytes(void);
+
+void *testlibfct1_int(void);
+void *testlibfct1_ptr(void);
+void *testlibfct1_24_bytes(void);
+
+void *testlibfct2_int(void);
+void *testlibfct2_ptr(void);
+void *testlibfct2_24_bytes(void);
+
+enum {
+       MATCH_PROGRAM_INT,
+       MATCH_PROGRAM_PTR,
+       MATCH_PROGRAM_24_BYTES,
+       MATCH_LIB_INT,
+       MATCH_LIB_PTR,
+       MATCH_LIB_24_BYTES,
+       NR_MATCH,
+};
+
+static bool match_matrix[NR_MATCH];
+
+int main()
+{
+       plan_tests(NUM_TESTS);
+
+       if (testfct_int() == &testint)
+               match_matrix[MATCH_PROGRAM_INT] = true;
+       if (testfct_ptr() == &testptr)
+               match_matrix[MATCH_PROGRAM_PTR] = true;
+       if (testfct_24_bytes() == &testsym_24_bytes)
+               match_matrix[MATCH_PROGRAM_24_BYTES] = true;
+
+       if (testlibfct1_int() == testlibfct2_int())
+               match_matrix[MATCH_LIB_INT] = true;
+       if (testlibfct1_ptr() == testlibfct2_ptr())
+               match_matrix[MATCH_LIB_PTR] = true;
+       if (testlibfct1_24_bytes() == testlibfct2_24_bytes())
+               match_matrix[MATCH_LIB_24_BYTES] = true;
+
+       diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (4 bytes integer object)",
+               match_matrix[MATCH_PROGRAM_INT] ? "match" : "MISMATCH");
+       diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (pointer object)",
+               match_matrix[MATCH_PROGRAM_PTR] ? "match" : "MISMATCH");
+       diag("Address of weak symbol with hidden visibility %s between compile units within same module for main program (24 bytes structure object)",
+               match_matrix[MATCH_PROGRAM_24_BYTES] ? "match" : "MISMATCH");
+
+       diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (4 bytes integer object)",
+               match_matrix[MATCH_LIB_INT] ? "match" : "MISMATCH");
+       diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (pointer object)",
+               match_matrix[MATCH_LIB_PTR] ? "match" : "MISMATCH");
+       diag("Address of weak symbol with hidden visibility %s between compile units within same module for shared library (24 bytes structure object)",
+               match_matrix[MATCH_LIB_24_BYTES] ? "match" : "MISMATCH");
+
+       ok(match_matrix[MATCH_PROGRAM_INT] == match_matrix[MATCH_PROGRAM_PTR],
+               "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within main program");
+       ok(match_matrix[MATCH_LIB_INT] == match_matrix[MATCH_LIB_PTR],
+               "Weak-hidden behavior is the same for 4 bytes integer and pointer objects within shared library");
+
+       return exit_status();
+}
diff --git a/tests/unit/pthread_name/Makefile.am b/tests/unit/pthread_name/Makefile.am
new file mode 100644 (file)
index 0000000..173191d
--- /dev/null
@@ -0,0 +1,5 @@
+AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/liblttng-ust -I$(top_srcdir)/tests/utils
+
+noinst_PROGRAMS = test_pthread_name
+test_pthread_name_SOURCES = pthread_name.c
+test_pthread_name_LDADD = $(top_builddir)/tests/utils/libtap.a
diff --git a/tests/unit/pthread_name/pthread_name.c b/tests/unit/pthread_name/pthread_name.c
new file mode 100644 (file)
index 0000000..b6c7831
--- /dev/null
@@ -0,0 +1,82 @@
+/* Copyright (C) 2020 Michael Jeanson <mjeanson@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; only
+ * 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 <stdio.h>
+#include <string.h>
+#include "compat.h"
+
+#include "tap.h"
+
+#define TEST_NAME_PROPER_LEN 16
+
+int main()
+{
+       int ret;
+       char name1[TEST_NAME_PROPER_LEN];
+       char name2[TEST_NAME_PROPER_LEN];
+       char too_long_name[] = "thisnameistoolong";
+       char short_name[] = "labatt50";
+       char short_name_ust[] = "labatt50-ust";
+       char long_name[] = "procrastinating";
+       char long_name_ust[] = "procrastina-ust";
+
+       plan_tests(12);
+
+       /* Get the initial thread name */
+       ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
+       ok(ret == 0, "Get the thread name: '%s'", name1);
+
+       /* Set a thread name of more than 16 bytes, should fail */
+       ret = lttng_pthread_setname_np(too_long_name);
+       ok(ret == ERANGE, "Set a too long thread name: '%s'", too_long_name);
+
+       /* Get the thread name again, shouldn't have changed */
+       ret = lttng_pthread_getname_np(name2, TEST_NAME_PROPER_LEN);
+       ok(ret == 0, "Get the thread name: '%s'", name2);
+       ok(strcmp(name1, name2) == 0, "Compare the initial thread name: '%s' == '%s'", name1, name2);
+
+       /* Set a thread name of less than 16 bytes */
+       ret = lttng_pthread_setname_np(short_name);
+       ok(ret == 0, "Set a short thread name: '%s'", short_name);
+
+       /* Get the thread name again, should be the one we set */
+       ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
+       ok(ret == 0, "Get a short thread name: '%s'", name1);
+       ok(strcmp(short_name, name1) == 0, "Compare the short thread name: '%s' == '%s'", short_name, name1);
+
+       /* Append "-ust" to the thread name */
+       lttng_ust_setustprocname();
+       ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
+       ok(strcmp(short_name_ust, name1) == 0, "Compare the short UST thread name: '%s' == '%s'", short_name_ust, name1);
+
+
+       /* Set a thread name of 16 bytes */
+       ret = lttng_pthread_setname_np(long_name);
+       ok(ret == 0, "Set a long thread name: '%s'", long_name);
+
+       /* Get the thread name again, should be the one we set */
+       ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
+       ok(ret == 0, "Get a long thread name: '%s'", name1);
+       ok(strncmp(long_name, name1, TEST_NAME_PROPER_LEN - 1) == 0, "Compare the long thread name: '%s' == '%s'", long_name, name1);
+
+       /* Append "-ust" to the thread name which will truncate its end */
+       lttng_ust_setustprocname();
+       ret = lttng_pthread_getname_np(name1, TEST_NAME_PROPER_LEN);
+       ok(strcmp(long_name_ust, name1) == 0, "Compare the long UST thread name: '%s' == '%s'", long_name_ust, name1);
+
+       return exit_status();
+}
diff --git a/tests/unit/snprintf/Makefile.am b/tests/unit/snprintf/Makefile.am
new file mode 100644 (file)
index 0000000..db0aca9
--- /dev/null
@@ -0,0 +1,8 @@
+AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
+
+noinst_PROGRAMS = test_snprintf
+test_snprintf_SOURCES = snprintf.c
+test_snprintf_LDADD = $(top_builddir)/snprintf/libustsnprintf.la \
+       $(top_builddir)/tests/utils/libtap.a
+
+EXTRA_DIST = README
diff --git a/tests/unit/snprintf/README b/tests/unit/snprintf/README
new file mode 100644 (file)
index 0000000..1321fad
--- /dev/null
@@ -0,0 +1,9 @@
+ust_safe_snprintf test
+-------------------
+
+Basic functionality test of the ust snprintf() implementation.
+
+DESCRIPTION
+-----------
+
+The ust_safe_snprintf() is tested against a known output string.
diff --git a/tests/unit/snprintf/snprintf.c b/tests/unit/snprintf/snprintf.c
new file mode 100644 (file)
index 0000000..c108740
--- /dev/null
@@ -0,0 +1,42 @@
+/* Copyright (C) 2009  Pierre-Marc Fournier
+ *
+ * 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 <string.h>
+#include "ust_snprintf.h"
+
+#include "tap.h"
+
+int main()
+{
+       char buf[100];
+       char *expected;
+       char test_fmt_str[] = "header %d, %s, %03d, '%3$*d'";
+       char escaped_test_fmt_str[] = "header %%d, %%s, %%03d, '%%3$*d'";
+
+       plan_tests(1);
+
+       expected = "header 9999, hello, 005, '    9'";
+       ust_safe_snprintf(buf, 99, test_fmt_str, 9999, "hello", 5, 9);
+
+       char test_desc_fmt_str[] = "Got expected output string with format string \"%s\"";
+       char test_desc[sizeof(escaped_test_fmt_str) + sizeof(test_desc_fmt_str) - 1];
+       sprintf(test_desc, test_desc_fmt_str, escaped_test_fmt_str);
+       ok(strcmp(buf, expected) == 0, test_desc);
+
+       return exit_status();
+}
diff --git a/tests/unit/ust-elf/Makefile.am b/tests/unit/ust-elf/Makefile.am
new file mode 100644 (file)
index 0000000..eadbaa8
--- /dev/null
@@ -0,0 +1,11 @@
+AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
+
+noinst_PROGRAMS = ust-elf
+ust_elf_SOURCES = ust-elf.c
+ust_elf_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la \
+       $(top_builddir)/tests/utils/libtap.a
+
+# Directories added to EXTRA_DIST will be recursively copied to the distribution.
+EXTRA_DIST = \
+       $(srcdir)/data \
+       README.md
diff --git a/tests/unit/ust-elf/README.md b/tests/unit/ust-elf/README.md
new file mode 100644 (file)
index 0000000..0091876
--- /dev/null
@@ -0,0 +1,52 @@
+lttng_ust_elf unit tests
+========================
+
+This is a series of unit tests for LTTng UST's ELF parser. The parser
+is used to retrieve memory size, build ID, and debug link information
+from ELF objects (standalone executable or shared object) for base
+address statedump or dl events.
+
+The parser should technically be able to read ELF files from any 32-
+or 64-bit architecture, little- or big- endian.
+
+However, to restrict the total amount of testing done, only 4
+architectures representing all combinations of bitness and endianness
+are currently tested:
+
+* x86
+* x86_64
+* armeb
+* aarch64_be
+
+For each architecture, there is a corresponding subdirectory under
+`data`, and each of these directories contains exactly 2 files,
+`main.elf` and `main.elf.debug`.
+
+The ELF files are generated from the trivial `main.c` program found in
+`data/`, using GNU toolchains. The program contains a static array in
+order to ensure the creation of a `.bss` section in the ELF file,
+which is one of the multiple factors leading to different file and
+in-memory size.
+
+The program is compiled with `gcc -g main.c -o main.elf`. On certain
+architectures, it is necessary to explicitly specify the
+`-Wl,--build-id=sha1` flags to include a build ID in the resulting
+executable.
+
+The debug information bundled in `main.elf` is then copied into
+`main.elf.debug` and stripped, and a debug link pointing to this file
+is added to the executable. The commands used are as follow:
+
+    $ objcopy --only-keep-debug main.elf main.elf.debug
+    $ strip -g main.elf
+    $ objcopy --add-gnu-debuglink=main.elf.debug main.elf
+
+There is also a series of tests used to check detection of
+position-independent code (PIC). These tests use three pre-compiled
+ELF files found under `data/pic/`, namely `hello.exec`, `hello.pie`,
+and `hello.pic`. These can be re-generated using the files `hello.c`
+and `libhello.c`, with the following commands:
+
+    $ gcc hello.c -o hello.exec
+    $ gcc hello.c -fPIC -pie -o hello.pie
+    $ gcc -shared -o hello.pic -fPIC libhello.c
diff --git a/tests/unit/ust-elf/data/aarch64_be/main.elf b/tests/unit/ust-elf/data/aarch64_be/main.elf
new file mode 100644 (file)
index 0000000..c30502e
Binary files /dev/null and b/tests/unit/ust-elf/data/aarch64_be/main.elf differ
diff --git a/tests/unit/ust-elf/data/aarch64_be/main.elf.debug b/tests/unit/ust-elf/data/aarch64_be/main.elf.debug
new file mode 100755 (executable)
index 0000000..c48fc19
Binary files /dev/null and b/tests/unit/ust-elf/data/aarch64_be/main.elf.debug differ
diff --git a/tests/unit/ust-elf/data/armeb/main.elf b/tests/unit/ust-elf/data/armeb/main.elf
new file mode 100644 (file)
index 0000000..10e470c
Binary files /dev/null and b/tests/unit/ust-elf/data/armeb/main.elf differ
diff --git a/tests/unit/ust-elf/data/armeb/main.elf.debug b/tests/unit/ust-elf/data/armeb/main.elf.debug
new file mode 100755 (executable)
index 0000000..0971af3
Binary files /dev/null and b/tests/unit/ust-elf/data/armeb/main.elf.debug differ
diff --git a/tests/unit/ust-elf/data/main.c b/tests/unit/ust-elf/data/main.c
new file mode 100644 (file)
index 0000000..d756a50
--- /dev/null
@@ -0,0 +1,6 @@
+int main()
+{
+       char buf[100];
+
+       return 0;
+}
diff --git a/tests/unit/ust-elf/data/pic/hello.c b/tests/unit/ust-elf/data/pic/hello.c
new file mode 100644 (file)
index 0000000..e89f5fb
--- /dev/null
@@ -0,0 +1,8 @@
+#include <stdio.h>
+
+int main()
+{
+       puts("hello, world");
+
+       return 0;
+}
diff --git a/tests/unit/ust-elf/data/pic/hello.exec b/tests/unit/ust-elf/data/pic/hello.exec
new file mode 100644 (file)
index 0000000..9af50ea
Binary files /dev/null and b/tests/unit/ust-elf/data/pic/hello.exec differ
diff --git a/tests/unit/ust-elf/data/pic/hello.pic b/tests/unit/ust-elf/data/pic/hello.pic
new file mode 100644 (file)
index 0000000..a9e3f47
Binary files /dev/null and b/tests/unit/ust-elf/data/pic/hello.pic differ
diff --git a/tests/unit/ust-elf/data/pic/hello.pie b/tests/unit/ust-elf/data/pic/hello.pie
new file mode 100644 (file)
index 0000000..384795f
Binary files /dev/null and b/tests/unit/ust-elf/data/pic/hello.pie differ
diff --git a/tests/unit/ust-elf/data/pic/libhello.c b/tests/unit/ust-elf/data/pic/libhello.c
new file mode 100644 (file)
index 0000000..d3f02e8
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+void hello()
+{
+       puts("hello, world");
+}
diff --git a/tests/unit/ust-elf/data/x86/main.elf b/tests/unit/ust-elf/data/x86/main.elf
new file mode 100644 (file)
index 0000000..30f7746
Binary files /dev/null and b/tests/unit/ust-elf/data/x86/main.elf differ
diff --git a/tests/unit/ust-elf/data/x86/main.elf.debug b/tests/unit/ust-elf/data/x86/main.elf.debug
new file mode 100755 (executable)
index 0000000..ea0aafc
Binary files /dev/null and b/tests/unit/ust-elf/data/x86/main.elf.debug differ
diff --git a/tests/unit/ust-elf/data/x86_64/main.elf b/tests/unit/ust-elf/data/x86_64/main.elf
new file mode 100644 (file)
index 0000000..341e4a2
Binary files /dev/null and b/tests/unit/ust-elf/data/x86_64/main.elf differ
diff --git a/tests/unit/ust-elf/data/x86_64/main.elf.debug b/tests/unit/ust-elf/data/x86_64/main.elf.debug
new file mode 100755 (executable)
index 0000000..275f2ca
Binary files /dev/null and b/tests/unit/ust-elf/data/x86_64/main.elf.debug differ
diff --git a/tests/unit/ust-elf/test_ust_elf.in b/tests/unit/ust-elf/test_ust_elf.in
new file mode 100644 (file)
index 0000000..280180c
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+TEST_DIR=$(dirname "$0")
+"${TEST_DIR}/ust-elf" "@abs_top_srcdir@/tests/unit/ust-elf"
diff --git a/tests/unit/ust-elf/ust-elf.c b/tests/unit/ust-elf/ust-elf.c
new file mode 100644 (file)
index 0000000..2410281
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2015  Antoine Busque <abusque@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; 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 <limits.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <lttng/ust-elf.h>
+#include "tap.h"
+
+#define NUM_ARCH 4
+#define NUM_TESTS_PER_ARCH 11
+#define NUM_TESTS_PIC 3
+#define NUM_TESTS (NUM_ARCH * NUM_TESTS_PER_ARCH) + NUM_TESTS_PIC + 1
+
+/*
+ * Expected memsz were computed using libelf, build ID and debug link
+ * were determined through readelf.
+ */
+#define X86_MEMSZ 5732
+#define X86_64_MEMSZ 2099376
+#define ARMEB_MEMSZ 34196
+#define AARCH64_BE_MEMSZ 67632
+
+#define X86_CRC 0x1531f73c
+#define X86_64_CRC 0xa048a98f
+#define ARMEB_CRC 0x9d40261b
+#define AARCH64_BE_CRC 0x2b8cedce
+
+#define BUILD_ID_LEN 20
+#define DBG_FILE "main.elf.debug"
+
+static const uint8_t x86_build_id[BUILD_ID_LEN] = {
+       0x27, 0x79, 0x2a, 0xe7, 0xaa, 0xef, 0x72, 0x5c, 0x9c, 0x52,
+       0x80, 0xec, 0x1e, 0x18, 0xd8, 0x09, 0x02, 0xba, 0xbc, 0x82
+};
+static const uint8_t x86_64_build_id[BUILD_ID_LEN] = {
+       0x0f, 0x87, 0xb2, 0xe2, 0x24, 0x9c, 0xe1, 0xc2, 0x24, 0xb1,
+       0xf8, 0xb6, 0x65, 0x83, 0xa3, 0xc1, 0xcb, 0x30, 0x5c, 0x63
+};
+static const uint8_t armeb_build_id[BUILD_ID_LEN] = {
+       0x60, 0x5d, 0x26, 0xa0, 0x0e, 0x30, 0xa4, 0x29, 0xf4, 0xf1,
+       0x85, 0x53, 0xda, 0x90, 0x68, 0xe1, 0xf5, 0x67, 0xbe, 0x42
+};
+static const uint8_t aarch64_be_build_id[BUILD_ID_LEN] = {
+       0xb9, 0x0a, 0xa0, 0xed, 0xd1, 0x41, 0x42, 0xc3, 0x34, 0x85,
+       0xfa, 0x27, 0x2e, 0xa9, 0x2f, 0xd2, 0xe4, 0xf7, 0xb6, 0x60
+};
+
+static
+void test_elf(const char *test_dir, const char *arch, uint64_t exp_memsz,
+               const uint8_t *exp_build_id, uint32_t exp_crc)
+{
+       char path[PATH_MAX];
+       struct lttng_ust_elf *elf = NULL;
+       int ret = 0;
+       uint64_t memsz = 0;
+       int has_build_id = 0;
+       uint8_t *build_id = NULL;
+       size_t build_id_len = 0;
+       int has_debug_link = 0;
+       char *dbg_file = NULL;
+       uint32_t crc = 0;
+
+       diag("Testing %s support", arch);
+
+       snprintf(path, PATH_MAX, "%s/data/%s/main.elf", test_dir, arch);
+       elf = lttng_ust_elf_create(path);
+       ok(elf != NULL, "lttng_ust_elf_create");
+
+       ret = lttng_ust_elf_get_memsz(elf, &memsz);
+       ok(ret == 0, "lttng_ust_elf_get_memsz returned successfully");
+       ok(memsz == exp_memsz,
+               "memsz - expected: %lu, got: %lu",
+               exp_memsz, memsz);
+
+       ret = lttng_ust_elf_get_build_id(elf, &build_id, &build_id_len,
+                                       &has_build_id);
+       ok(ret == 0, "lttng_ust_elf_get_build_id returned successfully");
+       ok(has_build_id == 1, "build id marked as found");
+       ok(build_id_len == BUILD_ID_LEN,
+               "build_id_len - expected: %u, got: %u",
+               BUILD_ID_LEN, build_id_len);
+       ok(memcmp(build_id, exp_build_id, build_id_len) == 0,
+               "build_id has expected value");
+
+       ret = lttng_ust_elf_get_debug_link(elf, &dbg_file, &crc,
+                                       &has_debug_link);
+       ok(ret == 0, "lttng_ust_elf_get_debug_link returned successfully");
+       ok(has_debug_link == 1, "debug link marked as found");
+       ok(dbg_file && strcmp(dbg_file, DBG_FILE) == 0,
+               "debug link filename - expected: %s, got: %s",
+               DBG_FILE, dbg_file);
+       ok(crc == exp_crc,
+               "debug link crc - expected: %#x, got: %#x",
+               exp_crc, crc);
+
+       free(build_id);
+       free(dbg_file);
+       lttng_ust_elf_destroy(elf);
+}
+
+static
+void test_pic(const char *test_dir)
+{
+       char exec_path[PATH_MAX];
+       char pie_path[PATH_MAX];
+       char pic_path[PATH_MAX];
+       struct lttng_ust_elf *elf = NULL;
+       uint8_t is_pic;
+
+       snprintf(exec_path, PATH_MAX, "%s/data/pic/hello.exec", test_dir);
+       snprintf(pie_path, PATH_MAX, "%s/data/pic/hello.pie", test_dir);
+       snprintf(pic_path, PATH_MAX, "%s/data/pic/hello.pic", test_dir);
+
+       elf = lttng_ust_elf_create(exec_path);
+       is_pic = lttng_ust_elf_is_pic(elf);
+       ok(is_pic == 0, "hello.exec is not PIC");
+       lttng_ust_elf_destroy(elf);
+
+       elf = lttng_ust_elf_create(pie_path);
+       is_pic = lttng_ust_elf_is_pic(elf);
+       ok(is_pic == 1, "hello.pie is PIC");
+       lttng_ust_elf_destroy(elf);
+
+       elf = lttng_ust_elf_create(pic_path);
+       is_pic = lttng_ust_elf_is_pic(elf);
+       ok(is_pic == 1, "hello.pic is PIC");
+       lttng_ust_elf_destroy(elf);
+}
+
+int main(int argc, char **argv)
+{
+       const char *test_dir;
+
+       plan_tests(NUM_TESTS);
+
+       ok(argc == 2, "Invoke as: %s <path>", argv[0]);
+       if (argc != 2) {
+               return EXIT_FAILURE;
+       } else {
+               test_dir = argv[1];
+       }
+
+       test_elf(test_dir, "x86", X86_MEMSZ, x86_build_id, X86_CRC);
+       test_elf(test_dir, "x86_64", X86_64_MEMSZ, x86_64_build_id, X86_64_CRC);
+       test_elf(test_dir, "armeb", ARMEB_MEMSZ, armeb_build_id, ARMEB_CRC);
+       test_elf(test_dir, "aarch64_be", AARCH64_BE_MEMSZ, aarch64_be_build_id,
+               AARCH64_BE_CRC);
+       test_pic(test_dir);
+
+       return exit_status();
+}
diff --git a/tests/ust-elf/Makefile.am b/tests/ust-elf/Makefile.am
deleted file mode 100644 (file)
index eadbaa8..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-AM_CPPFLAGS += -I$(top_srcdir)/tests/utils
-
-noinst_PROGRAMS = ust-elf
-ust_elf_SOURCES = ust-elf.c
-ust_elf_LDADD = $(top_builddir)/liblttng-ust/liblttng-ust.la \
-       $(top_builddir)/tests/utils/libtap.a
-
-# Directories added to EXTRA_DIST will be recursively copied to the distribution.
-EXTRA_DIST = \
-       $(srcdir)/data \
-       README.md
diff --git a/tests/ust-elf/README.md b/tests/ust-elf/README.md
deleted file mode 100644 (file)
index 0091876..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-lttng_ust_elf unit tests
-========================
-
-This is a series of unit tests for LTTng UST's ELF parser. The parser
-is used to retrieve memory size, build ID, and debug link information
-from ELF objects (standalone executable or shared object) for base
-address statedump or dl events.
-
-The parser should technically be able to read ELF files from any 32-
-or 64-bit architecture, little- or big- endian.
-
-However, to restrict the total amount of testing done, only 4
-architectures representing all combinations of bitness and endianness
-are currently tested:
-
-* x86
-* x86_64
-* armeb
-* aarch64_be
-
-For each architecture, there is a corresponding subdirectory under
-`data`, and each of these directories contains exactly 2 files,
-`main.elf` and `main.elf.debug`.
-
-The ELF files are generated from the trivial `main.c` program found in
-`data/`, using GNU toolchains. The program contains a static array in
-order to ensure the creation of a `.bss` section in the ELF file,
-which is one of the multiple factors leading to different file and
-in-memory size.
-
-The program is compiled with `gcc -g main.c -o main.elf`. On certain
-architectures, it is necessary to explicitly specify the
-`-Wl,--build-id=sha1` flags to include a build ID in the resulting
-executable.
-
-The debug information bundled in `main.elf` is then copied into
-`main.elf.debug` and stripped, and a debug link pointing to this file
-is added to the executable. The commands used are as follow:
-
-    $ objcopy --only-keep-debug main.elf main.elf.debug
-    $ strip -g main.elf
-    $ objcopy --add-gnu-debuglink=main.elf.debug main.elf
-
-There is also a series of tests used to check detection of
-position-independent code (PIC). These tests use three pre-compiled
-ELF files found under `data/pic/`, namely `hello.exec`, `hello.pie`,
-and `hello.pic`. These can be re-generated using the files `hello.c`
-and `libhello.c`, with the following commands:
-
-    $ gcc hello.c -o hello.exec
-    $ gcc hello.c -fPIC -pie -o hello.pie
-    $ gcc -shared -o hello.pic -fPIC libhello.c
diff --git a/tests/ust-elf/data/aarch64_be/main.elf b/tests/ust-elf/data/aarch64_be/main.elf
deleted file mode 100644 (file)
index c30502e..0000000
Binary files a/tests/ust-elf/data/aarch64_be/main.elf and /dev/null differ
diff --git a/tests/ust-elf/data/aarch64_be/main.elf.debug b/tests/ust-elf/data/aarch64_be/main.elf.debug
deleted file mode 100755 (executable)
index c48fc19..0000000
Binary files a/tests/ust-elf/data/aarch64_be/main.elf.debug and /dev/null differ
diff --git a/tests/ust-elf/data/armeb/main.elf b/tests/ust-elf/data/armeb/main.elf
deleted file mode 100644 (file)
index 10e470c..0000000
Binary files a/tests/ust-elf/data/armeb/main.elf and /dev/null differ
diff --git a/tests/ust-elf/data/armeb/main.elf.debug b/tests/ust-elf/data/armeb/main.elf.debug
deleted file mode 100755 (executable)
index 0971af3..0000000
Binary files a/tests/ust-elf/data/armeb/main.elf.debug and /dev/null differ
diff --git a/tests/ust-elf/data/main.c b/tests/ust-elf/data/main.c
deleted file mode 100644 (file)
index d756a50..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-int main()
-{
-       char buf[100];
-
-       return 0;
-}
diff --git a/tests/ust-elf/data/pic/hello.c b/tests/ust-elf/data/pic/hello.c
deleted file mode 100644 (file)
index e89f5fb..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <stdio.h>
-
-int main()
-{
-       puts("hello, world");
-
-       return 0;
-}
diff --git a/tests/ust-elf/data/pic/hello.exec b/tests/ust-elf/data/pic/hello.exec
deleted file mode 100644 (file)
index 9af50ea..0000000
Binary files a/tests/ust-elf/data/pic/hello.exec and /dev/null differ
diff --git a/tests/ust-elf/data/pic/hello.pic b/tests/ust-elf/data/pic/hello.pic
deleted file mode 100644 (file)
index a9e3f47..0000000
Binary files a/tests/ust-elf/data/pic/hello.pic and /dev/null differ
diff --git a/tests/ust-elf/data/pic/hello.pie b/tests/ust-elf/data/pic/hello.pie
deleted file mode 100644 (file)
index 384795f..0000000
Binary files a/tests/ust-elf/data/pic/hello.pie and /dev/null differ
diff --git a/tests/ust-elf/data/pic/libhello.c b/tests/ust-elf/data/pic/libhello.c
deleted file mode 100644 (file)
index d3f02e8..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <stdio.h>
-
-void hello()
-{
-       puts("hello, world");
-}
diff --git a/tests/ust-elf/data/x86/main.elf b/tests/ust-elf/data/x86/main.elf
deleted file mode 100644 (file)
index 30f7746..0000000
Binary files a/tests/ust-elf/data/x86/main.elf and /dev/null differ
diff --git a/tests/ust-elf/data/x86/main.elf.debug b/tests/ust-elf/data/x86/main.elf.debug
deleted file mode 100755 (executable)
index ea0aafc..0000000
Binary files a/tests/ust-elf/data/x86/main.elf.debug and /dev/null differ
diff --git a/tests/ust-elf/data/x86_64/main.elf b/tests/ust-elf/data/x86_64/main.elf
deleted file mode 100644 (file)
index 341e4a2..0000000
Binary files a/tests/ust-elf/data/x86_64/main.elf and /dev/null differ
diff --git a/tests/ust-elf/data/x86_64/main.elf.debug b/tests/ust-elf/data/x86_64/main.elf.debug
deleted file mode 100755 (executable)
index 275f2ca..0000000
Binary files a/tests/ust-elf/data/x86_64/main.elf.debug and /dev/null differ
diff --git a/tests/ust-elf/test_ust_elf.in b/tests/ust-elf/test_ust_elf.in
deleted file mode 100644 (file)
index f4a3017..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-TEST_DIR=$(dirname "$0")
-"${TEST_DIR}/ust-elf" "@abs_top_srcdir@/tests/ust-elf"
diff --git a/tests/ust-elf/ust-elf.c b/tests/ust-elf/ust-elf.c
deleted file mode 100644 (file)
index 2410281..0000000
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2015  Antoine Busque <abusque@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; 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 <limits.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <lttng/ust-elf.h>
-#include "tap.h"
-
-#define NUM_ARCH 4
-#define NUM_TESTS_PER_ARCH 11
-#define NUM_TESTS_PIC 3
-#define NUM_TESTS (NUM_ARCH * NUM_TESTS_PER_ARCH) + NUM_TESTS_PIC + 1
-
-/*
- * Expected memsz were computed using libelf, build ID and debug link
- * were determined through readelf.
- */
-#define X86_MEMSZ 5732
-#define X86_64_MEMSZ 2099376
-#define ARMEB_MEMSZ 34196
-#define AARCH64_BE_MEMSZ 67632
-
-#define X86_CRC 0x1531f73c
-#define X86_64_CRC 0xa048a98f
-#define ARMEB_CRC 0x9d40261b
-#define AARCH64_BE_CRC 0x2b8cedce
-
-#define BUILD_ID_LEN 20
-#define DBG_FILE "main.elf.debug"
-
-static const uint8_t x86_build_id[BUILD_ID_LEN] = {
-       0x27, 0x79, 0x2a, 0xe7, 0xaa, 0xef, 0x72, 0x5c, 0x9c, 0x52,
-       0x80, 0xec, 0x1e, 0x18, 0xd8, 0x09, 0x02, 0xba, 0xbc, 0x82
-};
-static const uint8_t x86_64_build_id[BUILD_ID_LEN] = {
-       0x0f, 0x87, 0xb2, 0xe2, 0x24, 0x9c, 0xe1, 0xc2, 0x24, 0xb1,
-       0xf8, 0xb6, 0x65, 0x83, 0xa3, 0xc1, 0xcb, 0x30, 0x5c, 0x63
-};
-static const uint8_t armeb_build_id[BUILD_ID_LEN] = {
-       0x60, 0x5d, 0x26, 0xa0, 0x0e, 0x30, 0xa4, 0x29, 0xf4, 0xf1,
-       0x85, 0x53, 0xda, 0x90, 0x68, 0xe1, 0xf5, 0x67, 0xbe, 0x42
-};
-static const uint8_t aarch64_be_build_id[BUILD_ID_LEN] = {
-       0xb9, 0x0a, 0xa0, 0xed, 0xd1, 0x41, 0x42, 0xc3, 0x34, 0x85,
-       0xfa, 0x27, 0x2e, 0xa9, 0x2f, 0xd2, 0xe4, 0xf7, 0xb6, 0x60
-};
-
-static
-void test_elf(const char *test_dir, const char *arch, uint64_t exp_memsz,
-               const uint8_t *exp_build_id, uint32_t exp_crc)
-{
-       char path[PATH_MAX];
-       struct lttng_ust_elf *elf = NULL;
-       int ret = 0;
-       uint64_t memsz = 0;
-       int has_build_id = 0;
-       uint8_t *build_id = NULL;
-       size_t build_id_len = 0;
-       int has_debug_link = 0;
-       char *dbg_file = NULL;
-       uint32_t crc = 0;
-
-       diag("Testing %s support", arch);
-
-       snprintf(path, PATH_MAX, "%s/data/%s/main.elf", test_dir, arch);
-       elf = lttng_ust_elf_create(path);
-       ok(elf != NULL, "lttng_ust_elf_create");
-
-       ret = lttng_ust_elf_get_memsz(elf, &memsz);
-       ok(ret == 0, "lttng_ust_elf_get_memsz returned successfully");
-       ok(memsz == exp_memsz,
-               "memsz - expected: %lu, got: %lu",
-               exp_memsz, memsz);
-
-       ret = lttng_ust_elf_get_build_id(elf, &build_id, &build_id_len,
-                                       &has_build_id);
-       ok(ret == 0, "lttng_ust_elf_get_build_id returned successfully");
-       ok(has_build_id == 1, "build id marked as found");
-       ok(build_id_len == BUILD_ID_LEN,
-               "build_id_len - expected: %u, got: %u",
-               BUILD_ID_LEN, build_id_len);
-       ok(memcmp(build_id, exp_build_id, build_id_len) == 0,
-               "build_id has expected value");
-
-       ret = lttng_ust_elf_get_debug_link(elf, &dbg_file, &crc,
-                                       &has_debug_link);
-       ok(ret == 0, "lttng_ust_elf_get_debug_link returned successfully");
-       ok(has_debug_link == 1, "debug link marked as found");
-       ok(dbg_file && strcmp(dbg_file, DBG_FILE) == 0,
-               "debug link filename - expected: %s, got: %s",
-               DBG_FILE, dbg_file);
-       ok(crc == exp_crc,
-               "debug link crc - expected: %#x, got: %#x",
-               exp_crc, crc);
-
-       free(build_id);
-       free(dbg_file);
-       lttng_ust_elf_destroy(elf);
-}
-
-static
-void test_pic(const char *test_dir)
-{
-       char exec_path[PATH_MAX];
-       char pie_path[PATH_MAX];
-       char pic_path[PATH_MAX];
-       struct lttng_ust_elf *elf = NULL;
-       uint8_t is_pic;
-
-       snprintf(exec_path, PATH_MAX, "%s/data/pic/hello.exec", test_dir);
-       snprintf(pie_path, PATH_MAX, "%s/data/pic/hello.pie", test_dir);
-       snprintf(pic_path, PATH_MAX, "%s/data/pic/hello.pic", test_dir);
-
-       elf = lttng_ust_elf_create(exec_path);
-       is_pic = lttng_ust_elf_is_pic(elf);
-       ok(is_pic == 0, "hello.exec is not PIC");
-       lttng_ust_elf_destroy(elf);
-
-       elf = lttng_ust_elf_create(pie_path);
-       is_pic = lttng_ust_elf_is_pic(elf);
-       ok(is_pic == 1, "hello.pie is PIC");
-       lttng_ust_elf_destroy(elf);
-
-       elf = lttng_ust_elf_create(pic_path);
-       is_pic = lttng_ust_elf_is_pic(elf);
-       ok(is_pic == 1, "hello.pic is PIC");
-       lttng_ust_elf_destroy(elf);
-}
-
-int main(int argc, char **argv)
-{
-       const char *test_dir;
-
-       plan_tests(NUM_TESTS);
-
-       ok(argc == 2, "Invoke as: %s <path>", argv[0]);
-       if (argc != 2) {
-               return EXIT_FAILURE;
-       } else {
-               test_dir = argv[1];
-       }
-
-       test_elf(test_dir, "x86", X86_MEMSZ, x86_build_id, X86_CRC);
-       test_elf(test_dir, "x86_64", X86_64_MEMSZ, x86_64_build_id, X86_64_CRC);
-       test_elf(test_dir, "armeb", ARMEB_MEMSZ, armeb_build_id, ARMEB_CRC);
-       test_elf(test_dir, "aarch64_be", AARCH64_BE_MEMSZ, aarch64_be_build_id,
-               AARCH64_BE_CRC);
-       test_pic(test_dir);
-
-       return exit_status();
-}
This page took 0.090462 seconds and 5 git commands to generate.