Fix regression test and example: checking if rules are loaded ok

It was checking only the amount of rules loaded, which could be 0 if
only configuration directives are loaded.
This commit is contained in:
Felipe Zimmerle 2015-08-25 07:31:27 -03:00
parent e94226f1d8
commit 15893e312b
2 changed files with 3 additions and 3 deletions

View File

@ -38,7 +38,7 @@ int main (int argc, char **argv)
rules = msc_create_rules_set();
ret = msc_rules_add_file(rules, main_rule_uri, &error);
if (ret == 0) {
if (ret < 0) {
fprintf(stderr, "Problems loading the rules --\n");
fprintf(stderr, "%s\n", error);
goto end;
@ -48,7 +48,7 @@ int main (int argc, char **argv)
ret = msc_rules_add_remote(rules, "test",
"https://www.modsecurity.org/modsecurity-regression-test-secremoterules.txt",
&error);
if (ret == 0) {
if (ret < 0) {
fprintf(stderr, "Problems loading the rules --\n");
fprintf(stderr, "%s\n", error);
goto end;

View File

@ -97,7 +97,7 @@ void perform_unit_test(std::vector<RegressionTest *> *tests,
" (ModSecurity regression test utility)");
modsec_rules = new ModSecurity::Rules(debug_log);
if (modsec_rules->load(t->rules.c_str(), filename) == false) {
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;