[rhmessaging-commits] rhmessaging commits: r1617 - in store/trunk/cpp: tests/jrnl/jtt and 1 other directory.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Mon Jan 28 15:57:09 EST 2008


Author: kpvdr
Date: 2008-01-28 15:57:09 -0500 (Mon, 28 Jan 2008)
New Revision: 1617

Added:
   store/trunk/cpp/tests/jrnl/jtt/args.cpp
   store/trunk/cpp/tests/jrnl/jtt/args.hpp
Removed:
   store/trunk/cpp/tests/jrnl/jtt/options.cpp
   store/trunk/cpp/tests/jrnl/jtt/options.hpp
Modified:
   store/trunk/cpp/lib/jrnl/jcntl.hpp
   store/trunk/cpp/tests/jrnl/jtt/Makefile.am
   store/trunk/cpp/tests/jrnl/jtt/_ut_jrnl_instance.cpp
   store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp
   store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp
   store/trunk/cpp/tests/jrnl/jtt/main.cpp
   store/trunk/cpp/tests/jrnl/jtt/test_case.cpp
   store/trunk/cpp/tests/jrnl/jtt/test_case.hpp
   store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp
   store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp
   store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp
   store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp
Log:
Journal test tool enhancements and bugfixes

Modified: store/trunk/cpp/lib/jrnl/jcntl.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.hpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/lib/jrnl/jcntl.hpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -161,6 +161,7 @@
          virtual ~jcntl();
          
          inline const std::string& id() const { return _jid; }
