diff options
author | Sergei Golubchik <serg@mariadb.org> | 2020-04-21 18:07:11 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2020-04-27 09:22:36 +0200 |
commit | c2db9397c792a774748f22ddb33b994aae547770 (patch) | |
tree | 11f79b758399bcdca6cd8081d53d555be37b8d50 /mysql-test/lib | |
parent | 81511b477676da29bcee7ca7f497b73af8a8f1d5 (diff) | |
download | mariadb-git-c2db9397c792a774748f22ddb33b994aae547770.tar.gz |
MDEV-18565 Galera mtr-suite fails if galera library is not installed
revert/simplify f5390eea9a9
remove galera-specific checks from mtr and the main suite
Diffstat (limited to 'mysql-test/lib')
-rw-r--r-- | mysql-test/lib/My/SafeProcess.pm | 6 | ||||
-rw-r--r-- | mysql-test/lib/My/SafeProcess/CMakeLists.txt | 2 | ||||
-rw-r--r-- | mysql-test/lib/My/SafeProcess/wsrep_check_version.c | 141 |
3 files changed, 31 insertions, 118 deletions
diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm index 87054019759..19f2893ea51 100644 --- a/mysql-test/lib/My/SafeProcess.pm +++ b/mysql-test/lib/My/SafeProcess.pm @@ -100,8 +100,6 @@ else $bindir = getcwd(); } -our $wsrep_check_version; - # Find the safe process binary or script sub find_bin { if (IS_WIN32PERL or IS_CYGWIN) @@ -121,10 +119,6 @@ sub find_bin { "my_safe_process"); push(@safe_process_cmd, $exe); } - # Wsrep version check utility: - $wsrep_check_version= - my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"], - "wsrep_check_version", NOT_REQUIRED); } diff --git a/mysql-test/lib/My/SafeProcess/CMakeLists.txt b/mysql-test/lib/My/SafeProcess/CMakeLists.txt index 4c3b62fa67e..44c0e6eb8cb 100644 --- a/mysql-test/lib/My/SafeProcess/CMakeLists.txt +++ b/mysql-test/lib/My/SafeProcess/CMakeLists.txt @@ -14,6 +14,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) + IF (WIN32) ADD_EXECUTABLE(my_safe_process safe_process_win.cc) ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc) diff --git a/mysql-test/lib/My/SafeProcess/wsrep_check_version.c b/mysql-test/lib/My/SafeProcess/wsrep_check_version.c index 91098be882a..7398bc8ad92 100644 --- a/mysql-test/lib/My/SafeProcess/wsrep_check_version.c +++ b/mysql-test/lib/My/SafeProcess/wsrep_check_version.c @@ -13,122 +13,39 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA */ -#include <stdlib.h> -#include <stdio.h> +#include <my_global.h> #include <string.h> -#include <errno.h> - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#ifdef _WIN32 -#include <windows.h> -#define dlsym(lib, name) GetProcAddress((HMODULE)lib, name) -#define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0) -#define dlclose(lib) FreeLibrary((HMODULE)lib) -#elif defined(HAVE_DLFCN_H) -#include <dlfcn.h> -#else -#define NO_DLL -#endif - -#ifndef NO_DLL - #include "../../../../wsrep-lib/wsrep-API/v26/wsrep_api.h" -/************************************************************************** - * Library loader - **************************************************************************/ - -static int wsrep_check_iface_version(const char *found, const char *iface_ver) -{ - if (strcmp(found, iface_ver)) { - return ERANGE; - } - return 0; -} - -typedef int (*wsrep_loader_fun)(wsrep_t*); - -static wsrep_loader_fun wsrep_dlf(void *dlh, const char *sym) -{ - union { - wsrep_loader_fun dlfun; - void *obj; - } alias; - alias.obj = dlsym(dlh, sym); - return alias.dlfun; -} - -static int wsrep_check_version_symbol(void *dlh) -{ - char** dlversion = NULL; - dlversion = (char**) dlsym(dlh, "wsrep_interface_version"); - if (dlversion == NULL) - return EINVAL; - return wsrep_check_iface_version(*dlversion, WSREP_INTERFACE_VERSION); -} - -static int wsrep_print_version(void *dlh) -{ - char** dlversion = NULL; - dlversion = (char**) dlsym(dlh, "wsrep_interface_version"); - if (dlversion == NULL) - return EINVAL; - printf("found: %s, need: %s\n", *dlversion, WSREP_INTERFACE_VERSION); - return 0; -} - int main(int argc, char **argv) { - int rc = EINVAL; - void *dlh; - wsrep_loader_fun dlfun; - const char *provider= getenv("WSREP_PROVIDER"); - - if (!provider) - { - fprintf(stderr, "WSREP_PROVIDER is not set\n"); - return 1; - } - if (!(dlh = dlopen(provider, RTLD_NOW | RTLD_LOCAL))) - { - fprintf(stderr, "Can't open WSREP_PROVIDER (%s) library, error: %s\n", - provider, dlerror()); - goto err; - } - - if (!(dlfun = wsrep_dlf(dlh, "wsrep_loader"))) - { - fprintf(stderr, "Can't find 'wsrep_loader' symbol in %s\n", - provider); - goto err; - } - - if (argc < 2 || strcmp(argv[1], "-p")) { - rc = wsrep_check_version_symbol(dlh); - } - else { - rc = wsrep_print_version(dlh); - } - -err: - if (dlh) dlclose(dlh); - - if (rc == 0) - return 0; - else if (rc == ERANGE) - return 2; - else - return 1; -} - -#else - -int main(void) -{ + int rc= 1; + void *dlh; + const char *provider= getenv("WSREP_PROVIDER"); + char** dlversion= NULL; + + if (!provider || !*provider) + { + printf("WSREP_PROVIDER is not set\n"); + return 1; + } + if (!(dlh= dlopen(provider, RTLD_NOW | RTLD_LOCAL))) + { + printf("Can't open WSREP_PROVIDER (%s) library, error: %s\n", + provider, dlerror()); return 1; + } + + dlversion= (char**) dlsym(dlh, "wsrep_interface_version"); + if (dlversion && *dlversion) + { + rc= strcmp(*dlversion, WSREP_INTERFACE_VERSION) ? 2 : 0; + if (rc) + printf("Wrong wsrep provider library version, found: %s, need: %s\n", *dlversion, WSREP_INTERFACE_VERSION); + } + else + printf("Galera library does not contain a version symbol"); + + dlclose(dlh); + return rc; } - -#endif |