Fixed errors in filter harness file comparing.
This commit is contained in:
@ -922,10 +922,16 @@ createInstance(char **options, FILTER_PARAMETER **params)
|
||||
{
|
||||
|
||||
if(fgets(buffer,2048,file) == NULL){
|
||||
free(my_instance);
|
||||
return NULL;
|
||||
if(ferror(file)){
|
||||
free(my_instance);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(feof(file)){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if((nl = strchr(buffer,'\n')) != NULL && ((char*)nl - (char*)buffer) < 2048){
|
||||
*nl = '\0';
|
||||
}
|
||||
|
@ -11,6 +11,14 @@ add_executable(harness harness_util.c harness_common.c ${CORE})
|
||||
target_link_libraries(harness_ui fullcore log_manager utils)
|
||||
target_link_libraries(harness fullcore)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${ERRMSG} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
add_test(TestHintfilter /bin/sh -c "MAXSCALE_HOME=\"${CMAKE_BINARY_DIR}\" ${CMAKE_CURRENT_BINARY_DIR}/harness -i ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.input -o ${CMAKE_CURRENT_BINARY_DIR}/hint_testing.output -c ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.cnf -t 1 -s 1 -e ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.expected")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fwtest.cnf.in ${CMAKE_CURRENT_BINARY_DIR}/fwfilter.cnf)
|
||||
|
||||
add_test(TestRegexfilter /bin/sh -c "MAXSCALE_HOME=\"${CMAKE_BINARY_DIR}\" ${CMAKE_CURRENT_BINARY_DIR}/harness -i ${CMAKE_CURRENT_SOURCE_DIR}/regextest.input -o ${CMAKE_CURRENT_BINARY_DIR}/regextest.output -c ${CMAKE_CURRENT_SOURCE_DIR}/regextest.cnf -t 1 -s 1 -e ${CMAKE_CURRENT_SOURCE_DIR}/regextest.expected")
|
||||
|
||||
|
||||
add_test(TestHintfilter /bin/sh -c "MAXSCALE_HOME=\"${CMAKE_BINARY_DIR}\" ${CMAKE_CURRENT_BINARY_DIR}/harness -i ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.input -o ${CMAKE_CURRENT_BINARY_DIR}/hint_testing.output -c ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.cnf -t 1 -s 1 -e ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.expected ")
|
||||
|
||||
add_test(TestRegexfilter /bin/sh -c "MAXSCALE_HOME=\"${CMAKE_BINARY_DIR}\" ${CMAKE_CURRENT_BINARY_DIR}/harness -i ${CMAKE_CURRENT_SOURCE_DIR}/regextest.input -o ${CMAKE_CURRENT_BINARY_DIR}/regextest.output -c ${CMAKE_CURRENT_SOURCE_DIR}/regextest.cnf -t 1 -s 1 -e ${CMAKE_CURRENT_SOURCE_DIR}/regextest.expected ")
|
||||
|
||||
add_test(TestFwfilter /bin/sh -c "MAXSCALE_HOME=\"${CMAKE_BINARY_DIR}\" ${CMAKE_CURRENT_BINARY_DIR}/harness -i ${CMAKE_CURRENT_SOURCE_DIR}/fwtest.input -o ${CMAKE_CURRENT_BINARY_DIR}/fwtest.output -c ${CMAKE_CURRENT_BINARY_DIR}/fwfilter.cnf -t 1 -s 1 -e ${CMAKE_CURRENT_SOURCE_DIR}/fwtest.expected ")
|
||||
|
||||
add_test(TestFwfilter2 /bin/sh -c "MAXSCALE_HOME=\"${CMAKE_BINARY_DIR}\" ${CMAKE_CURRENT_BINARY_DIR}/harness -i ${CMAKE_CURRENT_SOURCE_DIR}/fwtest2.input -o ${CMAKE_CURRENT_BINARY_DIR}/fwtest2.output -c ${CMAKE_CURRENT_BINARY_DIR}/fwfilter.cnf -t 1 -s 1 -e ${CMAKE_CURRENT_SOURCE_DIR}/fwtest2.expected ")
|
4
server/modules/filter/test/fwtest.expected
Executable file
4
server/modules/filter/test/fwtest.expected
Executable file
@ -0,0 +1,4 @@
|
||||
select 1;
|
||||
select 1;
|
||||
select 1;
|
||||
select 1;
|
3
server/modules/filter/test/fwtest2.expected
Normal file
3
server/modules/filter/test/fwtest2.expected
Normal file
@ -0,0 +1,3 @@
|
||||
select 1;
|
||||
select 1;
|
||||
select 1;
|
8
server/modules/filter/test/fwtest2.input
Normal file
8
server/modules/filter/test/fwtest2.input
Normal file
@ -0,0 +1,8 @@
|
||||
select 1;
|
||||
select 1 union select 2;
|
||||
select 1;
|
||||
delete from test.table;
|
||||
select 1;
|
||||
select 1;
|
||||
select 1;
|
||||
select 1;
|
@ -318,16 +318,16 @@ int clientReply(void* ins, void* session, GWBUF* queue)
|
||||
int fdgets(int fd, char* buff, int size)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while(i < size - 1 && read(fd,&buff[i],1))
|
||||
{
|
||||
if(buff[i] == '\n' || buff[i] == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if(fd > 0){
|
||||
while(i < size - 1 && read(fd,&buff[i],1))
|
||||
{
|
||||
if(buff[i] == '\n' || buff[i] == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
buff[i] = '\0';
|
||||
return i;
|
||||
}
|
||||
@ -1053,7 +1053,11 @@ int process_opts(int argc, char** argv)
|
||||
|
||||
case 'e':
|
||||
instance.expected = open_file(optarg,0);
|
||||
printf("Expected output is read from: %s\n",optarg);
|
||||
if(instance.expected > 0){
|
||||
printf("Expected output is read from: %s\n",optarg);
|
||||
}else{
|
||||
printf("Error: Failed to open file: %s\n",optarg);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
@ -1079,12 +1083,12 @@ int process_opts(int argc, char** argv)
|
||||
|
||||
case 's':
|
||||
instance.session_count = atoi(optarg);
|
||||
printf("Sessions: %i ",instance.session_count);
|
||||
printf("Sessions: %i\n",instance.session_count);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
instance.thrcount = atoi(optarg);
|
||||
printf("Threads: %i ",instance.thrcount);
|
||||
printf("Threads: %i\n",instance.thrcount);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
@ -1136,19 +1140,29 @@ int compare_files(int a,int b)
|
||||
{
|
||||
char in[4098];
|
||||
char exp[4098];
|
||||
int line = 1;
|
||||
int line = 1,ard, brd,running = 1;
|
||||
|
||||
if(a < 1 || b < 1){
|
||||
printf("Invalid file descriptors: %d %d\n",a,b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(lseek(a,0,SEEK_SET) < 0 ||
|
||||
lseek(b,0,SEEK_SET) < 0){
|
||||
printf("Failed lseek() call on file descriptors: %d %d\n",a,b);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while(fdgets(a,in,4098) && fdgets(b,exp,4098)){
|
||||
if(strcmp(in,exp)){
|
||||
while(running){
|
||||
|
||||
ard = fdgets(a,in,4098);
|
||||
brd = fdgets(b,exp,4098);
|
||||
|
||||
if(ard == 0 && brd == 0){
|
||||
break;
|
||||
}
|
||||
|
||||
if(ard == 0 || brd == 0 || strcmp(in,exp)){
|
||||
printf("The files differ at line %d:\n%s\n-------------------------------------\n%s\n",line,in,exp);
|
||||
return 1;
|
||||
}
|
||||
|
@ -41,7 +41,8 @@ int main(int argc,char** argv)
|
||||
}
|
||||
|
||||
route_buffers();
|
||||
if(inst->expected){
|
||||
|
||||
if(inst->expected > 0){
|
||||
return compare_files(inst->outfile,inst->expected);
|
||||
}
|
||||
return 0;
|
||||
|
@ -1,3 +1,4 @@
|
||||
rule union_regex deny regex '.*union.*'
|
||||
rule dont_delete_everything deny no_where_clause on_operations delete|update
|
||||
users %@% match any rules union_regex dont_delete_everything
|
||||
rule limit_speed deny limit_queries 3 100.0 10.0
|
||||
users %@% match any rules union_regex dont_delete_everything limit_speed
|
||||
|
Reference in New Issue
Block a user