[rhmessaging-commits] rhmessaging commits: r3716 - store/trunk/cpp/tests/jrnl/jtt.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Wed Nov 18 09:45:18 EST 2009


Author: kpvdr
Date: 2009-11-18 09:45:15 -0500 (Wed, 18 Nov 2009)
New Revision: 3716

Modified:
   store/trunk/cpp/tests/jrnl/jtt/args.cpp
   store/trunk/cpp/tests/jrnl/jtt/args.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:
Some fixes to the jtt tool.

Modified: store/trunk/cpp/tests/jrnl/jtt/args.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/args.cpp	2009-11-17 16:39:29 UTC (rev 3715)
+++ store/trunk/cpp/tests/jrnl/jtt/args.cpp	2009-11-18 14:45:15 UTC (rev 3716)
@@ -70,13 +70,13 @@
 
         ("lld-rd-num",
          po::value<unsigned>(&lld_rd_num)->default_value(10),
-         "Number of consecutive messages to read after only dequeueing <lld-skip-num> "
+         "Number of consecutive messages to read after only dequeueing lld-skip-num "
          "messages during lazy-loading. Ignored if read-mode is not set to LAZYLOAD.")
 
         ("lld-skip-num",
          po::value<unsigned>(&lld_skip_num)->default_value(100),
          "Number of consecutive messages to dequeue only (without reading) prior to "
-         "reading <lld-rd-num> messages. Ignored if read-mode is not set to LAZYLOAD.")
+         "reading lld-rd-num messages. Ignored if read-mode is not set to LAZYLOAD.")
 
         ("num-jrnls",
          po::value<unsigned>(&num_jrnls)->default_value(1),
@@ -88,7 +88,7 @@
 
         ("randomize",
          po::value<bool>(&randomize)->zero_tokens(),
-         "Randomize the order of the test case execution.")
+         "Randomize the order of the tests.")
 
         ("read-mode",
          po::value<read_arg>(&read_mode)->default_value(read_arg::NONE),
@@ -104,7 +104,7 @@
 
         ("repeat",
          po::value<bool>(&repeat_flag)->zero_tokens(),
-         "Repeat all test cases in CSV file indefinitely.")
+         "Repeat all test cases indefinitely.")
 
         ("reuse-instance",
          po::value<bool>(&reuse_instance)->zero_tokens(),
@@ -114,9 +114,9 @@
          po::value<unsigned>(&seed)->default_value(0),
          "Seed for use in random number generator.")
 
-        ("ja-path",
-        po::value<std::string>(&jfile_analyze_path),
-        "Path to jfile_analyze file.")
+        ("analyzer",
+        po::value<std::string>(&jfile_analyzer)->default_value("./file_chk.py"),
+        "Journal file analyzer program to use when the --format-chk option is used, ignored otherwise.")
 
         ;
 }

Modified: store/trunk/cpp/tests/jrnl/jtt/args.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/args.hpp	2009-11-17 16:39:29 UTC (rev 3715)
+++ store/trunk/cpp/tests/jrnl/jtt/args.hpp	2009-11-18 14:45:15 UTC (rev 3716)
@@ -38,7 +38,7 @@
         boost::program_options::variables_map _vmap;
 
         // Add args here
-        std::string jfile_analyze_path;
+        std::string jfile_analyzer;
         std::string test_case_csv_file_name;
         std::string journal_dir;
         bool format_chk;

Modified: store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp	2009-11-17 16:39:29 UTC (rev 3715)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.cpp	2009-11-18 14:45:15 UTC (rev 3716)
@@ -36,7 +36,7 @@
         _tc_average(true),
         _fmt_chk_done(false),
         _fmt_chk_err(false),
-        _rlist()
+        _res_list()
 {
 }
 
@@ -45,7 +45,7 @@
         _tc_average(false),
         _fmt_chk_done(false),
         _fmt_chk_err(false),
-        _rlist()
+        _res_list()
 {}
 
 test_case_result_agregation::~test_case_result_agregation()
@@ -61,14 +61,14 @@
         _num_read += tcrp->num_read();
         add_test_time(tcrp->test_time());
         _exception_list.insert(_exception_list.end(), tcrp->begin(), tcrp->end());
