diff --git a/test/regression/regression.cc b/test/regression/regression.cc index 1c23fc6e..b749afda 100644 --- a/test/regression/regression.cc +++ b/test/regression/regression.cc @@ -50,6 +50,13 @@ void print_help() { std::cout << std::endl; } +bool contains(const std::string &s, const std::string &pattern) { + bool ret; + modsecurity::Utils::Regex re(pattern); + ret = modsecurity::Utils::regex_search(s, re); + return ret; +} + void actions(ModSecurityTestResults *r, modsecurity::Transaction *a) { @@ -336,7 +343,7 @@ end: testRes->reason << "Debug log was not matching the " \ << "expected results." << std::endl; testRes->reason << KWHT << "Expecting: " << RESET \ - << t->debug_log + "."; + << t->debug_log + ""; testRes->passed = false; } else if (r.status != t->http_code) { if (test->m_automake_output) { @@ -349,6 +356,18 @@ end: std::to_string(t->http_code) + \ " got: " + std::to_string(r.status) + "\n"; testRes->passed = false; + } else if (!contains(serverLog.str(), t->error_log)) { + if (test->m_automake_output) { + std::cout << ":test-result: FAIL " << filename \ + << ":" << t->name << std::endl; + } else { + std::cout << KRED << "failed!" << RESET << std::endl; + } + testRes->reason << "Error log was not matching the " \ + << "expected results." << std::endl; + testRes->reason << KWHT << "Expecting: " << RESET \ + << t->error_log + ""; + testRes->passed = false; } else { if (test->m_automake_output) { std::cout << ":test-result: PASS " << filename \ @@ -364,9 +383,12 @@ end: testRes->reason << std::endl; testRes->reason << KWHT << "Debug log:" << RESET << std::endl; testRes->reason << d->log_messages() << std::endl; + testRes->reason << KWHT << "Error log:" << RESET << std::endl; + testRes->reason << serverLog.str() << std::endl; } } + after_debug_log: if (d != NULL) { r.log_raw_debug_log = d->log_messages(); diff --git a/test/regression/regression_test.cc b/test/regression/regression_test.cc index ab3ce633..02169e34 100644 --- a/test/regression/regression_test.cc +++ b/test/regression/regression_test.cc @@ -186,7 +186,7 @@ RegressionTest *RegressionTest::from_yajl_node(const yajl_val &node) { u->debug_log = YAJL_GET_STRING(val2); } if (strcmp(key2, "error_log") == 0) { - u->error_log = yajl_array_to_str(val2); + u->error_log = YAJL_GET_STRING(val2); } if (strcmp(key2, "http_code") == 0) { u->http_code = YAJL_GET_INTEGER(val2);