tests for log manager write order
This commit is contained in:
@ -45,6 +45,9 @@
|
|||||||
extern char *program_invocation_name;
|
extern char *program_invocation_name;
|
||||||
extern char *program_invocation_short_name;
|
extern char *program_invocation_short_name;
|
||||||
|
|
||||||
|
#if defined(SS_DEBUG)
|
||||||
|
static long write_index;
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* Variable holding the enabled logfiles information.
|
* Variable holding the enabled logfiles information.
|
||||||
* Used from log users to check enabled logs prior calling
|
* Used from log users to check enabled logs prior calling
|
||||||
@ -333,6 +336,7 @@ static bool logmanager_init_nomutex(
|
|||||||
#if defined(SS_DEBUG)
|
#if defined(SS_DEBUG)
|
||||||
lm->lm_chk_top = CHK_NUM_LOGMANAGER;
|
lm->lm_chk_top = CHK_NUM_LOGMANAGER;
|
||||||
lm->lm_chk_tail = CHK_NUM_LOGMANAGER;
|
lm->lm_chk_tail = CHK_NUM_LOGMANAGER;
|
||||||
|
write_index = 0;
|
||||||
#endif
|
#endif
|
||||||
lm->lm_clientmes = skygw_message_init();
|
lm->lm_clientmes = skygw_message_init();
|
||||||
lm->lm_logmes = skygw_message_init();
|
lm->lm_logmes = skygw_message_init();
|
||||||
@ -2374,7 +2378,14 @@ static void* thr_filewriter_fun(
|
|||||||
&bb->bb_mutex,
|
&bb->bb_mutex,
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
#if defined (SS_DEBUG)
|
||||||
|
if(bb->bb_buf_used > 0 && bb->bb_buf_size > 0){
|
||||||
|
char tmpstr[512];
|
||||||
|
sprintf(tmpstr,"filewrite:%lu\n",write_index++);
|
||||||
|
memcpy(bb->bb_buf,tmpstr,strlen(tmpstr)-1);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
skygw_file_write(file,
|
skygw_file_write(file,
|
||||||
(void *)bb->bb_buf,
|
(void *)bb->bb_buf,
|
||||||
bb->bb_buf_used,
|
bb->bb_buf_used,
|
||||||
|
@ -29,6 +29,7 @@ testall:
|
|||||||
cleantests:
|
cleantests:
|
||||||
- $(DEL) *.o
|
- $(DEL) *.o
|
||||||
- $(DEL) testlog
|
- $(DEL) testlog
|
||||||
|
- $(DEL) testorder
|
||||||
- $(DEL) *~
|
- $(DEL) *~
|
||||||
|
|
||||||
buildtests:
|
buildtests:
|
||||||
@ -41,6 +42,17 @@ buildtests:
|
|||||||
-I$(LOG_MANAGER_PATH) -I$(UTILS_PATH) testlog.c \
|
-I$(LOG_MANAGER_PATH) -I$(UTILS_PATH) testlog.c \
|
||||||
-lstdc++ -llog_manager $(LDLIBS) \
|
-lstdc++ -llog_manager $(LDLIBS) \
|
||||||
$(UTILS_PATH)/skygw_utils.o
|
$(UTILS_PATH)/skygw_utils.o
|
||||||
|
$(CC) $(CFLAGS) \
|
||||||
|
-L$(LOG_MANAGER_PATH) \
|
||||||
|
-Wl,-rpath,$(DEST)/lib \
|
||||||
|
-Wl,-rpath,$(LOG_MANAGER_PATH)/ \
|
||||||
|
-o testorder \
|
||||||
|
-I$(MARIADB_SRC_PATH)/include \
|
||||||
|
-I$(LOG_MANAGER_PATH) -I$(UTILS_PATH) testorder.c \
|
||||||
|
-lstdc++ -llog_manager $(LDLIBS) \
|
||||||
|
$(UTILS_PATH)/skygw_utils.o
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
runtests:
|
runtests:
|
||||||
|
85
log_manager/test/testorder.c
Normal file
85
log_manager/test/testorder.c
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* This file is distributed as part of the SkySQL Gateway. It is free
|
||||||
|
* software: you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation,
|
||||||
|
* version 2.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
* details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with
|
||||||
|
* this program; if not, write to the Free Software Foundation, Inc., 51
|
||||||
|
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Copyright SkySQL Ab 2013
|
||||||
|
*/
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <skygw_utils.h>
|
||||||
|
#include <log_manager.h>
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
int iterations = 0, i, interval = 10;
|
||||||
|
int succp = 0, err = 0;
|
||||||
|
char cwd[1024];
|
||||||
|
char tmp[2048];
|
||||||
|
char message[1024];
|
||||||
|
char** optstr;
|
||||||
|
long msg_index = 1;
|
||||||
|
|
||||||
|
|
||||||
|
memset(cwd,0,1024);
|
||||||
|
if( argc <3 ||
|
||||||
|
getcwd(cwd,sizeof(cwd)) == NULL ||
|
||||||
|
(optstr = malloc(sizeof(char*)*4)) == NULL){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(tmp,0,1024);
|
||||||
|
|
||||||
|
sprintf(tmp,"%s",cwd);
|
||||||
|
optstr[0] = strdup("log_manager");
|
||||||
|
optstr[1] = strdup("-j");
|
||||||
|
optstr[2] = strdup(tmp);
|
||||||
|
optstr[3] = NULL;
|
||||||
|
|
||||||
|
iterations = atoi(argv[1]);
|
||||||
|
interval = atoi(argv[2]);
|
||||||
|
|
||||||
|
succp = skygw_logmanager_init( 3, optstr);
|
||||||
|
ss_dassert(succp);
|
||||||
|
|
||||||
|
skygw_log_disable(LOGFILE_TRACE);
|
||||||
|
skygw_log_disable(LOGFILE_MESSAGE);
|
||||||
|
skygw_log_disable(LOGFILE_DEBUG);
|
||||||
|
|
||||||
|
for(i = 0;i<iterations;i++){
|
||||||
|
|
||||||
|
memset(message,' ',1024);
|
||||||
|
sprintf(message,"message:%ld",msg_index++);
|
||||||
|
message[1023] = '\0';
|
||||||
|
|
||||||
|
if(i % interval == 0){
|
||||||
|
err = skygw_log_write_flush(LOGFILE_ERROR, message);
|
||||||
|
}else{
|
||||||
|
err = skygw_log_write(LOGFILE_ERROR, message);
|
||||||
|
}
|
||||||
|
if(err){
|
||||||
|
fprintf(stderr,"Error: log_manager returned %d",err);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
skygw_logmanager_done();
|
||||||
|
free(optstr[0]);
|
||||||
|
free(optstr[1]);
|
||||||
|
free(optstr[2]);
|
||||||
|
free(optstr[3]);
|
||||||
|
free(optstr);
|
||||||
|
return 0;
|
||||||
|
}
|
Reference in New Issue
Block a user