@@ -173,7 +173,8 @@ UnitTestResult perform_unit_test_once(const UnitTest &t, modsecurity::Transactio
173173
174174
175175template <typename TestType>
176- UnitTestResult perform_unit_test_multithreaded (const UnitTest &t, modsecurity::Transaction &transaction) {
176+ UnitTestResult perform_unit_test_multithreaded (const UnitTest &t,
177+ modsecurity_test::ModSecurityTestContext &context) {
177178
178179 constexpr auto NUM_THREADS = 50 ;
179180 constexpr auto ITERATIONS = 5'000 ;
@@ -188,8 +189,9 @@ UnitTestResult perform_unit_test_multithreaded(const UnitTest &t, modsecurity::T
188189 {
189190 auto &result = results[i];
190191 threads[i] = std::thread (
191- [&item, &t, &result, &transaction ]()
192+ [&item, &t, &result, &context ]()
192193 {
194+ auto transaction = context.create_transaction ();
193195 for (auto j = 0 ; j != ITERATIONS; ++j)
194196 result = TestType::eval (*item.get (), t, transaction);
195197 });
@@ -212,12 +214,13 @@ UnitTestResult perform_unit_test_multithreaded(const UnitTest &t, modsecurity::T
212214
213215template <typename TestType>
214216void perform_unit_test_helper (const ModSecurityTest<UnitTest> &test, UnitTest &t,
215- ModSecurityTestResults<UnitTest> &res, modsecurity::Transaction &transaction) {
217+ ModSecurityTestResults<UnitTest> &res, modsecurity::Transaction &transaction,
218+ modsecurity_test::ModSecurityTestContext &context) {
216219
217220 if (!test.m_test_multithreaded )
218221 t.result = perform_unit_test_once<TestType>(t, transaction);
219222 else
220- t.result = perform_unit_test_multithreaded<TestType>(t, transaction );
223+ t.result = perform_unit_test_multithreaded<TestType>(t, context );
221224
222225 if (TestType::check (t.result , t)) {
223226 res.push_back (&t);
@@ -257,9 +260,9 @@ void perform_unit_test(const ModSecurityTest<UnitTest> &test, UnitTest &t,
257260 }
258261
259262 if (t.type == " op" ) {
260- perform_unit_test_helper<OperatorTest>(test, t, res, transaction);
263+ perform_unit_test_helper<OperatorTest>(test, t, res, transaction, context );
261264 } else if (t.type == " tfn" ) {
262- perform_unit_test_helper<TransformationTest>(test, t, res, transaction);
265+ perform_unit_test_helper<TransformationTest>(test, t, res, transaction, context );
263266 } else {
264267 std::cerr << " Failed. Test type is unknown: << " << t.type ;
265268 std::cerr << std::endl;
0 commit comments