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"
22 int dlopen_ust(const char *lib_soname
)
24 int ret
= EXIT_SUCCESS
;
27 handle
= dlopen(lib_soname
, RTLD_NOW
| RTLD_GLOBAL
);
29 printf("Error: dlopen of liblttng-ust shared library (%s).\n", lib_soname
);
32 printf("Success: dlopen of liblttng-ust shared library (%s).\n", lib_soname
);
41 return dlopen_ust(LTTNG_UST_LIB_ABI0_SO_NAME
);
47 return dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME
);
51 int dlopen_abi0_abi1(void)
53 int ret
= EXIT_SUCCESS
;
55 ret
= dlopen_ust(LTTNG_UST_LIB_ABI0_SO_NAME
);
56 if (ret
!= EXIT_SUCCESS
)
59 ret
= dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME
);
65 int dlopen_abi1_abi0(void)
67 int ret
= EXIT_SUCCESS
;
69 ret
= dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME
);
70 if (ret
!= EXIT_SUCCESS
)
73 ret
= dlopen_ust(LTTNG_UST_LIB_ABI0_SO_NAME
);
79 int dlopen_abi1_abi1(void)
81 int ret
= EXIT_SUCCESS
;
83 ret
= dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME
);
84 if (ret
!= EXIT_SUCCESS
)
87 ret
= dlopen_ust(LTTNG_UST_LIB_ABI1_SO_NAME
);
93 void usage(char **argv
)
95 printf("Usage: %s <test_type>\n", argv
[0]);
96 printf(" test_type: abi0, abi1, abi0_abi1, abi1_abi0, abi1_abi1\n");
99 int main(int argc
, char **argv
)
101 int ret
= EXIT_SUCCESS
;
102 const char *test_type
;
105 long values
[] = { 1, 2, 3 };
106 char text
[10] = "test";
109 bool mybool
= 123; /* should print "1" */
119 printf("This application is linked on liblttng-ust.\n");
121 if (strcmp(test_type
, "abi0") == 0)
123 else if (strcmp(test_type
, "abi1") == 0)
125 else if (strcmp(test_type
, "abi0_abi1") == 0)
126 ret
= dlopen_abi0_abi1();
127 else if (strcmp(test_type
, "abi1_abi0") == 0)
128 ret
= dlopen_abi1_abi0();
129 else if (strcmp(test_type
, "abi1_abi1") == 0)
130 ret
= dlopen_abi1_abi1();
136 for (i
= 0; i
< 10; i
++) {
138 lttng_ust_tracepoint(ust_tests_hello
, tptest
, i
, netint
, values
,
139 text
, strlen(text
), dbl
, flt
, mybool
);