[rhmessaging-commits] rhmessaging commits: r1975 - in store/trunk/cpp: tests and 2 other directories.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Thu Apr 24 14:21:49 EDT 2008
Author: kpvdr
Date: 2008-04-24 14:21:49 -0400 (Thu, 24 Apr 2008)
New Revision: 1975
Modified:
store/trunk/cpp/lib/jrnl/data_tok.hpp
store/trunk/cpp/lib/jrnl/rmgr.cpp
store/trunk/cpp/tests/Makefile.am
store/trunk/cpp/tests/jrnl/_st_basic.cpp
store/trunk/cpp/tests/jrnl/_st_basic_txn.cpp
store/trunk/cpp/tests/jrnl/_st_helper_fns.hpp
store/trunk/cpp/tests/jrnl/_st_read.cpp
store/trunk/cpp/tests/jrnl/_st_read_txn.cpp
store/trunk/cpp/tests/jrnl/_ut_jdir.cpp
store/trunk/cpp/tests/jrnl/jtt/Makefile.am
store/trunk/cpp/tests/jrnl/jtt/_ut_data_src.cpp
store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp
store/trunk/cpp/tests/jrnl/jtt/test_case.hpp
store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp
Log:
Fixes to several boost test memory leaks exposed when valgrind was enabled
Modified: store/trunk/cpp/lib/jrnl/data_tok.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/data_tok.hpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/lib/jrnl/data_tok.hpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -58,7 +58,7 @@
* \brief Data block token (data_tok) used to track wstate of a data block through asynchronous
* I/O process
*/
- class data_tok// : public qpid::RefCounted
+ class data_tok
{
public:
// TODO: Fix this, separate write state from operation
Modified: store/trunk/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -73,10 +73,10 @@
_rrfc.add_cmpl_cnt_dblks(tot_pg_offs_dblks);
}
+ clean();
// Allocate memory for reading file header
if (::posix_memalign(&_fhdr_buffer, _sblksize, _sblksize))
{
- clean();
std::ostringstream oss;
oss << "posix_memalign(): blksize=" << _sblksize << " size=" << _sblksize;
oss << " errno=" << errno;
Modified: store/trunk/cpp/tests/Makefile.am
===================================================================
--- store/trunk/cpp/tests/Makefile.am 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/Makefile.am 2008-04-24 18:21:49 UTC (rev 1975)
@@ -6,7 +6,7 @@
INCLUDES=-I$(top_srcdir)/lib -I$(top_srcdir)/lib/gen
-SUBDIRS = . jrnl
+SUBDIRS = jrnl .
TESTS = \
clean.sh \
Modified: store/trunk/cpp/tests/jrnl/_st_basic.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_st_basic.cpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/jrnl/_st_basic.cpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -50,7 +50,7 @@
string test_name = get_test_name(test_filename, "instantiation");
try
{
- jcntl jc(test_name, JRNL_DIR, test_name);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
BOOST_CHECK_EQUAL(jc.is_ready(), false);
}
catch(const exception& e) { BOOST_FAIL(e.what()); }
@@ -62,9 +62,9 @@
string test_name = get_test_name(test_filename, "initialization");
try
{
- jcntl jc(test_name, JRNL_DIR, test_name);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
BOOST_CHECK_EQUAL(jc.is_ready(), false);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
BOOST_CHECK_EQUAL(jc.is_ready(), true);
}
catch(const exception& e) { BOOST_FAIL(e.what()); }
@@ -78,8 +78,8 @@
{
string msg;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
BOOST_CHECK_EQUAL(enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false), u_int64_t(m));
for (int m=0; m<NUM_MSGS; m++)
@@ -96,8 +96,8 @@
{
string msg;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<2*NUM_MSGS; m+=2)
{
BOOST_CHECK_EQUAL(enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false), u_int64_t(m));
@@ -115,8 +115,8 @@
{
string msg;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
unsigned n = num_msgs_to_full(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS * JRNL_SBLK_SIZE,
MSG_REC_SIZE_DBLKS, true);
for (unsigned m=0; m<3*2*n; m+=2) // overwrite files 3 times
@@ -136,10 +136,10 @@
try
{
{
- jcntl jc(test_name, JRNL_DIR, test_name);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
BOOST_CHECK_EQUAL(jc.is_ready(), false);
BOOST_CHECK_EQUAL(jc.is_read_only(), false);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
BOOST_CHECK_EQUAL(jc.is_ready(), true);
BOOST_CHECK_EQUAL(jc.is_read_only(), false);
}
@@ -147,10 +147,10 @@
vector<string> txn_list;
u_int64_t hrid;
- jcntl jc(test_name, JRNL_DIR, test_name);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
BOOST_CHECK_EQUAL(jc.is_ready(), false);
BOOST_CHECK_EQUAL(jc.is_read_only(), false);
- jrnl_recover(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
+ jc.recover(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
BOOST_CHECK_EQUAL(jc.is_ready(), true);
BOOST_CHECK_EQUAL(jc.is_read_only(), true);
BOOST_CHECK_EQUAL(hrid, u_int64_t(0));
@@ -159,10 +159,10 @@
vector<string> txn_list;
u_int64_t hrid;
- jcntl jc(test_name, JRNL_DIR, test_name);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
BOOST_CHECK_EQUAL(jc.is_ready(), false);
BOOST_CHECK_EQUAL(jc.is_read_only(), false);
- jrnl_recover(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
+ jc.recover(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
BOOST_CHECK_EQUAL(jc.is_ready(), true);
BOOST_CHECK_EQUAL(jc.is_read_only(), true);
BOOST_CHECK_EQUAL(hrid, u_int64_t(0));
@@ -183,8 +183,8 @@
{
string msg;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
}
@@ -192,8 +192,8 @@
vector<string> txn_list;
u_int64_t hrid;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_recover(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.recover(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
BOOST_CHECK_EQUAL(hrid, u_int64_t(NUM_MSGS - 1));
jc.recover_complete();
for (int m=0; m<NUM_MSGS; m++)
@@ -216,20 +216,20 @@
for (int m=0; m<2*NUM_MSGS; m+=2)
{
{
- jcntl jc(test_name, JRNL_DIR, test_name);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
if (m == 0)
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS); // First time only
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS); // First time only
else
{
- jrnl_recover(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
+ jc.recover(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
BOOST_CHECK_EQUAL(hrid, u_int64_t(m - 1));
jc.recover_complete();
}
enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
}
{
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_recover(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.recover(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
BOOST_CHECK_EQUAL(hrid, u_int64_t(m));
jc.recover_complete();
deq_msg(jc, m);
@@ -248,8 +248,8 @@
{
string msg;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
// Transient msgs - should not recover
for (int m=0; m<NUM_MSGS; m++)
enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), true);
@@ -268,8 +268,8 @@
vector<string> txn_list;
u_int64_t hrid;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_recover(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.recover(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
// Recover non-transient msgs
for (int m=NUM_MSGS; m<NUM_MSGS*2; m++)
{
@@ -343,8 +343,8 @@
{
string msg;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS);
unsigned m;
// Fill journal to just below threshold
@@ -379,8 +379,8 @@
{
string msg;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_DEFAULT_JFILES, DEFAULT_JFSIZE_SBLKS);
unsigned m;
// Fill journal to just below threshold
@@ -408,8 +408,8 @@
{
string msg;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
u_int64_t rid = enq_msg(jc, 0, create_msg(msg, 0, MSG_SIZE), false);
deq_msg(jc, rid);
try{ deq_msg(jc, rid); BOOST_ERROR("Did not throw exception on second dequeue."); }
Modified: store/trunk/cpp/tests/jrnl/_st_basic_txn.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_st_basic_txn.cpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/jrnl/_st_basic_txn.cpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -53,8 +53,8 @@
string msg;
string xid;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
create_xid(xid, 0, XID_SIZE);
for (int m=0; m<NUM_MSGS; m++)
BOOST_CHECK_EQUAL(enq_txn_msg(jc, m, create_msg(msg, m, MSG_SIZE), xid, false),
@@ -75,8 +75,8 @@
string msg;
string xid;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
create_xid(xid, 0, XID_SIZE);
for (int m=0; m<NUM_MSGS; m++)
BOOST_CHECK_EQUAL(enq_txn_msg(jc, m, create_msg(msg, m, MSG_SIZE), xid, false),
@@ -104,8 +104,8 @@
string msg;
string xid;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
{
create_xid(xid, m, XID_SIZE);
@@ -127,8 +127,8 @@
string msg;
string xid;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
{
create_xid(xid, m, XID_SIZE);
@@ -155,8 +155,8 @@
string msg;
string xid;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
create_xid(xid, 0, XID_SIZE);
for (int m=0; m<NUM_MSGS; m++)
BOOST_CHECK_EQUAL(enq_txn_msg(jc, m, create_msg(msg, m, MSG_SIZE), xid, false),
@@ -177,8 +177,8 @@
string msg;
string xid;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
create_xid(xid, 0, XID_SIZE);
for (int m=0; m<NUM_MSGS; m++)
BOOST_CHECK_EQUAL(enq_txn_msg(jc, m, create_msg(msg, m, MSG_SIZE), xid, false),
@@ -199,8 +199,8 @@
string msg;
string xid;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
{
create_xid(xid, m, XID_SIZE);
@@ -222,8 +222,8 @@
string msg;
string xid;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
{
create_xid(xid, m, XID_SIZE);
Modified: store/trunk/cpp/tests/jrnl/_st_helper_fns.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_st_helper_fns.hpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/jrnl/_st_helper_fns.hpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -49,6 +49,39 @@
#define XLARGE_MSG_RATIO (1.0 * LARGE_MSG_REC_SIZE / JRNL_DBLK_SIZE / JRNL_SBLK_SIZE / JRNL_RMGR_PAGE_SIZE)
#define XLARGE_MSG_THRESHOLD (int)(JRNL_DEFAULT_FSIZE * NUM_DEFAULT_JFILES * JRNL_ENQ_THRESHOLD / 100 / LARGE_MSG_RATIO)
+class test_dtok : public data_tok
+{
+private:
+ bool flag;
+public:
+ test_dtok() : data_tok(), flag(false) {}
+ virtual ~test_dtok() {}
+ bool done() { if (flag || _wstate == NONE) return true; else { flag = true; return false; } }
+};
+
+class test_jrnl : public jcntl
+{
+public:
+ test_jrnl(const std::string& jid, const std::string& jdir, const std::string& base_filename) :
+ jcntl(jid, jdir, base_filename) {}
+ virtual ~test_jrnl() {}
+ void initialize(const u_int16_t num_jfiles, const u_int32_t jfsize_sblks)
+ { jcntl::initialize(num_jfiles, jfsize_sblks, 0, &aio_wr_callback); }
+ void recover(const u_int16_t num_jfiles, const u_int32_t jfsize_sblks, vector<string>& txn_list,
+ u_int64_t& highest_rid)
+ { jcntl::recover(num_jfiles, jfsize_sblks, 0, &aio_wr_callback, txn_list, highest_rid); }
+private:
+ static void aio_wr_callback(jcntl*, std::vector<data_tok*>& dtokl)
+ {
+ for (std::vector<data_tok*>::const_iterator i=dtokl.begin(); i!=dtokl.end(); i++)
+ {
+ test_dtok* dtp = static_cast<test_dtok*>(*i);
+ if (dtp->done())
+ delete dtp;
+ }
+ }
+};
+
const string
get_test_name(const string& file, const string& test_name)
{
@@ -83,30 +116,23 @@
return true;
}
-void
-jrnl_init(jcntl& jc, const u_int16_t num_jfiles, const u_int32_t jfsize_sblks)
-{
- jc.initialize(num_jfiles, jfsize_sblks, 0, 0);
-}
-
-void
-jrnl_recover(jcntl& jc, const u_int16_t num_jfiles, const u_int32_t jfsize_sblks,
- vector<string>& txn_list, u_int64_t& highest_rid)
-{
- jc.recover(num_jfiles, jfsize_sblks, 0, 0, txn_list, highest_rid);
-}
-
u_int64_t
enq_msg(jcntl& jc, const u_int64_t rid, const string& msg, const bool transient,
const iores exp_ret = RHM_IORES_SUCCESS)
{
ostringstream ctxt;
ctxt << "enq_msg(" << rid << ")";
- data_tok* dtp = new data_tok;
+ test_dtok* dtp = new test_dtok;
BOOST_CHECK_MESSAGE(dtp != 0, "Data token allocation failed (dtp == 0).");
- check_iores(ctxt.str(), jc.enqueue_data_record(msg.c_str(), msg.size(), msg.size(), dtp,
- transient), exp_ret);
- return dtp->rid();
+ try
+ {
+ iores res = jc.enqueue_data_record(msg.c_str(), msg.size(), msg.size(), dtp, transient);
+ check_iores(ctxt.str(), res, exp_ret);
+ u_int64_t dtok_rid = dtp->rid();
+ if (dtp->done()) delete dtp;
+ return dtok_rid;
+ }
+ catch (exception e) { delete dtp; throw; }
}
u_int64_t
@@ -115,10 +141,17 @@
{
ostringstream ctxt;
ctxt << "enq_extern_msg(" << rid << ")";
- data_tok* dtp = new data_tok;
+ test_dtok* dtp = new test_dtok;
BOOST_CHECK_MESSAGE(dtp != 0, "Data token allocation failed (dtp == 0).");
- check_iores(ctxt.str(), jc.enqueue_extern_data_record(msg_size, dtp, transient), exp_ret);
- return dtp->rid();
+ try
+ {
+ iores res = jc.enqueue_extern_data_record(msg_size, dtp, transient);
+ check_iores(ctxt.str(), res, exp_ret);
+ u_int64_t dtok_rid = dtp->rid();
+ if (dtp->done()) delete dtp;
+ return dtok_rid;
+ }
+ catch (exception e) { delete dtp; throw; }
}
u_int64_t
@@ -127,11 +160,18 @@
{
ostringstream ctxt;
ctxt << "enq_txn_msg(" << rid << ")";
- data_tok* dtp = new data_tok;
+ test_dtok* dtp = new test_dtok;
BOOST_CHECK_MESSAGE(dtp != 0, "Data token allocation failed (dtp == 0).");
- check_iores(ctxt.str(), jc.enqueue_txn_data_record(msg.c_str(), msg.size(), msg.size(), dtp,
- xid, transient), exp_ret);
- return dtp->rid();
+ try
+ {
+ iores res = jc.enqueue_txn_data_record(msg.c_str(), msg.size(), msg.size(), dtp, xid,
+ transient);
+ check_iores(ctxt.str(), res, exp_ret);
+ u_int64_t dtok_rid = dtp->rid();
+ if (dtp->done()) delete dtp;
+ return dtok_rid;
+ }
+ catch (exception e) { delete dtp; throw; }
}
u_int64_t
@@ -140,11 +180,17 @@
{
ostringstream ctxt;
ctxt << "enq_extern_txn_msg(" << rid << ")";
- data_tok* dtp = new data_tok;
+ test_dtok* dtp = new test_dtok;
BOOST_CHECK_MESSAGE(dtp != 0, "Data token allocation failed (dtp == 0).");
- check_iores(ctxt.str(), jc.enqueue_extern_txn_data_record(msg_size, dtp, xid, transient),
- exp_ret);
- return dtp->rid();
+ try
+ {
+ iores res = jc.enqueue_extern_txn_data_record(msg_size, dtp, xid, transient);
+ check_iores(ctxt.str(), res, exp_ret);
+ u_int64_t dtok_rid = dtp->rid();
+ if (dtp->done()) delete dtp;
+ return dtok_rid;
+ }
+ catch (exception e) { delete dtp; throw; }
}
u_int64_t
@@ -152,12 +198,19 @@
{
ostringstream ctxt;
ctxt << "deq_msg(" << drid << ")";
- data_tok* dtp = new data_tok;
+ test_dtok* dtp = new test_dtok;
BOOST_CHECK_MESSAGE(dtp != 0, "Data token allocation failed (dtp == 0).");
dtp->set_wstate(data_tok::ENQ);
dtp->set_rid(drid);
- check_iores(ctxt.str(), jc.dequeue_data_record(dtp), exp_ret);
- return dtp->rid();
+ try
+ {
+ iores res = jc.dequeue_data_record(dtp);
+ check_iores(ctxt.str(), res, exp_ret);
+ u_int64_t dtok_rid = dtp->rid();
+ if (dtp->done()) delete dtp;
+ return dtok_rid;
+ }
+ catch (exception e) { delete dtp; throw; }
}
u_int64_t
@@ -166,30 +219,51 @@
{
ostringstream ctxt;
ctxt << "deq_txn_msg(" << drid << ")";
- data_tok* dtp = new data_tok;
+ test_dtok* dtp = new test_dtok;
BOOST_CHECK_MESSAGE(dtp != 0, "Data token allocation failed (dtp == 0).");
dtp->set_wstate(data_tok::ENQ);
dtp->set_rid(drid);
- check_iores(ctxt.str(), jc.dequeue_txn_data_record(dtp, xid), exp_ret);
- return dtp->rid();
+ try
+ {
+ iores res = jc.dequeue_txn_data_record(dtp, xid);
+ check_iores(ctxt.str(), res, exp_ret);
+ u_int64_t dtok_rid = dtp->rid();
+ if (dtp->done()) delete dtp;
+ return dtok_rid;
+ }
+ catch (exception e) { delete dtp; throw; }
}
u_int64_t
txn_abort(jcntl& jc, const string& xid, const iores exp_ret = RHM_IORES_SUCCESS)
{
- data_tok* dtp = new data_tok;
+ test_dtok* dtp = new test_dtok;
BOOST_CHECK_MESSAGE(dtp != 0, "Data token allocation failed (dtp == 0).");
- check_iores("txn_abort", jc.txn_abort(dtp, xid), exp_ret);
- return dtp->rid();
+ try
+ {
+ iores res = jc.txn_abort(dtp, xid);
+ check_iores("txn_abort", res, exp_ret);
+ u_int64_t dtok_rid = dtp->rid();
+ if (dtp->done()) delete dtp;
+ return dtok_rid;
+ }
+ catch (exception e) { delete dtp; throw; }
}
u_int64_t
txn_commit(jcntl& jc, const string& xid, const iores exp_ret = RHM_IORES_SUCCESS)
{
- data_tok* dtp = new data_tok;
+ test_dtok* dtp = new test_dtok;
BOOST_CHECK_MESSAGE(dtp != 0, "Data token allocation failed (dtp == 0).");
- check_iores("txn_commit", jc.txn_commit(dtp, xid), exp_ret);
- return dtp->rid();
+ try
+ {
+ iores res = jc.txn_commit(dtp, xid);
+ check_iores("txn_commit", res, exp_ret);
+ u_int64_t dtok_rid = dtp->rid();
+ if (dtp->done()) delete dtp;
+ return dtok_rid;
+ }
+ catch (exception e) { delete dtp; throw; }
}
void
@@ -200,13 +274,18 @@
std::size_t msize = 0;
void* xp = 0;
std::size_t xsize = 0;
- data_tok* dtp = new data_tok;
+ test_dtok* dtp = new test_dtok;
BOOST_CHECK_MESSAGE(dtp != 0, "Data token allocation failed (dtp == 0).");
dtp->set_wstate(data_tok::ENQ);
unsigned aio_sleep_cnt = 0;
- while (handle_jcntl_response(jc.read_data_record(&mp, msize, &xp, xsize, transient, external,
- dtp), jc, aio_sleep_cnt, "read_msg", exp_ret)) ;
+ try
+ {
+ while (handle_jcntl_response(jc.read_data_record(&mp, msize, &xp, xsize, transient,
+ external, dtp), jc, aio_sleep_cnt, "read_msg", exp_ret)) ;
+ }
+ catch (exception e) { delete dtp; throw; }
+
if (mp)
msg.assign((char*)mp, msize);
if (xp)
@@ -220,7 +299,7 @@
std::free(mp);
mp = 0;
}
-
+ delete dtp;
}
u_int32_t
Modified: store/trunk/cpp/tests/jrnl/_st_read.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_st_read.cpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/jrnl/_st_read.cpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -57,8 +57,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
read_msg(jc, rmsg, xid, transientFlag, externalFlag, RHM_IORES_EMPTY);
}
catch(const exception& e) { BOOST_FAIL(e.what()); }
@@ -76,8 +76,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
jc.flush();
@@ -109,8 +109,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<2*NUM_MSGS; m+=2)
{
enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
@@ -137,8 +137,8 @@
{
string msg;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
}
@@ -151,8 +151,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_recover(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.recover(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
BOOST_CHECK_EQUAL(hrid, u_int64_t(NUM_MSGS - 1));
jc.recover_complete();
for (int m=0; m<NUM_MSGS; m++)
@@ -180,8 +180,8 @@
{
string msg;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
}
@@ -194,8 +194,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_recover(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.recover(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
BOOST_CHECK_EQUAL(hrid, u_int64_t(NUM_MSGS - 1));
for (int m=0; m<NUM_MSGS; m++)
{
@@ -216,8 +216,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_recover(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.recover(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS, txn_list, hrid);
BOOST_CHECK_EQUAL(hrid, u_int64_t(NUM_MSGS - 1));
for (int m=0; m<NUM_MSGS; m++)
{
@@ -257,8 +257,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
unsigned m;
for (m=0; m<2*NUM_MSGS; m+=2)
{
@@ -285,8 +285,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
unsigned m;
unsigned read_buffer_size_dblks = JRNL_RMGR_PAGES * JRNL_RMGR_PAGE_SIZE * JRNL_SBLK_SIZE;
unsigned n = num_msgs_to_full(1, read_buffer_size_dblks, MSG_REC_SIZE_DBLKS, true);
@@ -315,8 +315,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
unsigned read_buffer_size_dblks = JRNL_RMGR_PAGES * JRNL_RMGR_PAGE_SIZE * JRNL_SBLK_SIZE;
unsigned n = num_msgs_to_full(1, read_buffer_size_dblks, MSG_REC_SIZE_DBLKS, true);
unsigned m = 0;
Modified: store/trunk/cpp/tests/jrnl/_st_read_txn.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_st_read_txn.cpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/jrnl/_st_read_txn.cpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -57,8 +57,8 @@
string rxid;
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
create_xid(xid, 0, XID_SIZE);
for (int m=0; m<NUM_MSGS; m++)
enq_txn_msg(jc, m, create_msg(msg, m, MSG_SIZE), xid, false);
@@ -92,8 +92,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
{
create_xid(xid, m, XID_SIZE);
@@ -124,8 +124,8 @@
string rxid;
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
create_xid(xid, 1, XID_SIZE);
for (int m=0; m<NUM_MSGS; m++)
enq_txn_msg(jc, m, create_msg(msg, m, MSG_SIZE), xid, false);
@@ -151,8 +151,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
{
create_xid(xid, m, XID_SIZE);
@@ -180,8 +180,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
create_xid(xid, 2, XID_SIZE);
for (int m=0; m<NUM_MSGS; m++)
enq_txn_msg(jc, m, create_msg(msg, m, MSG_SIZE), xid, false);
@@ -207,8 +207,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
{
create_xid(xid, m, XID_SIZE);
@@ -236,8 +236,8 @@
bool externalFlag;
create_xid(xid, 3, XID_SIZE);
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
for (int m=0; m<NUM_MSGS; m++)
@@ -264,8 +264,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<3*NUM_MSGS; m+=3)
{
enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
@@ -295,8 +295,8 @@
bool externalFlag;
create_xid(xid, 4, XID_SIZE);
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<NUM_MSGS; m++)
enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
for (int m=0; m<NUM_MSGS; m++)
@@ -331,8 +331,8 @@
bool transientFlag;
bool externalFlag;
- jcntl jc(test_name, JRNL_DIR, test_name);
- jrnl_init(jc, NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
+ test_jrnl jc(test_name, JRNL_DIR, test_name);
+ jc.initialize(NUM_TEST_JFILES, TEST_JFSIZE_SBLKS);
for (int m=0; m<3*NUM_MSGS; m+=3)
{
enq_msg(jc, m, create_msg(msg, m, MSG_SIZE), false);
Modified: store/trunk/cpp/tests/jrnl/_ut_jdir.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/_ut_jdir.cpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/jrnl/_ut_jdir.cpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -128,6 +128,7 @@
other_cnt++;
}
}
+ ::closedir(dir);
if (incl_files)
{
if (incl_dirs)
Modified: store/trunk/cpp/tests/jrnl/jtt/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/Makefile.am 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/jrnl/jtt/Makefile.am 2008-04-24 18:21:49 UTC (rev 1975)
@@ -93,7 +93,7 @@
test_case.cpp \
test_case_result.cpp \
test_case_result_agregation.cpp
-_ut_read_arg_LDADD = -lboost_unit_test_framework -lrt -lboost_program_options $(LINK_BDB)
+_ut_read_arg_LDADD = -lboost_unit_test_framework -lrt -lboost_program_options $(LINK_BDB)
_ut_jrnl_instance_SOURCES = _ut_jrnl_instance.cpp ../../unit_test.cpp \
args.cpp \
@@ -104,13 +104,11 @@
test_case.cpp \
test_case_result.cpp \
test_case_result_agregation.cpp
-
_ut_jrnl_instance_LDADD = -lboost_unit_test_framework -laio -lrt -lboost_program_options $(LINK_BDB)
_ut_test_case_SOURCES = _ut_test_case.cpp ../../unit_test.cpp test_case.cpp test_case_result.cpp test_case_result_agregation.cpp
_ut_test_case_LDADD = -lboost_unit_test_framework -lrt $(LINK_BDB)
-
_ut_test_case_result_SOURCES = _ut_test_case_result.cpp ../../unit_test.cpp test_case_result.cpp
_ut_test_case_result_LDADD = -lboost_unit_test_framework -lrt $(LINK_BDB)
@@ -122,7 +120,6 @@
test_case_set.cpp \
test_case_result.cpp \
test_case_result_agregation.cpp
-
_ut_test_case_set_LDADD = -lboost_unit_test_framework -lrt $(LINK_BDB)
EXTRA_DIST = \
Modified: store/trunk/cpp/tests/jrnl/jtt/_ut_data_src.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/_ut_data_src.cpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/jrnl/jtt/_ut_data_src.cpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -58,6 +58,7 @@
QPID_AUTO_TEST_CASE(xid_data_xid)
{
+ const std::size_t num = 256;
cout << test_filename << ".xid_data_xid: " << flush;
BOOST_CHECK_EQUAL(data_src::get_xid(1), "0");
BOOST_CHECK_EQUAL(data_src::get_xid(2), "01");
@@ -75,7 +76,7 @@
BOOST_CHECK_EQUAL(data_src::get_xid(14), "xid:00000013:n");
BOOST_CHECK_EQUAL(data_src::get_xid(15), "xid:00000014:no");
std::size_t i = 15;
- for (; i<1024; i++)
+ for (; i<num; i++)
{
string xid(data_src::get_xid(i));
@@ -87,7 +88,7 @@
BOOST_CHECK_EQUAL(xid[13], 'n');
BOOST_CHECK_EQUAL(xid[i-1], (char)('a' + ((i-1)%26)));
}
- for (std::size_t j=data_src::max_xsize-1024; j<data_src::max_xsize; j++,i++)
+ for (std::size_t j=data_src::max_xsize-num; j<data_src::max_xsize; j++,i++)
{
string xid(data_src::get_xid(j));
Modified: store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -73,8 +73,8 @@
const std::string& base_filename,
const u_int16_t num_jfiles = jrnl_init_params::def_num_jfiles,
const u_int32_t jfsize_sblks = jrnl_init_params::def_jfsize_sblks);
- jrnl_instance(const jrnl_init_params::shared_ptr& params);
- ~jrnl_instance();
+ jrnl_instance(const jrnl_init_params::shared_ptr& params);
+ virtual ~jrnl_instance();
inline const jrnl_init_params::shared_ptr& params() const { return _jpp; }
inline const std::string& jid() const { return _jpp->jid(); }
Modified: store/trunk/cpp/tests/jrnl/jtt/test_case.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case.hpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case.hpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -74,7 +74,7 @@
const bool auto_deq, const std::size_t min_xid_size,
const std::size_t max_xid_size, const transient_t transient,
const external_t external, const std::string& comment);
- ~test_case();
+ virtual ~test_case();
inline unsigned test_case_num() const { return _test_case_num; }
inline u_int32_t num_msgs() const { return _num_msgs; }
Modified: store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp 2008-04-24 15:38:31 UTC (rev 1974)
+++ store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp 2008-04-24 18:21:49 UTC (rev 1975)
@@ -49,7 +49,7 @@
public:
test_mgr(args& args);
- ~test_mgr();
+ virtual ~test_mgr();
void run();
static void signal_handler(int signal);
More information about the rhmessaging-commits
mailing list