-        _rlist.push_back(tcrp);
+        _res_list.push_back(tcrp);
     }
 }
 
 bool
 test_case_result_agregation::exception() const
 {
-    for (tcrp_list_citr i = _rlist.begin(); i < _rlist.end(); i++)
+    for (tcrp_list_citr i = _res_list.begin(); i < _res_list.end(); i++)
         if ((*i)->exception())
             return true;
     return false;
@@ -78,7 +78,7 @@
 test_case_result_agregation::exception_count() const
 {
     unsigned cnt = 0;
-    for (tcrp_list_citr i = _rlist.begin(); i < _rlist.end(); i++)
+    for (tcrp_list_citr i = _res_list.begin(); i < _res_list.end(); i++)
         cnt += (*i)->exception_count();
     return cnt;
 }
@@ -87,7 +87,7 @@
 test_case_result_agregation::clear()
 {
     test_case_result::clear();
-    _rlist.clear();
+    _res_list.clear();
 }
 
 const std::string
@@ -95,13 +95,13 @@
 {
     std::ostringstream oss;
     if (last_only)
-        oss << "  " << _rlist.at(_rlist.size()-1)->str(summary);
+        oss << "  " << _res_list.at(_res_list.size()-1)->str(summary);
     else
     {
-        for (tcrp_list_citr i=_rlist.begin(); i!=_rlist.end(); i++)
+        for (tcrp_list_citr i=_res_list.begin(); i!=_res_list.end(); i++)
             oss << "  " << (*i)->str(summary);
     }
-    if (_rlist.size() > 1)
+    if (_res_list.size() > 1)
          oss << "  " << (summary ? str_summary(last_only) : str_full(last_only));
     return oss.str();
 }
@@ -115,9 +115,9 @@
         oss << "Average across all journal instances:" << std::endl;
     else
         oss << "Average for jid=\"" << _jid << "\":" << std::endl;
-    oss << "  total number results: " << _rlist.size() << std::endl;
+    oss << "  total number results: " << _res_list.size() << std::endl;
     oss << "     number exceptions: " << _exception_list.size() << " (" <<
-            (100.0 * _rlist.size() / _exception_list.size()) << "%)" << std::endl;
+            (100.0 * _res_list.size() / _exception_list.size()) << "%)" << std::endl;
 
     oss << test_case_result::str_full();
 
@@ -129,10 +129,10 @@
             oss << "  " << n << ". " << (*i) << std::endl;
     }
 
-    if (!_tc_average && _rlist.size() > 1)
+    if (!_tc_average && _res_list.size() > 1)
     {
         oss << "Individual results:" << std::endl;
-        for (tcrp_list_citr i=_rlist.begin(); i!=_rlist.end(); i++)
+        for (tcrp_list_citr i=_res_list.begin(); i!=_res_list.end(); i++)
             oss << "  " << (*i)->str(false) << std::endl;
         oss << std::endl;
     }
@@ -145,13 +145,13 @@
 {
     std::ostringstream oss;
     if (_tc_average)
-        oss << "overall average [" << _rlist.size() << "]:";
+        oss << "overall average [" << _res_list.size() << "]:";
     else
-        oss << "average (" << _rlist.size() << "):";
+        oss << "average (" << _res_list.size() << "):";
 
     oss << test_case_result::str_summary();
     if (_fmt_chk_done)
-        oss << " fmt-chk=" << (_fmt_chk_err ? "ok" : "fail");
+        oss << " fmt-chk=" << (_fmt_chk_err ? "fail" : "ok");
 
     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	2009-11-17 16:39:29 UTC (rev 3715)
+++ store/trunk/cpp/tests/jrnl/jtt/test_case_result_agregation.hpp	2009-11-18 14:45:15 UTC (rev 3716)
@@ -26,6 +26,7 @@
 
 #include "test_case_result.hpp"
 
+#include <iostream>
 #include <vector>
 
 namespace mrg
@@ -45,7 +46,7 @@
         bool _tc_average;
         bool _fmt_chk_done;
         bool _fmt_chk_err;
-        tcrp_list _rlist;
+        tcrp_list _res_list;
 
     public:
         test_case_result_agregation(); // used for average across jrnl instances
@@ -58,12 +59,12 @@
         inline bool fmt_chk_done() const { return _fmt_chk_done; }
         inline 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 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(); }
+                { _fmt_chk_done = true; _fmt_chk_err |= err; if (err) add_exception("Journal format error"); }
+        inline u_int32_t num_results() const { return _res_list.size(); }
+        inline tcrp_list_citr rlist_begin() const { return _res_list.begin(); }
+        inline tcrp_list_citr rlist_end() const { return _res_list.end(); }
         inline const test_case_result::shared_ptr& operator[](unsigned i) const
