X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=tests%2Fregression%2Fabi0-conflict%2Fapp_noust_dlopen.c;fp=tests%2Fregression%2Fabi0-conflict%2Fapp_noust_dlopen.c;h=9a52bc79da8429d0aeb5e1c4d89670278b32f001;hb=6825ea4493cbd97e428def01d1cf3b94477e4912;hp=0000000000000000000000000000000000000000;hpb=67418c3530a55e28691fdc14b4181b716a84a41a;p=lttng-ust.git diff --git a/tests/regression/abi0-conflict/app_noust_dlopen.c b/tests/regression/abi0-conflict/app_noust_dlopen.c new file mode 100644 index 00000000..9a52bc79 --- /dev/null +++ b/tests/regression/abi0-conflict/app_noust_dlopen.c @@ -0,0 +1,125 @@ +/* + * SPDX-License-Identifier: LGPL-2.1-only + * + * Copyright (C) 2021 Michael Jeanson + */ + +#include +#include +#include +#include +#include +#include + +#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 \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; +}