Modifications to building
This commit is contained in:
@ -25,3 +25,7 @@ target_link_libraries(topfilter log_manager utils)
|
|||||||
install(TARGETS topfilter DESTINATION modules)
|
install(TARGETS topfilter DESTINATION modules)
|
||||||
|
|
||||||
add_subdirectory(hint)
|
add_subdirectory(hint)
|
||||||
|
|
||||||
|
if(BUILD_TESTS)
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif()
|
||||||
@ -1,4 +1,6 @@
|
|||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
add_executable(harness_ui harness_ui.c harness_common.c)
|
add_executable(harness_ui harness_ui.c harness_common.c)
|
||||||
add_executable(harness harness_util.c harness_common.c)
|
add_executable(harness harness_util.c harness_common.c)
|
||||||
target_link_libraries(harness_ui log_manager utils pthread)
|
target_link_libraries(harness_ui log_manager utils pthread fullcore)
|
||||||
target_link_libraries(harness log_manager utils pthread)
|
target_link_libraries(harness log_manager utils pthread fullcore)
|
||||||
|
add_test(TestHintfilter /bin/sh -c "${CMAKE_CURRENT_BINARY_DIR}/harness -i ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.input -o ${CMAKE_CURRENT_BINARY_DIR}/hint_testig.output -c ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.cnf -t 2 -s 10 && diff ${CMAKE_CURRENT_SOURCE_DIR}/hint_testing.expected ${CMAKE_CURRENT_BINARY_DIR}/hint_testig.output;exit $?")
|
||||||
@ -33,14 +33,14 @@ LDFLAGS=-rdynamic -L$(LOGPATH) -L$(UTILSPATH) -L$(EMBEDDED_LIB) \
|
|||||||
-Wl,-rpath,$(LOGPATH) -Wl,-rpath,$(UTILSPATH) \
|
-Wl,-rpath,$(LOGPATH) -Wl,-rpath,$(UTILSPATH) \
|
||||||
-Wl,-rpath,$(EMBEDDED_LIB)
|
-Wl,-rpath,$(EMBEDDED_LIB)
|
||||||
|
|
||||||
SRCS=harness.c
|
SRCS=harness_util.c harness_common.c
|
||||||
OBJ=$(SRCS:.c=.o)
|
OBJ=$(SRCS:.c=.o)
|
||||||
COREOBJ=$(COREPATH)/load_utils.o $(COREPATH)/dcb.o $(COREPATH)/utils.o \
|
COREOBJ=$(COREPATH)/load_utils.o $(COREPATH)/dcb.o $(COREPATH)/utils.o \
|
||||||
$(COREPATH)/gw_utils.o $(COREPATH)/buffer.o $(COREPATH)/poll.o \
|
$(COREPATH)/gw_utils.o $(COREPATH)/buffer.o $(COREPATH)/poll.o \
|
||||||
$(COREPATH)/spinlock.o $(COREPATH)/gwbitmask.o $(COREPATH)/session.o \
|
$(COREPATH)/spinlock.o $(COREPATH)/gwbitmask.o $(COREPATH)/session.o \
|
||||||
$(COREPATH)/atomic.o $(COREPATH)/hashtable.o $(COREPATH)/filter.o $(COREPATH)/modutil.o $(ROOT_PATH)/server/inih/ini.o \
|
$(COREPATH)/atomic.o $(COREPATH)/hashtable.o $(COREPATH)/filter.o $(COREPATH)/modutil.o $(ROOT_PATH)/server/inih/ini.o \
|
||||||
$(COREPATH)/hint.o
|
$(COREPATH)/hint.o $(COREPATH)/config.o $(COREPATH)/service.o $(COREPATH)/server.o $(COREPATH)/monitor.o $(COREPATH)/housekeeper.o $(COREPATH)/adminusers.o $(COREPATH)/dbusers.o $(COREPATH)/thread.o $(COREPATH)/users.o $(COREPATH)/secrets.o
|
||||||
LIBS= $(UTILSPATH)/skygw_utils.o -lssl -pthread -llog_manager -lmysqld -ldl -lcrypto
|
LIBS= $(UTILSPATH)/skygw_utils.o -lssl -pthread -llog_manager -lmysqld -ldl -lcrypto -lcrypt -lm
|
||||||
MODULES := $(wildcard ../*.so)
|
MODULES := $(wildcard ../*.so)
|
||||||
|
|
||||||
all: build
|
all: build
|
||||||
|
|||||||
@ -75,9 +75,9 @@
|
|||||||
*/
|
*/
|
||||||
typedef struct CONFIG_ITEM_T
|
typedef struct CONFIG_ITEM_T
|
||||||
{
|
{
|
||||||
char* name;
|
char* name;
|
||||||
char* value;
|
char* value;
|
||||||
struct CONFIG_ITEM_T* next;
|
struct CONFIG_ITEM_T* next;
|
||||||
}CONFIG_ITEM;
|
}CONFIG_ITEM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -86,9 +86,9 @@ typedef struct CONFIG_ITEM_T
|
|||||||
*/
|
*/
|
||||||
typedef struct CONFIG_T
|
typedef struct CONFIG_T
|
||||||
{
|
{
|
||||||
char* section;
|
char* section;
|
||||||
CONFIG_ITEM* item;
|
CONFIG_ITEM* item;
|
||||||
struct CONFIG_T* next;
|
struct CONFIG_T* next;
|
||||||
|
|
||||||
}CONFIG;
|
}CONFIG;
|
||||||
|
|
||||||
@ -98,13 +98,13 @@ typedef struct CONFIG_T
|
|||||||
*/
|
*/
|
||||||
struct FILTERCHAIN_T
|
struct FILTERCHAIN_T
|
||||||
{
|
{
|
||||||
FILTER* filter; /**An instance of a particular filter*/
|
FILTER* filter; /**An instance of a particular filter*/
|
||||||
FILTER_OBJECT* instance; /**Dynamically loaded module*/
|
FILTER_OBJECT* instance; /**Dynamically loaded module*/
|
||||||
SESSION** session; /**A list of sessions*/
|
SESSION** session; /**A list of sessions*/
|
||||||
DOWNSTREAM** down; /** A list of next filters downstreams*/
|
DOWNSTREAM** down; /** A list of next filters downstreams*/
|
||||||
UPSTREAM** up; /** A list of next filters upstreams*/
|
UPSTREAM** up; /** A list of next filters upstreams*/
|
||||||
char* name; /**Module name*/
|
char* name; /**Module name*/
|
||||||
struct FILTERCHAIN_T* next;
|
struct FILTERCHAIN_T* next;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct FILTERCHAIN_T FILTERCHAIN;
|
typedef struct FILTERCHAIN_T FILTERCHAIN;
|
||||||
@ -114,27 +114,29 @@ typedef struct FILTERCHAIN_T FILTERCHAIN;
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int running;
|
int running;
|
||||||
int verbose; /**Whether to print to stdout*/
|
int verbose; /**Whether to print to stdout*/
|
||||||
int infile; /**A file where the queries are loaded from*/
|
int infile; /**A file where the queries are loaded from*/
|
||||||
char* infile_name;
|
int error;
|
||||||
int outfile; /**A file where the output of the filters is logged*/
|
char* mod_dir; /**Module directory absolute path*/
|
||||||
char* outfile_name;
|
char* infile_name;
|
||||||
FILTERCHAIN* head; /**The head of the filter chain*/
|
int outfile; /**A file where the output of the filters is logged*/
|
||||||
FILTERCHAIN* tail; /**The tail of the filter chain*/
|
char* outfile_name;
|
||||||
GWBUF** buffer; /**Buffers that are fed to the filter chain*/
|
FILTERCHAIN* head; /**The head of the filter chain*/
|
||||||
int buffer_count;
|
FILTERCHAIN* tail; /**The tail of the filter chain*/
|
||||||
int session_count;
|
GWBUF** buffer; /**Buffers that are fed to the filter chain*/
|
||||||
DOWNSTREAM dummyrouter; /**Dummy downstream router for data extraction*/
|
int buffer_count;
|
||||||
UPSTREAM dummyclient; /**Dummy downstream router for data extraction*/
|
int session_count;
|
||||||
CONFIG* conf; /**Configurations loaded from a file*/
|
DOWNSTREAM dummyrouter; /**Dummy downstream router for data extraction*/
|
||||||
pthread_mutex_t work_mtx; /**Mutex for buffer routing*/
|
UPSTREAM dummyclient; /**Dummy downstream router for data extraction*/
|
||||||
int buff_ind; /**Index of first unrouted buffer*/
|
CONFIG* conf; /**Configurations loaded from a file*/
|
||||||
int sess_ind;/**Index of first unused session*/
|
pthread_mutex_t work_mtx; /**Mutex for buffer routing*/
|
||||||
int last_ind; /**Index of last used session*/
|
int buff_ind; /**Index of first unrouted buffer*/
|
||||||
pthread_t* thrpool;
|
int sess_ind;/**Index of first unused session*/
|
||||||
int thrcount; /**Number of active threads*/
|
int last_ind; /**Index of last used session*/
|
||||||
int rt_delay; /**Delay each thread waits after routing a query, in milliseconds*/
|
pthread_t* thrpool;
|
||||||
|
int thrcount; /**Number of active threads*/
|
||||||
|
int rt_delay; /**Delay each thread waits after routing a query, in milliseconds*/
|
||||||
}HARNESS_INSTANCE;
|
}HARNESS_INSTANCE;
|
||||||
|
|
||||||
static HARNESS_INSTANCE instance;
|
static HARNESS_INSTANCE instance;
|
||||||
@ -144,33 +146,33 @@ static HARNESS_INSTANCE instance;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
UNDEFINED,
|
UNDEFINED,
|
||||||
RUNFILTERS,
|
RUNFILTERS,
|
||||||
LOAD_FILTER,
|
LOAD_FILTER,
|
||||||
DELETE_FILTER,
|
DELETE_FILTER,
|
||||||
LOAD_CONFIG,
|
LOAD_CONFIG,
|
||||||
SET_INFILE,
|
SET_INFILE,
|
||||||
SET_OUTFILE,
|
SET_OUTFILE,
|
||||||
THR_COUNT,
|
THR_COUNT,
|
||||||
SESS_COUNT,
|
SESS_COUNT,
|
||||||
OK,
|
OK,
|
||||||
QUIT
|
QUIT
|
||||||
} operation_t;
|
} operation_t;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
PACKET_OK,
|
PACKET_OK,
|
||||||
PACKET_ERROR,
|
PACKET_ERROR,
|
||||||
PACKET_RESULT_SET
|
PACKET_RESULT_SET
|
||||||
} packet_t;
|
} packet_t;
|
||||||
|
|
||||||
typedef packet_t PACKET;
|
typedef packet_t PACKET;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the static instance.
|
* Initialize the static instance.
|
||||||
*/
|
*/
|
||||||
int init(int argc,char** argv);
|
int harness_init(int argc,char** argv);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Frees all the query buffers
|
* Frees all the query buffers
|
||||||
@ -257,7 +259,7 @@ int load_query();
|
|||||||
* @return Non-zero on success, zero in case parsing is finished.
|
* @return Non-zero on success, zero in case parsing is finished.
|
||||||
* @see load_config()
|
* @see load_config()
|
||||||
*/
|
*/
|
||||||
static int handler(void* user, const char* section, const char* name,const char* value);
|
int handler(void* user, const char* section, const char* name,const char* value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all non-filter modules from the configuration
|
* Removes all non-filter modules from the configuration
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include <harness.h>
|
#include <harness.h>
|
||||||
|
|
||||||
int harness_init(int argc, char** argv){
|
int harness_init(int argc, char** argv){
|
||||||
|
int i = 0;
|
||||||
if(!(argc == 2 && strcmp(argv[1],"-h") == 0)){
|
if(!(argc == 2 && strcmp(argv[1],"-h") == 0)){
|
||||||
skygw_logmanager_init(0,NULL);
|
skygw_logmanager_init(0,NULL);
|
||||||
}
|
}
|
||||||
@ -36,8 +36,6 @@ int harness_init(int argc, char** argv){
|
|||||||
pthread_create(&instance.thrpool[i],NULL,(void*)work_buffer,(void*)thr_num++);
|
pthread_create(&instance.thrpool[i],NULL,(void*)work_buffer,(void*)thr_num++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,7 +370,7 @@ int load_query()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int handler(void* user, const char* section, const char* name,
|
int handler(void* user, const char* section, const char* name,
|
||||||
const char* value)
|
const char* value)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -509,7 +507,18 @@ int load_config( char* fname)
|
|||||||
|
|
||||||
if(!strcmp("module",item->name)){
|
if(!strcmp("module",item->name)){
|
||||||
|
|
||||||
instance.head = load_filter_module(item->value);
|
if(instance.mod_dir){
|
||||||
|
char* modstr = malloc(sizeof(char)*(strlen(instance.mod_dir) + strlen(item->value)));
|
||||||
|
strcpy(modstr,instance.mod_dir);
|
||||||
|
strcat(modstr,"/");
|
||||||
|
strcat(modstr,item->value);
|
||||||
|
instance.head = load_filter_module(modstr);
|
||||||
|
free(modstr);
|
||||||
|
}else{
|
||||||
|
instance.head = load_filter_module(item->value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!instance.head || !load_filter(instance.head,instance.conf)){
|
if(!instance.head || !load_filter(instance.head,instance.conf)){
|
||||||
|
|
||||||
printf("Error creating filter instance!\nModule: %s\n",item->value);
|
printf("Error creating filter instance!\nModule: %s\n",item->value);
|
||||||
@ -916,7 +925,7 @@ int process_opts(int argc, char** argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
char* conf_name = NULL;
|
char* conf_name = NULL;
|
||||||
while((rd = getopt(argc,argv,"c:i:o:s:t:d:qh")) > 0){
|
while((rd = getopt(argc,argv,"m:c:i:o:s:t:d:qh")) > 0){
|
||||||
switch(rd){
|
switch(rd){
|
||||||
|
|
||||||
case 'o':
|
case 'o':
|
||||||
@ -968,6 +977,11 @@ int process_opts(int argc, char** argv)
|
|||||||
"\t-d\tRouting delay\n");
|
"\t-d\tRouting delay\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'm':
|
||||||
|
instance.mod_dir = strdup(optarg);
|
||||||
|
printf("Module directory: %s",optarg);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -188,7 +188,7 @@ int main(int argc, char** argv){
|
|||||||
}
|
}
|
||||||
|
|
||||||
instance.thrpool = t_thr_pool;
|
instance.thrpool = t_thr_pool;
|
||||||
thr_num = 1;
|
int thr_num = 1;
|
||||||
|
|
||||||
for(i = 0;i<instance.thrcount;i++){
|
for(i = 0;i<instance.thrcount;i++){
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#include <harness.h>
|
#include <harness.h>
|
||||||
int main()
|
int main(int argc,char** argv)
|
||||||
{
|
{
|
||||||
if(harness_init(argc,argv)){
|
if(harness_init(argc,argv) || instance.error){
|
||||||
printf("Error: Initialization failed.\n");
|
printf("Error: Initialization failed.\n");
|
||||||
skygw_log_write(LOGFILE_ERROR,"Error: Initialization failed.\n");
|
skygw_log_write(LOGFILE_ERROR,"Error: Initialization failed.\n");
|
||||||
skygw_logmanager_done();
|
skygw_logmanager_done();
|
||||||
|
|||||||
Reference in New Issue
Block a user