-                { return _rlist[i]; }
+                { return _res_list[i]; }
         bool exception() const;
         unsigned exception_count() const;
 

Modified: store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp	2009-11-17 16:39:29 UTC (rev 3715)
+++ store/trunk/cpp/tests/jrnl/jtt/test_mgr.cpp	2009-11-18 14:45:15 UTC (rev 3716)
@@ -25,6 +25,7 @@
 
 #include <cstdlib>
 #include <iostream>
+#include <sys/stat.h>
 #include "test_case_set.hpp"
 
 namespace mrg
@@ -97,18 +98,22 @@
                 (*jii)->run_tc();
             for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
                 (*jii)->tc_wait_compl();
+
             if (_args.format_chk)
             {
                 for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
                 {
                     jrnl_init_params::shared_ptr jpp = (*jii)->params();
-                    std::string path = _args.jfile_analyze_path;
-                    if (path.empty()) path = ".";
-                    if (path[path.size()-1] != '/') path += "/";
+                    std::string ja = _args.jfile_analyzer;
+                    if (ja.empty()) ja = "./jfile_chk.py";
+                    if (!exists(ja))
+                    {
+                        std::ostringstream oss;
+                        oss << "ERROR: Validation program \"" << ja << "\" does not exist" << std::endl;
+                        throw std::runtime_error(oss.str());
+                    }
                     std::ostringstream oss;
-                    oss << path << "jfile_chk.py -q";
-                    oss << " -d " << jpp->jdir();
-                    oss << " -b " << jpp->base_filename();
+                    oss << ja << " -q -d " << jpp->jdir() << " -b " << jpp->base_filename();
                     // TODO: When jfile_check.py can handle previously recovered journals for
                     // specific tests, then remove this exclusion.
                     if (!_args.recover_mode)
@@ -116,10 +121,12 @@
                         oss << " -c" << _args.test_case_csv_file_name;
                         oss << " -t" << (*tci)->test_case_num();
                     }
-                    bool res = system(oss.str().c_str()) == 0;
-                        (*tci)->set_fmt_chk_res(res, jpp->jid());
+                    bool res = system(oss.str().c_str()) != 0;
+                    (*tci)->set_fmt_chk_res(res, jpp->jid());
+                    if (res) _err_flag = true;
                 }
             }
+
             if (!_args.recover_mode && !_args.keep_jrnls)
                 for (ji_list_citr jii=_ji_list.begin(); jii!=_ji_list.end(); jii++)
                     try { mrg::journal::jdir::delete_dir((*jii)->jrnl_dir()); }
@@ -154,6 +161,22 @@
     std::cout << "********************************" << std::endl << std::endl;
 }
 
+bool
+test_mgr::exists(std::string fname)
+{
+    struct stat s;
+    if (::stat(fname.c_str(), &s))
+    {
+        if (errno == ENOENT) // No such dir or file
+            return false;
+        // Throw for any other condition
+        std::ostringstream oss;
+        oss << "ERROR: test_mgr::exists(): file=\"" << fname << "\": " << FORMAT_SYSERR(errno);
+        throw std::runtime_error(oss.str());
+    }
+    return true;
+}
+
 void
 test_mgr::initialize_jrnls()
 {
@@ -177,12 +200,12 @@
     if (!summary)
         std::cout << "  === Results ===" << std::endl;
 
-// TODO - the reporting is broken when --repeat is used. The following commented-ot
+// TODO - the reporting is broken when --repeat is used. The following commented-out
 // section was an attempt to fix it, but there are too many side-effects.
 //     for (test_case::res_map_citr i=tcp->jmap_begin(); i!=tcp->jmap_end(); i++)
 //         std::cout << (*i).second->str(summary, summary);
 //     if (tcp->num_jrnls() > 1)
-        std::cout << tcp->average().str(false, summary);
+    std::cout << tcp->average().str(false, summary);
 
     if (!summary)
         std::cout << std::endl;

Modified: store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp	2009-11-17 16:39:29 UTC (rev 3715)
+++ store/trunk/cpp/tests/jrnl/jtt/test_mgr.hpp	2009-11-18 14:45:15 UTC (rev 3716)
@@ -57,6 +57,7 @@
         static void signal_handler(int signal);
 
     private:
+        static bool exists(std::string file_name);
         void initialize_jrnls();
         void print_results(test_case::shared_ptr tcp, const bool summary);
         inline static ptrdiff_t random_fn(const ptrdiff_t i)



More information about the rhmessaging-commits mailing list