Author: kpvdr
Date: 2007-09-06 09:10:59 -0400 (Thu, 06 Sep 2007)
New Revision: 911
Modified:
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/pmgr.cpp
store/trunk/cpp/lib/jrnl/wmgr.cpp
store/trunk/cpp/lib/jrnl/wrfc.cpp
store/trunk/cpp/lib/jrnl/wrfc.hpp
store/trunk/cpp/tests/jrnl/JournalTest.cpp
store/trunk/cpp/tests/jrnl/jtest.cpp
store/trunk/cpp/tests/jrnl/msg_producer.cpp
Log:
Solved possible static test interactions between runs of the tests
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -101,6 +101,7 @@
_datafh[i] = ::new lfh(ss.str(), i);
}
+ // TODO: Check the following comment/note (may be obsolete):
// NOTE: The write RFC must initialize first. This sets all the file handle object
// (lfh) counters and pointers for both read and write, since write activity
// constrains read activity (i.e. one can't read what has not yet been written).
Modified: store/trunk/cpp/lib/jrnl/pmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -123,6 +123,13 @@
{
std::stringstream ss;
+ // As static use of this class keeps old values around, clean up first...
+ _pg_index = 0;
+ _pg_cntr = 0;
+ _pg_offset_dblks = 0;
+ _aio_evt_rem = 0;
+ clean();
+
// 1. Allocate page memory (as a single block)
size_t pagesize = _pages * _pagesize * _sblksize;
if (::posix_memalign(&_page_base_ptr, _sblksize, pagesize))
Modified: store/trunk/cpp/lib/jrnl/wmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -406,6 +406,8 @@
}
_page_cb_arr[0]._state = IN_USE;
_ddtokl.clear();
+ _cached_offset_dblks = 0;
+ _enq_busy = false;
}
const iores
Modified: store/trunk/cpp/lib/jrnl/wrfc.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wrfc.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/lib/jrnl/wrfc.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -52,6 +52,19 @@
wrfc::~wrfc() {}
+void
+wrfc::initialize(u_int32_t nfiles, nlfh** fh_arr, u_int32_t fh_index) throw (jexception)
+{
+ rrfc::initialize(nfiles, fh_arr, fh_index);
+#ifdef DRHM_TESTVALS
+ // TODO: Find method of specifying 64-bit literals under gcc with -pedantic option
+ _rid = u_int64_t(0xffeeddcc) << 32;
+#else
+ _rid = 0;
+#endif
+ _reset_ok = false;
+}
+
bool
wrfc::rotate() throw (jexception)
{
Modified: store/trunk/cpp/lib/jrnl/wrfc.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wrfc.hpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/lib/jrnl/wrfc.hpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -63,6 +63,16 @@
~wrfc();
/**
+ * \brief Initialize the controller.
+ * \param nfiles Number of files in the rotating file group.
+ * \param fh_arr Pointer to an array of file handles (nlogging_fh or subclasses),
+ * each of which correspond to one of the physical files.
+ * \param fh_index Initial index of journal file. Default = 0.
+ */
+ void initialize(u_int32_t nfiles, nlfh** fh_arr, u_int32_t fh_index = 0)
+ throw (jexception);
+
+ /**
* \brief Rotate active file handle to next file in rotating file group.
* \exception jerrno::JERR__NINIT if called before calling initialize().
*/
Modified: store/trunk/cpp/tests/jrnl/JournalTest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/tests/jrnl/JournalTest.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -72,7 +72,7 @@
const unsigned max_msg_szie, const bool auto_deq, const unsigned iterations,
const char* test_descr)
{
- std::cout << " " << test_descr << " "
<< std::flush;
+ std::cout << " [" << test_descr << "] "
<< std::flush;
jtest::targs ta(num_msgs, min_msg_size, max_msg_szie, auto_deq, test_descr);
for (unsigned i=0; i<iterations; i++)
{
@@ -85,10 +85,8 @@
catch (rhm::journal::jexception e)
{
t.finalize();
- std::cout << e << std::endl;
- std::cout << std::hex << std::setfill('0');
- std::cerr << "*** jtest failed with code 0x" <<
std::setw(4) << e.err_code() << " ***" << std::endl <<
std::flush;
- throw e;
+ std::string s;
+ CPPUNIT_FAIL(e.to_string(s));
}
t.finalize();
}
@@ -187,7 +185,8 @@
void Test_018()
{
- runJournalTest(8, 3933, 3933, true, 5, "8*(1/8 page - 1 dblk for deq record
+ 1 byte), auto-deq");
+ runJournalTest(8, 3933, 3933, true, 5,
+ "8*(1/8 page - 1 dblk for deq record + 1 byte), auto-deq");
}
void Test_019()
@@ -197,37 +196,39 @@
void Test_020()
{
- runJournalTest(33, 32732, 32732, false, 5, "33*(1 page exact fit)");
+ runJournalTest(33, 32732, 32732, false, 10, "33*(1 page exact fit)");
}
void Test_021()
{
- runJournalTest(22, 49116, 49116, false, 5, "22*(1.5 pages)");
+ runJournalTest(22, 49116, 49116, false, 10, "22*(1.5 pages)");
}
void Test_022()
{
- runJournalTest(22, 48988, 48988, true, 5, "22*(1.5 pages - 1 dblk for deq
record), auto-deq");
+ runJournalTest(22, 48988, 48988, true, 10,
+ "22*(1.5 pages - 1 dblk for deq record), auto-deq");
}
void Test_023()
{
- runJournalTest(48, 32732, 32732, false, 5, "48*(1 page exact fit)");
+ runJournalTest(48, 32732, 32732, false, 10, "48*(1 page exact fit)");
}
void Test_024()
{
- runJournalTest(49, 32732, 32732, false, 5, "49*(1 page exact fit)");
+ runJournalTest(49, 32732, 32732, false, 10, "49*(1 page exact fit)");
}
void Test_025()
{
- runJournalTest(20, 81884, 81884, false, 5, "20*(2.5 pages)");
+ runJournalTest(20, 81884, 81884, false, 10, "20*(2.5 pages)");
}
void Test_026()
{
- runJournalTest(20, 81756, 81756, true, 5, "20*(2.5 pages - 1 dblk for deq
record), auto-deq");
+ runJournalTest(20, 81756, 81756, true, 10,
+ "20*(2.5 pages - 1 dblk for deq record), auto-deq");
}
};
Modified: store/trunk/cpp/tests/jrnl/jtest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -186,6 +186,16 @@
{
_mp.finalize();
_mc.finalize();
+ if (p_args)
+ {
+ delete p_args;
+ p_args = NULL;
+ }
+ if (c_args)
+ {
+ delete c_args;
+ c_args = NULL;
+ }
}
string&
Modified: store/trunk/cpp/tests/jrnl/msg_producer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-09-06 11:37:08 UTC (rev 910)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-09-06 13:10:59 UTC (rev 911)
@@ -137,7 +137,7 @@
}
rhm::journal::data_tok* dtokp = _dtok_master_list[msgCntr];
const void* const msg = (char*)_msg_buff + (msgCntr%10);
-//std::cout << "e" << dtokp->id() << "-"
<< dtokp->wstate_str() << " " << std::flush;
+//std::cout << "e" << dtokp->id() << /*"-"
<< dtokp->wstate_str() <<*/ " " << std::flush;
bool written = false;
while (!written)
{
@@ -305,7 +305,8 @@
std::stringstream ss;
ss << "Journal flush phase 1 failed, _num_msgs_enq="
<< _num_msgs_enq;
ss << " num_msgs_sent=" << num_msgs_sent;
- throw rhm::journal::jexception(EXCEPTION_BASE+4, ss.str(),
"msg_producer", "jrnl_flush");
+ throw rhm::journal::jexception(EXCEPTION_BASE+4, ss.str(),
"msg_producer",
+ "jrnl_flush");
}
//std::cout << "+" << std::flush;
jc.get_wr_events();
@@ -331,7 +332,8 @@
std::stringstream ss;
ss << "Journal flush phase 2 failed, _num_msgs_deq="
<< _num_msgs_deq;
ss << " num_msgs_sent=" << num_msgs_sent;
- throw rhm::journal::jexception(EXCEPTION_BASE+5, ss.str(),
"msg_producer", "jrnl_flush");
+ throw rhm::journal::jexception(EXCEPTION_BASE+5, ss.str(),
"msg_producer",
+ "jrnl_flush");
}
//std::cout << "*" << std::flush;
jc.get_wr_events();