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){
|
if(fgets(buffer,2048,file) == NULL){
|
||||||
|
if(ferror(file)){
|
||||||
free(my_instance);
|
free(my_instance);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(feof(file)){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if((nl = strchr(buffer,'\n')) != NULL && ((char*)nl - (char*)buffer) < 2048){
|
if((nl = strchr(buffer,'\n')) != NULL && ((char*)nl - (char*)buffer) < 2048){
|
||||||
*nl = '\0';
|
*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_ui fullcore log_manager utils)
|
||||||
target_link_libraries(harness fullcore)
|
target_link_libraries(harness fullcore)
|
||||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${ERRMSG} ${CMAKE_CURRENT_BINARY_DIR})
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${ERRMSG} ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fwtest.cnf.in ${CMAKE_CURRENT_BINARY_DIR}/fwfilter.cnf)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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(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(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,7 +318,7 @@ int clientReply(void* ins, void* session, GWBUF* queue)
|
|||||||
int fdgets(int fd, char* buff, int size)
|
int fdgets(int fd, char* buff, int size)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
if(fd > 0){
|
||||||
while(i < size - 1 && read(fd,&buff[i],1))
|
while(i < size - 1 && read(fd,&buff[i],1))
|
||||||
{
|
{
|
||||||
if(buff[i] == '\n' || buff[i] == '\0')
|
if(buff[i] == '\n' || buff[i] == '\0')
|
||||||
@ -327,7 +327,7 @@ int fdgets(int fd, char* buff, int size)
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
buff[i] = '\0';
|
buff[i] = '\0';
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -1053,7 +1053,11 @@ int process_opts(int argc, char** argv)
|
|||||||
|
|
||||||
case 'e':
|
case 'e':
|
||||||
instance.expected = open_file(optarg,0);
|
instance.expected = open_file(optarg,0);
|
||||||
|
if(instance.expected > 0){
|
||||||
printf("Expected output is read from: %s\n",optarg);
|
printf("Expected output is read from: %s\n",optarg);
|
||||||
|
}else{
|
||||||
|
printf("Error: Failed to open file: %s\n",optarg);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
@ -1079,12 +1083,12 @@ int process_opts(int argc, char** argv)
|
|||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
instance.session_count = atoi(optarg);
|
instance.session_count = atoi(optarg);
|
||||||
printf("Sessions: %i ",instance.session_count);
|
printf("Sessions: %i\n",instance.session_count);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 't':
|
case 't':
|
||||||
instance.thrcount = atoi(optarg);
|
instance.thrcount = atoi(optarg);
|
||||||
printf("Threads: %i ",instance.thrcount);
|
printf("Threads: %i\n",instance.thrcount);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
@ -1136,19 +1140,29 @@ int compare_files(int a,int b)
|
|||||||
{
|
{
|
||||||
char in[4098];
|
char in[4098];
|
||||||
char exp[4098];
|
char exp[4098];
|
||||||
int line = 1;
|
int line = 1,ard, brd,running = 1;
|
||||||
|
|
||||||
if(a < 1 || b < 1){
|
if(a < 1 || b < 1){
|
||||||
|
printf("Invalid file descriptors: %d %d\n",a,b);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lseek(a,0,SEEK_SET) < 0 ||
|
if(lseek(a,0,SEEK_SET) < 0 ||
|
||||||
lseek(b,0,SEEK_SET) < 0){
|
lseek(b,0,SEEK_SET) < 0){
|
||||||
|
printf("Failed lseek() call on file descriptors: %d %d\n",a,b);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(fdgets(a,in,4098) && fdgets(b,exp,4098)){
|
while(running){
|
||||||
if(strcmp(in,exp)){
|
|
||||||
|
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);
|
printf("The files differ at line %d:\n%s\n-------------------------------------\n%s\n",line,in,exp);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,8 @@ int main(int argc,char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
route_buffers();
|
route_buffers();
|
||||||
if(inst->expected){
|
|
||||||
|
if(inst->expected > 0){
|
||||||
return compare_files(inst->outfile,inst->expected);
|
return compare_files(inst->outfile,inst->expected);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
rule union_regex deny regex '.*union.*'
|
rule union_regex deny regex '.*union.*'
|
||||||
rule dont_delete_everything deny no_where_clause on_operations delete|update
|
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