<commit_before>//////////////////////////////////////////////////////////////////////////////
// Licensed to Qualys, Inc. (QUALYS) under one or more
// contributor license agreements.  See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// QUALYS licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License.  You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
/// @file
/// @brief IronBee --- PCRE module tests
///
/// @author <NAME> <<EMAIL>>
//////////////////////////////////////////////////////////////////////////////

#include "gtest/gtest.h"

#include "base_fixture.h"
#include <ironbee/rule_engine.h>
#include <ironbee/operator.h>
#include <ironbee/hash.h>
#include <ironbee/mpool.h>
#include <ironbee/field.h>
#include <ironbee/capture.h>
#include <ironbee/bytestr.h>

// @todo Remove once ib_engine_operator_get() is available.
#include "engine_private.h"

#include <string>

class PcreModuleTest : public BaseModuleFixture
{
public:

    ib_rule_exec_t rule_exec1;
    ib_rule_exec_t rule_exec2;
    ib_rule_t *rule1;
    ib_rule_t *rule2;
    ib_field_t* field1;
    ib_field_t* field2;

    PcreModuleTest() : BaseModuleFixture("ibmod_pcre.so")
    {
    }

    virtual void SetUp()
    {
        ib_status_t rc;
        const char *s1 = "string 1";
        const char *s2 = "string 2";

        BaseModuleFixture::SetUp();
        performTx();

        ib_mpool_t *mp = ib_engine_pool_main_get(ib_engine);
        char* str1 = (char *)ib_mpool_alloc(mp, (strlen(s1)+1));
        if (str1 == NULL) {
            throw std::runtime_error("Could not allocate string 1.");<commit_msg>modules/tests/test_module_pcre: Don't load pcre module twice.<commit_after>//////////////////////////////////////////////////////////////////////////////
// Licensed to Qualys, Inc. (QUALYS) under one or more
// contributor license agreements.  See the NOTICE file distributed with
// this work for additional information regarding copyright ownership.
// QUALYS licenses this file to You under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance with
// the License.  You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
/// @file
/// @brief IronBee --- PCRE module tests
///
/// @author <NAME> <<EMAIL>>
//////////////////////////////////////////////////////////////////////////////

#include "gtest/gtest.h"

#include "base_fixture.h"
#include <ironbee/rule_engine.h>
#include <ironbee/operator.h>
#include <ironbee/hash.h>
#include <ironbee/mpool.h>
#include <ironbee/field.h>
#include <ironbee/capture.h>
#include <ironbee/bytestr.h>

// @todo Remove once ib_engine_operator_get() is available.
#include "engine_private.h"

#include <string>

class PcreModuleTest : public BaseTransactionFixture
{
public:

    ib_rule_exec_t rule_exec1;
    ib_rule_exec_t rule_exec2;
    ib_rule_t *rule1;
    ib_rule_t *rule2;
    ib_field_t* field1;
    ib_field_t* field2;

    virtual void SetUp()
    {
        ib_status_t rc;
        const char *s1 = "string 1";
        const char *s2 = "string 2";

        BaseTransactionFixture::SetUp();
        configureIronBee();
        performTx();

        ib_mpool_t *mp = ib_engine_pool_main_get(ib_engine);
        char* str1 = (char *)ib_mpool_alloc(mp, (strlen(s1)+1));
        if (str1 == NULL) {
            throw std::runtime_error("Could not allocate string 1.");
{'fraction_non_alphanumeric': 0.23312073894875743, 'fraction_numerical': 0.008357158566087531, 'mean_word_length': 1.9783889980353635, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '228294', 'n_tokens_mistral': 1257, 'n_tokens_neox': 1233, 'n_words': 403}