Commit 30cdc3cb authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[4271] Debug in LogContnetTest class implemented.

parent f59eab97
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
// file, You can obtain one at http://mozilla.org/MPL/2.0/. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <testutils/log_utils.h> #include <testutils/log_utils.h>
#include <iostream>
namespace isc { namespace isc {
namespace dhcp { namespace dhcp {
namespace test { namespace test {
LogContentTest::LogContentTest() { LogContentTest::LogContentTest()
:verbose_(false) {
// Get rid of any old files // Get rid of any old files
remFile(); remFile();
...@@ -41,18 +43,31 @@ bool LogContentTest::checkFile() { ...@@ -41,18 +43,31 @@ bool LogContentTest::checkFile() {
int i = 0; int i = 0;
bool found = true; bool found = true;
using namespace std;
while (getline(file, line) && (i != exp_strings_.size())) { while (getline(file, line) && (i != exp_strings_.size())) {
exp_line = exp_strings_[i]; exp_line = exp_strings_[i];
if (verbose_) {
cout << "Read line :" << line << endl;
cout << "Looking for:" << exp_line << endl;
}
i++; i++;
if (string::npos == line.find(exp_line)) { if (string::npos == line.find(exp_line)) {
if (verbose_) {
cout << "Verdict : not found" << endl;
}
found = false; found = false;
} }
} }
file.close(); 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 (false);
}
return (true); return (true);
} }
......
...@@ -63,6 +63,12 @@ public: ...@@ -63,6 +63,12 @@ public:
/// @brief remove the test log file /// @brief remove the test log file
void remFile(); 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 /// @brief Add a string to the vector of expected strings
/// ///
/// @param new_string the string to add to the end of the vector /// @param new_string the string to add to the end of the vector
...@@ -71,6 +77,8 @@ public: ...@@ -71,6 +77,8 @@ public:
vector<string> exp_strings_; vector<string> exp_strings_;
static const char* LOG_FILE; static const char* LOG_FILE;
bool verbose_;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment