2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2021 Michael Jeanson <mjeanson@efficios.com>
13 #include <arpa/inet.h>
15 #define LTTNG_UST_TRACEPOINT_DEFINE
16 #include "ust_tests_hello.h"
18 #define LTTNG_UST_LIB_ABI0_SO_NAME "libfakeust0.so"
19 #define LTTNG_UST_LIB_ABI1_SO_NAME "liblttng-ust.so.1"
26 static struct lib_desc lib_desc
[] = {
28 .soname
= LTTNG_UST_LIB_ABI0_SO_NAME
,
31 .soname
= LTTNG_UST_LIB_ABI1_SO_NAME
,
34 .soname
= LTTNG_UST_LIB_ABI1_SO_NAME
,
39 int dlopen_ust(struct lib_desc
*desc
)
41 int ret
= EXIT_SUCCESS
;
43 desc
->handle
= dlopen(desc
->soname
, RTLD_NOW
| RTLD_GLOBAL
);
45 printf("Error: dlopen of liblttng-ust shared library (%s).\n", desc
->soname
);
48 printf("Success: dlopen of liblttng-ust shared library (%s).\n", desc
->soname
);
57 return dlopen_ust(&lib_desc
[0]);
63 return dlopen_ust(&lib_desc
[1]);
67 int dlopen_abi0_abi1(void)
69 int ret
= EXIT_SUCCESS
;
71 ret
= dlopen_ust(&lib_desc
[0]);
72 if (ret
!= EXIT_SUCCESS
)
75 ret
= dlopen_ust(&lib_desc
[1]);
81 int dlopen_abi1_abi0(void)
83 int ret
= EXIT_SUCCESS
;
85 ret
= dlopen_ust(&lib_desc
[1]);
86 if (ret
!= EXIT_SUCCESS
)
89 ret
= dlopen_ust(&lib_desc
[0]);
95 int dlopen_abi1_abi1(void)
97 int ret
= EXIT_SUCCESS
;
99 ret
= dlopen_ust(&lib_desc
[1]);
100 if (ret
!= EXIT_SUCCESS
)
103 ret
= dlopen_ust(&lib_desc
[2]);
109 void usage(char **argv
)
111 printf("Usage: %s <test_type>\n", argv
[0]);
112 printf(" test_type: abi0, abi1, abi0_abi1, abi1_abi0, abi1_abi1\n");
115 int main(int argc
, char **argv
)
117 int ret
= EXIT_SUCCESS
;
118 const char *test_type
;
120 long values
[] = { 1, 2, 3 };
121 char text
[10] = "test";
124 bool mybool
= 123; /* should print "1" */
133 printf("This application is linked on liblttng-ust.\n");
135 if (strcmp(test_type
, "abi0") == 0)
137 else if (strcmp(test_type
, "abi1") == 0)
139 else if (strcmp(test_type
, "abi0_abi1") == 0)
140 ret
= dlopen_abi0_abi1();
141 else if (strcmp(test_type
, "abi1_abi0") == 0)
142 ret
= dlopen_abi1_abi0();
143 else if (strcmp(test_type
, "abi1_abi1") == 0)
144 ret
= dlopen_abi1_abi1();
150 for (i
= 0; i
< 10; i
++) {
152 lttng_ust_tracepoint(ust_tests_hello
, tptest
, i
, netint
, values
,
153 text
, strlen(text
), dbl
, flt
, mybool
);