From: Tomek Mrugalski Date: Tue, 9 Aug 2016 14:36:04 +0000 (+0200) Subject: [4271] Debug in LogContnetTest class implemented. X-Git-Tag: trac4631_base~25^2~11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=30cdc3cbd8a981e34f0e30cfe3c29ff8e4371323;p=thirdparty%2Fkea.git [4271] Debug in LogContnetTest class implemented. --- diff --git a/src/lib/testutils/log_utils.cc b/src/lib/testutils/log_utils.cc index 2bfcc78843..669d91e01d 100644 --- a/src/lib/testutils/log_utils.cc +++ b/src/lib/testutils/log_utils.cc @@ -5,12 +5,14 @@ // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include +#include namespace isc { namespace dhcp { namespace test { -LogContentTest::LogContentTest() { +LogContentTest::LogContentTest() + :verbose_(false) { // Get rid of any old files remFile(); @@ -41,18 +43,31 @@ bool LogContentTest::checkFile() { int i = 0; bool found = true; + using namespace std; + while (getline(file, line) && (i != exp_strings_.size())) { exp_line = exp_strings_[i]; + if (verbose_) { + cout << "Read line :" << line << endl; + cout << "Looking for:" << exp_line << endl; + } i++; if (string::npos == line.find(exp_line)) { + if (verbose_) { + cout << "Verdict : not found" << endl; + } found = false; } } file.close(); - if ((i != exp_strings_.size()) || (found == false)) + if ((i != exp_strings_.size()) || (found == false)) { + if (verbose_) { + cout << "Final verdict: false" << endl; + } return (false); + } return (true); } diff --git a/src/lib/testutils/log_utils.h b/src/lib/testutils/log_utils.h index fbfd24cb33..340ef8a9b3 100644 --- a/src/lib/testutils/log_utils.h +++ b/src/lib/testutils/log_utils.h @@ -63,6 +63,12 @@ public: /// @brief remove the test log file void remFile(); + /// @brief Enables or disables verbose mode. + /// @param talk_a_lot (true - as the name says, false - shut up) + void logCheckVerbose(bool talk_a_lot) { + verbose_ = talk_a_lot; + } + /// @brief Add a string to the vector of expected strings /// /// @param new_string the string to add to the end of the vector @@ -71,6 +77,8 @@ public: vector exp_strings_; static const char* LOG_FILE; + + bool verbose_; };