mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 11:44:32 +03:00
Added support to run unit tests in a multithreaded context
- This is controlled by specifying the 'mtstress' argument when running `unit_test`. - The goal is to detect if the operator/transformation fails in this context. - In this mode, the test will be executed 5'000 times in 50 threads concurrently. - Allocation & initialization of the operator/transformation is performed once in the main thread, while the evaluation is executed in the threads. - This is consistent with the library's support for multithreading, where initialization and loading of rules is expected to run once. See issue #3215.
This commit is contained in:
@@ -102,15 +102,15 @@ std::string UnitTest::print() {
|
||||
i << " \"param\": \"" << this->param << "\"" << std::endl;
|
||||
i << " \"output\": \"" << this->output << "\"" << std::endl;
|
||||
i << "}" << std::endl;
|
||||
if (this->ret != this->obtained) {
|
||||
if (this->ret != this->result.ret) {
|
||||
i << "Expecting: \"" << this->ret << "\" - returned: \"";
|
||||
i << this->obtained << "\"" << std::endl;
|
||||
i << this->result.ret << "\"" << std::endl;
|
||||
}
|
||||
if (this->output != this->obtainedOutput) {
|
||||
if (this->output != this->result.output) {
|
||||
i << "Expecting: \"";
|
||||
i << modsecurity::utils::string::toHexIfNeeded(this->output);
|
||||
i << "\" - returned: \"";
|
||||
i << modsecurity::utils::string::toHexIfNeeded(this->obtainedOutput);
|
||||
i << modsecurity::utils::string::toHexIfNeeded(this->result.output);
|
||||
i << "\"";
|
||||
i << std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user