Add abi0 conflict tests
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 27 Apr 2021 16:14:15 +0000 (12:14 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 14 May 2021 21:03:37 +0000 (17:03 -0400)
Add tests to make sure abi0 detection works properly in different
linking and dlopen scenarios.

Change-Id: I70927298163e5961e255250f7d8d6dd849d9d135
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
18 files changed:
.gitignore
configure.ac
tests/Makefile.am
tests/regression/Makefile.am [new file with mode: 0644]
tests/regression/abi0-conflict/Makefile.am [new file with mode: 0644]
tests/regression/abi0-conflict/app_noust.c [new file with mode: 0644]
tests/regression/abi0-conflict/app_noust_dlopen.c [new file with mode: 0644]
tests/regression/abi0-conflict/app_ust.c [new file with mode: 0644]
tests/regression/abi0-conflict/app_ust_dlopen.c [new file with mode: 0644]
tests/regression/abi0-conflict/fake-ust.c [new file with mode: 0644]
tests/regression/abi0-conflict/fake-ust.h [new file with mode: 0644]
tests/regression/abi0-conflict/libone.c [new file with mode: 0644]
tests/regression/abi0-conflict/libone.h [new file with mode: 0644]
tests/regression/abi0-conflict/libzero.c [new file with mode: 0644]
tests/regression/abi0-conflict/libzero.h [new file with mode: 0644]
tests/regression/abi0-conflict/test_abi0_conflict [new file with mode: 0755]
tests/regression/abi0-conflict/tp.c [new file with mode: 0644]
tests/regression/abi0-conflict/ust_tests_hello.h [new file with mode: 0644]

index 12ec06c09df19ba79004781e8d5f2ed90911dba5..9d504cc08753a4eb85b8a5e236916f434465bdee 100644 (file)
@@ -100,6 +100,16 @@ cscope.*
 /tests/compile/api1/test-app-ctx/hello-compatapi1
 /tests/compile/api1/ust-fields/ust-fields
 /tests/compile/api1/ust-fields/ust-fields-compatapi1
+/tests/regression/abi0-conflict/app_noust
+/tests/regression/abi0-conflict/app_noust_dlopen
+/tests/regression/abi0-conflict/app_noust_indirect_abi0
+/tests/regression/abi0-conflict/app_noust_indirect_abi0_abi1
+/tests/regression/abi0-conflict/app_noust_indirect_abi1
+/tests/regression/abi0-conflict/app_ust
+/tests/regression/abi0-conflict/app_ust_dlopen
+/tests/regression/abi0-conflict/app_ust_indirect_abi0
+/tests/regression/abi0-conflict/app_ust_indirect_abi0_abi1
+/tests/regression/abi0-conflict/app_ust_indirect_abi1
 /tests/unit/gcc-weak-hidden/test_gcc_weak_hidden
 /tests/unit/libmsgpack/test_msgpack
 /tests/unit/libringbuffer/test_shm
@@ -184,6 +194,8 @@ cscope.*
 /tests/compile/api1/hello/Makefile
 /tests/compile/api1/same_line_tracepoint/Makefile
 /tests/compile/api1/test-app-ctx/Makefile
+/tests/regression/abi0-conflict/Makefile
+/tests/regression/Makefile
 /tests/unit/Makefile
 /tests/unit/gcc-weak-hidden/Makefile
 /tests/unit/libmsgpack/Makefile
index 2e2fbb93264a072ed6f254d959aab5e115231e5d..7a5775f37e541bb5c83f0bc32143322d8d9f1a52 100644 (file)
@@ -622,6 +622,8 @@ AC_CONFIG_FILES([
   tests/compile/api1/test-app-ctx/Makefile
   tests/compile/Makefile
   tests/Makefile
+  tests/regression/abi0-conflict/Makefile
+  tests/regression/Makefile
   tests/unit/gcc-weak-hidden/Makefile
   tests/unit/libmsgpack/Makefile
   tests/unit/libringbuffer/Makefile
index b2c1c2b51e4cc96105a6b59c5b598640512caee6..d750ae391ac7309034ae631fa5391100b11b0375 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: LGPL-2.1-only
 
-SUBDIRS = utils unit compile benchmark
+SUBDIRS = utils unit compile benchmark regression
 
 LOG_DRIVER_FLAGS = --merge --comments
 LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \
@@ -8,6 +8,8 @@ LOG_DRIVER = env AM_TAP_AWK='$(AWK)' \
        UST_TESTS_BUILDDIR='$(abs_top_builddir)/tests' \
        $(SHELL) $(srcdir)/utils/tap-driver.sh
 
+# Unit tests
+
 TESTS = \
        unit/libringbuffer/test_shm \
        unit/gcc-weak-hidden/test_gcc_weak_hidden \
@@ -23,6 +25,11 @@ TESTS += \
        unit/ust-utils/test_ust_utils_cxx
 endif
 
+# Regression tests
+
+TESTS += \
+       regression/abi0-conflict/test_abi0_conflict
+
 EXTRA_DIST = README
 
 check-loop:
diff --git a/tests/regression/Makefile.am b/tests/regression/Makefile.am
new file mode 100644 (file)
index 0000000..50bdbc7
--- /dev/null
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: LGPL-2.1-only
+
+SUBDIRS = \
+       abi0-conflict
diff --git a/tests/regression/abi0-conflict/Makefile.am b/tests/regression/abi0-conflict/Makefile.am
new file mode 100644 (file)
index 0000000..5b8761b
--- /dev/null
@@ -0,0 +1,83 @@
+# SPDX-License-Identifier: LGPL-2.1-only
+
+AM_CPPFLAGS += -I$(top_srcdir)/tests/utils -I$(srcdir)
+
+noinst_LTLIBRARIES = \
+       libfakeust0.la \
+       libone.la \
+       libzero.la
+
+libfakeust0_la_SOURCES = fake-ust.c fake-ust.h
+libfakeust0_la_LDFLAGS = -module -shared -avoid-version -rpath $(abs_builddir)/.libs/
+
+libzero_la_SOURCES = libzero.c libzero.h
+libzero_la_LDFLAGS = -module -shared -avoid-version -rpath $(abs_builddir)/.libs/
+libzero_la_LIBADD = libfakeust0.la
+
+libone_la_SOURCES = libone.c libone.h
+libone_la_LDFLAGS = -module -shared -avoid-version -rpath $(abs_builddir)/.libs/
+libone_la_LIBADD = $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la
+
+noinst_PROGRAMS = \
+       app_noust \
+       app_noust_dlopen \
+       app_noust_indirect_abi0 \
+       app_noust_indirect_abi0_abi1 \
+       app_noust_indirect_abi1 \
+       app_ust \
+       app_ust_dlopen \
+       app_ust_indirect_abi0 \
+       app_ust_indirect_abi0_abi1 \
+       app_ust_indirect_abi1
+
+app_ust_SOURCES = app_ust.c tp.c ust_tests_hello.h
+app_ust_LDADD = \
+       $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la \
+       $(DL_LIBS)
+
+app_ust_indirect_abi0_SOURCES = app_ust.c tp.c ust_tests_hello.h
+app_ust_indirect_abi0_CFLAGS = -DUSE_LIBZERO $(AM_CFLAGS)
+app_ust_indirect_abi0_LDADD = \
+       $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la \
+       libzero.la \
+       $(DL_LIBS)
+
+app_ust_indirect_abi1_SOURCES = app_ust.c tp.c ust_tests_hello.h
+app_ust_indirect_abi1_CFLAGS = -DUSE_LIBONE $(AM_CFLAGS)
+app_ust_indirect_abi1_LDADD = \
+       $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la \
+       libone.la \
+       $(DL_LIBS)
+
+app_ust_indirect_abi0_abi1_SOURCES = app_ust.c tp.c ust_tests_hello.h
+app_ust_indirect_abi0_abi1_CFLAGS = -DUSE_LIBZERO -DUSE_LIBONE $(AM_CFLAGS)
+app_ust_indirect_abi0_abi1_LDADD = \
+       $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la \
+       libzero.la \
+       libone.la \
+       $(DL_LIBS)
+
+app_ust_dlopen_SOURCES = app_ust_dlopen.c tp.c ust_tests_hello.h
+app_ust_dlopen_LDADD = \
+       $(top_builddir)/src/lib/lttng-ust/liblttng-ust.la \
+       $(DL_LIBS)
+
+app_noust_SOURCES = app_noust.c
+
+app_noust_indirect_abi0_SOURCES = app_noust.c
+app_noust_indirect_abi0_CFLAGS = -DUSE_LIBZERO $(AM_CFLAGS)
+app_noust_indirect_abi0_LDADD = libzero.la
+
+app_noust_indirect_abi1_SOURCES = app_noust.c
+app_noust_indirect_abi1_CFLAGS = -DUSE_LIBONE $(AM_CFLAGS)
+app_noust_indirect_abi1_LDADD = libone.la
+
+app_noust_indirect_abi0_abi1_SOURCES = app_noust.c
+app_noust_indirect_abi0_abi1_CFLAGS = -DUSE_LIBZERO -DUSE_LIBONE $(AM_CFLAGS)
+app_noust_indirect_abi0_abi1_LDADD = libzero.la libone.la
+
+app_noust_dlopen_SOURCES = app_noust_dlopen.c
+app_noust_dlopen_LDADD = \
+       $(DL_LIBS)
+
+dist_noinst_SCRIPTS = test_abi0_conflict
diff --git a/tests/regression/abi0-conflict/app_noust.c b/tests/regression/abi0-conflict/app_noust.c
new file mode 100644 (file)
index 0000000..35d1111
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#include <stdio.h>
+
+#include "./libzero.h"
+#include "./libone.h"
+
+int main(void)
+{
+       printf("This application is NOT linked on liblttng-ust.\n");
+
+#ifdef USE_LIBZERO
+       libzero();
+#endif
+#ifdef USE_LIBONE
+       libone();
+#endif
+
+       return 0;
+}
diff --git a/tests/regression/abi0-conflict/app_noust_dlopen.c b/tests/regression/abi0-conflict/app_noust_dlopen.c
new file mode 100644 (file)
index 0000000..9a52bc7
--- /dev/null
@@ -0,0 +1,125 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#include <dlfcn.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+
+#define LTTNG_UST_LIB_ABI0_SO_NAME "libfakeust0.so"
+#define LTTNG_UST_LIB_ABI1_SO_NAME "liblttng-ust.so.1"
+
+static
+int dlopen_ust(const char *lib_soname)
+{
+       int ret = EXIT_SUCCESS;
+       void *handle;
+
+       handle = dlopen(lib_soname, RTLD_NOW | RTLD_GLOBAL);
+       if (!handle) {
+               printf("Error: dlopen of liblttng-ust shared library (%s).\n", lib_soname);
+               ret = EXIT_FAILURE;
+       } else {
+               printf("Success: dlopen of liblttng-ust shared library (%s).\n", lib_soname);
+       }
+
+       return ret;
+}
+
+static
+int dlopen_abi0(void)
+{
+       return dlopen_ust(LTTNG_UST_LIB_ABI0_SO_NAME);
+}
+
+static
+int dlopen_abi1(void)
+{
+       return dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME);
+}
+
+static
+int dlopen_abi0_abi1(void)
+{
+       int ret = EXIT_SUCCESS;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI0_SO_NAME);
+       if (ret != EXIT_SUCCESS)
+               return ret;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME);
+
+       return ret;
+}
+
+static
+int dlopen_abi1_abi0(void)
+{
+       int ret = EXIT_SUCCESS;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME);
+       if (ret != EXIT_SUCCESS)
+               return ret;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI0_SO_NAME);
+
+       return ret;
+}
+
+static
+int dlopen_abi1_abi1(void)
+{
+       int ret = EXIT_SUCCESS;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME);
+       if (ret != EXIT_SUCCESS)
+               return ret;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME);
+
+       return ret;
+}
+
+static
+void usage(char **argv)
+{
+       printf("Usage: %s <test_type>\n", argv[0]);
+       printf("  test_type: abi0, abi1, abi0_abi1, abi1_abi0, abi1_abi1\n");
+}
+
+int main(int argc, char **argv)
+{
+       int ret = EXIT_SUCCESS;
+       const char *test_type;
+
+       if (argc != 2) {
+               usage(argv);
+               return EXIT_FAILURE;
+       } else {
+               test_type = argv[1];
+       }
+
+       printf("This application is NOT linked on liblttng-ust.\n");
+
+       if (strcmp(test_type, "abi0") == 0)
+               ret = dlopen_abi0();
+       else if (strcmp(test_type, "abi1") == 0)
+               ret = dlopen_abi1();
+       else if (strcmp(test_type, "abi0_abi1") == 0)
+               ret = dlopen_abi0_abi1();
+       else if (strcmp(test_type, "abi1_abi0") == 0)
+               ret = dlopen_abi1_abi0();
+       else if (strcmp(test_type, "abi1_abi1") == 0)
+               ret = dlopen_abi1_abi1();
+       else {
+               usage(argv);
+               ret = EXIT_FAILURE;
+       }
+
+       return ret;
+}
diff --git a/tests/regression/abi0-conflict/app_ust.c b/tests/regression/abi0-conflict/app_ust.c
new file mode 100644 (file)
index 0000000..d9c17b6
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <arpa/inet.h>
+
+#include "./libzero.h"
+#include "./libone.h"
+
+#define LTTNG_UST_TRACEPOINT_DEFINE
+#include "ust_tests_hello.h"
+
+int main(void)
+{
+       int i, netint;
+       long values[] = { 1, 2, 3 };
+       char text[10] = "test";
+       double dbl = 2.0;
+       float flt = 2222.0;
+       bool mybool = 123;      /* should print "1" */
+
+       printf("This application is linked on liblttng-ust.\n");
+
+#ifdef USE_LIBZERO
+       libzero();
+#endif
+#ifdef USE_LIBONE
+       libone();
+#endif
+
+       for (i = 0; i < 10; i++) {
+               netint = htonl(i);
+               lttng_ust_tracepoint(ust_tests_hello, tptest, i, netint, values,
+                          text, strlen(text), dbl, flt, mybool);
+       }
+
+       return 0;
+}
diff --git a/tests/regression/abi0-conflict/app_ust_dlopen.c b/tests/regression/abi0-conflict/app_ust_dlopen.c
new file mode 100644 (file)
index 0000000..ad9d1b2
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#include <dlfcn.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <arpa/inet.h>
+
+#define LTTNG_UST_TRACEPOINT_DEFINE
+#include "ust_tests_hello.h"
+
+#define LTTNG_UST_LIB_ABI0_SO_NAME "libfakeust0.so"
+#define LTTNG_UST_LIB_ABI1_SO_NAME "liblttng-ust.so.1"
+
+static
+int dlopen_ust(const char *lib_soname)
+{
+       int ret = EXIT_SUCCESS;
+       void *handle;
+
+       handle = dlopen(lib_soname, RTLD_NOW | RTLD_GLOBAL);
+       if (!handle) {
+               printf("Error: dlopen of liblttng-ust shared library (%s).\n", lib_soname);
+               ret = EXIT_FAILURE;
+       } else {
+               printf("Success: dlopen of liblttng-ust shared library (%s).\n", lib_soname);
+       }
+
+       return ret;
+}
+
+static
+int dlopen_abi0(void)
+{
+       return dlopen_ust(LTTNG_UST_LIB_ABI0_SO_NAME);
+}
+
+static
+int dlopen_abi1(void)
+{
+       return dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME);
+}
+
+static
+int dlopen_abi0_abi1(void)
+{
+       int ret = EXIT_SUCCESS;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI0_SO_NAME);
+       if (ret != EXIT_SUCCESS)
+               return ret;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME);
+
+       return ret;
+}
+
+static
+int dlopen_abi1_abi0(void)
+{
+       int ret = EXIT_SUCCESS;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME);
+       if (ret != EXIT_SUCCESS)
+               return ret;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI0_SO_NAME);
+
+       return ret;
+}
+
+static
+int dlopen_abi1_abi1(void)
+{
+       int ret = EXIT_SUCCESS;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME);
+       if (ret != EXIT_SUCCESS)
+               return ret;
+
+       ret = dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME);
+
+       return ret;
+}
+
+static
+void usage(char **argv)
+{
+       printf("Usage: %s <test_type>\n", argv[0]);
+       printf("  test_type: abi0, abi1, abi0_abi1, abi1_abi0, abi1_abi1\n");
+}
+
+int main(int argc, char **argv)
+{
+       int ret = EXIT_SUCCESS;
+       const char *test_type;
+
+       int i, netint;
+       long values[] = { 1, 2, 3 };
+       char text[10] = "test";
+       double dbl = 2.0;
+       float flt = 2222.0;
+       bool mybool = 123;      /* should print "1" */
+
+
+       if (argc != 2) {
+               usage(argv);
+               return EXIT_FAILURE;
+       } else {
+               test_type = argv[1];
+       }
+
+       printf("This application is linked on liblttng-ust.\n");
+
+       if (strcmp(test_type, "abi0") == 0)
+               ret = dlopen_abi0();
+       else if (strcmp(test_type, "abi1") == 0)
+               ret = dlopen_abi1();
+       else if (strcmp(test_type, "abi0_abi1") == 0)
+               ret = dlopen_abi0_abi1();
+       else if (strcmp(test_type, "abi1_abi0") == 0)
+               ret = dlopen_abi1_abi0();
+       else if (strcmp(test_type, "abi1_abi1") == 0)
+               ret = dlopen_abi1_abi1();
+       else {
+               usage(argv);
+               ret = EXIT_FAILURE;
+       }
+
+       for (i = 0; i < 10; i++) {
+               netint = htonl(i);
+               lttng_ust_tracepoint(ust_tests_hello, tptest, i, netint, values,
+                          text, strlen(text), dbl, flt, mybool);
+       }
+
+       return ret;
+}
diff --git a/tests/regression/abi0-conflict/fake-ust.c b/tests/regression/abi0-conflict/fake-ust.c
new file mode 100644 (file)
index 0000000..f47cdc2
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+
+#include "./fake-ust.h"
+
+void init_usterr(void)
+{
+       fprintf(stderr, "libfakeust0: init_usterr() called.\n");
+}
+
+/*
+ * The symbol used by liblttng-ust.so.1 to detect liblttng-ust.so.0 in a
+ * process.
+ */
+int ltt_probe_register(struct lttng_probe_desc *desc __attribute__((unused)))
+{
+       fprintf(stderr, "libfakeust0: ltt_probe_register() called.\n");
+       return 0;
+}
+
+/*
+ * This constructor calls the 'init_usterr' canary function which is provided
+ * by liblttng-ust.so.1.
+ */
+static
+void fake_ust_ctor(void)
+       __attribute__((constructor));
+static void fake_ust_ctor(void)
+{
+       init_usterr();
+}
diff --git a/tests/regression/abi0-conflict/fake-ust.h b/tests/regression/abi0-conflict/fake-ust.h
new file mode 100644 (file)
index 0000000..f784806
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#define LTTNG_UST_PROBE_DESC_PADDING    12
+struct lttng_probe_desc {
+        char padding[LTTNG_UST_PROBE_DESC_PADDING];
+};
+
+void init_usterr(void);
+
+/*
+ * The symbol used by liblttng-ust.so.1 to detect liblttng-ust.so.0 in a
+ * process.
+ */
+int ltt_probe_register(struct lttng_probe_desc *desc);
diff --git a/tests/regression/abi0-conflict/libone.c b/tests/regression/abi0-conflict/libone.c
new file mode 100644 (file)
index 0000000..089b7e8
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#include <stdio.h>
+#include <lttng/ust-fork.h>
+
+#include "./libone.h"
+
+/*
+ * Dummy function to ensure we are properly linked on liblttng-ust.so.1.
+ */
+void libone_dummy(void)
+{
+       lttng_ust_after_setns();
+}
+
+void libone(void)
+{
+       printf("libone: this is libone()\n");
+}
diff --git a/tests/regression/abi0-conflict/libone.h b/tests/regression/abi0-conflict/libone.h
new file mode 100644 (file)
index 0000000..120623f
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+void libone_dummy(void);
+void libone(void);
diff --git a/tests/regression/abi0-conflict/libzero.c b/tests/regression/abi0-conflict/libzero.c
new file mode 100644 (file)
index 0000000..83f648c
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+#include <stdio.h>
+
+#include "./libzero.h"
+#include "./fake-ust.h"
+
+/*
+ * Dummy function to ensure we are properly linked on libfakeust0.
+ */
+int libzero_dummy(void)
+{
+       struct lttng_probe_desc probe_desc;
+
+       return ltt_probe_register(&probe_desc);
+}
+
+void libzero(void)
+{
+       printf("libzero: this is libzero()\n");
+}
diff --git a/tests/regression/abi0-conflict/libzero.h b/tests/regression/abi0-conflict/libzero.h
new file mode 100644 (file)
index 0000000..ad9f367
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
+ */
+
+int libzero_dummy(void);
+void libzero(void);
diff --git a/tests/regression/abi0-conflict/test_abi0_conflict b/tests/regression/abi0-conflict/test_abi0_conflict
new file mode 100755 (executable)
index 0000000..e79e377
--- /dev/null
@@ -0,0 +1,129 @@
+#!/bin/bash
+# SPDX-License-Identifier: LGPL-2.1-only
+
+if [ "x${UST_TESTS_SRCDIR:-}" != "x" ]; then
+       UTILSSH="$UST_TESTS_SRCDIR/utils/utils.sh"
+else
+       UTILSSH="$(dirname "$0")/../../utils/utils.sh"
+fi
+
+# shellcheck source=../../utils/utils.sh
+source "$UTILSSH"
+
+# shellcheck source=../../utils/tap.sh
+source "$UST_TESTS_SRCDIR/utils/tap.sh"
+
+CURDIR="${UST_TESTS_BUILDDIR}/regression/abi0-conflict"
+
+LIBFAKEUST0_PATH="${CURDIR}/.libs"
+LIBFAKEUST0="${LIBFAKEUST0_PATH}/libfakeust0.so"
+
+LIBUST1_PATH="${UST_TESTS_BUILDDIR}/../src/lib/lttng-ust/.libs/"
+LIBUST1="${LIBUST1_PATH}/liblttng-ust.so.1"
+
+STD_OUTPUT="/dev/null"
+STD_ERROR="/dev/null"
+
+# Force abort on CRIT() to detect ABI conflicts
+export LTTNG_UST_ABORT_ON_CRITICAL=1
+
+plan_tests 22
+
+###
+##  LD_PRELOAD tests
+###
+
+diag "LD_PRELOAD"
+
+## App NOT linked on liblttn-ust
+
+"${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
+ok $? "LD_PRELOAD: no-ust app works"
+
+LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
+ok $? "LD_PRELOAD: no-ust app with abi0 preload succeeds"
+
+LD_PRELOAD="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "LD_PRELOAD: no-ust app with abi0 and abi1 preload fails"
+
+LD_PRELOAD="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_noust" >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "LD_PRELOAD: no-ust app with abi1 and abi0 preload fails"
+
+
+## App linked on liblttn-ust.so.1
+
+"${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
+ok $? "LD_PRELOAD: ust app works"
+
+LD_PRELOAD="${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "LD_PRELOAD: ust app with abi0 preload fails"
+
+LD_PRELOAD="${LIBFAKEUST0}:${LIBUST1}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "LD_PRELOAD: ust app with abi0 and abi1 preload fails"
+
+LD_PRELOAD="${LIBUST1}:${LIBFAKEUST0}" "${CURDIR}/app_ust" >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "LD_PRELOAD: ust app with abi1 and abi0 preload fails"
+
+
+###
+## dlopen tests
+###
+
+diag "dlopen"
+
+## App NOT linked on liblttn-ust
+
+LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
+ok $? "dlopen: no-ust app works"
+
+LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
+ok $? "dlopen: no-ust app with abi1 and abi1 succeeds"
+
+LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi0_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "dlopen: no-ust app with abi0 and abi1 fails"
+
+LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_noust_dlopen" abi1_abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "dlopen: no-ust app with abi1 and abi0 fails"
+
+## App linked on liblttn-ust.so.1
+
+LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
+ok $? "dlopen: ust app works"
+
+LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "dlopen: ust app with abi0 fails"
+
+LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi0_abi1 >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "dlopen: ust app with abi0 and abi1 fails"
+
+LD_LIBRARY_PATH="$LIBFAKEUST0_PATH:$LIBUST1_PATH" "${CURDIR}/app_ust_dlopen" abi1_abi0 >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "dlopen: ust app with abi1 and abi0 fails"
+
+
+###
+##  Indirect linking
+###
+
+diag "Indirect linking"
+
+## App NOT linked on liblttn-ust
+
+"${CURDIR}/app_noust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
+ok $? "indirect: no-ust app with abi0 succeeds"
+
+"${CURDIR}/app_noust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
+ok $? "indirect: no-ust app with abi1 succeeds"
+
+"${CURDIR}/app_noust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "indirect: no-ust app with abi0 and abi1 fails"
+
+## App linked on liblttn-ust
+
+"${CURDIR}/app_ust_indirect_abi0" >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "indirect: ust app with abi0 fails"
+
+"${CURDIR}/app_ust_indirect_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
+ok $? "indirect: ust app with abi1 succeeds"
+
+"${CURDIR}/app_ust_indirect_abi0_abi1" >"$STD_OUTPUT" 2>"$STD_ERROR"
+isnt $? 0 "indirect: ust app with abi0 and abi1 fails"
diff --git a/tests/regression/abi0-conflict/tp.c b/tests/regression/abi0-conflict/tp.c
new file mode 100644 (file)
index 0000000..98669b6
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#define LTTNG_UST_TRACEPOINT_CREATE_PROBES
+#include "ust_tests_hello.h"
diff --git a/tests/regression/abi0-conflict/ust_tests_hello.h b/tests/regression/abi0-conflict/ust_tests_hello.h
new file mode 100644 (file)
index 0000000..639c7c9
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#undef LTTNG_UST_TRACEPOINT_PROVIDER
+#define LTTNG_UST_TRACEPOINT_PROVIDER ust_tests_hello
+
+#if !defined(_TRACEPOINT_UST_TESTS_HELLO_H) || defined(LTTNG_UST_TRACEPOINT_HEADER_MULTI_READ)
+#define _TRACEPOINT_UST_TESTS_HELLO_H
+
+#include <lttng/tracepoint.h>
+#include <stdbool.h>
+#include <stddef.h>
+
+LTTNG_UST_TRACEPOINT_EVENT(ust_tests_hello, tptest,
+       LTTNG_UST_TP_ARGS(int, anint, int, netint, long *, values,
+               char *, text, size_t, textlen,
+               double, doublearg, float, floatarg,
+               bool, boolarg),
+       LTTNG_UST_TP_FIELDS(
+               lttng_ust_field_integer(int, intfield, anint)
+               lttng_ust_field_integer_hex(int, intfield2, anint)
+               lttng_ust_field_integer(long, longfield, anint)
+               lttng_ust_field_integer_network(int, netintfield, netint)
+               lttng_ust_field_integer_network_hex(int, netintfieldhex, netint)
+               lttng_ust_field_array_nowrite(long, arrfield1z, values, 3)
+               lttng_ust_field_array(long, blah, values, 3)
+               lttng_ust_field_array(long, arrfield1, values, 3)
+               lttng_ust_field_array_hex(long, arrfield1_hex, values, 3)
+               lttng_ust_field_array_network(long, arrfield1_network, values, 3)
+               lttng_ust_field_array_network_hex(long, arrfield1_network_hex, values, 3)
+               lttng_ust_field_array_text(char, arrfield2, text, 10)
+               lttng_ust_field_sequence(char, seqfield1, text,
+                            size_t, textlen)
+               lttng_ust_field_sequence_nowrite(char, seqfield1z, text,
+                            size_t, textlen)
+               lttng_ust_field_sequence_hex(char, seqfield1_hex, text,
+                            size_t, textlen)
+               lttng_ust_field_sequence_text(char, seqfield2, text,
+                            size_t, textlen)
+               lttng_ust_field_sequence_network(long, seqfield_network_3, values,
+                            size_t, 3)
+               lttng_ust_field_string(stringfield, text)
+               lttng_ust_field_float(float, floatfield, floatarg)
+               lttng_ust_field_float(double, doublefield, doublearg)
+               lttng_ust_field_integer(bool, boolfield, boolarg)
+               lttng_ust_field_integer_nowrite(int, filterfield, anint)
+       )
+)
+
+LTTNG_UST_TRACEPOINT_EVENT(ust_tests_hello, tptest_sighandler,
+       LTTNG_UST_TP_ARGS(),
+       LTTNG_UST_TP_FIELDS()
+)
+
+#endif /* _TRACEPOINT_UST_TESTS_HELLO_H */
+
+#undef LTTNG_UST_TRACEPOINT_INCLUDE
+#define LTTNG_UST_TRACEPOINT_INCLUDE "./ust_tests_hello.h"
+
+/* This part must be outside ifdef protection */
+#include <lttng/tracepoint-event.h>
This page took 0.036141 seconds and 4 git commands to generate.