Added tests to cmake
This commit is contained in:
5
README
5
README
@ -195,6 +195,11 @@ If you have your headers and libraries in non-standard locations, you can define
|
|||||||
By default, MaxScale installs to '/usr/local/skysql/maxscale' and places init.d scripts and ldconfig files into their folders. Change the INSTALL_DIR
|
By default, MaxScale installs to '/usr/local/skysql/maxscale' and places init.d scripts and ldconfig files into their folders. Change the INSTALL_DIR
|
||||||
variable to your desired installation directory and set INSTALL_SYSTEM_FILES=N to prevent the init.d script and ldconfig file installation.
|
variable to your desired installation directory and set INSTALL_SYSTEM_FILES=N to prevent the init.d script and ldconfig file installation.
|
||||||
|
|
||||||
|
If you run into any trouble while configuring CMake, you can always remove the 'CMakeCache.txt' file to clear CMake's
|
||||||
|
internal cache. This resets all values to their defaults and can be used to fix a 'stuck' configuration of CMake. This
|
||||||
|
is also a good reason why you should always build into a separate directory, because you can safely wipe the build directory clean without the
|
||||||
|
danger of deleting important files.
|
||||||
|
|
||||||
All the parameters affecting CMake can be found in 'macros.cmake'. This file also has the parameters CMake uses for testing.
|
All the parameters affecting CMake can be found in 'macros.cmake'. This file also has the parameters CMake uses for testing.
|
||||||
|
|
||||||
All the variables that control the CMake build process:
|
All the variables that control the CMake build process:
|
||||||
|
0
etc/ubuntu/init.d/maxscale
Executable file → Normal file
0
etc/ubuntu/init.d/maxscale
Executable file → Normal file
32
macros.cmake
32
macros.cmake
@ -69,28 +69,30 @@ macro(check_deps)
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(DEPS_ERROR)
|
if(DEPS_ERROR)
|
||||||
message(FATAL_ERROR "Cannot find dependencies: ${FAILED_DEPS}")
|
|
||||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||||
|
message(FATAL_ERROR "Cannot find dependencies: ${FAILED_DEPS}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(check_dirs)
|
macro(check_dirs)
|
||||||
|
|
||||||
# Find the MySQL headers if they were not defined
|
# Find the MySQL headers if they were not defined
|
||||||
if(DEFINED MYSQL_DIR)
|
if(DEFINED MYSQL_DIR)
|
||||||
message(STATUS "Searching for MySQL headers at: ${MYSQL_DIR}")
|
message(STATUS "Searching for MySQL headers at: ${MYSQL_DIR}")
|
||||||
find_path(MYSQL_DIR_LOC mysql.h PATHS ${MYSQL_DIR} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
|
find_path(MYSQL_DIR_LOC mysql.h PATHS ${MYSQL_DIR} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
|
||||||
else()
|
|
||||||
find_path(MYSQL_DIR_LOC mysql.h PATH_SUFFIXES mysql mariadb)
|
|
||||||
endif()
|
endif()
|
||||||
|
find_path(MYSQL_DIR_LOC mysql.h PATH_SUFFIXES mysql mariadb)
|
||||||
message(STATUS "Search returned: ${MYSQL_DIR_LOC}")
|
message(STATUS "Search returned: ${MYSQL_DIR_LOC}")
|
||||||
set(MYSQL_DIR ${MYSQL_DIR_LOC} CACHE PATH "Path to MySQL headers" FORCE)
|
|
||||||
if(${MYSQL_DIR} STREQUAL "MYSQL_DIR-NOTFOUND")
|
if(${MYSQL_DIR_LOC} STREQUAL "MYSQL_DIR_LOC-NOTFOUND")
|
||||||
message(FATAL_ERROR "Fatal Error: MySQL headers were not found.")
|
|
||||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||||
|
message(FATAL_ERROR "Fatal Error: MySQL headers were not found.")
|
||||||
else()
|
else()
|
||||||
message(STATUS "Using MySQL headers found at: ${MYSQL_DIR}")
|
message(STATUS "Using MySQL headers found at: ${MYSQL_DIR}")
|
||||||
|
set(MYSQL_DIR ${MYSQL_DIR_LOC} CACHE PATH "Path to MySQL headers" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
set(MYSQL_DIR_LOC "" INTERNAL)
|
||||||
|
|
||||||
# Find the errmsg.sys file if it was not defied
|
# Find the errmsg.sys file if it was not defied
|
||||||
if( DEFINED ERRMSG )
|
if( DEFINED ERRMSG )
|
||||||
@ -98,12 +100,13 @@ macro(check_dirs)
|
|||||||
endif()
|
endif()
|
||||||
find_file(ERRMSG_FILE errmsg.sys PATHS /usr/share/mysql /usr/local/share/mysql PATH_SUFFIXES english)
|
find_file(ERRMSG_FILE errmsg.sys PATHS /usr/share/mysql /usr/local/share/mysql PATH_SUFFIXES english)
|
||||||
if(${ERRMSG_FILE} MATCHES "ERRMSG_FILE-NOTFOUND")
|
if(${ERRMSG_FILE} MATCHES "ERRMSG_FILE-NOTFOUND")
|
||||||
message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found, please define the path to it by using -DERRMSG=<path>")
|
|
||||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||||
|
message(FATAL_ERROR "Fatal Error: The errmsg.sys file was not found, please define the path to it by using -DERRMSG=<path>")
|
||||||
else()
|
else()
|
||||||
message(STATUS "Using errmsg.sys found at: ${ERRMSG_FILE}")
|
message(STATUS "Using errmsg.sys found at: ${ERRMSG_FILE}")
|
||||||
endif()
|
endif()
|
||||||
set(ERRMSG ${ERRMSG_FILE} CACHE FILEPATH "Path to the errmsg.sys file." FORCE)
|
set(ERRMSG ${ERRMSG_FILE} CACHE FILEPATH "Path to the errmsg.sys file." FORCE)
|
||||||
|
set(ERRMSG_FILE "" INTERNAL)
|
||||||
|
|
||||||
# Find the embedded mysql library
|
# Find the embedded mysql library
|
||||||
if(STATIC_EMBEDDED)
|
if(STATIC_EMBEDDED)
|
||||||
@ -119,12 +122,12 @@ macro(check_dirs)
|
|||||||
message(STATUS "Search returned: ${EMBEDDED_LIB_STATIC}")
|
message(STATUS "Search returned: ${EMBEDDED_LIB_STATIC}")
|
||||||
set(EMBEDDED_LIB ${EMBEDDED_LIB_STATIC} CACHE FILEPATH "Path to libmysqld" FORCE)
|
set(EMBEDDED_LIB ${EMBEDDED_LIB_STATIC} CACHE FILEPATH "Path to libmysqld" FORCE)
|
||||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
|
set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIXES})
|
||||||
|
set(OLD_SUFFIXES "" INTERNAL)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
if (DEFINED EMBEDDED_LIB)
|
if (DEFINED EMBEDDED_LIB)
|
||||||
message(STATUS "Searching for libmysqld.so at: ${EMBEDDED_LIB}")
|
message(STATUS "Searching for libmysqld.so at: ${EMBEDDED_LIB}")
|
||||||
find_library(EMBEDDED_LIB_DYNAMIC mysqld PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
|
find_library(EMBEDDED_LIB_DYNAMIC mysqld PATHS ${EMBEDDED_LIB} PATH_SUFFIXES mysql mariadb NO_DEFAULT_PATH)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
find_library(EMBEDDED_LIB_DYNAMIC mysqld PATH_SUFFIXES mysql mariadb)
|
find_library(EMBEDDED_LIB_DYNAMIC mysqld PATH_SUFFIXES mysql mariadb)
|
||||||
endif()
|
endif()
|
||||||
@ -132,12 +135,13 @@ macro(check_dirs)
|
|||||||
set(EMBEDDED_LIB ${EMBEDDED_LIB_DYNAMIC} CACHE FILEPATH "Path to libmysqld" FORCE)
|
set(EMBEDDED_LIB ${EMBEDDED_LIB_DYNAMIC} CACHE FILEPATH "Path to libmysqld" FORCE)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
set(EMBEDDED_LIB_DYNAMIC "" INTERNAL)
|
||||||
|
set(EMBEDDED_LIB_STATIC "" INTERNAL)
|
||||||
|
|
||||||
# Inform the user about the embedded library
|
# Inform the user about the embedded library
|
||||||
if( (${EMBEDDED_LIB} STREQUAL "EMBEDDED_LIB_STATIC-NOTFOUND") OR (${EMBEDDED_LIB} STREQUAL "EMBEDDED_LIB_DYNAMIC-NOTFOUND"))
|
if( (${EMBEDDED_LIB} STREQUAL "EMBEDDED_LIB_STATIC-NOTFOUND") OR (${EMBEDDED_LIB} STREQUAL "EMBEDDED_LIB_DYNAMIC-NOTFOUND"))
|
||||||
message(FATAL_ERROR "Library not found: libmysqld. If your install of MySQL is in a non-default location, please provide the location with -DEMBEDDED_LIB=<path to library>")
|
|
||||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||||
|
message(FATAL_ERROR "Library not found: libmysqld. If your install of MySQL is in a non-default location, please provide the location with -DEMBEDDED_LIB=<path to library>")
|
||||||
else()
|
else()
|
||||||
get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} REALPATH)
|
get_filename_component(EMBEDDED_LIB ${EMBEDDED_LIB} REALPATH)
|
||||||
message(STATUS "Using embedded library: ${EMBEDDED_LIB}")
|
message(STATUS "Using embedded library: ${EMBEDDED_LIB}")
|
||||||
@ -149,14 +153,16 @@ macro(check_dirs)
|
|||||||
if(${RPM_FNC} MATCHES "RPM_FNC-NOTFOUND")
|
if(${RPM_FNC} MATCHES "RPM_FNC-NOTFOUND")
|
||||||
find_file(DEB_FNC init-functions PATHS /lib/lsb)
|
find_file(DEB_FNC init-functions PATHS /lib/lsb)
|
||||||
if(${DEB_FNC} MATCHES "DEB_FNC-NOTFOUND")
|
if(${DEB_FNC} MATCHES "DEB_FNC-NOTFOUND")
|
||||||
message(FATAL_ERROR "Cannot find required init-functions in /lib/lsb/ or /etc/rc.d/init.d/, please confirm that your system files are OK.")
|
|
||||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||||
|
message(FATAL_ERROR "Cannot find required init-functions in /lib/lsb/ or /etc/rc.d/init.d/, please confirm that your system files are OK.")
|
||||||
else()
|
else()
|
||||||
set(DEB_BASED TRUE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
|
set(DEB_BASED TRUE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
set(DEB_BASED FALSE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
|
set(DEB_BASED FALSE CACHE BOOL "If init.d script uses /lib/lsb/init-functions instead of /etc/rc.d/init.d/functions.")
|
||||||
endif()
|
endif()
|
||||||
|
set(DEB_FNC "" INTERNAL)
|
||||||
|
set(RPM_FNC "" INTERNAL)
|
||||||
|
|
||||||
#Check RabbitMQ headers and libraries
|
#Check RabbitMQ headers and libraries
|
||||||
if(BUILD_RABBITMQ)
|
if(BUILD_RABBITMQ)
|
||||||
@ -166,8 +172,8 @@ macro(check_dirs)
|
|||||||
endif()
|
endif()
|
||||||
find_library(RMQ_LIB rabbitmq)
|
find_library(RMQ_LIB rabbitmq)
|
||||||
if(RMQ_LIB STREQUAL "RMQ_LIB-NOTFOUND")
|
if(RMQ_LIB STREQUAL "RMQ_LIB-NOTFOUND")
|
||||||
message(FATAL_ERROR "Cannot find RabbitMQ libraries, please define the path to the libraries with -DRABBITMQ_LIB=<path>")
|
|
||||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||||
|
message(FATAL_ERROR "Cannot find RabbitMQ libraries, please define the path to the libraries with -DRABBITMQ_LIB=<path>")
|
||||||
else()
|
else()
|
||||||
set(RABBITMQ_LIB ${RMQ_LIB} CACHE PATH "Path to RabbitMQ libraries" FORCE)
|
set(RABBITMQ_LIB ${RMQ_LIB} CACHE PATH "Path to RabbitMQ libraries" FORCE)
|
||||||
message(STATUS "Using RabbitMQ libraries found at: ${RABBITMQ_LIB}")
|
message(STATUS "Using RabbitMQ libraries found at: ${RABBITMQ_LIB}")
|
||||||
@ -178,8 +184,8 @@ macro(check_dirs)
|
|||||||
endif()
|
endif()
|
||||||
find_file(RMQ_HEADERS amqp.h)
|
find_file(RMQ_HEADERS amqp.h)
|
||||||
if(RMQ_HEADERS STREQUAL "RMQ_HEADERS-NOTFOUND")
|
if(RMQ_HEADERS STREQUAL "RMQ_HEADERS-NOTFOUND")
|
||||||
message(FATAL_ERROR "Cannot find RabbitMQ headers, please define the path to the headers with -DRABBITMQ_HEADERS=<path>")
|
|
||||||
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
set(DEPS_OK FALSE CACHE BOOL "If all the dependencies were found.")
|
||||||
|
message(FATAL_ERROR "Cannot find RabbitMQ headers, please define the path to the headers with -DRABBITMQ_HEADERS=<path>")
|
||||||
else()
|
else()
|
||||||
set(RABBITMQ_HEADERS ${RMQ_HEADERS} CACHE PATH "Path to RabbitMQ headers" FORCE)
|
set(RABBITMQ_HEADERS ${RMQ_HEADERS} CACHE PATH "Path to RabbitMQ headers" FORCE)
|
||||||
message(STATUS "Using RabbitMQ headers found at: ${RABBITMQ_HEADERS}")
|
message(STATUS "Using RabbitMQ headers found at: ${RABBITMQ_HEADERS}")
|
||||||
|
@ -1,3 +1,20 @@
|
|||||||
|
if(${ERRMSG} MATCHES "NOTFOUND")
|
||||||
|
message(FATAL_ERROR "The errmsg.sys file was not found, please define the path with -DERRMSG=<path>")
|
||||||
|
else()
|
||||||
|
file(COPY ${ERRMSG} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(canonical_tests)
|
add_subdirectory(canonical_tests)
|
||||||
add_executable(classify classify.c)
|
add_executable(classify classify.c)
|
||||||
target_link_libraries(classify fullcore)
|
target_link_libraries(classify query_classifier fullcore)
|
||||||
|
add_test(NAME TestQueryClassifier
|
||||||
|
COMMAND /bin/sh -c "${CMAKE_CURRENT_BINARY_DIR}/classify < ${CMAKE_CURRENT_SOURCE_DIR}/input.sql > ${CMAKE_CURRENT_BINARY_DIR}/output.sql &&
|
||||||
|
diff ${CMAKE_CURRENT_BINARY_DIR}/output.sql ${CMAKE_CURRENT_SOURCE_DIR}/expected.sql;
|
||||||
|
if [[ $? -eq 1 ]];
|
||||||
|
then
|
||||||
|
echo \"TEST FAILED\";
|
||||||
|
exit 1;
|
||||||
|
else
|
||||||
|
echo\"TEST PASSED\";
|
||||||
|
exit 0;
|
||||||
|
fi")
|
@ -1,62 +1,158 @@
|
|||||||
# cleantests - clean local and subdirectories' tests
|
# CMAKE generated file: DO NOT EDIT!
|
||||||
# buildtests - build all local and subdirectories' tests
|
# Generated by "Unix Makefiles" Generator, CMake Version 2.8
|
||||||
# runtests - run all local tests
|
|
||||||
# testall - clean, build and run local and subdirectories' tests
|
|
||||||
|
|
||||||
include ../../../build_gateway.inc
|
# Default target executed when no arguments are given to make.
|
||||||
include ../../../makefile.inc
|
default_target: all
|
||||||
include ../../../test.inc
|
.PHONY : default_target
|
||||||
|
|
||||||
CC = gcc
|
#=============================================================================
|
||||||
CPP = g++
|
# Special targets provided by cmake.
|
||||||
|
|
||||||
TESTPATH := $(shell pwd)
|
# Disable implicit rules so canonical targets will work.
|
||||||
TESTLOG := $(TESTPATH)/testqclass.log
|
.SUFFIXES:
|
||||||
QUERY_CLASSIFIER_PATH := $(ROOT_PATH)/query_classifier
|
|
||||||
LOG_MANAGER_PATH := $(ROOT_PATH)/log_manager
|
|
||||||
UTILS_PATH := $(ROOT_PATH)/utils
|
|
||||||
CORE_PATH := $(ROOT_PATH)/server/core
|
|
||||||
TESTAPP = $(TESTPATH)/canonizer
|
|
||||||
|
|
||||||
LDFLAGS=-L$(QUERY_CLASSIFIER_PATH) \
|
# Remove some rules from gmake that .SUFFIXES does not remove.
|
||||||
-L$(LOG_MANAGER_PATH) \
|
SUFFIXES =
|
||||||
-L$(EMBEDDED_LIB) \
|
|
||||||
-Wl,-rpath,$(DEST)/lib \
|
|
||||||
-Wl,-rpath,$(EMBEDDED_LIB) \
|
|
||||||
-Wl,-rpath,$(LOG_MANAGER_PATH) \
|
|
||||||
-Wl,-rpath,$(QUERY_CLASSIFIER_PATH)
|
|
||||||
|
|
||||||
LIBS=-lstdc++ -lpthread -lquery_classifier -lz -ldl -lssl -laio -lcrypt -lcrypto -lrt -lm \
|
.SUFFIXES: .hpux_make_needs_suffix_list
|
||||||
-llog_manager $(UTILS_PATH)/skygw_utils.o $(CORE_PATH)/buffer.o $(CORE_PATH)/atomic.o $(CORE_PATH)/spinlock.o $(CORE_PATH)/hint.o
|
|
||||||
|
|
||||||
CFLAGS=-g $(MYSQL_HEADERS) \
|
# Suppress display of executed commands.
|
||||||
-I$(QUERY_CLASSIFIER_PATH) \
|
$(VERBOSE).SILENT:
|
||||||
$(MYSQL_HEADERS) \
|
|
||||||
-I$(ROOT_PATH)/server/include \
|
# A target that is always out of date.
|
||||||
-I$(UTILS_PATH)
|
cmake_force:
|
||||||
|
.PHONY : cmake_force
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Set environment variables for the build.
|
||||||
|
|
||||||
|
# The shell in which to execute make rules.
|
||||||
|
SHELL = /bin/sh
|
||||||
|
|
||||||
|
# The CMake executable.
|
||||||
|
CMAKE_COMMAND = /usr/bin/cmake
|
||||||
|
|
||||||
|
# The command to remove a file.
|
||||||
|
RM = /usr/bin/cmake -E remove -f
|
||||||
|
|
||||||
|
# Escaping for special characters.
|
||||||
|
EQUALS = =
|
||||||
|
|
||||||
|
# The program to use to edit the cache.
|
||||||
|
CMAKE_EDIT_COMMAND = /usr/bin/ccmake
|
||||||
|
|
||||||
|
# The top-level source directory on which CMake was run.
|
||||||
|
CMAKE_SOURCE_DIR = /home/markus/max_origin/MaxScale/query_classifier/test
|
||||||
|
|
||||||
|
# The top-level build directory on which CMake was run.
|
||||||
|
CMAKE_BINARY_DIR = /home/markus/max_origin/MaxScale/query_classifier/test
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Targets provided globally by CMake.
|
||||||
|
|
||||||
|
# Special rule for the target edit_cache
|
||||||
|
edit_cache:
|
||||||
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
|
||||||
|
/usr/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
||||||
|
.PHONY : edit_cache
|
||||||
|
|
||||||
|
# Special rule for the target edit_cache
|
||||||
|
edit_cache/fast: edit_cache
|
||||||
|
.PHONY : edit_cache/fast
|
||||||
|
|
||||||
|
# Special rule for the target rebuild_cache
|
||||||
|
rebuild_cache:
|
||||||
|
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
|
||||||
|
/usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
||||||
|
.PHONY : rebuild_cache
|
||||||
|
|
||||||
|
# Special rule for the target rebuild_cache
|
||||||
|
rebuild_cache/fast: rebuild_cache
|
||||||
|
.PHONY : rebuild_cache/fast
|
||||||
|
|
||||||
|
# The main all target
|
||||||
|
all: cmake_check_build_system
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(CMAKE_COMMAND) -E cmake_progress_start /home/markus/max_origin/MaxScale/query_classifier/test/CMakeFiles /home/markus/max_origin/MaxScale/query_classifier/test/canonical_tests/CMakeFiles/progress.marks
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(MAKE) -f CMakeFiles/Makefile2 canonical_tests/all
|
||||||
|
$(CMAKE_COMMAND) -E cmake_progress_start /home/markus/max_origin/MaxScale/query_classifier/test/CMakeFiles 0
|
||||||
|
.PHONY : all
|
||||||
|
|
||||||
|
# The main clean target
|
||||||
|
clean:
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(MAKE) -f CMakeFiles/Makefile2 canonical_tests/clean
|
||||||
|
.PHONY : clean
|
||||||
|
|
||||||
|
# The main clean target
|
||||||
|
clean/fast: clean
|
||||||
|
.PHONY : clean/fast
|
||||||
|
|
||||||
|
# Prepare targets for installation.
|
||||||
|
preinstall: all
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(MAKE) -f CMakeFiles/Makefile2 canonical_tests/preinstall
|
||||||
|
.PHONY : preinstall
|
||||||
|
|
||||||
|
# Prepare targets for installation.
|
||||||
|
preinstall/fast:
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(MAKE) -f CMakeFiles/Makefile2 canonical_tests/preinstall
|
||||||
|
.PHONY : preinstall/fast
|
||||||
|
|
||||||
|
# clear depends
|
||||||
|
depend:
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
|
||||||
|
.PHONY : depend
|
||||||
|
|
||||||
|
# Convenience name for target.
|
||||||
|
canonical_tests/CMakeFiles/canonizer.dir/rule:
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(MAKE) -f CMakeFiles/Makefile2 canonical_tests/CMakeFiles/canonizer.dir/rule
|
||||||
|
.PHONY : canonical_tests/CMakeFiles/canonizer.dir/rule
|
||||||
|
|
||||||
|
# Convenience name for target.
|
||||||
|
canonizer: canonical_tests/CMakeFiles/canonizer.dir/rule
|
||||||
|
.PHONY : canonizer
|
||||||
|
|
||||||
|
# fast build rule for target.
|
||||||
|
canonizer/fast:
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(MAKE) -f canonical_tests/CMakeFiles/canonizer.dir/build.make canonical_tests/CMakeFiles/canonizer.dir/build
|
||||||
|
.PHONY : canonizer/fast
|
||||||
|
|
||||||
|
# target to build an object file
|
||||||
|
canonizer.o:
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(MAKE) -f canonical_tests/CMakeFiles/canonizer.dir/build.make canonical_tests/CMakeFiles/canonizer.dir/canonizer.o
|
||||||
|
.PHONY : canonizer.o
|
||||||
|
|
||||||
|
# target to preprocess a source file
|
||||||
|
canonizer.i:
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(MAKE) -f canonical_tests/CMakeFiles/canonizer.dir/build.make canonical_tests/CMakeFiles/canonizer.dir/canonizer.i
|
||||||
|
.PHONY : canonizer.i
|
||||||
|
|
||||||
|
# target to generate assembly for a file
|
||||||
|
canonizer.s:
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(MAKE) -f canonical_tests/CMakeFiles/canonizer.dir/build.make canonical_tests/CMakeFiles/canonizer.dir/canonizer.s
|
||||||
|
.PHONY : canonizer.s
|
||||||
|
|
||||||
|
# Help Target
|
||||||
|
help:
|
||||||
|
@echo "The following are some of the valid targets for this Makefile:"
|
||||||
|
@echo "... all (the default if no target is provided)"
|
||||||
|
@echo "... clean"
|
||||||
|
@echo "... depend"
|
||||||
|
@echo "... canonizer"
|
||||||
|
@echo "... edit_cache"
|
||||||
|
@echo "... rebuild_cache"
|
||||||
|
@echo "... canonizer.o"
|
||||||
|
@echo "... canonizer.i"
|
||||||
|
@echo "... canonizer.s"
|
||||||
|
.PHONY : help
|
||||||
|
|
||||||
|
|
||||||
testall:
|
|
||||||
$(MAKE) cleantests
|
|
||||||
$(MAKE) buildtests
|
|
||||||
$(MAKE) runtests
|
|
||||||
|
|
||||||
cleantests:
|
#=============================================================================
|
||||||
- $(DEL) *.o
|
# Special targets to cleanup operation of make.
|
||||||
- $(DEL) *~
|
|
||||||
- $(DEL) canonizer
|
|
||||||
- $(DEL) aria_log*
|
|
||||||
- $(DEL) ib*
|
|
||||||
|
|
||||||
buildtests: $(OBJS)
|
# Special rule to run CMake to check the build system integrity.
|
||||||
cp $(ERRMSG)/errmsg.sys .
|
# No rule that depends on this can have commands that come from listfiles
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) canonizer.c -o $(TESTAPP) $(LDLIBS) $(LDMYSQL)
|
# because they might be regenerated.
|
||||||
|
cmake_check_build_system:
|
||||||
|
cd /home/markus/max_origin/MaxScale/query_classifier/test && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
|
||||||
|
.PHONY : cmake_check_build_system
|
||||||
|
|
||||||
runtests:
|
|
||||||
@echo "" > $(TESTLOG)
|
|
||||||
@echo "-------------------------------" >> $(TESTLOG)
|
|
||||||
@echo $(shell date) >> $(TESTLOG)
|
|
||||||
@echo "Canonical Query Tests" >> $(TESTLOG)
|
|
||||||
@echo "-------------------------------" >> $(TESTLOG)
|
|
||||||
@echo "" >> $(TESTLOG)
|
|
||||||
./canontest.sh $(TESTLOG) input.sql output.sql expected.sql
|
|
||||||
|
@ -31,8 +31,12 @@ int main(int argc, char** argv)
|
|||||||
int rd = 0,buffsz = getpagesize(),strsz = 0;
|
int rd = 0,buffsz = getpagesize(),strsz = 0;
|
||||||
char buffer[buffsz], *strbuff = (char*)calloc(buffsz,sizeof(char));
|
char buffer[buffsz], *strbuff = (char*)calloc(buffsz,sizeof(char));
|
||||||
|
|
||||||
mysql_library_init(num_elements, server_options, server_groups);
|
if(mysql_library_init(num_elements, server_options, server_groups))
|
||||||
|
{
|
||||||
|
printf("Error: Cannot initialize Embedded Library.");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
while((rd = fread(buffer,sizeof(char),buffsz,stdin))){
|
while((rd = fread(buffer,sizeof(char),buffsz,stdin))){
|
||||||
|
|
||||||
/**Fill the read buffer*/
|
/**Fill the read buffer*/
|
||||||
|
19
query_classifier/test/expected.sql
Normal file
19
query_classifier/test/expected.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
QUERY_TYPE_UNKNOWN
|
||||||
|
QUERY_TYPE_UNKNOWN
|
||||||
|
QUERY_TYPE_READ
|
||||||
|
QUERY_TYPE_UNKNOWN
|
||||||
|
QUERY_TYPE_READ
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_WRITE
|
||||||
|
QUERY_TYPE_UNKNOWN
|
19
query_classifier/test/input.sql
Normal file
19
query_classifier/test/input.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
select sleep(2);
|
||||||
|
select * from tst where lname='Doe';
|
||||||
|
select 1,2,3,4,5,6 from tst;
|
||||||
|
select * from tst where fname like '%a%';
|
||||||
|
select * from tst where lname like '%e%' order by fname;
|
||||||
|
insert into tst values ("John"," Doe"),("Donald","Duck"),("Plato",""),("Richard","Stallman");
|
||||||
|
insert into tst values ("Jane"," Doe"),("Daisy","Duck"),("Marie","Curie");
|
||||||
|
insert into tst values ("John","Doe"),("Donald","Duck"),("Plato",""),("Richard","Stallman");
|
||||||
|
insert into tst values ("Jane","Doe"),("Daisy","Duck"),("Marie","Curie");
|
||||||
|
insert into tst values ("John","Doe"),("Donald","Duck"),("Plato",""),("Richard","Stallman");
|
||||||
|
insert into tst values ("Jane","Doe"),("Daisy","Duck"),("Marie","Curie");
|
||||||
|
update tst set fname="Farmer", lname="McDonald" where lname="%Doe" and fname="John";
|
||||||
|
update tst set fname="John" where lname="Doe";
|
||||||
|
update tst set lname="Philosopher" where fname="Plato";
|
||||||
|
update tst set fname="Human" where fname like 'Richard%';
|
||||||
|
update tst set lname="Creature" where lname like '%man%';
|
||||||
|
update tst set fname="Jane" where lname="%Doe";
|
||||||
|
update tst set lname="Human" where fname like '%a%' or lname like '%a%';
|
||||||
|
|
Reference in New Issue
Block a user