Adds support to make check

The regression and unit tests are now integrated with `make check`.
It is possible to use make check -jN to have multiple tests running
in parallel.
This commit is contained in:
Felipe Zimmerle
2016-06-14 09:45:15 -03:00
parent 2e3da7ea24
commit f0155e3f32
8 changed files with 510 additions and 98 deletions

View File

@@ -136,34 +136,28 @@ std::pair<std::string, std::vector<T *>>* ModSecurityTest<T>::load_tests() {
template <class T>
void ModSecurityTest<T>::cmd_options(int argc, char **argv) {
#if HAS_GETOPT
int option_char;
GetOpt getopt(argc, argv, "hvct:");
while ((option_char = getopt()) != EOF) {
switch (option_char) {
case 'h':
print_help();
return;
break;
case 'v':
this->verbose = true;
break;
case 'c':
this->color = false;
break;
case 't':
this->target_folder = getopt.optarg;
break;
}
int i = 1;
if (argc > i && strcmp(argv[i], "automake") == 0) {
i++;
m_automake_output = true;
}
#else
if (argv[1]) {
this->target = argv[1];
if(const char* env_p = std::getenv("AUTOMAKE_TESTS")) {
m_automake_output = true;
}
if (argc > i && argv[i]) {
this->target = argv[i];
size_t pos = this->target.find(":");
if (pos != std::string::npos) {
std::string test_numbers = std::string(this->target, pos + 1,
this->target.length() - pos);
this->target = std::string(this->target, 0, pos);
m_test_number = std::atoi(test_numbers.c_str());
}
} else {
this->target = default_test_path;
}
#endif
}
} // namespace modsecurity_test

View File

@@ -31,6 +31,10 @@ namespace modsecurity_test {
template <class T> class ModSecurityTest :
public std::unordered_map<std::string, std::vector<T *> *> {
public:
ModSecurityTest()
: m_test_number(0),
m_automake_output(false) { }
std::string header();
void cmd_options(int, char **);
std::pair<std::string, std::vector<T *>>* load_tests();
@@ -40,6 +44,8 @@ template <class T> class ModSecurityTest :
std::string target;
bool verbose = false;
bool color = false;
int m_test_number;
bool m_automake_output;
};
} // namespace modsecurity_test