+         inline const std::string& jrnl_dir() const { return _jdir.dirname(); }
 
         /**
         * \brief Initialize the journal for storing data.

Modified: store/trunk/cpp/tests/jrnl/jtt/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/Makefile.am	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/Makefile.am	2008-01-28 20:57:09 UTC (rev 1617)
@@ -47,11 +47,11 @@
     _ut_jrnl_instance
 
 jtt_SOURCES = \
+    args.cpp \
     data_src.cpp \
     jrnl_init_params.cpp \
     jrnl_instance.cpp \
     main.cpp \
-    options.cpp \
     test_case.cpp \
     test_case_result.cpp \
     test_case_result_agregation.cpp \

Modified: store/trunk/cpp/tests/jrnl/jtt/_ut_jrnl_instance.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/_ut_jrnl_instance.cpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/_ut_jrnl_instance.cpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -45,7 +45,7 @@
     test_case::shared_ptr p(new test_case(1, 0, 0, 0, false, 0, 0, test_case::JTT_PERSISTNET,
             test_case::JDL_INTERNAL, "t1"));
     jrnl_instance ji(jid, jdir, bfn, num_jfiles, jfsize_sblks);
-    ji.init_tc(p, false, true);
+    ji.init_tc(p, false);
     ji.run_tc();
     ji.tc_wait_compl();
     try { jdir::verify_dir(jdir, bfn); }
@@ -67,7 +67,7 @@
     jrnl_init_params::shared_ptr jpp(new jrnl_init_params(jid, jdir, bfn, num_jfiles,
             jfsize_sblks));
     jrnl_instance ji(jpp);
-    ji.init_tc(p, false, true);
+    ji.init_tc(p, false);
     ji.run_tc();
     ji.tc_wait_compl();
     try { jdir::verify_dir(jdir, bfn); }
@@ -89,7 +89,7 @@
     jrnl_init_params::shared_ptr jpp(new jrnl_init_params(jid, jdir, bfn, num_jfiles,
             jfsize_sblks));
     jrnl_instance ji(jpp);
-    ji.init_tc(p, false, true);
+    ji.init_tc(p, false);
     ji.run_tc();
     ji.tc_wait_compl();
     try { jdir::verify_dir(jdir, bfn); }
@@ -111,12 +111,12 @@
     jrnl_init_params::shared_ptr jpp(new jrnl_init_params(jid, jdir, bfn, num_jfiles,
             jfsize_sblks));
     jrnl_instance ji(jpp);
-    ji.init_tc(p, false, true);
+    ji.init_tc(p, false);
     ji.run_tc();
     ji.tc_wait_compl();
     try { jdir::verify_dir(jdir, bfn); }
     catch (const jexception& e) { BOOST_ERROR(e.what()); }
-    ji.init_tc(p, true, true);
+    ji.init_tc(p, true);
     ji.run_tc();
     ji.tc_wait_compl();
     try { jdir::verify_dir(jdir, bfn); }
@@ -138,7 +138,7 @@
     jrnl_init_params::shared_ptr jpp(new jrnl_init_params(jid, jdir, bfn, num_jfiles,
             jfsize_sblks));
     jrnl_instance ji(jpp);
-    ji.init_tc(p, true, true);
+    ji.init_tc(p, true);
     ji.run_tc();
     ji.tc_wait_compl();
     try { jdir::verify_dir(jdir, bfn); }
@@ -146,32 +146,3 @@
     jdir::delete_dir(jdir);
 }
 
-BOOST_AUTO_TEST_CASE(jrnl_instance_no_jrnl_keep)
-{
-    const std::string jid = "jid7";
-    const std::string jdir = "/tmp/test7";
-    const std::string bfn = "test";
-    const u_int16_t num_jfiles = 20;
-    const u_int32_t jfsize_sblks = 128;
-
-    using rhm::jtt::test_case;
-    test_case::shared_ptr p(new test_case(7, 0, 0, 0, false, 0, 0, test_case::JTT_PERSISTNET,
-            test_case::JDL_INTERNAL, "t7"));
-    jrnl_instance ji(jid, jdir, bfn, num_jfiles, jfsize_sblks);
-    ji.init_tc(p, false, false);
-    ji.run_tc();
-    ji.tc_wait_compl();
-    try
-    {
-        jdir::verify_dir(jdir, bfn);
-        BOOST_ERROR("Failed to delete journal directory.");
-    }
-    catch (const jexception& e)
-    {
-        if (e.err_code() != rhm::journal::jerrno::JERR_JDIR_STAT)
-            BOOST_ERROR(e.what());
-    }
-    jdir::delete_dir(jdir);
-}
-
-

Copied: store/trunk/cpp/tests/jrnl/jtt/args.cpp (from rev 1615, store/trunk/cpp/tests/jrnl/jtt/options.cpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/args.cpp	                        (rev 0)
+++ store/trunk/cpp/tests/jrnl/jtt/args.cpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -0,0 +1,152 @@
+/**
+* Copyright 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library 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
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include "args.hpp"
+
+#include <iostream>
+
+namespace po = boost::program_options;
+
+namespace rhm
+{
+namespace jtt
+{
+
+args::args(std::string opt_title):
+    _options_descr(opt_title),
+    jrnl_format_chk(false),
+    keep_jrnls(false),
+    num_jrnls(1),
+    pause_secs(0),
+    randomize(false),
+    recover_mode(false),
+    repeat_flag(false),
+    reuse_instance(false),
+    seed(0)
+{
+    _options_descr.add_options()
+            ("csv-file,c",
+                    po::value<std::string>(&test_case_csv_file_name)->default_value("jtt.csv"),
+                    "CSV file containing test cases")
+            ("help,h", "This help message")
+            ("jrnl-format-chk", po::value<bool>(&jrnl_format_chk)->zero_tokens(),
+                    "If true, will check the format of each journal file")
+            ("keep-jrnls", po::value<bool>(&keep_jrnls)->zero_tokens(),
+                    "If true, will keep all test journals in backup dirs")
+            ("num-jrnls", po::value<unsigned>(&num_jrnls)->default_value(1),
+                    "Number of simultaneous journal instances to test")
+            ("pause", po::value<unsigned>(&pause_secs)->default_value(0),
+                    "Pause in seconds between test cases (allows disk to catch up)")
+            ("randomize", po::value<bool>(&randomize)->zero_tokens(),
+                    "Randomize the order of the test case execution")
+            ("recover-mode", po::value<bool>(&recover_mode)->zero_tokens(),
+                    "If true, will cause the journal from the previous test to be recovered")
+            ("repeat", po::value<bool>(&repeat_flag)->zero_tokens(),
+                    "If true, will repeat tests in csv file indefinitely")
+            ("reuse-instance", po::value<bool>(&reuse_instance)->zero_tokens(),
+                    "If true, will cause first journal instance to be reused for all test cases")
+            ("seed", po::value<unsigned>(&seed)->default_value(0),
+                    "Seed for use in random number generator");
+}
+
+const bool
+args::parse(int argc, char** argv) // return true if error, false if ok
+{
+    try
+    {
+        po::store(po::parse_command_line(argc, argv, _options_descr), _vmap);
+        po::notify(_vmap);
+    }
+    catch (const std::exception& e)
+    {
+        std::cout << "ERROR: " << e.what() << std::endl;
+        return usage();
+    }
+    if (_vmap.count("help"))
+        return usage();
+    if (num_jrnls == 0)
+    {
+        std::cout << "ERROR: num_jrnls must be 1 or more." << std::endl;
+        return usage();
+    }
+    if (repeat_flag && keep_jrnls)
+    {
+        std::string resp;
+        std::cout << "WARNING: repeat and keep-jrnls: Monitor disk usage as test journals will"
+                " accumulate." << std::endl;
+        std::cout << "Continue? <y/n> ";
+        std::cin >> resp;
+        if (resp.size() == 1)
+        {
+            if (resp[0] != 'y' && resp[0] != 'Y')
+                return true;
+        }
+        else if (resp.size() == 3) // any combo of lower- and upper-case
+        {
+            if (resp[0] != 'y' && resp[0] != 'Y')
+                return true;
+            if (resp[1] != 'e' && resp[1] != 'E')
+                return true;
+            if (resp[2] != 's' && resp[2] != 'S')
+                return true;
+        }
+        else
+            return true;
+    }
+    return false;
+}
+
+const bool
+args::usage() const
+{
+    std::cout << _options_descr << std::endl;
+    return true;
+}
+
+const void
+args::print_flags() const
+{
+    if (jrnl_format_chk || keep_jrnls || randomize || recover_mode || repeat_flag ||
+            reuse_instance)
+    {
+        std::cout << "Options:";
+        // TODO: Get flag args and their strings directly from _options_descr.
+        if (jrnl_format_chk)
+            std::cout << " jrnl-format-chk";
+        if (keep_jrnls)
+            std::cout << " keep-jrnls";
+        if (randomize)
+            std::cout << " randomize";
+        if (recover_mode)
+            std::cout << " recover-mode";
+        if (repeat_flag)
+            std::cout << " repeat-flag";
+        if (reuse_instance)
+            std::cout << " reuse-instance";
+        std::cout << std::endl;
+    }
+    std::cout << std::endl;
+}
+    
+} // namespace jtt
+} // namespace rhm

Copied: store/trunk/cpp/tests/jrnl/jtt/args.hpp (from rev 1615, store/trunk/cpp/tests/jrnl/jtt/options.hpp)
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/args.hpp	                        (rev 0)
+++ store/trunk/cpp/tests/jrnl/jtt/args.hpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -0,0 +1,60 @@
+/**
+* Copyright 2008 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library 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
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#ifndef rhm_jtt_args_hpp
+#define rhm_jtt_args_hpp
+
+#include <boost/program_options.hpp>
+
+namespace rhm
+{
+namespace jtt
+{
+
+    struct args
+    {
+        boost::program_options::options_description _options_descr;
+        boost::program_options::variables_map _vmap;
+
+        // Add args here
+        std::string test_case_csv_file_name;
+        bool jrnl_format_chk;
+        bool keep_jrnls;
+        unsigned num_jrnls;
+        unsigned pause_secs;
+        bool randomize;
+    	bool recover_mode;
+        bool repeat_flag;
+        bool reuse_instance;
+        unsigned seed;
+
+        args(std::string opt_title);
+        const bool parse(int argc, char** argv); // return true if error, false if ok
+        const bool usage() const; // return true
+        const void print_flags() const;
+    };
+
+} // namespace jtt
+} // namespace rhm
+
+#endif // ifndef rhm_jtt_args_hpp

Modified: store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.cpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -46,9 +46,7 @@
         _dtok_master_txn_list(),
         _dtok_deq_list(),
         _tcp(),
-        _tcrp(),
-        _recover_mode(false),
-        _keep_jrnls(false)
+        _tcrp()
 {
     pthread_mutex_init(&_ddl_mutex, 0);
 }
@@ -61,9 +59,7 @@
         _dtok_master_txn_list(),
         _dtok_deq_list(),
         _tcp(),
-        _tcrp(),
-        _recover_mode(false),
-        _keep_jrnls(false)
+        _tcrp()
 {
     pthread_mutex_init(&_ddl_mutex, 0);
 }
@@ -75,7 +71,7 @@
 
 
 void
-jrnl_instance::init_tc(test_case::shared_ptr& tcp, const bool recover_mode, const bool keep_jrnls)
+jrnl_instance::init_tc(test_case::shared_ptr& tcp, const bool recover_mode)
         throw ()
 {
     test_case_result::shared_ptr p(new test_case_result(_jpp->jid()));
@@ -83,13 +79,11 @@
     try
     {
         _tcp = tcp;
-        _recover_mode = recover_mode;
-        _keep_jrnls = keep_jrnls;
         _dtok_master_enq_list.clear();
         _dtok_master_txn_list.clear();
         _dtok_deq_list.clear();
 
-        if (_recover_mode)
+        if (recover_mode)
         {
             try
             {
@@ -139,10 +133,6 @@
     catch (...) { _tcrp->add_exception("Unknown exception"); }
     _tcrp->set_stop_time();
     _tcp->add_result(_tcrp);
-    
-    if (!_recover_mode && !_keep_jrnls)
-        try { rhm::journal::jdir::delete_dir(_jpp->jdir()); }
-        catch (...) {} // TODO - work out exception strategy for failure here...
 }
 
 void

Modified: store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/jrnl_instance.hpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -56,8 +56,6 @@
         pthread_t _read_thread;
         test_case::shared_ptr _tcp;
         test_case_result::shared_ptr _tcrp;
-        bool _recover_mode;
-        bool _keep_jrnls;
 
     public:
         jrnl_instance(const std::string& jid, const std::string& jdir,
@@ -70,7 +68,7 @@
         inline const jrnl_init_params::shared_ptr& params() const { return _jpp; }
         inline const std::string& jid() const { return _jpp->jid(); }
 
-        void init_tc(test_case::shared_ptr& tcp, const bool recover_mode, const bool keep_jrnls)
+        void init_tc(test_case::shared_ptr& tcp, const bool recover_mode)
                 throw ();
         void run_tc() throw ();
         void tc_wait_compl() throw ();

Modified: store/trunk/cpp/tests/jrnl/jtt/main.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/main.cpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/main.cpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -25,7 +25,7 @@
 #include "test_mgr.hpp"
 
 #include <iostream>
-#include "options.hpp"
+#include "args.hpp"
 #include <signal.h>
 
 namespace po = boost::program_options;
@@ -39,12 +39,12 @@
 
     std::ostringstream oss;
     oss << PACKAGE_NAME << " options";
-    rhm::jtt::options opts(oss.str());
-    if (opts.validate(argc, argv)) return 1;
+    rhm::jtt::args args(oss.str());
+    if (args.parse(argc, argv)) return 1;
 
     try
     {
-        rhm::jtt::test_mgr tm(opts);
+        rhm::jtt::test_mgr tm(args);
         tm.run();
     }
     catch (const std::exception& e)

Deleted: store/trunk/cpp/tests/jrnl/jtt/options.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/options.cpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/options.cpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -1,139 +0,0 @@
-/**
-* Copyright 2008 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#include "options.hpp"
-
-#include <iostream>
-
-namespace po = boost::program_options;
-
-namespace rhm
-{
-namespace jtt
-{
-
-options::options(std::string opt_title):
-    _options_descr(opt_title),
-    jrnl_format_chk(false),
-    reuse_instance(false),
-    recover_mode(false),
-    repeat_flag(false),
-    keep_jrnls(false)
-{
-    _options_descr.add_options()
-            ("help,h", "This help message")
-            ("num-jrnls", po::value<unsigned>(&num_jrnls)->default_value(1),
-                    "Number of simultaneous journal instances to test")
-            ("csv-file,c",
-                    po::value<std::string>(&test_case_csv_file_name)->default_value("jtt.csv"),
-                    "CSV file containing test cases")
-            ("jrnl-format-chk", po::value<bool>(&jrnl_format_chk)->zero_tokens(),
-                    "If true, will check the format of each journal file")
-            ("reuse-instance", po::value<bool>(&reuse_instance)->zero_tokens(),
-                    "If true, will cause first journal instance to be reused for all test cases")
-            ("recover-mode", po::value<bool>(&recover_mode)->zero_tokens(),
-                    "If true, will cause the journal from the previous test to be recovered")
-            ("repeat", po::value<bool>(&repeat_flag)->zero_tokens(),
-                    "If true, will repeat tests in csv file indefinitely")
-            ("keep-jrnls", po::value<bool>(&keep_jrnls)->zero_tokens(),
-                    "If true, will keep all test journals in backup dirs");
-}
-
-const bool
-options::validate(int argc, char** argv) // return true if error, false if ok
-{
-    try
-    {
-        po::store(po::parse_command_line(argc, argv, _options_descr), _vmap);
-        po::notify(_vmap);
-    }
-    catch (const std::exception& e)
-    {
-        std::cout << "ERROR: " << e.what() << std::endl;
-        return usage();
-    }
-    if (_vmap.count("help"))
-        return usage();
-    if (num_jrnls == 0)
-    {
-        std::cout << "ERROR: num_jrnls must be 1 or more." << std::endl;
-        return usage();
-    }
-    if (repeat_flag && keep_jrnls)
-    {
-        std::string resp;
-        std::cout << "WARNING: repeat and keep-jrnls: Monitor disk usage as test journals will"
-                " accumulate." << std::endl;
-        std::cout << "Continue? <y/n> ";
-        std::cin >> resp;
-        if (resp.size() == 1)
-        {
-            if (resp[0] != 'y' && resp[0] != 'Y')
-                return true;
-        }
-        else if (resp.size() == 3) // any combo of lower- and upper-case
-        {
-            if (resp[0] != 'y' && resp[0] != 'Y')
-                return true;
-            if (resp[1] != 'e' && resp[1] != 'E')
-                return true;
-            if (resp[2] != 's' && resp[2] != 'S')
-                return true;
-        }
-        else
-            return true;
-    }
-    return false;
-}
-
-const bool
-options::usage() const
-{
-    std::cout << _options_descr << std::endl;
-    return true;
-}
-
-const void
-options::print_flags() const
-{
-    if (jrnl_format_chk || reuse_instance || recover_mode || repeat_flag || keep_jrnls)
-    {
-        std::cout << "Options:";
-        // TODO: Get flag options and their strings directly from _options_descr.
-        if (jrnl_format_chk)
-            std::cout << " jrnl-format-chk";
-        if (reuse_instance)
-            std::cout << " reuse-instance";
-        if (recover_mode)
-            std::cout << " recover-mode";
-        if (repeat_flag)
-            std::cout << " repeat-flag";
-        if (keep_jrnls)
-            std::cout << " keep-jrnls";
-        std::cout << std::endl;
-    }
-    std::cout << std::endl;
-}
-    
-} // namespace jtt
-} // namespace rhm

Deleted: store/trunk/cpp/tests/jrnl/jtt/options.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/options.hpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/options.hpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -1,57 +0,0 @@
-/**
-* Copyright 2008 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library 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
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#ifndef rhm_jtt_options_hpp
-#define rhm_jtt_options_hpp
-
-#include <boost/program_options.hpp>
-
-namespace rhm
-{
-namespace jtt
-{
-
-    struct options
-    {
-        boost::program_options::options_description _options_descr;
-        boost::program_options::variables_map _vmap;
-
-        // Add options here
-        unsigned num_jrnls;
-        std::string test_case_csv_file_name;
-        bool jrnl_format_chk;
-        bool reuse_instance;
-    	bool recover_mode;
-        bool repeat_flag;
-        bool keep_jrnls;
-
-        options(std::string opt_title);
-        const bool validate(int argc, char** argv); // return true if error, false if ok
-        const bool usage() const; // return true
-        const void print_flags() const;
-    };
-
-} // namespace jtt
-} // namespace rhm
-
-#endif // ifndef rhm_jtt_options_hpp

Modified: store/trunk/cpp/tests/jrnl/jtt/test_case.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case.cpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case.cpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -113,6 +113,15 @@
         ari->second->add_test_result(tcrp);
 }
 
+void
+test_case::set_fmt_chk_res(const bool res, const std::string& jid)
+{
+    _result_average.set_fmt_chk_res(res);
+    res_map_citr ari = _result_jmap.find(jid);
+    if (ari != _result_jmap.end())
+        ari->second->set_fmt_chk_res(res);
+}
+
 const test_case_result::shared_ptr
 test_case::jmap_last(std::string& jid) const
 {

Modified: store/trunk/cpp/tests/jrnl/jtt/test_case.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case.hpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case.hpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -90,6 +90,7 @@
         inline const std::string& comment() const { return _comment; }
         
         void add_result(test_case_result::shared_ptr& p);
+        void set_fmt_chk_res(const bool res, const std::string& jid);
 
         inline const test_case_result_agregation& average() const { return _result_average; }
         inline const u_int32_t num_results() const { return _result_average.num_results(); }

Modified: store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -34,6 +34,8 @@
 test_case_result_agregation::test_case_result_agregation():
         test_case_result("Average"),
         _tc_average(true),
+        _fmt_chk_done(false),
+        _fmt_chk_err(false),
         _rlist()
 {
 }
@@ -41,6 +43,8 @@
 test_case_result_agregation::test_case_result_agregation(const std::string& jid):
         test_case_result(jid),
         _tc_average(false),
+        _fmt_chk_done(false),
+        _fmt_chk_err(false),
         _rlist()
 {}
 
@@ -128,6 +132,8 @@
         oss << "average (" << _rlist.size() << "):";
 
     oss << test_case_result::str_summary();
+    if (_fmt_chk_done)
+        oss << " fmt-chk=" << (_fmt_chk_err ? "ok" : "fail");
 
     if (_exception_list.size())
     {

Modified: store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -43,6 +43,8 @@
 
     private:
         bool _tc_average;
+        bool _fmt_chk_done;
+        bool _fmt_chk_err;
         tcrp_list _rlist;
 
     public:
@@ -53,6 +55,10 @@
         void add_test_result(const test_case_result::shared_ptr& tcrp);
 
         inline const bool tc_average_mode() const { return _tc_average; }
+        inline const bool fmt_chk_done() const { return _fmt_chk_done; }
+        inline const bool fmt_chk_res() const { return _fmt_chk_err; }
+        inline void set_fmt_chk_res(const bool err)
+                { _fmt_chk_done = true; if (!_fmt_chk_err && err) _fmt_chk_err = err; }
         inline const u_int32_t num_results() const { return _rlist.size(); }
         inline tcrp_list_citr rlist_begin() const { return _rlist.begin(); }
         inline tcrp_list_citr rlist_end() const { return _rlist.end(); }

Modified: store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -31,11 +31,14 @@
 namespace jtt
 {
 
-test_mgr::test_mgr(options& opts):
+test_mgr::test_mgr(args& args):
         _ji_list(),
-        _opts(opts)
+        _args(args),
+        _random_fn_ptr(random_fn)
 {
-    std::cout << "Number of journals: " << _opts.num_jrnls << std::endl;
+    std::cout << "Number of journals: " << _args.num_jrnls << std::endl;
+    if (args.seed)
+        ::srandom(args.seed);
 }
 
 test_mgr::~test_mgr()
@@ -51,8 +54,8 @@
     //       defualt: none of these, similar to current summary = true version.
     const bool summary = true;
 
-    std::cout << "CSV file: \"" << _opts.test_case_csv_file_name << "\"";
-    test_case_set tcs(_opts.test_case_csv_file_name, _opts.recover_mode);
+    std::cout << "CSV file: \"" << _args.test_case_csv_file_name << "\"";
+    test_case_set tcs(_args.test_case_csv_file_name, _args.recover_mode);
     const unsigned num_test_cases = tcs.size();
     if (num_test_cases)
     {
@@ -61,7 +64,7 @@
         if (tcs.ignored())
             std::cout << "WARNING: " << tcs.ignored() << " test cases were ignored. "
                     "(recover-mode selected and test has no auto-dequeue.)" << std::endl;
-        _opts.print_flags();
+        _args.print_flags();
     }
     else
         std::cout << " (WARNING: This CSV file is empty or does not exist.)" << std::endl;
@@ -69,6 +72,8 @@
     do
     {
         unsigned u = 0;
+        if (_args.randomize)
+            random_shuffle(tcs.begin(), tcs.end(), _random_fn_ptr);
         for (test_case_set::tcl_itr tci = tcs.begin(); tci != tcs.end(); tci++, u++)
         {
             if (summary)
@@ -76,39 +81,42 @@
                         (*tci)->comment() << "\"" << std::endl;
             else
                 std::cout << (*tci)->str() << std::endl;
-            if (!_opts.reuse_instance || _ji_list.empty())
+            if (!_args.reuse_instance || _ji_list.empty())
                 initialize_jrnls();
             for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
-                (*jii)->init_tc(*tci, _opts.recover_mode, _opts.keep_jrnls);
+                (*jii)->init_tc(*tci, _args.recover_mode);
             for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
                 (*jii)->run_tc();
             for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
                 (*jii)->tc_wait_compl();
-            if (_opts.jrnl_format_chk)
+            if (_args.jrnl_format_chk)
             {
                 for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
                 {
                     jrnl_init_params::shared_ptr jpp = (*jii)->params();
                     std::ostringstream oss;
-                    oss << "jfile_chk.py -q";
+                    oss << "./jfile_chk.py -q";
                     oss << " -d " << jpp->jdir();
                     oss << " -b " << jpp->base_filename();
-                    oss << " -c" << _opts.test_case_csv_file_name;
+                    oss << " -c" << _args.test_case_csv_file_name;
                     oss << " -t" << (*tci)->test_case_num();
-                    if (system(oss.str().c_str()))
-                    {
-                        std::cout << "  Format check of journal in \"" << jpp->jdir() <<
-                                "\" failed." << std::endl;
-                        std::cout << (*tci)->str() << std::endl;
-                    }
+                    bool res = system(oss.str().c_str()) == 0;
+                        (*tci)->set_fmt_chk_res(res, jpp->jid());
                 }
             }
+            if (!_args.recover_mode && !_args.keep_jrnls)
+                for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
+                    try { rhm::journal::jdir::delete_dir((*jii)->jrnl_dir()); }
+                    catch (...) {} // TODO - work out exception strategy for failure here...
+
             print_results(*tci, summary);
-            if (_abort || (!_opts.repeat_flag && _signal))
+            if (_abort || (!_args.repeat_flag && _signal))
                 break;
+            if (_args.pause_secs && tci != tcs.end())
+                ::usleep(_args.pause_secs * 1000000);
         }
     }
-    while (_opts.repeat_flag && !_signal);
+    while (_args.repeat_flag && !_signal);
 }
 
 // static fn:
@@ -132,7 +140,7 @@
 test_mgr::initialize_jrnls()
 {
     _ji_list.clear();
-    for (unsigned i=0; i<_opts.num_jrnls; i++)
+    for (unsigned i=0; i<_args.num_jrnls; i++)
     {
         std::ostringstream jid;
         jid << std::hex << std::setfill('0');

Modified: store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp	2008-01-28 16:00:39 UTC (rev 1616)
+++ store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp	2008-01-28 20:57:09 UTC (rev 1617)
@@ -25,7 +25,7 @@
 #define rhm_jtt_test_mgr_hpp
 
 #include "jrnl_instance.hpp"
-#include "options.hpp"
+#include "args.hpp"
 #include <signal.h>
 
 namespace rhm
@@ -41,12 +41,13 @@
 
     private:
         ji_list _ji_list;
-        options& _opts;
+        args& _args;
+        ptrdiff_t (*_random_fn_ptr)(const ptrdiff_t i);
         static volatile sig_atomic_t _signal;
         static volatile bool _abort;
 
     public:
-        test_mgr(options& opts);
+        test_mgr(args& args);
         ~test_mgr();
         void run();
         
@@ -55,6 +56,8 @@
     private:
         void initialize_jrnls();
         void print_results(test_case::shared_ptr tcp, const bool summary);
+        inline static ptrdiff_t random_fn(const ptrdiff_t i)
+                { return static_cast<ptrdiff_t>(1.0 * i * random() / RAND_MAX); }
     };
     
 } // namespace jtt




More information about the rhmessaging-commits mailing list