MXS-2900 Move test description array to a .cc-file
The array is now compiled into the maxtest-library. Also cleaned up the array handling a bit.
This commit is contained in:
parent
89a8d6ace5
commit
36244e9c7b
@ -13,6 +13,7 @@
|
||||
# BREAKS_REPL
|
||||
# BREAKS_GALERA
|
||||
set(CTEST_BUILD_NAME "${BUILDNAME}")
|
||||
set(CNF_TEMPLATES "" CACHE INTERNAL "")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "-std=c++11 -ggdb -Wall -Wextra -Werror -Wno-format-overflow -Wno-unused-function -Wno-unused-parameter -Werror=format-security")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -ggdb -Wall -Werror -Wno-format-overflow -Wno-unused-function")
|
||||
@ -29,9 +30,6 @@ include_directories(${CMAKE_SOURCE_DIR}/connectors/cdc-connector)
|
||||
include_directories(${CMAKE_BINARY_DIR})
|
||||
# Include the CDC connector headers
|
||||
include_directories(${CMAKE_SOURCE_DIR}/../connectors/cdc-connector/)
|
||||
|
||||
# The core testing library
|
||||
add_subdirectory(maxtest)
|
||||
include_directories(maxtest/include/maxtest)
|
||||
|
||||
# Tool used to check backend state
|
||||
@ -1158,4 +1156,6 @@ set_tests_properties(bug471_big PROPERTIES TIMEOUT 3600)
|
||||
# DO NOT ADD TESTS AFTER THIS #
|
||||
###############################
|
||||
|
||||
configure_file(templates.h.in ${CMAKE_CURRENT_BINARY_DIR}/templates.h @ONLY)
|
||||
# The core testing library
|
||||
configure_file(maxtest/src/test_info.cc.in maxtest/src/test_info.cc @ONLY)
|
||||
add_subdirectory(maxtest)
|
||||
|
4
maxscale-system-test/maxtest/include/maxtest/test_dir.hh
Normal file
4
maxscale-system-test/maxtest/include/maxtest/test_dir.hh
Normal file
@ -0,0 +1,4 @@
|
||||
#pragma once
|
||||
/** This is the working directory for all tests */
|
||||
extern const char* test_dir;
|
||||
|
14
maxscale-system-test/maxtest/include/maxtest/test_info.hh
Normal file
14
maxscale-system-test/maxtest/include/maxtest/test_info.hh
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#include "test_dir.hh"
|
||||
|
||||
struct TestDefinition
|
||||
{
|
||||
const char* name;
|
||||
const char* config_template;
|
||||
const char* labels;
|
||||
};
|
||||
|
||||
extern const TestDefinition* test_definitions;
|
||||
|
||||
/** The default template to use */
|
||||
extern const char* default_template;
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "mariadb_nodes.h"
|
||||
#include "maxscales.h"
|
||||
#include "templates.h"
|
||||
#include "test_dir.hh"
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/time.h>
|
||||
@ -736,7 +736,7 @@ std::string dump_status(const StringSet& current, const StringSet& expected);
|
||||
* @param labels pointer to string for storing all test labels
|
||||
* @return Name of maxscale.cnf file template
|
||||
*/
|
||||
const char *get_template_name(char * test_name, const char **labels);
|
||||
const char* get_template_name(char* test_name, const char**labels);
|
||||
|
||||
/**
|
||||
* @brief readenv_and_set_default Read enviromental variable and set default values if
|
||||
|
@ -23,6 +23,7 @@ add_library(maxtest SHARED
|
||||
tcp_connection.cpp
|
||||
test_binlog_fnc.cpp
|
||||
testconnections.cpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/test_info.cc
|
||||
# Include the CDC connector in the core library
|
||||
${CMAKE_SOURCE_DIR}/connectors/cdc-connector/cdc_connector.cpp)
|
||||
target_link_libraries(maxtest ${MARIADB_CONNECTOR_LIBRARIES} ${JANSSON_LIBRARIES} z m pthread ssl dl rt crypto crypt maxbase)
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
|
||||
#include "mariadb_func.h"
|
||||
#include "templates.h"
|
||||
#include "test_dir.hh"
|
||||
#include <ctype.h>
|
||||
#include <sstream>
|
||||
|
||||
|
11
maxscale-system-test/maxtest/src/test_info.cc.in
Normal file
11
maxscale-system-test/maxtest/src/test_info.cc.in
Normal file
@ -0,0 +1,11 @@
|
||||
#include "test_info.hh"
|
||||
|
||||
const TestDefinition test_definitions_arr[] =
|
||||
{
|
||||
@CNF_TEMPLATES@{nullptr, nullptr, nullptr}
|
||||
};
|
||||
|
||||
const TestDefinition* test_definitions = test_definitions_arr;
|
||||
const char* default_template = "replication";
|
||||
const char* test_dir = "@CMAKE_CURRENT_SOURCE_DIR@";
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "maxadmin_operations.h"
|
||||
#include "sql_t1.h"
|
||||
#include "testconnections.h"
|
||||
#include "test_info.hh"
|
||||
#include "labels_table.h"
|
||||
#include "envv.h"
|
||||
|
||||
@ -266,7 +267,7 @@ TestConnections::TestConnections(int argc, char* argv[])
|
||||
test_name = basename(argv[0]);
|
||||
}
|
||||
|
||||
const char * labels_string = NULL;
|
||||
const char* labels_string = "";
|
||||
template_name = get_template_name(test_name, &labels_string);
|
||||
tprintf("testname: '%s', template: '%s'", test_name, template_name);
|
||||
labels = strstr(labels_string, "LABELS;");
|
||||
@ -699,25 +700,31 @@ void TestConnections::print_env()
|
||||
}
|
||||
}
|
||||
|
||||
const char * get_template_name(char * test_name, const char ** labels)
|
||||
const char* get_template_name(char* test_name, const char** labels)
|
||||
{
|
||||
int i = 0;
|
||||
*labels = NULL;
|
||||
while (cnf_templates[i].test_name && strcmp(cnf_templates[i].test_name, test_name) != 0)
|
||||
const TestDefinition* found = nullptr;
|
||||
for (int i = 0; test_definitions[i].name; i++)
|
||||
{
|
||||
i++;
|
||||
auto* test = &test_definitions[i];
|
||||
if (strcmp(test->name, test_name) == 0)
|
||||
{
|
||||
found = test;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (cnf_templates[i].test_name)
|
||||
if (found)
|
||||
{
|
||||
*labels = (char *) cnf_templates[i].test_labels;
|
||||
return cnf_templates[i].test_template;
|
||||
*labels = found->labels;
|
||||
return found->config_template;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Failed to find configuration template for test '%s', using default template '%s'.\n",
|
||||
test_name, default_template);
|
||||
return default_template;
|
||||
}
|
||||
|
||||
printf("Failed to find configuration template for test '%s', using default template '%s'.\n",
|
||||
test_name,
|
||||
default_template);
|
||||
return default_template;
|
||||
}
|
||||
|
||||
void TestConnections::process_template(int m, const char* template_name, const char* dest)
|
||||
|
@ -1,18 +0,0 @@
|
||||
#ifndef TEMPLATES_H
|
||||
#define TEMPLATES_H
|
||||
|
||||
static struct
|
||||
{
|
||||
const char* test_name;
|
||||
const char* test_template;
|
||||
const char* test_labels;
|
||||
} cnf_templates[] __attribute__((unused)) = {
|
||||
@CNF_TEMPLATES@ {NULL, NULL, NULL}};
|
||||
|
||||
/** The default template to use */
|
||||
static const char * default_template __attribute__((unused)) = "replication";
|
||||
|
||||
/** This is the working directory for all tests */
|
||||
static const char *test_dir __attribute__((unused)) = "@CMAKE_CURRENT_SOURCE_DIR@";
|
||||
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
|
||||
# Helper function to add a configuration template
|
||||
function(add_template name template labels)
|
||||
set(CNF_TEMPLATES "${CNF_TEMPLATES}{\"${name}\",\"${template}\", \"${labels}\"}," CACHE INTERNAL "")
|
||||
set(CNF_TEMPLATES "${CNF_TEMPLATES}{\"${name}\", \"${template}\", \"${labels}\"}," CACHE INTERNAL "")
|
||||
endfunction()
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user