Added tests to cmake

This commit is contained in:
Markus Makela
2014-09-25 10:14:42 +03:00
parent 1cf3fa367c
commit 25850c056f
8 changed files with 233 additions and 67 deletions

View File

@ -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_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")

View File

@ -1,62 +1,158 @@
# cleantests - clean local and subdirectories' tests
# buildtests - build all local and subdirectories' tests
# runtests - run all local tests
# testall - clean, build and run local and subdirectories' tests
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8
include ../../../build_gateway.inc
include ../../../makefile.inc
include ../../../test.inc
# Default target executed when no arguments are given to make.
default_target: all
.PHONY : default_target
CC = gcc
CPP = g++
#=============================================================================
# Special targets provided by cmake.
TESTPATH := $(shell pwd)
TESTLOG := $(TESTPATH)/testqclass.log
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
# Disable implicit rules so canonical targets will work.
.SUFFIXES:
LDFLAGS=-L$(QUERY_CLASSIFIER_PATH) \
-L$(LOG_MANAGER_PATH) \
-L$(EMBEDDED_LIB) \
-Wl,-rpath,$(DEST)/lib \
-Wl,-rpath,$(EMBEDDED_LIB) \
-Wl,-rpath,$(LOG_MANAGER_PATH) \
-Wl,-rpath,$(QUERY_CLASSIFIER_PATH)
# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =
LIBS=-lstdc++ -lpthread -lquery_classifier -lz -ldl -lssl -laio -lcrypt -lcrypto -lrt -lm \
-llog_manager $(UTILS_PATH)/skygw_utils.o $(CORE_PATH)/buffer.o $(CORE_PATH)/atomic.o $(CORE_PATH)/spinlock.o $(CORE_PATH)/hint.o
.SUFFIXES: .hpux_make_needs_suffix_list
CFLAGS=-g $(MYSQL_HEADERS) \
-I$(QUERY_CLASSIFIER_PATH) \
$(MYSQL_HEADERS) \
-I$(ROOT_PATH)/server/include \
-I$(UTILS_PATH)
# Suppress display of executed commands.
$(VERBOSE).SILENT:
# A target that is always out of date.
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
- $(DEL) *~
- $(DEL) canonizer
- $(DEL) aria_log*
- $(DEL) ib*
#=============================================================================
# Special targets to cleanup operation of make.
buildtests: $(OBJS)
cp $(ERRMSG)/errmsg.sys .
$(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) canonizer.c -o $(TESTAPP) $(LDLIBS) $(LDMYSQL)
# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# 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

View File

@ -31,8 +31,12 @@ int main(int argc, char** argv)
int rd = 0,buffsz = getpagesize(),strsz = 0;
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))){
/**Fill the read buffer*/

View 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

View 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%';