Author: kpvdr
Date: 2007-09-04 16:37:27 -0400 (Tue, 04 Sep 2007)
New Revision: 904
Modified:
store/trunk/cpp/tests/jrnl/Makefile.rtest
store/trunk/cpp/tests/jrnl/jtest.cpp
store/trunk/cpp/tests/jrnl/msg_consumer.cpp
store/trunk/cpp/tests/jrnl/msg_producer.cpp
store/trunk/cpp/tests/jrnl/rtest
Log:
Fixed manual makefile tests/jrnl/Makefile.rtest; found and fixed double-delete bug
introduced into msg_producer and msg_consumer
Modified: store/trunk/cpp/tests/jrnl/Makefile.rtest
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-08-31 17:03:31 UTC (rev 903)
+++ store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-09-04 20:37:27 UTC (rev 904)
@@ -1,181 +1,78 @@
-# RHM_DEFINES
-# The following defines are usable during the build of rhmj:
-# RHM_CLEAN: Writes 0x00 to all unused disk space bytes. This makes debugging easier,
-# but the memcpy required incurs a performance penalty. Do not use for
-# production or performance checks.
-# RHM_TESTVALS: Uses special values (e.g. RIDs starting at 0xffeeddcc00000000 rather than
0)
-# for testing purposes, or to expose special test conditions.
-# RHM_JOWRITE: Defeats the relocation of previous journal files into a subdir, makes
-# the execution quicker provided the files are of the same size as
previous
-# run. If the files are not present, they will be created.
-# RHM_WRONLY: Defeats the test which check that a journal file has been read before it
-# overwritten. NOTE: ONLY USE FOR PERFORMANCE TESTS!
-# RHM_RDONLY: Defeats the test which check that a journal file has been written before
it
-# read. Use together with RHM_JOWRITE if test reads from previously
written
-# journal. Ensure journal contains valid entries in all files. NOTE: ONLY
USE
-# FOR PERFORMANCE TESTS!
-# Prefix each define with -D. (eg RHM_DEFINES = -DRHM_JOWRITE -DRHM_WRONLY)
-#RHM_DEFINES = -DRHM_WRONLY
-#RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY
-#RHM_DEFINES = -DRHM_CLEAN -DRHM_WRONLY
-#RHM_DEFINES = -DRHM_CLEAN
-#RHM_DEFINES = -DRHM_TESTVALS
+SHELL = /bin/bash
+.SUFFIXES:
+.SUFFIXES: .cpp .o
+
RHM_JRNL_SRC_DIR = ../../lib/jrnl
-RHM_JRNL_OBJ_DIR = .lib
-RHM_TEST_SRC_DIR = test
-RHM_TEST_OBJ_DIR = .lib
-#RHM_DOC_DIR = ../../docs
-#RHM_JOURNAL_DIR = jdata
-#
-CXXINCLUDES = \
- -I. -I../../lib
-JRNL_OBJFILES = \
- $(RHM_JRNL_OBJ_DIR)/jexception.o \
- $(RHM_JRNL_OBJ_DIR)/jerrno.o \
- $(RHM_JRNL_OBJ_DIR)/jinf.o \
- $(RHM_JRNL_OBJ_DIR)/enq_map.o \
- $(RHM_JRNL_OBJ_DIR)/jdir.o \
- $(RHM_JRNL_OBJ_DIR)/data_tok.o \
- $(RHM_JRNL_OBJ_DIR)/file_hdr.o \
- $(RHM_JRNL_OBJ_DIR)/jrec.o \
- $(RHM_JRNL_OBJ_DIR)/data_rec.o \
- $(RHM_JRNL_OBJ_DIR)/nlfh.o \
- $(RHM_JRNL_OBJ_DIR)/lfh.o \
- $(RHM_JRNL_OBJ_DIR)/rrfc.o \
- $(RHM_JRNL_OBJ_DIR)/wrfc.o \
- $(RHM_JRNL_OBJ_DIR)/pmgr.o \
- $(RHM_JRNL_OBJ_DIR)/rmgr.o \
- $(RHM_JRNL_OBJ_DIR)/wmgr.o \
- $(RHM_JRNL_OBJ_DIR)/jcntl.o \
+VPATH = $(RHM_JRNL_SRC_DIR)
+JRNL_OBJ_FILES = \
+ jexception.o \
+ jerrno.o \
+ jinf.o \
+ enq_map.o \
+ jdir.o \
+ data_tok.o \
+ file_hdr.o \
+ jrec.o \
+ data_rec.o \
+ nlfh.o \
+ lfh.o \
+ rrfc.o \
+ wrfc.o \
+ pmgr.o \
+ rmgr.o \
+ wmgr.o \
+ jcntl.o \
+
JTEST_OBJ_FILES = \
- $(RHM_TEST_OBJ_DIR)/jtest.o \
- $(RHM_TEST_OBJ_DIR)/msg_producer.o \
- $(RHM_TEST_OBJ_DIR)/msg_consumer.o \
+ msg_producer.o \
+ msg_consumer.o \
-JTEST_FILES = \
- jtest \
+JTEST_FILES = jtest
-#CC = gcc
CXX = g++
-CXXDEBUGFLAGS = -g -O0
-#CXXFLAGS = $(RHM_DEFINES) -Wall -Wextra -Werror -pedantic -O3 -pthread $(CXXINCLUDES)
-CXXFLAGS = $(RHM_DEFINES) -Wall -Wextra -Werror -pedantic -ggdb -O0 -pthread
$(CXXINCLUDES)
+CXXINCLUDES = -I. -I../../lib
+CXXFLAGS = $(RHM_DEFINES) -Wall -Wextra -Werror -Wno-shadow -Wpointer-arith -Wcast-qual
-Wcast-align -Wno-long-long -Wvolatile-register-var -Winvalid-pch -Wno-system-headers
-pedantic -ggdb -O0 -pthread $(CXXINCLUDES)
LDFLAGS = -lpthread -laio -lrt
-LDLIBS =
-RM = rm -f
-RMDIRS = rm -rf
-
-# These targets are not actual files, only conventient names
.PHONY: jrtest jwtest jrwtest
-# Default build operation
default: jtest
-## Default clean operation
-#clean: clean-jtest clean-jmgmt clean-jrnl clean-core-files
+help:
+ @echo "The following make options are available: (* is default)"
+ @echo " *jtest: Make the journal test suite"
+ @echo " jrtest: Make the journal test suite for read tests"
+ @echo " jwtest: Make the journal test suite for write tests"
+ @echo " jrwtest: Make the journal test suite for simultaneous write/read
tests"
+ @echo " check: Run complete regression test suite; compiles with special
flags"
+ @echo " clean: Clean build"
+ @echo " clean-data: Clean journal data files"
+ @echo " clean-all: Clean build and journal data files"
-#all: jrnl jmgmt jtest aiotest docs test
+# Build all journal and test object files, produces jtest executable
+jtest: $(JRNL_OBJ_FILES) $(JTEST_OBJ_FILES)
-#clean-all: clean-jtest clean-jmgmt clean-jrnl clean-docs clean-jdata clean-core-files
+jrtest: RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY -DRHM_TESTVALS
+jrtest: $(JTEST_FILES)
-## Print make options
-#help:
-# @echo "The following make options are available: (* is default)"
-# @echo " Make operations: "
-# @echo " all: Make everything"
-# @echo " help: This message"
-# @echo " *jtest: Make the journal test suite"
-# @echo " jrtest: Make the journal test suite for read tests"
-# @echo " jwtest: Make the journal test suite for write tests"
-# @echo " jmgmt: Make the jouranl management utils"
-# @echo " jrnl: Build the journal library"
-# @echo " docs: Make the doxygen docs"
-# @echo " test: Run regression test suite"
-# @echo " Clean operations: "
-# @echo " clean: Clean most things (not docs or journal data)"
-# @echo " clean-all: Blow it *all* away!"
-# @echo " clean-jtest: Clean journal tests and test support files"
-# @echo " clean-jmgmt: Clean management utils"
-# @echo " clean-jrnl: Clean journal object files"
-# @echo " clean-docs: Blow the docs dir away"
-# @echo " clean-jdata: Clear all jouranl data files"
-#
-## Run regression test script
-#test: jtest #ref
-# @./rtest
-#
-#ref: $(RHM_TESTREF_DIR)
-#
-#$(RHM_TESTREF_DIR): $(RHM_TESTREF_TAR)
-# @tar -C $(RHM_TEST_SRC_DIR) -xzf $(RHM_TESTREF_TAR)
-#
-## Build all journal and test object files, produces jtest executable
-#jtest: $(JTEST_FILES)
-
-#jrtest: RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY -DRHM_TESTVALS
-#jrtest: $(JTEST_FILES)
-
jwtest: RHM_DEFINES = -DRHM_CLEAN -DRHM_WRONLY -DRHM_TESTVALS
jwtest: $(JTEST_FILES)
-#jrwtest: RHM_DEFINES = -DRHM_CLEAN -DRHM_TESTVALS
-#jrwtest: $(JTEST_FILES)
+jrwtest: RHM_DEFINES = -DRHM_CLEAN -DRHM_TESTVALS
+jrwtest: $(JTEST_FILES)
-$(JTEST_FILES): $(JRNL_OBJFILES) $(JTEST_OBJ_FILES)
+check:
+ @./rtest
-#$(JRNL_OBJFILES): $(RHM_JRNL_SRC_DIR)/$(*F)
+clean:
+ @rm -f *.o
+ @rm -f jtest
-#$(JTEST_OBJ_FILES): $(RHM_TEST_SRC_DIR)/$(*F)
+clean-data:
+ @rm -rf jdata
+ @rm -rf rd_test_jrnls
-## Clean all journal test executables and build artifacts
-#clean-jtest:
-# @-$(RM) $(RHM_TEST_SRC_DIR)/*~
-# @-$(RM) $(JTEST_OBJ_FILES)
-# @-$(RM) $(JTEST_FILES)
-# @-$(RMDIRS) $(RHM_TESTRES_DIR)
-## @-$(RMDIRS) $(RHM_TESTREF_DIR)
-#
-## Build management utilities
-#jmgmt: $(MGMT_FILES)
-#
-#$(MGMT_FILES): $(JRNL_OBJFILES) $(MGMT_OBJ_FILES)
-#
-## Clean up all management utility build and edit artifacts
-#clean-jmgmt:
-# @-$(RM) $(RHM_MGMT_SRC_DIR)/*~
-# @-$(RM) $(MGMT_OBJ_FILES)
-# @-$(RM) $(MGMT_FILES)
-#
-## Builds just the journal object files. No executable is produced
-#jrnl: $(JRNL_OBJFILES)
-#
-## Clean up all journal build and edit artifacts
-#clean-jrnl:
-# @-$(RM) $(RHM_JRNL_SRC_DIR)/*~
-# @-$(RM) $(JRNL_OBJFILES)
-#
-## Build all Doxygen docs, produce a pdf and ps file from the latex output
-#docs:
-# @mkdir -p $(RHM_DOC_DIR)
-# @doxygen test_tmpl.dox
-# @make -C $(RHM_DOC_DIR)/latex
-# @cd $(RHM_DOC_DIR)/latex; dvipdf refman.dvi refman.pdf
-# @cd $(RHM_DOC_DIR)/latex; dvips refman.dvi -o refman.ps
-#
-## Clean up all Doxygen docs located in $(RHM_DOC_DIR)
-#clean-docs:
-# @-$(RMDIRS) $(RHM_DOC_DIR)
-#
-## Clean up journal artifacts located in $(RHM_JOURNAL_DIR)
-#clean-jdata:
-# @-$(RMDIRS) $(RHM_JOURNAL_DIR)
-# @-$(RMDIRS) $(RHM_RTEST_DIR)
-#
-## Find and remove any core files lying around
-#clean-core-files:
-# @-$(RM) core*
-# @-$(RM) vgcore*
+clean-all: clean clean-data
Modified: store/trunk/cpp/tests/jrnl/jtest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp 2007-08-31 17:03:31 UTC (rev 903)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-09-04 20:37:27 UTC (rev 904)
@@ -123,8 +123,12 @@
p_args = new msg_producer::_p_args(_jc, ta._num_msgs, ta._min_msg_size,
ta._max_msg_size,
ta._auto_deq);
c_args = new msg_consumer::_c_args(_jc, ta._num_msgs, ta._min_msg_size,
ta._max_msg_size);
+#ifndef RHM_RDONLY
_mp.initialize(p_args);
+#endif
+#ifndef RHM_WRONLY
_mc.initialize(c_args);
+#endif
_jc.initialize(&_mc.aio_dtokl(), NULL, &_mp.aio_dtokl(), &mp_aio_cb);
// gettimeofday(_end_time, _tz_ptr);
@@ -350,6 +354,9 @@
#ifdef RHM_CLEAN
cout << "*** WARNING: Compiled with RHM_CLEAN defined." <<
endl;
#endif
+#ifdef RHM_TESTVALS
+ cout << "*** WARNING: Compiled with RHM_TESTVALS defined." <<
endl;
+#endif
#ifdef RHM_JOWRITE
cout << "*** WARNING: Compiled with RHM_JOWRITE defined." <<
endl;
#endif
@@ -359,7 +366,7 @@
#ifdef RHM_RDONLY
cout << "*** WARNING: Compiled with RHM_RDONLY defined." <<
endl;
#endif
-#if defined(RHM_CLEAN) || defined(RHM_JOWRITE) || defined(RHM_WRONLY) ||
defined(RHM_RDONLY )
+#if defined(RHM_CLEAN) || defined(RHM_TESTVALS) || defined(RHM_JOWRITE) ||
defined(RHM_WRONLY) || defined(RHM_RDONLY)
cout << endl;
#endif
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-08-31 17:03:31 UTC (rev 903)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-09-04 20:37:27 UTC (rev 904)
@@ -55,10 +55,13 @@
msg_consumer::~msg_consumer()
{
- for (u_int32_t i=0; i<_num_msgs; i++)
+ for (u_int32_t i=0; i<_dtok_master_list.size(); i++)
{
- delete _dtok_master_list[i];
- _dtok_master_list[i] = NULL;
+ if (_dtok_master_list[i])
+ {
+ delete _dtok_master_list[i];
+ _dtok_master_list[i] = NULL;
+ }
}
instCnt--;
}
@@ -91,8 +94,11 @@
_aio_cmpl_dtok_list.clear();
for (u_int32_t i=0; i<_dtok_master_list.size(); i++)
{
- delete _dtok_master_list[i];
- _dtok_master_list[i] = NULL;
+ if (_dtok_master_list[i])
+ {
+ delete _dtok_master_list[i];
+ _dtok_master_list[i] = NULL;
+ }
}
_dtok_master_list.clear();
}
Modified: store/trunk/cpp/tests/jrnl/msg_producer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-08-31 17:03:31 UTC (rev 903)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-09-04 20:37:27 UTC (rev 904)
@@ -63,11 +63,15 @@
msg_producer::~msg_producer()
{
- for (u_int32_t i=0; i<_num_msgs; i++)
+ for (u_int32_t i=0; i<_dtok_master_list.size(); i++)
{
- delete _dtok_master_list[i];
- _dtok_master_list[i] = NULL;
+ if (_dtok_master_list[i])
+ {
+ delete _dtok_master_list[i];
+ _dtok_master_list[i] = NULL;
+ }
}
+ _dtok_master_list.clear();
instance_cnt--;
}
@@ -100,8 +104,11 @@
_dd_dtok_list.clear();
for (u_int32_t i=0; i<_dtok_master_list.size(); i++)
{
- delete _dtok_master_list[i];
- _dtok_master_list[i] = NULL;
+ if (_dtok_master_list[i])
+ {
+ delete _dtok_master_list[i];
+ _dtok_master_list[i] = NULL;
+ }
}
_dtok_master_list.clear();
}
Modified: store/trunk/cpp/tests/jrnl/rtest
===================================================================
--- store/trunk/cpp/tests/jrnl/rtest 2007-08-31 17:03:31 UTC (rev 903)
+++ store/trunk/cpp/tests/jrnl/rtest 2007-09-04 20:37:27 UTC (rev 904)
@@ -22,8 +22,7 @@
# The GNU Lesser General Public License is available in the file COPYING.
JDATA_DIR=jdata
-TEST_DIR=test
-TAR_DIR=${TEST_DIR}/rd_test_jrnls
+TAR_DIR=rd_test_jrnls
NULL_FILE=/dev/null
TEMP_T_FILE=/tmp/t.txt
TEMP_C_FILE=/tmp/c.txt
@@ -34,21 +33,21 @@
# Write test
W_DO_TEST=T
-W_TEST_FILE=${TEST_DIR}/wtests.csv
+W_TEST_FILE=wtests.csv
W_TEST_START=0
W_TEST_STOP=81
W_NITER=5
# Read test
R_DO_TEST=T
-R_TEST_FILE=${TEST_DIR}/rtests.csv
+R_TEST_FILE=rtests.csv
R_TEST_START=0
R_TEST_STOP=45
R_NITER=5
# Read-Write test
RW_DO_TEST=T
-RW_TEST_FILE=${TEST_DIR}/rwtests.csv
+RW_TEST_FILE=rwtests.csv
RW_TEST_START=0
RW_TEST_STOP=1
RW_NITER=1
@@ -56,9 +55,9 @@
RM=rm
RM_DIR="${RM} -rf"
TEST_PROG="./jtest"
-CHK_PROG="./test/ftest.py"
+CHK_PROG="./ftest.py"
VALGRIND="valgrind -q --track-fds=yes --leak-check=full --leak-resolution=high
--show-reachable=yes --suppressions=/usr/lib/valgrind/glibc-2.5.supp"
-MAKE="make"
+MAKE="make -f Makefile.rtest"
function usage
@@ -403,7 +402,7 @@
echo -n "Creating test journal archives: "
for (( f=${test_start}; f<=${test_stop}; f++ )); do
- ${MAKE} clean-jdata
+ ${MAKE} clean-data
run_test jrtest $f 0 ${test_file}
local ret=$?
if (( ${ret} != 0 )); then
Show replies by date