mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Cosmetic: Makes the parser error more verbose on the regression tests
This commit is contained in:
parent
5b18db779e
commit
6782fd0989
@ -103,8 +103,9 @@ void perform_unit_test(std::vector<RegressionTest *> *tests,
|
||||
|
||||
if (modsec_rules->load(t->rules.c_str(), filename) < 0) {
|
||||
if (t->parser_error.empty() == true) {
|
||||
std::cerr << "parse failed." << std::endl;
|
||||
std::cout << modsec_rules->getParserError() << std::endl;
|
||||
testRes->reason << KRED << "parse failed." << RESET << std::endl;
|
||||
testRes->reason << modsec_rules->getParserError() << std::endl;
|
||||
testRes->passed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -113,21 +114,29 @@ void perform_unit_test(std::vector<RegressionTest *> *tests,
|
||||
std::string s = modsec_rules->getParserError();
|
||||
|
||||
if (regex_search(s, &match, re) && match.size() >= 1) {
|
||||
std::cout << "passed!" << std::endl;
|
||||
testRes->reason << KGRN << "passed!" << RESET << std::endl;
|
||||
testRes->passed = true;
|
||||
return;
|
||||
} else {
|
||||
std::cout << "failed!" << std::endl;
|
||||
std::cout << "Expected a parser error." << std::endl;
|
||||
std::cout << "Expected: " << t->parser_error << std::endl;
|
||||
std::cout << "Produced: " << s << std::endl;
|
||||
testRes->reason << KRED << "failed!" << RESET << std::endl;
|
||||
testRes->reason << KWHT << "Expected a parser error." \
|
||||
<< RESET << std::endl;
|
||||
testRes->reason << KWHT << "Expected: " << RESET \
|
||||
<< t->parser_error << std::endl;
|
||||
testRes->reason << KWHT << "Produced: " << RESET \
|
||||
<< s << std::endl;
|
||||
testRes->passed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
if (t->parser_error.empty() == false) {
|
||||
std::cout << "failed!" << std::endl;
|
||||
std::cout << "Expected a parser error." << std::endl;
|
||||
std::cout << "Expected: " << t->parser_error << std::endl;
|
||||
std::cout << KRED << "failed!" << std::endl;
|
||||
std::cout << KWHT << "Expected a parser error." \
|
||||
<< RESET << std::endl;
|
||||
std::cout << KWHT << "Expected: " << RESET \
|
||||
<< t->parser_error << std::endl;
|
||||
testRes->passed = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user