Author: kpvdr
Date: 2007-08-30 14:26:06 -0400 (Thu, 30 Aug 2007)
New Revision: 900
Modified:
store/trunk/cpp/tests/jrnl/
store/trunk/cpp/tests/jrnl/JournalTest.cpp
store/trunk/cpp/tests/jrnl/Makefile.am
store/trunk/cpp/tests/jrnl/Makefile.rtest
store/trunk/cpp/tests/jrnl/jtest.cpp
store/trunk/cpp/tests/jrnl/jtest.hpp
store/trunk/cpp/tests/setup
Log:
Added jtest methods to directly input test parameters (in addition to csv file),
implemented in JournalTest thus removing need for absolute path. Also solved rpm packaging
issue.
Property changes on: store/trunk/cpp/tests/jrnl
___________________________________________________________________
Name: svn:ignore
+ .deps
.libs
Makefile
Makefile.in
jtest
Modified: store/trunk/cpp/tests/jrnl/JournalTest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-08-30 18:26:06 UTC (rev 900)
@@ -34,19 +34,18 @@
#include "msg_consumer.hpp"
#include "jtest.hpp"
-#define JTEST_CSV_FILE "/home/kpvdr/store/cpp/tests/jrnl/rwtests.csv"
-
class JournalTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(JournalTest);
- CPPUNIT_TEST(SingleMsgReadWrite);
+ CPPUNIT_TEST(Test_001);
CPPUNIT_TEST_SUITE_END();
public:
- void SingleMsgReadWrite()
+ void Test_001()
{
- jtest t(1);
- t.initialize(JTEST_CSV_FILE);
+ jtest::targs ta(1, 10, 10, false, "Test 1");
+ jtest t;
+ t.initialize(ta);
t.run();
t.report();
t.finalize();
Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2007-08-30 18:26:06 UTC (rev 900)
@@ -4,8 +4,6 @@
INCLUDES=-I../../lib
-EXTRA_DIST = ftest.py rwtests.csv
-
TESTS = run-journal-tests
check_LTLIBRARIES = \
@@ -25,3 +23,5 @@
libdlclose_noop_la_SOURCES = ../dlclose_noop.c
libdlclose_noop_la_LDFLAGS = -module -rpath $(abs_builddir)
+
+EXTRA_DIST = $(TESTS) ftest.py
Modified: store/trunk/cpp/tests/jrnl/Makefile.rtest
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/jrnl/Makefile.rtest 2007-08-30 18:26:06 UTC (rev 900)
@@ -19,48 +19,46 @@
#RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY
#RHM_DEFINES = -DRHM_CLEAN -DRHM_WRONLY
#RHM_DEFINES = -DRHM_CLEAN
-RHM_DEFINES = -DRHM_TESTVALS
+#RHM_DEFINES = -DRHM_TESTVALS
-RHM_JRNL_SRC_DIR = jrnl
-RHM_MGMT_SRC_DIR = mgmt
+RHM_JRNL_SRC_DIR = ../../lib/jrnl
+RHM_JRNL_OBJ_DIR = .lib
RHM_TEST_SRC_DIR = test
-RHM_DOC_DIR = docs
-RHM_JOURNAL_DIR = jdata
-RHM_TESTRES_DIR = ${RHM_TEST_SRC_DIR}/res
-RHM_TESTREF_DIR = ${RHM_TEST_SRC_DIR}/ref
-RHM_TESTREF_TAR = ${RHM_TEST_SRC_DIR}/ref.tar.gz
-
+RHM_TEST_OBJ_DIR = .lib
+#RHM_DOC_DIR = ../../docs
+#RHM_JOURNAL_DIR = jdata
+#
CXXINCLUDES = \
- -I.
+ -I. -I../../lib
JRNL_OBJFILES = \
- $(RHM_JRNL_SRC_DIR)/jexception.o \
- $(RHM_JRNL_SRC_DIR)/jerrno.o \
- $(RHM_JRNL_SRC_DIR)/jinf.o \
- $(RHM_JRNL_SRC_DIR)/enq_map.o \
- $(RHM_JRNL_SRC_DIR)/jdir.o \
- $(RHM_JRNL_SRC_DIR)/data_tok.o \
- $(RHM_JRNL_SRC_DIR)/file_hdr.o \
- $(RHM_JRNL_SRC_DIR)/jrec.o \
- $(RHM_JRNL_SRC_DIR)/data_rec.o \
- $(RHM_JRNL_SRC_DIR)/nlfh.o \
- $(RHM_JRNL_SRC_DIR)/lfh.o \
- $(RHM_JRNL_SRC_DIR)/rrfc.o \
- $(RHM_JRNL_SRC_DIR)/wrfc.o \
- $(RHM_JRNL_SRC_DIR)/pmgr.o \
- $(RHM_JRNL_SRC_DIR)/rmgr.o \
- $(RHM_JRNL_SRC_DIR)/wmgr.o \
- $(RHM_JRNL_SRC_DIR)/jcntl.o \
+ $(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 \
JTEST_OBJ_FILES = \
- $(RHM_TEST_SRC_DIR)/jtest.o \
- $(RHM_TEST_SRC_DIR)/msg_producer.o \
- $(RHM_TEST_SRC_DIR)/msg_consumer.o \
+ $(RHM_TEST_OBJ_DIR)/jtest.o \
+ $(RHM_TEST_OBJ_DIR)/msg_producer.o \
+ $(RHM_TEST_OBJ_DIR)/msg_consumer.o \
JTEST_FILES = \
- $(RHM_TEST_SRC_DIR)/jtest \
+ jtest \
-CC = g++
+#CC = gcc
CXX = g++
CXXDEBUGFLAGS = -g -O0
#CXXFLAGS = $(RHM_DEFINES) -Wall -Wextra -Werror -pedantic -O3 -pthread $(CXXINCLUDES)
@@ -72,108 +70,112 @@
RMDIRS = rm -rf
# These targets are not actual files, only conventient names
-.PHONY: default clean all help clean-all clean-jtest jmgmt clean-jmgmt jrnl clean-jrnl
docs clean-docs test
+.PHONY: jrtest jwtest jrwtest
# Default build operation
default: jtest
-# Default clean operation
-clean: clean-jtest clean-jmgmt clean-jrnl clean-core-files
+## Default clean operation
+#clean: clean-jtest clean-jmgmt clean-jrnl clean-core-files
-all: jrnl jmgmt jtest aiotest docs test
+#all: jrnl jmgmt jtest aiotest docs test
-clean-all: clean-jtest clean-jmgmt clean-jrnl clean-docs clean-jdata clean-core-files
+#clean-all: clean-jtest clean-jmgmt clean-jrnl clean-docs clean-jdata clean-core-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"
+## 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)
-# Run regression test script
-test: jtest #ref
- @./rtest
+#jrtest: RHM_DEFINES = -DRHM_JOWRITE -DRHM_RDONLY -DRHM_TESTVALS
+#jrtest: $(JTEST_FILES)
-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)
-# 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)
+#$(JRNL_OBJFILES): $(RHM_JRNL_SRC_DIR)/$(*F)
-# Build management utilities
-jmgmt: $(MGMT_FILES)
+#$(JTEST_OBJ_FILES): $(RHM_TEST_SRC_DIR)/$(*F)
-$(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 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*
Modified: store/trunk/cpp/tests/jrnl/jtest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-08-30 18:26:06 UTC (rev 900)
@@ -51,8 +51,8 @@
assert(tnum >= 0);
std::cout << "Test data file: \"" << test_csv_file
<< "\"" << std::endl;
cout << "jtest: starting test " << tnum << endl;
- jtest t(tnum);
- t.initialize(test_csv_file);
+ jtest t;
+ t.initialize(tnum, test_csv_file);
t.run();
t.report();
t.finalize();
@@ -68,11 +68,27 @@
return 0;
}
-jtest::jtest(int tnum) throw (rhm::journal::jexception):
+jtest::targs::targs():
+ _num_msgs(0),
+ _min_msg_size(0),
+ _max_msg_size(0),
+ _auto_deq(false),
+ _comment(NULL)
+{}
+
+jtest::targs::targs(const u_int32_t num_msgs, const size_t min_msg_size, const size_t
max_msg_size, const bool auto_deq,
+ const char* comment):
+ _num_msgs(num_msgs),
+ _min_msg_size(min_msg_size),
+ _max_msg_size(max_msg_size),
+ _auto_deq(auto_deq),
+ _comment(comment)
+{}
+
+jtest::jtest() throw (rhm::journal::jexception):
_start_time(new timeval),
_end_time(new timeval),
- _tz_ptr(NULL),
- _tnum(tnum)
+ _tz_ptr(NULL)
{}
jtest::~jtest()
@@ -92,12 +108,18 @@
}
void
-jtest::initialize(const char* test_csv_file) throw (rhm::journal::jexception)
+jtest::initialize(const int test_num, const char* test_csv_file) throw
(rhm::journal::jexception)
{
+ targs ta;
+ jtest::get_test(&ta, std::string(test_csv_file), test_num);
+ initialize(ta);
+}
+
+void
+jtest::initialize(const targs& ta) throw (rhm::journal::jexception)
+{
gettimeofday(_start_time, _tz_ptr);
- targs ta;
- jtest::get_test(&ta, std::string(test_csv_file), _tnum);
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);
@@ -293,9 +315,9 @@
tap->_max_msg_size = atol(toks[3]);
tap->_auto_deq = strcmp(toks[4], "FALSE") != 0;
if (toks.size() > 5)
- tap->_comment = std::string(toks[5]);
+ tap->_comment = toks[5];
else
- tap->_comment = std::string();
+ tap->_comment = NULL;
std::cout << "Test " << tnum << ":
Messages=" << tap->_num_msgs << " Size=" <<
tap->_min_msg_size;
if (tap->_min_msg_size == tap->_max_msg_size)
@@ -303,7 +325,7 @@
else
std::cout << " - " << tap->_max_msg_size
<< " (random)";
std::cout << (tap->_auto_deq ? " auto-dequeue" :
" no dequeue");
- if (tap->_comment.size())
+ if (tap->_comment)
std::cout << " [" << tap->_comment <<
"]";
std::cout << std::endl;
}
Modified: store/trunk/cpp/tests/jrnl/jtest.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.hpp 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/jrnl/jtest.hpp 2007-08-30 18:26:06 UTC (rev 900)
@@ -55,7 +55,10 @@
size_t _min_msg_size;
size_t _max_msg_size;
bool _auto_deq;
- std::string _comment;
+ const char* _comment;
+ targs();
+ targs(const u_int32_t num_msgs, const size_t min_msg_size, const size_t
max_msg_size, const bool auto_deq = false,
+ const char* comment = NULL);
};
private:
@@ -69,19 +72,18 @@
struct timezone* _tz_ptr;
pthread_t _p_thread;
pthread_t _c_thread;
- int _tnum;
public:
- jtest(int test_num) throw (rhm::journal::jexception);
+ jtest() throw (rhm::journal::jexception);
~jtest();
static void proc_args(int argc, char** argv, char** test_file_name, int* test_num)
throw (rhm::journal::jexception);
- void initialize(const char* test_csv_file) throw (rhm::journal::jexception);
+ void initialize(const int test_num, const char* test_csv_file) throw
(rhm::journal::jexception);
+ void initialize(const targs& ta) throw (rhm::journal::jexception);
void run() throw (rhm::journal::jexception);
void report() throw (rhm::journal::jexception);
void finalize() throw (rhm::journal::jexception);
- inline const int test_num() const { return _tnum; }
static void get_test(targs* tap, const std::string& filename, const unsigned
test_num)
throw (rhm::journal::jexception);
static void print_compile_defs(bool verbose);
Modified: store/trunk/cpp/tests/setup
===================================================================
--- store/trunk/cpp/tests/setup 2007-08-30 14:30:17 UTC (rev 899)
+++ store/trunk/cpp/tests/setup 2007-08-30 18:26:06 UTC (rev 900)
@@ -19,6 +19,7 @@
vg_options="
--suppressions=$abs_srcdir/.vg-supp
+ --suppressions=/usr/lib/valgrind/glibc-2.5.supp
--num-callers=25
--demangle=yes
--track-fds=yes