diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 4b5a4ca5e..3898f9824 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -13,64 +13,22 @@ concurrency: cancel-in-progress: true jobs: - build_dependencies: - name: Build deps [ubuntu] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Get dependencies hash - id: get-hash - run: echo "deps_hash=`cat docker/build_deps.sh | shasum`" >> $GITHUB_OUTPUT - - name: Cache lookup - uses: actions/cache/restore@v4 - id: cache-lookup - with: - path: deps - key: deps-${{ steps.get-hash.outputs.deps_hash }} - lookup-only: true - - name: Set up dependencies - if: steps.cache-lookup.outputs.cache-hit != 'true' - run: | - sudo apt-get update - sudo apt-get install -qy build-essential \ - gdb \ - curl \ - python3.10 \ - python3-pip \ - cmake \ - ninja-build \ - pkg-config \ - bison \ - libfl-dev \ - libbenchmark-dev \ - libgmock-dev \ - libz-dev - - name: Fetch & Build non packaged dependencies - if: steps.cache-lookup.outputs.cache-hit != 'true' - run: | - mkdir -p deps - cd deps - ../docker/build_deps.sh - - name: Cache save - if: steps.cache-lookup.outputs.cache-hit != 'true' - uses: actions/cache/save@v4 - with: - path: deps - key: deps-${{ steps.get-hash.outputs.deps_hash }} + get_dependencies: + name: "Dependencies" + uses: ./.github/workflows/dependencies.yaml build_ubuntu: name: Build [ubuntu] runs-on: ubuntu-latest - needs: build_dependencies + needs: get_dependencies steps: - uses: actions/checkout@v4 - - name: Get dependencies hash - id: get-hash - run: echo "deps_hash=`cat docker/build_deps.sh | shasum`" >> $GITHUB_OUTPUT + - uses: actions/cache/restore@v4 with: path: deps - key: deps-${{ steps.get-hash.outputs.deps_hash }} + key: ${{ needs.get_dependencies.outputs.cache_key }} + - name: Set up dependencies run: | sudo apt-get update @@ -87,9 +45,11 @@ jobs: libbenchmark-dev \ libgmock-dev \ libz-dev + - name: Install cached non packaged dependencies working-directory: deps run: ../docker/build_deps.sh + - name: Build BlazingMQ env: PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig:/opt/bb/lib64/pkgconfig @@ -103,10 +63,12 @@ jobs: -DCMAKE_PREFIX_PATH=${{ github.workspace }}/deps/srcs/bde-tools/BdeBuildSystem \ -DCMAKE_INSTALL_LIBDIR=lib64 cmake --build build/blazingmq --parallel 8 --target all + - name: Clean-up build directories before caching run: | find . -name "*.o" -type f -delete find . -name "*.a" -type f -delete + - uses: actions/cache@v4 with: path: | @@ -118,16 +80,15 @@ jobs: unit_tests_cxx: name: UT [c++] runs-on: ubuntu-latest - needs: build_dependencies + needs: get_dependencies steps: - uses: actions/checkout@v4 - - name: Get dependencies hash - id: get-hash - run: echo "deps_hash=`cat docker/build_deps.sh | shasum`" >> $GITHUB_OUTPUT + - uses: actions/cache/restore@v4 with: path: deps - key: deps-${{ steps.get-hash.outputs.deps_hash }} + key: ${{ needs.get_dependencies.outputs.cache_key }} + - name: Set up dependencies run: | sudo apt-get update @@ -144,9 +105,11 @@ jobs: libbenchmark-dev \ libgmock-dev \ libz-dev + - name: Install cached non packaged dependencies working-directory: deps run: ../docker/build_deps.sh + - name: Build BlazingMQ UTs env: PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig:/opt/bb/lib64/pkgconfig @@ -160,6 +123,7 @@ jobs: -DCMAKE_PREFIX_PATH=${{ github.workspace }}/deps/srcs/bde-tools/BdeBuildSystem \ -DCMAKE_INSTALL_LIBDIR=lib64 cmake --build build/blazingmq --parallel 8 --target all.t + - name: Run C++ Unit Tests run: | cd ${{ github.workspace }}/build/blazingmq @@ -171,6 +135,7 @@ jobs: needs: build_ubuntu steps: - uses: actions/checkout@v4 + - uses: actions/cache/@v4 with: path: | @@ -178,6 +143,7 @@ jobs: deps /opt/bb/include key: cache-${{ github.sha }} + - name: Run Python Unit Tests env: PYTHONPATH: ${{ github.workspace }}/src/python @@ -200,6 +166,7 @@ jobs: needs: build_ubuntu steps: - uses: actions/checkout@v4 + - uses: actions/cache/@v4 with: path: | @@ -207,6 +174,7 @@ jobs: deps /opt/bb/include key: cache-${{ github.sha }} + - name: Run Integration Tests run: | pip install -r ${{ github.workspace }}/src/python/requirements.txt @@ -239,6 +207,7 @@ jobs: needs: build_ubuntu steps: - uses: actions/checkout@v4 + - uses: actions/cache/@v4 with: path: | @@ -246,6 +215,7 @@ jobs: deps /opt/bb/include key: cache-${{ github.sha }} + - name: Run Fuzz Test run: | pip install -r ${{ github.workspace }}/src/python/requirements.txt @@ -262,6 +232,7 @@ jobs: arch: arm64 steps: - uses: actions/checkout@v4 + - name: Set up dependencies run: | brew install \ @@ -271,6 +242,7 @@ jobs: bison \ flex \ google-benchmark + - name: Build BlazingMQ run: bin/build-darwin.sh @@ -280,6 +252,7 @@ jobs: needs: build_ubuntu steps: - uses: actions/checkout@v4 + - uses: actions/cache/@v4 with: path: | @@ -287,6 +260,7 @@ jobs: deps /opt/bb/include key: cache-${{ github.sha }} + - name: Set up plugins dependencies run: | sudo apt-get update @@ -304,11 +278,14 @@ jobs: libz-dev \ autoconf \ libtool + - name: Create dependency fetcher working directory run: mkdir -p deps + - name: Fetch & Build non packaged plugins dependencies working-directory: deps run: ${{ github.workspace }}/src/plugins/bmqprometheus/build_prometheus_deps.sh + - name: Build plugins env: PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig:/opt/bb/lib64/pkgconfig @@ -323,23 +300,30 @@ jobs: -DCMAKE_INSTALL_LIBDIR=lib64 \ -DINSTALL_TARGETS=prometheus cmake --build build/blazingmq --parallel 8 --target all + - name: Create prometheus dir run: mkdir -p prometheus_dir + - name: Download Prometheus run: curl -SL "https://github.com/prometheus/prometheus/releases/download/v2.45.1/prometheus-2.45.1.linux-amd64.tar.gz" | tar -xzC prometheus_dir/ + - name: Run Prometheus run: ./prometheus_dir/prometheus-2.45.1.linux-amd64/prometheus --config.file=${{ github.workspace }}/src/plugins/bmqprometheus/tests/prometheus_localhost.yaml --web.enable-lifecycle --storage.tsdb.path=${{ github.workspace }}/prometheus_dir/data & + - name: Run Pushgateway run: | docker pull prom/pushgateway docker run -d -p 9091:9091 prom/pushgateway + - name: Run BMQPrometheus plugin integration test in "pull" mode run: ${{ github.workspace }}/src/plugins/bmqprometheus/tests/bmqprometheus_prometheusstatconsumer_test.py -p ${{ github.workspace }}/build/blazingmq -m pull --no-docker + - name: Clear Prometheus database and restart run: | curl -X POST "http://localhost:9090/-/quit" rm -rf prometheus_dir/data ./prometheus_dir/prometheus-2.45.1.linux-amd64/prometheus --config.file=${{ github.workspace }}/src/plugins/bmqprometheus/tests/prometheus_localhost.yaml --web.enable-lifecycle --storage.tsdb.path=${{ github.workspace }}/prometheus_dir/data & + - name: Run Prometheus plugin integration test in "push" mode run: ${{ github.workspace }}/src/plugins/bmqprometheus/tests/bmqprometheus_prometheusstatconsumer_test.py -p ${{ github.workspace }}/build/blazingmq -m push --no-docker @@ -348,13 +332,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up dependencies run: | sudo apt-get update sudo apt-get install -qy doxygen + - name: Set up output directory run: | mkdir -p docs/docs/apidocs + - name: Build docs run: | doxygen Doxyfile @@ -364,6 +351,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Run ShellCheck uses: ludeeus/action-shellcheck@master @@ -372,7 +360,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Docker Single-Node Workflow run: docker compose -f docker/single-node/docker-compose.yaml up --build -d + - name: Docker Cluster Workflow run: docker compose -f docker/cluster/docker-compose.yaml up --build -d diff --git a/.github/workflows/dependencies.yaml b/.github/workflows/dependencies.yaml new file mode 100644 index 000000000..469c340f2 --- /dev/null +++ b/.github/workflows/dependencies.yaml @@ -0,0 +1,70 @@ +name: Dependencies + +on: + workflow_call: + outputs: + cache_key: + description: "GH Actions Cache key associated with the built dependencies" + value: ${{ jobs.build_dependencies.outputs.cache_key }} + schedule: + # Rebuild dependencies cache from the "main" branch at the beginning of a new day, + # so it is accessible from other branches' PRs + - cron: "10 0 * * *" + +concurrency: + group: deps-${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +jobs: + build_dependencies: + name: Build [ubuntu] + runs-on: ubuntu-latest + outputs: + cache_key: ${{ steps.get-cache-key.outputs.cache_key }} + steps: + - uses: actions/checkout@v4 + + - name: Generate dependencies cache key + id: get-cache-key + run: | + echo "cache_key=deps-`date +%y-%m-%d`-`cat docker/build_deps.sh | shasum`" >> $GITHUB_OUTPUT + + - name: Cache lookup + uses: actions/cache/restore@v4 + id: cache-lookup + with: + path: deps + key: ${{ steps.get-cache-key.outputs.cache_key }} + lookup-only: true + + - name: Set up build dependencies + if: steps.cache-lookup.outputs.cache-hit != 'true' + run: | + sudo apt-get update + sudo apt-get install -qy build-essential \ + gdb \ + curl \ + python3.10 \ + python3-pip \ + cmake \ + ninja-build \ + pkg-config \ + bison \ + libfl-dev \ + libbenchmark-dev \ + libgmock-dev \ + libz-dev + + - name: Fetch & build non packaged dependencies + if: steps.cache-lookup.outputs.cache-hit != 'true' + run: | + mkdir -p deps + cd deps + ../docker/build_deps.sh + + - name: Cache save + if: steps.cache-lookup.outputs.cache-hit != 'true' + uses: actions/cache/save@v4 + with: + path: deps + key: ${{ steps.get-cache-key.outputs.cache_key }} diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessorfactory.t.cpp b/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessorfactory.t.cpp index f819858cc..f4a3a62ee 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessorfactory.t.cpp +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessorfactory.t.cpp @@ -42,17 +42,18 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); // Empty parameters - CommandLineArguments arguments(s_allocator_p); - Parameters params(arguments, s_allocator_p); - bslma::ManagedPtr fileManager(new (*s_allocator_p) - FileManagerMock(), - s_allocator_p); + CommandLineArguments arguments(bmqtst::TestHelperUtil::allocator()); + Parameters params(arguments, bmqtst::TestHelperUtil::allocator()); + bslma::ManagedPtr fileManager( + new (*bmqtst::TestHelperUtil::allocator()) FileManagerMock(), + bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr cmdProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - bsl::cout, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + bsl::cout, + bmqtst::TestHelperUtil::allocator()); ASSERT(dynamic_cast(cmdProcessor.get()) != 0); } @@ -70,7 +71,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_journalfileprocessor.t.cpp b/src/applications/bmqstoragetool/m_bmqstoragetool_journalfileprocessor.t.cpp index d05da9b5a..b5fd76178 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_journalfileprocessor.t.cpp +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_journalfileprocessor.t.cpp @@ -180,28 +180,31 @@ static void test1_breathingTest() // Simulate journal file const size_t k_NUM_RECORDS = 15; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); journalFile.addAllTypesRecords(&records); // Prepare parameters - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected output with list of message GUIDs in Journal file - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); bsl::list::const_iterator recordIter = records.begin(); bsl::size_t foundMessagesCount = 0; @@ -235,12 +238,13 @@ static void test2_searchGuidTest() // Simulate journal file const size_t k_NUM_RECORDS = 15; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); journalFile.addAllTypesRecords(&records); // Prepare parameters - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); // Get list of message GUIDs for searching bsl::vector& searchGuids = params.d_guid; bsl::list::const_iterator recordIter = @@ -253,27 +257,30 @@ static void test2_searchGuidTest() continue; // Skip odd messages for test purposes const MessageRecord& msg = *reinterpret_cast( recordIter->second.buffer()); - bmqu::MemOutStream ss(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); ss << msg.messageGUID(); - searchGuids.push_back(bsl::string(ss.str(), s_allocator_p)); + searchGuids.push_back( + bsl::string(ss.str(), bmqtst::TestHelperUtil::allocator())); } } // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected output - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); bsl::vector::const_iterator guidIt = searchGuids.cbegin(); for (; guidIt != searchGuids.cend(); ++guidIt) { expectedStream << (*guidIt) << bsl::endl; @@ -299,38 +306,42 @@ static void test3_searchNonExistingGuidTest() // Simulate journal file const size_t k_NUM_RECORDS = 15; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); journalFile.addAllTypesRecords(&records); // Prepare parameters - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); // Get list of message GUIDs for searching bsl::vector& searchGuids = params.d_guid; bmqt::MessageGUID guid; for (int i = 0; i < 2; ++i) { mqbu::MessageGUIDUtil::generateGUID(&guid); - bmqu::MemOutStream ss(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); ss << guid; - searchGuids.push_back(bsl::string(ss.str(), s_allocator_p)); + searchGuids.push_back( + bsl::string(ss.str(), bmqtst::TestHelperUtil::allocator())); } // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected output - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); expectedStream << "No message GUID found." << bsl::endl; expectedStream << bsl::endl @@ -357,12 +368,13 @@ static void test4_searchExistingAndNonExistingGuidTest() // Simulate journal file const size_t k_NUM_RECORDS = 15; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); journalFile.addAllTypesRecords(&records); // Prepare parameters - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); // Get list of message GUIDs for searching bsl::vector& searchGuids = params.d_guid; @@ -378,9 +390,10 @@ static void test4_searchExistingAndNonExistingGuidTest() break; // Take two GUIDs const MessageRecord& msg = *reinterpret_cast( recordIter->second.buffer()); - bmqu::MemOutStream ss(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); ss << msg.messageGUID(); - searchGuids.push_back(bsl::string(ss.str(), s_allocator_p)); + searchGuids.push_back( + bsl::string(ss.str(), bmqtst::TestHelperUtil::allocator())); } } @@ -388,27 +401,30 @@ static void test4_searchExistingAndNonExistingGuidTest() bmqt::MessageGUID guid; for (int i = 0; i < 2; ++i) { mqbu::MessageGUIDUtil::generateGUID(&guid); - bmqu::MemOutStream ss(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); ss << guid; - searchGuids.push_back(bsl::string(ss.str(), s_allocator_p)); + searchGuids.push_back( + bsl::string(ss.str(), bmqtst::TestHelperUtil::allocator())); } // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected output - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); expectedStream << searchGuids[0] << bsl::endl << searchGuids[1] << bsl::endl; expectedStream << "2 message GUID(s) found." << bsl::endl; @@ -435,33 +451,37 @@ static void test5_searchOutstandingMessagesTest() // Simulate journal file const size_t k_NUM_RECORDS = 15; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); - JournalFile::GuidVectorType outstandingGUIDS(s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); + JournalFile::GuidVectorType outstandingGUIDS( + bmqtst::TestHelperUtil::allocator()); journalFile.addJournalRecordsWithOutstandingAndConfirmedMessages( &records, &outstandingGUIDS, true); // Configure parameters to search outstanding messages - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); params.d_outstanding = true; // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected output - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); JournalFile::GuidVectorType::const_iterator guidIt = outstandingGUIDS.cbegin(); for (; guidIt != outstandingGUIDS.cend(); ++guidIt) { @@ -496,33 +516,37 @@ static void test6_searchConfirmedMessagesTest() // Simulate journal file const size_t k_NUM_RECORDS = 15; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); - JournalFile::GuidVectorType confirmedGUIDS(s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); + JournalFile::GuidVectorType confirmedGUIDS( + bmqtst::TestHelperUtil::allocator()); journalFile.addJournalRecordsWithOutstandingAndConfirmedMessages( &records, &confirmedGUIDS, false); // Configure parameters to search confirmed messages - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); params.d_confirmed = true; // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected output - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); JournalFile::GuidVectorType::const_iterator guidIt = confirmedGUIDS.cbegin(); for (; guidIt != confirmedGUIDS.cend(); ++guidIt) { @@ -560,32 +584,36 @@ static void test7_searchPartiallyConfirmedMessagesTest() // k_NUM_RECORDS must be multiple 3 plus one to cover all combinations // (confirmed, deleted, not confirmed) const size_t k_NUM_RECORDS = 16; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); - JournalFile::GuidVectorType partiallyConfirmedGUIDS(s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); + JournalFile::GuidVectorType partiallyConfirmedGUIDS( + bmqtst::TestHelperUtil::allocator()); journalFile.addJournalRecordsWithPartiallyConfirmedMessages( &records, &partiallyConfirmedGUIDS); // Configure parameters to search partially confirmed messages - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); params.d_partiallyConfirmed = true; // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected output - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); JournalFile::GuidVectorType::const_iterator guidIt = partiallyConfirmedGUIDS.cbegin(); for (; guidIt != partiallyConfirmedGUIDS.cend(); ++guidIt) { @@ -620,35 +648,39 @@ static void test8_searchMessagesByQueueKeyTest() // Simulate journal file const size_t k_NUM_RECORDS = 15; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); const char* queueKey1 = "ABCDE12345"; const char* queueKey2 = "12345ABCDE"; - JournalFile::GuidVectorType queueKey1GUIDS(s_allocator_p); + JournalFile::GuidVectorType queueKey1GUIDS( + bmqtst::TestHelperUtil::allocator()); journalFile.addJournalRecordsWithTwoQueueKeys(&records, &queueKey1GUIDS, queueKey1, queueKey2); // Configure parameters to search messages by queueKey1 - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); params.d_queueKey.push_back(queueKey1); // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected output - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); JournalFile::GuidVectorType::const_iterator guidIt = queueKey1GUIDS.cbegin(); for (; guidIt != queueKey1GUIDS.cend(); ++guidIt) { @@ -677,45 +709,49 @@ static void test9_searchMessagesByQueueNameTest() // Simulate journal file const size_t k_NUM_RECORDS = 15; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); const char* queueKey1 = "ABCDE12345"; const char* queueKey2 = "12345ABCDE"; - JournalFile::GuidVectorType queueKey1GUIDS(s_allocator_p); + JournalFile::GuidVectorType queueKey1GUIDS( + bmqtst::TestHelperUtil::allocator()); journalFile.addJournalRecordsWithTwoQueueKeys(&records, &queueKey1GUIDS, queueKey1, queueKey2); // Configure parameters to search messages by 'queue1' name - bmqp_ctrlmsg::QueueInfo queueInfo(s_allocator_p); + bmqp_ctrlmsg::QueueInfo queueInfo(bmqtst::TestHelperUtil::allocator()); queueInfo.uri() = "queue1"; mqbu::StorageKey key(mqbu::StorageKey::HexRepresentation(), queueKey1); for (int i = 0; i < mqbu::StorageKey::e_KEY_LENGTH_BINARY; i++) { queueInfo.key().push_back(key.data()[i]); } - QueueMap qMap(s_allocator_p); + QueueMap qMap(bmqtst::TestHelperUtil::allocator()); - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); params.d_queueName.push_back("queue1"); params.d_queueMap.insert(queueInfo); // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected output - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); JournalFile::GuidVectorType::const_iterator guidIt = queueKey1GUIDS.cbegin(); for (; guidIt != queueKey1GUIDS.cend(); ++guidIt) { @@ -745,11 +781,13 @@ static void test10_searchMessagesByQueueNameAndQueueKeyTest() // Simulate journal file const size_t k_NUM_RECORDS = 15; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); const char* queueKey1 = "ABCDE12345"; const char* queueKey2 = "12345ABCDE"; - JournalFile::GuidVectorType queueKey1GUIDS(s_allocator_p); + JournalFile::GuidVectorType queueKey1GUIDS( + bmqtst::TestHelperUtil::allocator()); journalFile.addJournalRecordsWithTwoQueueKeys(&records, &queueKey1GUIDS, queueKey1, @@ -758,35 +796,37 @@ static void test10_searchMessagesByQueueNameAndQueueKeyTest() // Configure parameters to search messages by 'queue1' name and queueKey2 // key. - bmqp_ctrlmsg::QueueInfo queueInfo(s_allocator_p); + bmqp_ctrlmsg::QueueInfo queueInfo(bmqtst::TestHelperUtil::allocator()); queueInfo.uri() = "queue1"; mqbu::StorageKey key(mqbu::StorageKey::HexRepresentation(), queueKey1); for (int i = 0; i < mqbu::StorageKey::e_KEY_LENGTH_BINARY; i++) { queueInfo.key().push_back(key.data()[i]); } - QueueMap qMap(s_allocator_p); + QueueMap qMap(bmqtst::TestHelperUtil::allocator()); - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); params.d_queueName.push_back("queue1"); params.d_queueMap.insert(queueInfo); params.d_queueKey.push_back(queueKey2); // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected output - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); JournalFile::GuidVectorType::const_iterator guidIt = queueKey1GUIDS.cbegin(); for (; guidIt != queueKey1GUIDS.cend(); ++guidIt) { @@ -814,24 +854,26 @@ static void test11_searchMessagesByTimestamp() // Simulate journal file const size_t k_NUM_RECORDS = 50; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); journalFile.addAllTypesRecords(&records); const bsls::Types::Uint64 ts1 = 10 * journalFile.timestampIncrement(); const bsls::Types::Uint64 ts2 = 40 * journalFile.timestampIncrement(); // Configure parameters to search messages by timestamps - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); params.d_timestampGt = ts1; params.d_timestampLt = ts2; // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Get GUIDs of messages with matching timestamps and prepare expected // output - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); bsl::list::const_iterator recordIter = records.begin(); @@ -851,12 +893,13 @@ static void test11_searchMessagesByTimestamp() expectedStream << msgCnt << " message GUID(s) found." << bsl::endl; // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); ASSERT_EQ(resultStream.str(), expectedStream.str()); @@ -883,33 +926,38 @@ static void test12_printMessagesDetailsTest() // Simulate journal file const size_t k_NUM_RECORDS = 15; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); - JournalFile::GuidVectorType confirmedGUIDS(s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); + JournalFile::GuidVectorType confirmedGUIDS( + bmqtst::TestHelperUtil::allocator()); journalFile.addJournalRecordsWithOutstandingAndConfirmedMessages( &records, &confirmedGUIDS, false); // Configure parameters to print message details - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); params.d_details = true; // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Check that substrings are present in resultStream in correct order - bsl::string resultString(resultStream.str(), s_allocator_p); + bsl::string resultString(resultStream.str(), + bmqtst::TestHelperUtil::allocator()); size_t startIdx = 0; const char* messageRecordCaption = "MESSAGE Record"; const char* confirmRecordCaption = "CONFIRM Record"; @@ -922,9 +970,9 @@ static void test12_printMessagesDetailsTest() startIdx = foundIdx + bsl::strlen(messageRecordCaption); // Check GUID - bmqu::MemOutStream ss(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); outputGuidString(ss, confirmedGUIDS.at(i)); - bsl::string guidStr(ss.str(), s_allocator_p); + bsl::string guidStr(ss.str(), bmqtst::TestHelperUtil::allocator()); foundIdx = resultString.find(guidStr, startIdx); ASSERT_D(guidStr, (foundIdx != bsl::string::npos)); ASSERT_D(guidStr, (foundIdx >= startIdx)); @@ -991,8 +1039,9 @@ static void test13_searchMessagesWithPayloadDumpTest() FileHeader fileHeader; MappedFileDescriptor mfdData; - bsl::vector messageOffsets(s_allocator_p); - char* pd = addDataRecords(s_allocator_p, + bsl::vector messageOffsets( + bmqtst::TestHelperUtil::allocator()); + char* pd = addDataRecords(bmqtst::TestHelperUtil::allocator(), &mfdData, &fileHeader, MESSAGES, @@ -1007,9 +1056,11 @@ static void test13_searchMessagesWithPayloadDumpTest() const size_t k_NUM_RECORDS = k_NUM_MSGS * 2; // k_NUM_MSGS records + k_NUM_MSGS deletion records - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); - JournalFile::GuidVectorType confirmedGUIDS(s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); + JournalFile::GuidVectorType confirmedGUIDS( + bmqtst::TestHelperUtil::allocator()); journalFile.addJournalRecordsWithConfirmedMessagesWithDifferentOrder( &records, &confirmedGUIDS, @@ -1018,30 +1069,34 @@ static void test13_searchMessagesWithPayloadDumpTest() // Configure parameters to search confirmed messages GUIDs with dumping // messages payload. - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); params.d_confirmed = true; params.d_dumpPayload = true; // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); EXPECT_CALL(static_cast(*fileManager), dataFileIterator()) .WillRepeatedly(testing::Return(&dataIt)); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected data - bsl::string resultString(resultStream.str(), s_allocator_p); + bsl::string resultString(resultStream.str(), + bmqtst::TestHelperUtil::allocator()); size_t startIdx = 0; - bsl::vector expectedPayloadSubstring(s_allocator_p); + bsl::vector expectedPayloadSubstring( + bmqtst::TestHelperUtil::allocator()); expectedPayloadSubstring.push_back("DATA_1"); expectedPayloadSubstring.push_back("DATA_3"); expectedPayloadSubstring.push_back("DATA_2"); @@ -1055,9 +1110,9 @@ static void test13_searchMessagesWithPayloadDumpTest() for (unsigned int i = 0; i < k_NUM_MSGS; i++) { // Check GUID bmqt::MessageGUID guid = confirmedGUIDS.at(i); - bmqu::MemOutStream ss(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); outputGuidString(ss, guid); - bsl::string guidStr(ss.str(), s_allocator_p); + bsl::string guidStr(ss.str(), bmqtst::TestHelperUtil::allocator()); size_t foundIdx = resultString.find(guidStr, startIdx); ASSERT_D(guidStr, (foundIdx != bsl::string::npos)); @@ -1074,7 +1129,7 @@ static void test13_searchMessagesWithPayloadDumpTest() startIdx = foundIdx + dumpStr.length(); } - s_allocator_p->deallocate(pd); + bmqtst::TestHelperUtil::allocator()->deallocate(pd); } static void test14_summaryTest() @@ -1092,38 +1147,42 @@ static void test14_summaryTest() // Simulate journal file const size_t k_NUM_RECORDS = 15; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); - JournalFile::GuidVectorType partiallyConfirmedGUIDS(s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); + JournalFile::GuidVectorType partiallyConfirmedGUIDS( + bmqtst::TestHelperUtil::allocator()); journalFile.addJournalRecordsWithPartiallyConfirmedMessages( &records, &partiallyConfirmedGUIDS); // Configure parameters to output summary - Parameters params(s_allocator_p); + Parameters params(bmqtst::TestHelperUtil::allocator()); params.d_summary = true; // Prepare file manager bslma::ManagedPtr fileManager( - new (*s_allocator_p) FileManagerMock(journalFile), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + FileManagerMock(journalFile), + bmqtst::TestHelperUtil::allocator()); // Run search - bmqu::MemOutStream resultStream(s_allocator_p); + bmqu::MemOutStream resultStream(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr searchProcessor = - CommandProcessorFactory::createCommandProcessor(¶ms, - fileManager, - resultStream, - s_allocator_p); + CommandProcessorFactory::createCommandProcessor( + ¶ms, + fileManager, + resultStream, + bmqtst::TestHelperUtil::allocator()); searchProcessor->process(); // Prepare expected output - bmqu::MemOutStream expectedStream(s_allocator_p); + bmqu::MemOutStream expectedStream(bmqtst::TestHelperUtil::allocator()); expectedStream << "5 message(s) found.\nNumber of confirmed messages: 3\nNumber of " "partially confirmed messages: 2\n" "Number of outstanding messages: 2\nOutstanding ratio: 40% (2/5)\n"; - bsl::string res(resultStream.str(), s_allocator_p); + bsl::string res(resultStream.str(), bmqtst::TestHelperUtil::allocator()); ASSERT(res.starts_with(expectedStream.str())); } @@ -1143,8 +1202,9 @@ static void test15_timestampSearchTest() // Simulate journal file const size_t k_NUM_RECORDS = 50; - JournalFile::RecordsListType records(s_allocator_p); - JournalFile journalFile(k_NUM_RECORDS, s_allocator_p); + JournalFile::RecordsListType records(bmqtst::TestHelperUtil::allocator()); + JournalFile journalFile(k_NUM_RECORDS, + bmqtst::TestHelperUtil::allocator()); journalFile.addAllTypesRecords(&records); struct ResultChecker { @@ -1278,7 +1338,7 @@ int main(int argc, char* argv[]) case 15: test15_timestampSearchTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_searchresultfactory.t.cpp b/src/applications/bmqstoragetool/m_bmqstoragetool_searchresultfactory.t.cpp index 91cd63194..1c1aa77f9 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_searchresultfactory.t.cpp +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_searchresultfactory.t.cpp @@ -43,17 +43,18 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); // Empty parameters - CommandLineArguments arguments(s_allocator_p); - Parameters params(arguments, s_allocator_p); - bslma::ManagedPtr fileManager(new (*s_allocator_p) - FileManagerMock(), - s_allocator_p); + CommandLineArguments arguments(bmqtst::TestHelperUtil::allocator()); + Parameters params(arguments, bmqtst::TestHelperUtil::allocator()); + bslma::ManagedPtr fileManager( + new (*bmqtst::TestHelperUtil::allocator()) FileManagerMock(), + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr searchResult = - SearchResultFactory::createSearchResult(¶ms, - fileManager, - bsl::cout, - s_allocator_p); + SearchResultFactory::createSearchResult( + ¶ms, + fileManager, + bsl::cout, + bmqtst::TestHelperUtil::allocator()); ASSERT(dynamic_cast(searchResult.get()) != 0); } @@ -70,7 +71,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/applications/bmqtool/m_bmqtool_inpututil.t.cpp b/src/applications/bmqtool/m_bmqtool_inpututil.t.cpp index f52c32057..37fba0b55 100644 --- a/src/applications/bmqtool/m_bmqtool_inpututil.t.cpp +++ b/src/applications/bmqtool/m_bmqtool_inpututil.t.cpp @@ -101,12 +101,17 @@ static void test1_decodeHexDumpTest() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bsl::istringstream input(bsl::string(test.d_hexdumpStr, s_allocator_p), - s_allocator_p); - bmqu::MemOutStream output(s_allocator_p); - bmqu::MemOutStream error(s_allocator_p); - const bool rc = - InputUtil::decodeHexDump(&output, &error, input, s_allocator_p); + bsl::istringstream input( + bsl::string(test.d_hexdumpStr, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream output(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream error(bmqtst::TestHelperUtil::allocator()); + const bool rc = InputUtil::decodeHexDump( + &output, + &error, + input, + bmqtst::TestHelperUtil::allocator()); // Check rc ASSERT_EQ_D(test.d_line, rc, test.d_expectedRc); // Check error @@ -251,13 +256,14 @@ static void test2_loadMessageFromFileTest() // Check wrong file path { - bmqu::MemOutStream stream(s_allocator_p); - bmqu::MemOutStream error(s_allocator_p); - const bool rc = InputUtil::loadMessageFromFile(&stream, - &stream, - &error, - "wrongFilePath", - s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream error(bmqtst::TestHelperUtil::allocator()); + const bool rc = InputUtil::loadMessageFromFile( + &stream, + &stream, + &error, + "wrongFilePath", + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, false); ASSERT_EQ(error.str(), "Failed to open file: wrongFilePath"); } @@ -267,7 +273,7 @@ static void test2_loadMessageFromFileTest() const Test& test = k_DATA[idx]; // Create temp file and write content - bmqu::TempFile tempFile(s_allocator_p); + bmqu::TempFile tempFile(bmqtst::TestHelperUtil::allocator()); const bsl::string filePath = tempFile.path(); { bsl::ofstream ofs(filePath.c_str()); @@ -275,14 +281,15 @@ static void test2_loadMessageFromFileTest() ofs << test.d_fileContent; } - bmqu::MemOutStream payload(s_allocator_p); - bsl::ostringstream properties(s_allocator_p); - bmqu::MemOutStream error(s_allocator_p); - const bool rc = InputUtil::loadMessageFromFile(&payload, - &properties, - &error, - filePath, - s_allocator_p); + bmqu::MemOutStream payload(bmqtst::TestHelperUtil::allocator()); + bsl::ostringstream properties(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream error(bmqtst::TestHelperUtil::allocator()); + const bool rc = InputUtil::loadMessageFromFile( + &payload, + &properties, + &error, + filePath, + bmqtst::TestHelperUtil::allocator()); // Check rc ASSERT_EQ_D(test.d_line, rc, test.d_expectedRc); // Check error @@ -290,9 +297,12 @@ static void test2_loadMessageFromFileTest() // Check payload ASSERT_EQ_D(test.d_line, payload.str(), test.d_expectedPayload); // Check properties (deserialize into properties instance) - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); - bmqa::MessageProperties messageProperties(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bmqa::MessageProperties messageProperties( + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, properties.str().c_str(), static_cast(properties.str().size())); @@ -314,7 +324,7 @@ int main(int argc, char* argv[]) case 2: test2_loadMessageFromFileTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqa/bmqa_abstractsession.t.cpp b/src/groups/bmq/bmqa/bmqa_abstractsession.t.cpp index 84d416755..3355f20be 100644 --- a/src/groups/bmq/bmqa/bmqa_abstractsession.t.cpp +++ b/src/groups/bmq/bmqa/bmqa_abstractsession.t.cpp @@ -291,7 +291,7 @@ static void test1_breathingTest() // PROTOCOL TEST // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // The default allocator check fails in this test case because the // 'markDone' methods of AbstractSession may sometimes return a // memory-aware object without utilizing the parameter allocator. @@ -302,7 +302,8 @@ static void test1_breathingTest() bmqa::AbstractSession concreteObj; PV("Creating a test object"); - bsls::ProtocolTest testObj(s_verbosityLevel > 2); + bsls::ProtocolTest testObj( + bmqtst::TestHelperUtil::verbosityLevel() > 2); PV("Verify that the protocol is NOT abstract"); ASSERT(!testObj.testAbstract()); @@ -327,9 +328,11 @@ static void test1_breathingTest() bmqt::Uri dummyUri; bsls::TimeInterval dummyTimeInterval(0); - bmqa::OpenQueueStatus openQueueResult(s_allocator_p); - bmqa::ConfigureQueueStatus configureQueueResult(s_allocator_p); - bmqa::CloseQueueStatus closeQueueResult(s_allocator_p); + bmqa::OpenQueueStatus openQueueResult(bmqtst::TestHelperUtil::allocator()); + bmqa::ConfigureQueueStatus configureQueueResult( + bmqtst::TestHelperUtil::allocator()); + bmqa::CloseQueueStatus closeQueueResult( + bmqtst::TestHelperUtil::allocator()); const bmqa::AbstractSession::OpenQueueCallback openQueueCallback; const bmqa::AbstractSession::ConfigureQueueCallback configureQueueCallback; @@ -442,7 +445,7 @@ static void test2_instanceInvariants() // INSTANCE INVARIANTS // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't ensure no default memory is allocated because a default // QueueId is instantiated and that uses the default allocator to // allocate memory for an automatically generated CorrelationId. @@ -464,12 +467,14 @@ static void test2_instanceInvariants() bmqa::QueueId* dummyQueueIdPtr = 0; bmqt::CorrelationId dummyCorrelationId; bmqt::QueueOptions dummyQueueOptions; - bmqt::Uri dummyUri(s_allocator_p); + bmqt::Uri dummyUri(bmqtst::TestHelperUtil::allocator()); bsls::TimeInterval dummyTimeInterval(0); - bmqa::OpenQueueStatus openQueueResult(s_allocator_p); - bmqa::ConfigureQueueStatus configureQueueResult(s_allocator_p); - bmqa::CloseQueueStatus closeQueueResult(s_allocator_p); + bmqa::OpenQueueStatus openQueueResult(bmqtst::TestHelperUtil::allocator()); + bmqa::ConfigureQueueStatus configureQueueResult( + bmqtst::TestHelperUtil::allocator()); + bmqa::CloseQueueStatus closeQueueResult( + bmqtst::TestHelperUtil::allocator()); const bmqa::AbstractSession::OpenQueueCallback openQueueCallback; const bmqa::AbstractSession::ConfigureQueueCallback configureQueueCallback; @@ -622,7 +627,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqa/bmqa_closequeuestatus.t.cpp b/src/groups/bmq/bmqa/bmqa_closequeuestatus.t.cpp index fe20d2321..31222e65b 100644 --- a/src/groups/bmq/bmqa/bmqa_closequeuestatus.t.cpp +++ b/src/groups/bmq/bmqa/bmqa_closequeuestatus.t.cpp @@ -55,27 +55,28 @@ static void test1_breathingTest() PV("Default Constructor"); { - bmqa::CloseQueueStatus obj(s_allocator_p); + bmqa::CloseQueueStatus obj(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bool(obj), true); ASSERT_EQ(obj.result(), bmqt::CloseQueueResult::e_SUCCESS); - ASSERT_EQ(obj.errorDescription(), bsl::string("", s_allocator_p)); + ASSERT_EQ(obj.errorDescription(), + bsl::string("", bmqtst::TestHelperUtil::allocator())); } PV("Valued Constructor"); { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::CloseQueueResult::Enum statusCode = bmqt::CloseQueueResult::e_CANCELED; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::CloseQueueStatus obj(queueId, statusCode, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bool(obj), false); ASSERT_EQ(obj.queueId(), queueId); @@ -87,18 +88,18 @@ static void test1_breathingTest() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::CloseQueueResult::Enum statusCode = bmqt::CloseQueueResult::e_UNKNOWN; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::CloseQueueStatus obj1(queueId, statusCode, errorDescription, - s_allocator_p); - bmqa::CloseQueueStatus obj2(obj1, s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqa::CloseQueueStatus obj2(obj1, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bool(obj1), bool(obj2)); ASSERT_EQ(obj1.queueId(), obj2.queueId()); @@ -110,18 +111,18 @@ static void test1_breathingTest() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::CloseQueueResult::Enum statusCode = bmqt::CloseQueueResult::e_UNKNOWN; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::CloseQueueStatus obj1(queueId, statusCode, errorDescription, - s_allocator_p); - bmqa::CloseQueueStatus obj2(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqa::CloseQueueStatus obj2(bmqtst::TestHelperUtil::allocator()); obj2 = obj1; ASSERT_EQ(bool(obj1), bool(obj2)); @@ -157,18 +158,18 @@ static void test2_comparison() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::CloseQueueResult::Enum statusCode = bmqt::CloseQueueResult::e_UNKNOWN; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::CloseQueueStatus obj1(queueId, statusCode, errorDescription, - s_allocator_p); - bmqa::CloseQueueStatus obj2(obj1, s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqa::CloseQueueStatus obj2(obj1, bmqtst::TestHelperUtil::allocator()); ASSERT(obj1 == obj2); } @@ -177,23 +178,23 @@ static void test2_comparison() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::CloseQueueResult::Enum statusCode1 = bmqt::CloseQueueResult::e_UNKNOWN; const bmqt::CloseQueueResult::Enum statusCode2 = bmqt::CloseQueueResult::e_TIMEOUT; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::CloseQueueStatus obj1(queueId, statusCode1, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqa::CloseQueueStatus obj2(queueId, statusCode2, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT(obj1 != obj2); } @@ -216,27 +217,30 @@ static void test3_print() // const bmqa::CloseQueueStatus& rhs); // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'bmqa::OpenQueueResult::print' and // operator '<<' temporarily allocate a string using the default allocator. bmqtst::TestHelper::printTestName("PRINT"); const bmqt::CorrelationId correlationId(2); - bmqa::QueueId queueId = bmqa::QueueId(correlationId, s_allocator_p); + bmqa::QueueId queueId = bmqa::QueueId(correlationId, + bmqtst::TestHelperUtil::allocator()); const bmqt::CloseQueueResult::Enum statusCode = bmqt::CloseQueueResult::e_TIMEOUT; - const bsl::string errorDescription = bsl::string("ERROR", s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); // Set URI on the queueId bsl::shared_ptr& queue = reinterpret_cast&>(queueId); - queue->setUri(bmqt::Uri("bmq://bmq.test.mem.priority/q1", s_allocator_p)); + queue->setUri(bmqt::Uri("bmq://bmq.test.mem.priority/q1", + bmqtst::TestHelperUtil::allocator())); bmqa::CloseQueueStatus obj(queueId, statusCode, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); PVV(obj); const char* expected = "[ queueId = [ uri = bmq://bmq.test.mem.priority/q1" @@ -244,7 +248,7 @@ static void test3_print() " result = \"TIMEOUT (-2)\"" " errorDescription = \"ERROR\" ]"; - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); // operator<< out << obj; @@ -265,7 +269,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -274,7 +278,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqa/bmqa_configurequeuestatus.t.cpp b/src/groups/bmq/bmqa/bmqa_configurequeuestatus.t.cpp index 34add1a91..f71925a13 100644 --- a/src/groups/bmq/bmqa/bmqa_configurequeuestatus.t.cpp +++ b/src/groups/bmq/bmqa/bmqa_configurequeuestatus.t.cpp @@ -55,27 +55,28 @@ static void test1_breathingTest() PV("Default Constructor"); { - bmqa::ConfigureQueueStatus obj(s_allocator_p); + bmqa::ConfigureQueueStatus obj(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bool(obj), true); ASSERT_EQ(obj.result(), bmqt::ConfigureQueueResult::e_SUCCESS); - ASSERT_EQ(obj.errorDescription(), bsl::string("", s_allocator_p)); + ASSERT_EQ(obj.errorDescription(), + bsl::string("", bmqtst::TestHelperUtil::allocator())); } PV("Valued Constructor"); { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::ConfigureQueueResult::Enum result = bmqt::ConfigureQueueResult::e_UNKNOWN; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::ConfigureQueueStatus obj(queueId, result, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bool(obj), false); ASSERT_EQ(obj.queueId(), queueId); @@ -87,18 +88,19 @@ static void test1_breathingTest() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::ConfigureQueueResult::Enum result = bmqt::ConfigureQueueResult::e_TIMEOUT; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::ConfigureQueueStatus obj1(queueId, result, errorDescription, - s_allocator_p); - bmqa::ConfigureQueueStatus obj2(obj1, s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqa::ConfigureQueueStatus obj2(obj1, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bool(obj1), bool(obj2)); ASSERT_EQ(obj1.queueId(), obj2.queueId()); @@ -110,18 +112,18 @@ static void test1_breathingTest() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::ConfigureQueueResult::Enum result = bmqt::ConfigureQueueResult::e_UNKNOWN; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::ConfigureQueueStatus obj1(queueId, result, errorDescription, - s_allocator_p); - bmqa::ConfigureQueueStatus obj2(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqa::ConfigureQueueStatus obj2(bmqtst::TestHelperUtil::allocator()); obj2 = obj1; ASSERT_EQ(bool(obj1), bool(obj2)); @@ -157,18 +159,19 @@ static void test2_comparison() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::ConfigureQueueResult::Enum result = bmqt::ConfigureQueueResult::e_UNKNOWN; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::ConfigureQueueStatus obj1(queueId, result, errorDescription, - s_allocator_p); - bmqa::ConfigureQueueStatus obj2(obj1, s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqa::ConfigureQueueStatus obj2(obj1, + bmqtst::TestHelperUtil::allocator()); ASSERT(obj1 == obj2); } @@ -177,23 +180,23 @@ static void test2_comparison() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::ConfigureQueueResult::Enum result1 = bmqt::ConfigureQueueResult::e_SUCCESS; const bmqt::ConfigureQueueResult::Enum result2 = bmqt::ConfigureQueueResult::e_UNKNOWN; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::ConfigureQueueStatus obj1(queueId, result1, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqa::ConfigureQueueStatus obj2(queueId, result2, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT(obj1 != obj2); } @@ -216,27 +219,30 @@ static void test3_print() // const bmqa::ConfigureQueueStatus& rhs); // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'bmqa::OpenQueueResult::print' and // operator '<<' temporarily allocate a string using the default allocator. bmqtst::TestHelper::printTestName("PRINT"); const bmqt::CorrelationId correlationId(2); - bmqa::QueueId queueId = bmqa::QueueId(correlationId, s_allocator_p); + bmqa::QueueId queueId = bmqa::QueueId(correlationId, + bmqtst::TestHelperUtil::allocator()); const bmqt::ConfigureQueueResult::Enum result = bmqt::ConfigureQueueResult::e_TIMEOUT; - const bsl::string errorDescription = bsl::string("ERROR", s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); // Set URI on the queueId bsl::shared_ptr& queue = reinterpret_cast&>(queueId); - queue->setUri(bmqt::Uri("bmq://bmq.test.mem.priority/q1", s_allocator_p)); + queue->setUri(bmqt::Uri("bmq://bmq.test.mem.priority/q1", + bmqtst::TestHelperUtil::allocator())); bmqa::ConfigureQueueStatus obj(queueId, result, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); PVV(obj); const char* expected = "[ queueId = [ uri = bmq://bmq.test.mem.priority/q1" @@ -244,7 +250,7 @@ static void test3_print() " result = \"TIMEOUT (-2)\"" " errorDescription = \"ERROR\" ]"; - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); // operator<< out << obj; @@ -265,7 +271,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -274,7 +280,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqa/bmqa_event.t.cpp b/src/groups/bmq/bmqa/bmqa_event.t.cpp index 81b07bdc8..2487288d5 100644 --- a/src/groups/bmq/bmqa/bmqa_event.t.cpp +++ b/src/groups/bmq/bmqa/bmqa_event.t.cpp @@ -60,12 +60,16 @@ static bmqa::Event convertEvent(const bsl::shared_ptr& event) static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { PV("Creating a default uninitialized event"); bsl::shared_ptr eventImpl( - new (*s_allocator_p) bmqimp::Event(&bufferFactory, s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bmqimp::Event(&bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bmqa::Event event = convertEvent(eventImpl); ASSERT_EQ(event.isSessionEvent(), false); @@ -76,8 +80,10 @@ static void test1_breathingTest() { PV("Creating a SessionEvent"); bsl::shared_ptr eventImpl( - new (*s_allocator_p) bmqimp::Event(&bufferFactory, s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bmqimp::Event(&bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); eventImpl->configureAsSessionEvent(bmqt::SessionEventType::e_TIMEOUT, -3, bmqt::CorrelationId(13), @@ -111,7 +117,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqa/bmqa_message.t.cpp b/src/groups/bmq/bmqa/bmqa_message.t.cpp index 9446eb0c9..d12225587 100644 --- a/src/groups/bmq/bmqa/bmqa_message.t.cpp +++ b/src/groups/bmq/bmqa/bmqa_message.t.cpp @@ -98,7 +98,7 @@ static void test1_messageOnStackIsInvalid() // 'Message clone(bslma::Allocator *basicAllocator = 0)' of invalid msg // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't ensure no default memory is allocated because a default // QueueId is instantiated and that uses the default allocator to // allocate memory for an automatically generated CorrelationId. @@ -156,18 +156,22 @@ static void test2_validPushMessagePrint() // 'Message clone(bslma::Allocator *basicAllocator = 0)' of invalid msg // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't ensure no default memory is allocated because a default // QueueId is instantiated and that uses the default allocator to // allocate memory for an automatically generated CorrelationId. typedef bsl::shared_ptr EventImplSp; - bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 4 * 1024, + bmqtst::TestHelperUtil::allocator()); bmqa::Event event; EventImplSp& implPtr = reinterpret_cast(event); - implPtr = bsl::make_shared(&bufferFactory, s_allocator_p); + implPtr = bsl::make_shared( + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); const int queueId = 4321; const bmqt::MessageGUID guid; @@ -176,14 +180,16 @@ static void test2_validPushMessagePrint() const int numSubQueueInfos = bmqp::Protocol::SubQueueInfosArray::static_size + 4; - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&payload, buffer, bsl::strlen(buffer)); ASSERT_EQ(static_cast(payload.length()), bsl::strlen(buffer)); // Create PushEventBuilder - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(sizeof(bmqp::EventHeader), static_cast(peb.eventSize())); ASSERT_EQ(sizeof(bmqp::EventHeader), static_cast(peb.blob().length())); @@ -209,7 +215,9 @@ static void test2_validPushMessagePrint() ASSERT_LT(payload.length(), peb.eventSize()); ASSERT_EQ(1, peb.messageCount()); - bmqp::Event bmqpEvent(&peb.blob(), s_allocator_p, true); + bmqp::Event bmqpEvent(&peb.blob(), + bmqtst::TestHelperUtil::allocator(), + true); implPtr->configureAsMessageEvent(bmqpEvent); implPtr->addCorrelationId(bmqt::CorrelationId()); @@ -234,25 +242,28 @@ static void test3_messageProperties() // 'Message clone(bslma::Allocator *basicAllocator = 0)' of invalid msg // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't ensure no default memory is allocated because a default // QueueId is instantiated and that uses the default allocator to // allocate memory for an automatically generated CorrelationId. - bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 4 * 1024, + bmqtst::TestHelperUtil::allocator()); const int queueId = 4321; const bmqt::MessageGUID guid; const char* buffer = "abcdefghijklmnopqrstuvwxyz"; const int flags = 0; - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(&bufferFactory, bmqtst::TestHelperUtil::allocator()); const unsigned int subQueueId = 1234; subQueueInfos.push_back(bmqp::SubQueueInfo(subQueueId)); - bmqp::MessageProperties in(s_allocator_p); + bmqp::MessageProperties in(bmqtst::TestHelperUtil::allocator()); bmqp::MessagePropertiesInfo input(true, 1, false); const char x[] = "x"; const char y[] = "y"; @@ -269,7 +280,8 @@ static void test3_messageProperties() bdlbb::BlobUtil::append(&payload, buffer, bsl::strlen(buffer)); // Create PushEventBuilder - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Add SubQueueInfo option bmqt::EventBuilderResult::Enum rc = peb.addSubQueueInfosOption( @@ -291,15 +303,20 @@ static void test3_messageProperties() bsl::shared_ptr& implPtr = reinterpret_cast&>(event); - implPtr = bsl::make_shared(&bufferFactory, s_allocator_p); + implPtr = bsl::make_shared( + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); // For the ScheamLearner bsl::shared_ptr queue = - bsl::allocate_shared(s_allocator_p); + bsl::allocate_shared( + bmqtst::TestHelperUtil::allocator()); queue->setId(queueId); implPtr->insertQueue(subQueueId, queue); - bmqp::Event bmqpEvent(&peb.blob(), s_allocator_p, true); + bmqp::Event bmqpEvent(&peb.blob(), + bmqtst::TestHelperUtil::allocator(), + true); implPtr->configureAsMessageEvent(bmqpEvent); implPtr->addCorrelationId(bmqt::CorrelationId()); @@ -309,12 +326,12 @@ static void test3_messageProperties() mIter.nextMessage(); bmqa::Message message = mIter.message(); - bmqa::MessageProperties out1(s_allocator_p); + bmqa::MessageProperties out1(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, message.loadProperties(&out1)); // 1st setProperty w/o getProperty and then getProperty { - bmqa::MessageProperties out2(s_allocator_p); + bmqa::MessageProperties out2(bmqtst::TestHelperUtil::allocator()); // The second read is/was optimized (only one MPS header) ASSERT_EQ(0, message.loadProperties(&out2)); @@ -328,7 +345,7 @@ static void test3_messageProperties() // 2nd getProperty, setProperty and then load all { - bmqa::MessageProperties out3(s_allocator_p); + bmqa::MessageProperties out3(bmqtst::TestHelperUtil::allocator()); // The third read is/was optimized (only one MPS header) ASSERT_EQ(0, message.loadProperties(&out3)); @@ -336,7 +353,7 @@ static void test3_messageProperties() ASSERT_EQ(y, out3.getPropertyAsString("y")); ASSERT_EQ(0, out3.setPropertyAsString("y", mod)); - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); out3.print(os, 0, -1); PV(os.str()); @@ -353,7 +370,7 @@ static void test3_messageProperties() // 3rd getProperty, setProperty and then getProperty { - bmqa::MessageProperties out4(s_allocator_p); + bmqa::MessageProperties out4(bmqtst::TestHelperUtil::allocator()); // The fourth read is/was optimized (only one MPS header) ASSERT_EQ(0, message.loadProperties(&out4)); @@ -382,7 +399,7 @@ static void test4_subscriptionHandle() // and PUT messages // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't ensure no default memory is allocated because a default // QueueId is instantiated and that uses the default allocator to // allocate memory for an automatically generated CorrelationId. @@ -401,9 +418,11 @@ static void test4_subscriptionHandle() const bmqt::CorrelationId cId(queueId); bsl::shared_ptr queueSp = bsl::make_shared( - s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, s_allocator_p); - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 4 * 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(&bufferFactory, bmqtst::TestHelperUtil::allocator()); queueSp->setId(queueId); @@ -417,14 +436,17 @@ static void test4_subscriptionHandle() const unsigned int sId = sHandle.id(); bmqa::Event event; - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); EventImplSp& implPtr = reinterpret_cast(event); - implPtr = bsl::make_shared(&bufferFactory, - s_allocator_p); + implPtr = bsl::make_shared( + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Create PushEventBuilder - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, peb.messageCount()); // Add SubQueueInfo option (subscription Id) @@ -451,7 +473,9 @@ static void test4_subscriptionHandle() ASSERT_LT(payload.length(), peb.eventSize()); ASSERT_EQ(1, peb.messageCount()); - bmqp::Event bmqpEvent(&peb.blob(), s_allocator_p, true); + bmqp::Event bmqpEvent(&peb.blob(), + bmqtst::TestHelperUtil::allocator(), + true); implPtr->configureAsMessageEvent(bmqpEvent); implPtr->insertQueue(sId, queueSp); @@ -481,11 +505,13 @@ static void test4_subscriptionHandle() bmqa::Event event; EventImplSp& implPtr = reinterpret_cast(event); - implPtr = bsl::make_shared(&bufferFactory, - s_allocator_p); + implPtr = bsl::make_shared( + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Create PushEventBuilder - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, peb.messageCount()); // Add message @@ -500,7 +526,9 @@ static void test4_subscriptionHandle() ASSERT_LT(payload.length(), peb.eventSize()); ASSERT_EQ(1, peb.messageCount()); - bmqp::Event bmqpEvent(&peb.blob(), s_allocator_p, true); + bmqp::Event bmqpEvent(&peb.blob(), + bmqtst::TestHelperUtil::allocator(), + true); implPtr->configureAsMessageEvent(bmqpEvent); implPtr->insertQueue(defaultSubscriptionId, queueSp); @@ -525,11 +553,13 @@ static void test4_subscriptionHandle() bmqa::Event event; EventImplSp& implPtr = reinterpret_cast(event); - implPtr = bsl::make_shared(&bufferFactory, - s_allocator_p); + implPtr = bsl::make_shared( + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Create PutEventBuilder - bmqp::PutEventBuilder builder(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder builder(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, builder.messageCount()); // Add message @@ -542,7 +572,8 @@ static void test4_subscriptionHandle() ASSERT_EQ(rc, bmqt::EventBuilderResult::e_SUCCESS); ASSERT_EQ(1, builder.messageCount()); - bmqp::Event bmqpEvent(&builder.blob(), s_allocator_p); + bmqp::Event bmqpEvent(&builder.blob(), + bmqtst::TestHelperUtil::allocator()); implPtr->configureAsMessageEvent(bmqpEvent); implPtr->insertQueue(queueSp); @@ -563,11 +594,13 @@ static void test4_subscriptionHandle() bmqa::Event event; EventImplSp& implPtr = reinterpret_cast(event); - implPtr = bsl::make_shared(&bufferFactory, - s_allocator_p); + implPtr = bsl::make_shared( + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Create AckEventBuilder - bmqp::AckEventBuilder builder(&bufferFactory, s_allocator_p); + bmqp::AckEventBuilder builder(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, builder.messageCount()); bmqt::EventBuilderResult::Enum rc = @@ -576,7 +609,8 @@ static void test4_subscriptionHandle() ASSERT_EQ(rc, bmqt::EventBuilderResult::e_SUCCESS); ASSERT_EQ(1, builder.messageCount()); - bmqp::Event bmqpEvent(&builder.blob(), s_allocator_p); + bmqp::Event bmqpEvent(&builder.blob(), + bmqtst::TestHelperUtil::allocator()); implPtr->configureAsMessageEvent(bmqpEvent); implPtr->insertQueue(queueSp); @@ -600,7 +634,7 @@ static void test4_subscriptionHandle() int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: case 1: test1_messageOnStackIsInvalid(); break; @@ -609,7 +643,7 @@ int main(int argc, char* argv[]) case 4: test4_subscriptionHandle(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } bmqp::ProtocolUtil::shutdown(); diff --git a/src/groups/bmq/bmqa/bmqa_messageevent.t.cpp b/src/groups/bmq/bmqa/bmqa_messageevent.t.cpp index ec0730013..46e06bbc1 100644 --- a/src/groups/bmq/bmqa/bmqa_messageevent.t.cpp +++ b/src/groups/bmq/bmqa/bmqa_messageevent.t.cpp @@ -153,7 +153,7 @@ static void test1_breathingTest() static void test2_ackMesageIteratorTest() { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't ensure no default memory is allocated because a default // QueueId is instantiated and that uses the default allocator to // allocate memory for an automatically generated CorrelationId. @@ -164,17 +164,22 @@ static void test2_ackMesageIteratorTest() const int k_NUM_MSGS = 5; - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::AckEventBuilder builder(&bufferFactory, s_allocator_p); - bsl::vector messages(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::AckEventBuilder builder(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector messages(bmqtst::TestHelperUtil::allocator()); PVV("Appending messages"); appendMessages(&builder, &messages, k_NUM_MSGS); - bmqp::Event rawEvent(&builder.blob(), s_allocator_p); + bmqp::Event rawEvent(&builder.blob(), bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr eventImpl; - eventImpl.createInplace(s_allocator_p, &bufferFactory, s_allocator_p); + eventImpl.createInplace(bmqtst::TestHelperUtil::allocator(), + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); eventImpl->configureAsMessageEvent(rawEvent); for (bsl::vector::const_iterator i = messages.begin(); @@ -207,7 +212,7 @@ static void test2_ackMesageIteratorTest() static void test3_putMessageIteratorTest() { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't ensure no default memory is allocated because a default // QueueId is instantiated and that uses the default allocator to // allocate memory for an automatically generated CorrelationId. @@ -221,24 +226,30 @@ static void test3_putMessageIteratorTest() const int k_NUM_MSGS = 5; - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::PutEventBuilder builder(&bufferFactory, s_allocator_p); - bsl::vector messages(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutEventBuilder builder(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector messages(bmqtst::TestHelperUtil::allocator()); PVV("Appending messages"); for (size_t dataIdx = 0; dataIdx < k_NUM_MSGS; ++dataIdx) { - bmqt::EventBuilderResult::Enum rc = appendMessage(dataIdx, - &builder, - &messages, - &bufferFactory, - s_allocator_p); + bmqt::EventBuilderResult::Enum rc = appendMessage( + dataIdx, + &builder, + &messages, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, bmqt::EventBuilderResult::e_SUCCESS); } - bmqp::Event rawEvent(&builder.blob(), s_allocator_p); + bmqp::Event rawEvent(&builder.blob(), bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr eventImpl; - eventImpl.createInplace(s_allocator_p, &bufferFactory, s_allocator_p); + eventImpl.createInplace(bmqtst::TestHelperUtil::allocator(), + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); eventImpl->configureAsMessageEvent(rawEvent); // Fill event's correlationId list as it is done in the @@ -262,7 +273,8 @@ static void test3_putMessageIteratorTest() ASSERT_EQ(msg->correlationId(), bmqt::CorrelationId(offset)); - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int rc = msg->getData(&payload); ASSERT_EQ(rc, 0); // Content isn't the same. Length is. Why? @@ -284,13 +296,13 @@ int main(int argc, char* argv[]) // Temporary workaround to suppress the 'unused operator // NestedTraitDeclaration' warning/error generated by clang. TBD: figure // out the right way to "fix" this. - PutData dummy(s_allocator_p); + PutData dummy(bmqtst::TestHelperUtil::allocator()); static_cast( static_cast >( dummy)); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -299,7 +311,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqa/bmqa_messageeventbuilder.t.cpp b/src/groups/bmq/bmqa/bmqa_messageeventbuilder.t.cpp index 90a91e979..659d633b6 100644 --- a/src/groups/bmq/bmqa/bmqa_messageeventbuilder.t.cpp +++ b/src/groups/bmq/bmqa/bmqa_messageeventbuilder.t.cpp @@ -33,7 +33,7 @@ using namespace bsl; static void test1_breathingTest() { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't ensure no default memory is allocated because a default // QueueId is instantiated and that uses the default allocator to // allocate memory for an automatically generated CorrelationId. @@ -45,7 +45,7 @@ static void test1_breathingTest() static void test2_testMessageEventSizeCount() { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't ensure no default memory is allocated because a default // QueueId is instantiated and that uses the default allocator to // allocate memory for an automatically generated CorrelationId. @@ -54,8 +54,9 @@ static void test2_testMessageEventSizeCount() // Stage 1: preparation // Start a session and open a queue - bmqa::MockSession session(bmqt::SessionOptions(s_allocator_p), - s_allocator_p); + bmqa::MockSession session( + bmqt::SessionOptions(bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); { // Start session @@ -64,18 +65,19 @@ static void test2_testMessageEventSizeCount() ASSERT_EQ(rc, 0); } - bmqt::Uri uri(s_allocator_p); + bmqt::Uri uri(bmqtst::TestHelperUtil::allocator()); { // Parse uri - bsl::string error(s_allocator_p); - bsl::string input("bmq://my.domain/queue", s_allocator_p); + bsl::string error(bmqtst::TestHelperUtil::allocator()); + bsl::string input("bmq://my.domain/queue", + bmqtst::TestHelperUtil::allocator()); const int rc = bmqt::UriParser::parse(&uri, &error, input); ASSERT_EQ(rc, 0); } bmqt::CorrelationId queueCId = bmqt::CorrelationId::autoValue(); - bmqa::QueueId queueId(queueCId, s_allocator_p); + bmqa::QueueId queueId(queueCId, bmqtst::TestHelperUtil::allocator()); { // Open queue @@ -96,7 +98,8 @@ static void test2_testMessageEventSizeCount() ASSERT(builder.messageEventSize() > 0); ASSERT_EQ(0, builder.messageCount()); - const bsl::string payload("test payload", s_allocator_p); + const bsl::string payload("test payload", + bmqtst::TestHelperUtil::allocator()); // Pack some messages for (int i = 1; i <= 5; i++) { @@ -172,7 +175,7 @@ int main(int argc, char* argv[]) case 2: test2_testMessageEventSizeCount(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqa/bmqa_mocksession.h b/src/groups/bmq/bmqa/bmqa_mocksession.h index 0e1771c99..b9ba02dd8 100644 --- a/src/groups/bmq/bmqa/bmqa_mocksession.h +++ b/src/groups/bmq/bmqa/bmqa_mocksession.h @@ -218,7 +218,7 @@ /// // any case but if events need to be built outside the scope of the /// // creation of 'MockSession' you will need to explicitly invoke this /// // static initializer method. -/// // bmqa::MockSession::initialize(s_allocator_p); +/// bmqa::MockSession::initialize(s_allocator_p); /// /// bslma::ManagedPtr handlerMp; /// handlerMp.load(&eventHandler, 0, bslma::ManagedPtrUtil::noOpDeleter); diff --git a/src/groups/bmq/bmqa/bmqa_mocksession.t.cpp b/src/groups/bmq/bmqa/bmqa_mocksession.t.cpp index ddffcffc9..7e25c03a2 100644 --- a/src/groups/bmq/bmqa/bmqa_mocksession.t.cpp +++ b/src/groups/bmq/bmqa/bmqa_mocksession.t.cpp @@ -123,7 +123,7 @@ struct EventHandler : public bmqa::SessionEventHandler { queueId->correlationId(), 0, "", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); BMQA_EXPECT_CALL(mockSession, openQueueAsync(0, // Dont care about queueId @@ -148,8 +148,8 @@ struct EventHandler : public bmqa::SessionEventHandler { // opted to just compare the streams of the two messageEvents which is // markedly a weak test, but serves us well enough for basic testing. - bmqu::MemOutStream lstr(s_allocator_p); - bmqu::MemOutStream rstr(s_allocator_p); + bmqu::MemOutStream lstr(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream rstr(bmqtst::TestHelperUtil::allocator()); lhs.print(lstr); rhs.print(rstr); @@ -266,7 +266,9 @@ static void test1_staticMethods() bmqtst::TestHelper::printTestName("STATIC METHODS"); - bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 4 * 1024, + bmqtst::TestHelperUtil::allocator()); { PVV("Create Session Event"); @@ -276,7 +278,7 @@ static void test1_staticMethods() bmqt::CorrelationId(1), 0, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqa::SessionEvent sessionEvent = event.sessionEvent(); ASSERT_EQ(sessionEvent.type(), bmqt::SessionEventType::e_CONNECTED); @@ -293,7 +295,7 @@ static void test1_staticMethods() bmqt::CorrelationId(1), 0, "", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); } { @@ -307,13 +309,14 @@ static void test1_staticMethods() bmqt::MessageGUID guid; guid.fromHex(guidHex); - bsl::vector acks(s_allocator_p); + bsl::vector acks( + bmqtst::TestHelperUtil::allocator()); acks.emplace_back(bmqt::AckResult::e_SUCCESS, corrId, guid, queueId); bmqa::Event event = bmqa::MockSessionUtil::createAckEvent( acks, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqa::MessageEvent ackEvent = event.messageEvent(); ASSERT_EQ(ackEvent.type(), bmqt::MessageEventType::e_ACK); @@ -338,7 +341,7 @@ static void test1_staticMethods() corrId, 0, "", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqa::SessionEvent openQueueEvent = event.sessionEvent(); ASSERT_EQ(openQueueEvent.type(), @@ -354,8 +357,9 @@ static void test1_staticMethods() bmqa::QueueId queueId(1); bsl::vector pushMsgs( - s_allocator_p); - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&payload, "hello", 6); const char guidHex[] = "00000000000000000000000000000001"; @@ -370,7 +374,7 @@ static void test1_staticMethods() bmqa::Event event = bmqa::MockSessionUtil::createPushEvent( pushMsgs, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqa::MessageEvent pushMsgEvt = event.messageEvent(); @@ -399,9 +403,10 @@ static void test2_call() bsl::shared_ptr mockSession_sp; - mockSession_sp.createInplace(s_allocator_p, - bmqt::SessionOptions(s_allocator_p), - s_allocator_p); + mockSession_sp.createInplace( + bmqtst::TestHelperUtil::allocator(), + bmqt::SessionOptions(bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bmqa::MockSession& mockSession = *mockSession_sp; @@ -430,7 +435,7 @@ static void test2_call() PVV("Custom callback with non empty expect call queue"); // Only used for the custom callback - EventHandler eventHandler(s_allocator_p); + EventHandler eventHandler(bmqtst::TestHelperUtil::allocator()); mockSession.setFailureCallback( bdlf::BindUtil::bind(&EventHandler::incrementAsserts, @@ -455,20 +460,23 @@ static void test3_queueManagement() { bmqtst::TestHelper::printTestName("QUEUE MANAGEMENT"); - EventHandler eventHandler(s_allocator_p); + EventHandler eventHandler(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr handlerMp; handlerMp.load(&eventHandler, 0, bslma::ManagedPtrUtil::noOpDeleter); - bmqa::MockSession mockSession(handlerMp, - bmqt::SessionOptions(s_allocator_p), - s_allocator_p); - - bsl::string error(s_allocator_p); - bsl::string input1("bmq://my.domain/queue1", s_allocator_p); - bsl::string input2("bmq://my.domain/queue2", s_allocator_p); - bmqt::Uri uri1(s_allocator_p); - bmqt::Uri uri2(s_allocator_p); + bmqa::MockSession mockSession( + handlerMp, + bmqt::SessionOptions(bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); + + bsl::string error(bmqtst::TestHelperUtil::allocator()); + bsl::string input1("bmq://my.domain/queue1", + bmqtst::TestHelperUtil::allocator()); + bsl::string input2("bmq://my.domain/queue2", + bmqtst::TestHelperUtil::allocator()); + bmqt::Uri uri1(bmqtst::TestHelperUtil::allocator()); + bmqt::Uri uri2(bmqtst::TestHelperUtil::allocator()); bmqt::UriParser::parse(&uri1, &error, input1); bmqt::UriParser::parse(&uri2, &error, input2); @@ -477,8 +485,8 @@ static void test3_queueManagement() bmqt::CorrelationId corrId1(nextCorrId++); bmqt::CorrelationId corrId2(nextCorrId++); - bmqa::QueueId queueId1(corrId1, s_allocator_p); - bmqa::QueueId queueId2(corrId2, s_allocator_p); + bmqa::QueueId queueId1(corrId1, bmqtst::TestHelperUtil::allocator()); + bmqa::QueueId queueId2(corrId2, bmqtst::TestHelperUtil::allocator()); bmqa::MockSession::OpenQueueCallback openQueueCallback = bdlf::MemFnUtil::memFn(&EventHandler::onOpenQueueStatus, @@ -502,7 +510,7 @@ static void test3_queueManagement() queueId1, bmqt::OpenQueueResult::e_UNKNOWN, "", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BMQA_EXPECT_CALL(mockSession, openQueueAsync(&queueId1, uri1, @@ -546,7 +554,7 @@ static void test3_queueManagement() queueId1, bmqt::OpenQueueResult::e_SUCCESS, "", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); mockSession.openQueueAsync(&queueId1, uri1, @@ -580,21 +588,21 @@ static void test3_queueManagement() { PVVV("Valid queue by uri"); - bmqa::QueueId queueIdFound(s_allocator_p); + bmqa::QueueId queueIdFound(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(mockSession.getQueueId(&queueIdFound, uri1), 0); ASSERT_EQ(queueIdFound, queueId1); } { PVVV("Valid queue by uri"); - bmqa::QueueId queueIdFound(s_allocator_p); + bmqa::QueueId queueIdFound(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(mockSession.getQueueId(&queueIdFound, corrId1), 0); ASSERT_EQ(queueIdFound, queueId1); } { PVVV("Registered but unused queue"); - bmqa::QueueId queueIdFound(s_allocator_p); + bmqa::QueueId queueIdFound(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(mockSession.getQueueId(&queueIdFound, uri2), -1); ASSERT_EQ(mockSession.getQueueId(&queueIdFound, corrId2), -1); } @@ -607,7 +615,7 @@ static void test3_queueManagement() queueId1, bmqt::CloseQueueResult::e_SUCCESS, "", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Close queue and then attempt to get queue BMQA_EXPECT_CALL(mockSession, closeQueueSync(&queueId1)) @@ -617,7 +625,7 @@ static void test3_queueManagement() ASSERT_EQ(closeResult1.result(), bmqt::CloseQueueResult::e_SUCCESS); - bmqa::QueueId queueIdFound(s_allocator_p); + bmqa::QueueId queueIdFound(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(mockSession.getQueueId(&queueIdFound, uri1), -1); ASSERT_EQ(mockSession.getQueueId(&queueIdFound, corrId1), -1); @@ -627,7 +635,7 @@ static void test3_queueManagement() queueId1, bmqt::CloseQueueResult::e_SUCCESS, "", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BMQA_EXPECT_CALL(mockSession, closeQueueSync(&queueId1)) .returning(closeResult2); @@ -646,17 +654,18 @@ static void test3_queueManagement() queueId1, bmqt::OpenQueueResult::e_SUCCESS, "", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Generate a new queueId with the same correlationId. The underlying // impl is different so the queueIds are different. Ensure correct // behaviour with new queueId. // Save the original queueId to compare. - bmqa::QueueId savedQueueId(queueId1, s_allocator_p); + bmqa::QueueId savedQueueId(queueId1, + bmqtst::TestHelperUtil::allocator()); // Overwrite the queueId we are going to use. - queueId1 = bmqa::QueueId(corrId1, s_allocator_p); + queueId1 = bmqa::QueueId(corrId1, bmqtst::TestHelperUtil::allocator()); BMQA_EXPECT_CALL( mockSession, @@ -675,7 +684,7 @@ static void test3_queueManagement() ASSERT_EQ(implPtr->correlationId(), corrId1); ASSERT_EQ(implPtr->state(), bmqimp::QueueState::e_OPENED); - bmqa::QueueId queueIdFound(s_allocator_p); + bmqa::QueueId queueIdFound(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(mockSession.getQueueId(&queueIdFound, uri1), 0); ASSERT(queueId1 == queueIdFound); @@ -686,7 +695,7 @@ static void test3_queueManagement() queueId1, bmqt::CloseQueueResult::e_SUCCESS, "", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Close queue and then attempt to get queue BMQA_EXPECT_CALL(mockSession, closeQueueSync(&queueId1)) @@ -699,13 +708,14 @@ static void test4_queueManagementSync() { bmqtst::TestHelper::printTestName("QUEUE MANAGEMENT SYNC MODE"); - bmqa::MockSession mockSession(bmqt::SessionOptions(s_allocator_p), - s_allocator_p); + bmqa::MockSession mockSession( + bmqt::SessionOptions(bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bsl::string input1 = "bmq://my.domain/queue1"; bsl::string input2 = "bmq://my.domain/queue2"; - bmqt::Uri uri1(s_allocator_p); - bmqt::Uri uri2(s_allocator_p); + bmqt::Uri uri1(bmqtst::TestHelperUtil::allocator()); + bmqt::Uri uri2(bmqtst::TestHelperUtil::allocator()); bsl::string error; bmqt::UriParser::parse(&uri1, &error, input1); @@ -730,7 +740,7 @@ static void test4_queueManagementSync() queueId1.correlationId(), 1, "", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(mockSession.openQueueAsync(&queueId1, uri1, 10), 0); typedef bsl::shared_ptr& QueueImplPtr; @@ -763,7 +773,7 @@ static void test4_queueManagementSync() queueId1.correlationId(), 0, "", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(mockSession.openQueueAsync(&queueId1, uri1, 10), 0); typedef bsl::shared_ptr& QueueImplPtr; @@ -789,16 +799,19 @@ static void test5_confirmingMessages() { bmqtst::TestHelper::printTestName("CONSUME AND CONFIRM"); - EventHandler eventHandler(s_allocator_p); + EventHandler eventHandler(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr handlerMp; handlerMp.load(&eventHandler, 0, bslma::ManagedPtrUtil::noOpDeleter); - bmqa::MockSession mockSession(handlerMp, - bmqt::SessionOptions(s_allocator_p), - s_allocator_p); + bmqa::MockSession mockSession( + handlerMp, + bmqt::SessionOptions(bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); - bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 4 * 1024, + bmqtst::TestHelperUtil::allocator()); bmqt::CorrelationId corrId(1); bmqa::QueueId queueId(corrId); @@ -810,7 +823,7 @@ static void test5_confirmingMessages() implPtr->setState(bmqimp::QueueState::e_OPENED); implPtr->setId(1); // arbitrary id for queue - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&payload, "hello", 6); const char guidHex1[] = "00000000000000000000000000000001"; @@ -829,15 +842,15 @@ static void test5_confirmingMessages() mockSession.loadMessageProperties(&properties); bsl::vector pushMsgs( - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); pushMsgs.emplace_back(payload, queueId, guid1, properties); pushMsgs.emplace_back(payload, queueId, guid2, properties); pushMsgs.emplace_back(payload, queueId, guid3, properties); - mockSession.enqueueEvent( - bmqa::MockSessionUtil::createPushEvent(pushMsgs, - &bufferFactory, - s_allocator_p)); + mockSession.enqueueEvent(bmqa::MockSessionUtil::createPushEvent( + pushMsgs, + &bufferFactory, + bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(mockSession.emitEvent(), true); @@ -857,13 +870,14 @@ static void test5_confirmingMessages() invalidGUID.fromHex(invalidGuidHex); bsl::vector invalidMsg( - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); invalidMsg.emplace_back(payload, queueId, invalidGUID, properties); bmqa::MessageEvent invalidEvent = - bmqa::MockSessionUtil ::createPushEvent(invalidMsg, - &bufferFactory, - s_allocator_p) + bmqa::MockSessionUtil ::createPushEvent( + invalidMsg, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()) .messageEvent(); bmqa::ConfirmEventBuilder confirmBuilder; @@ -960,20 +974,23 @@ static void test6_runThrough() { bmqtst::TestHelper::printTestName("RUN THROUGH"); - EventHandler eventHandler(s_allocator_p); + EventHandler eventHandler(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr handlerMp; handlerMp.load(&eventHandler, 0, bslma::ManagedPtrUtil::noOpDeleter); - bmqa::MockSession mockSession(handlerMp, - bmqt::SessionOptions(s_allocator_p), - s_allocator_p); + bmqa::MockSession mockSession( + handlerMp, + bmqt::SessionOptions(bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); - bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 4 * 1024, + bmqtst::TestHelperUtil::allocator()); bmqt::CorrelationId corrId(1); bmqa::QueueId queueId(corrId); bsl::string input = "bmq://my.domain/queue"; - bmqt::Uri uri(s_allocator_p); + bmqt::Uri uri(bmqtst::TestHelperUtil::allocator()); bsl::string error; bmqt::UriParser::parse(&uri, &error, input); @@ -983,28 +1000,28 @@ static void test6_runThrough() bmqt::CorrelationId(1), 0, "", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); bmqa::OpenQueueStatus testOpenQueueResult = bmqa::MockSessionUtil::createOpenQueueStatus( queueId, bmqt::OpenQueueResult::e_SUCCESS, "", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqa::ConfigureQueueStatus testConfigureQueueResult = bmqa::MockSessionUtil::createConfigureQueueStatus( queueId, bmqt::ConfigureQueueResult::e_SUCCESS, "", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqa::CloseQueueStatus testCloseQueueResult = bmqa::MockSessionUtil::createCloseQueueStatus( queueId, bmqt::CloseQueueResult::e_SUCCESS, "", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Callback setup bmqa::MockSession::OpenQueueCallback openQueueCallback = @@ -1140,7 +1157,8 @@ static void test6_runThrough() messageGUID.fromHex(msgGUIDHex); // Create payload - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&payload, "hello", 6); // Quickly make a valid queue available. @@ -1152,16 +1170,17 @@ static void test6_runThrough() // Now create params to build push message bsl::vector pushParams( - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); pushParams.emplace_back(payload, queueId, messageGUID, bmqa::MessageProperties()); - bmqa::MessageEvent pushMsgEvt = bmqa::MockSessionUtil::createPushEvent( - pushParams, - &bufferFactory, - s_allocator_p) - .messageEvent(); + bmqa::MessageEvent pushMsgEvt = + bmqa::MockSessionUtil::createPushEvent( + pushParams, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()) + .messageEvent(); bmqa::MessageIterator mIter = pushMsgEvt.messageIterator(); @@ -1215,17 +1234,18 @@ static void test7_postAndAccess() { bmqtst::TestHelper::printTestName("POST AND ACCESS"); - EventHandler eventHandler(s_allocator_p); + EventHandler eventHandler(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr handlerMp; handlerMp.load(&eventHandler, 0, bslma::ManagedPtrUtil::noOpDeleter); - bmqa::MockSession mockSession(handlerMp, - bmqt::SessionOptions(s_allocator_p), - s_allocator_p); + bmqa::MockSession mockSession( + handlerMp, + bmqt::SessionOptions(bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bsl::string input = "bmq://my.domain/queue"; - bmqt::Uri uri(s_allocator_p); + bmqt::Uri uri(bmqtst::TestHelperUtil::allocator()); bsl::string error; bmqt::UriParser::parse(&uri, &error, input); @@ -1236,11 +1256,13 @@ static void test7_postAndAccess() EventHandler::openQueue(&mockSession, &queueId, uri); // Build payloads - bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, s_allocator_p); - bdlbb::Blob payload1(&bufferFactory, s_allocator_p); - bdlbb::Blob payload2(&bufferFactory, s_allocator_p); - bdlbb::Blob payload3(&bufferFactory, s_allocator_p); - bdlbb::Blob payload4(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 4 * 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload1(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload2(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload3(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload4(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&payload1, "hello!", 7); bdlbb::BlobUtil::append(&payload2, "hola!", 6); @@ -1335,17 +1357,18 @@ static void test8_postBlockedToSuspendedQueue() { bmqtst::TestHelper::printTestName("POST BLOCKED TO SUSPENDED QUEUE"); - EventHandler eventHandler(s_allocator_p); + EventHandler eventHandler(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr handlerMp; handlerMp.load(&eventHandler, 0, bslma::ManagedPtrUtil::noOpDeleter); - bmqa::MockSession mockSession(handlerMp, - bmqt::SessionOptions(s_allocator_p), - s_allocator_p); + bmqa::MockSession mockSession( + handlerMp, + bmqt::SessionOptions(bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bsl::string input = "bmq://my.domain/queue"; - bmqt::Uri uri(s_allocator_p); + bmqt::Uri uri(bmqtst::TestHelperUtil::allocator()); bsl::string error; bmqt::UriParser::parse(&uri, &error, input); @@ -1361,8 +1384,10 @@ static void test8_postBlockedToSuspendedQueue() implPtr->setIsSuspended(true); // Build payload - bdlbb::PooledBlobBufferFactory bufferFactory(4 * 1024, s_allocator_p); - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 4 * 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&payload, "hello!", 7); bmqa::MessageEventBuilder builder; @@ -1392,7 +1417,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -1406,7 +1431,7 @@ int main(int argc, char* argv[]) case 1: test1_staticMethods(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqa/bmqa_openqueuestatus.t.cpp b/src/groups/bmq/bmqa/bmqa_openqueuestatus.t.cpp index 207cb0fff..beefb5cc1 100644 --- a/src/groups/bmq/bmqa/bmqa_openqueuestatus.t.cpp +++ b/src/groups/bmq/bmqa/bmqa_openqueuestatus.t.cpp @@ -56,27 +56,28 @@ static void test1_breathingTest() PV("Default Constructor"); { - bmqa::OpenQueueStatus obj(s_allocator_p); + bmqa::OpenQueueStatus obj(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bool(obj), true); ASSERT_EQ(obj.result(), bmqt::OpenQueueResult::e_SUCCESS); - ASSERT_EQ(obj.errorDescription(), bsl::string("", s_allocator_p)); + ASSERT_EQ(obj.errorDescription(), + bsl::string("", bmqtst::TestHelperUtil::allocator())); } PV("Valued Constructor"); { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::OpenQueueResult::Enum result = bmqt::OpenQueueResult::e_TIMEOUT; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::OpenQueueStatus obj(queueId, result, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bool(obj), false); ASSERT_EQ(obj.queueId(), queueId); @@ -88,18 +89,18 @@ static void test1_breathingTest() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::OpenQueueResult::Enum result = bmqt::OpenQueueResult::e_TIMEOUT; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::OpenQueueStatus obj1(queueId, result, errorDescription, - s_allocator_p); - bmqa::OpenQueueStatus obj2(obj1, s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqa::OpenQueueStatus obj2(obj1, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bool(obj2), bool(obj1)); ASSERT_EQ(obj1.queueId(), obj2.queueId()); @@ -111,18 +112,18 @@ static void test1_breathingTest() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::OpenQueueResult::Enum result = bmqt::OpenQueueResult::e_TIMEOUT; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::OpenQueueStatus obj1(queueId, result, errorDescription, - s_allocator_p); - bmqa::OpenQueueStatus obj2(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqa::OpenQueueStatus obj2(bmqtst::TestHelperUtil::allocator()); obj2 = obj1; ASSERT_EQ(bool(obj1), bool(obj2)); @@ -158,18 +159,18 @@ static void test2_comparison() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::OpenQueueResult::Enum result = bmqt::OpenQueueResult::e_TIMEOUT; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::OpenQueueStatus obj1(queueId, result, errorDescription, - s_allocator_p); - bmqa::OpenQueueStatus obj2(obj1, s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqa::OpenQueueStatus obj2(obj1, bmqtst::TestHelperUtil::allocator()); ASSERT(obj1 == obj2); } @@ -178,23 +179,23 @@ static void test2_comparison() { const bmqt::CorrelationId correlationId = bmqt::CorrelationId::autoValue(); - const bmqa::QueueId queueId = bmqa::QueueId(correlationId, - s_allocator_p); + const bmqa::QueueId queueId = + bmqa::QueueId(correlationId, bmqtst::TestHelperUtil::allocator()); const bmqt::OpenQueueResult::Enum result1 = bmqt::OpenQueueResult::e_SUCCESS; const bmqt::OpenQueueResult::Enum result2 = bmqt::OpenQueueResult::e_TIMEOUT; - const bsl::string errorDescription = bsl::string("ERROR", - s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); bmqa::OpenQueueStatus obj1(queueId, result1, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqa::OpenQueueStatus obj2(queueId, result2, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT(obj1 != obj2); } @@ -217,27 +218,30 @@ static void test3_print() // const bmqa::OpenQueueStatus& rhs); // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'bmqa::OpenQueueStatus::print' and // operator '<<' temporarily allocate a string using the default allocator. bmqtst::TestHelper::printTestName("PRINT"); const bmqt::CorrelationId correlationId(2); - bmqa::QueueId queueId = bmqa::QueueId(correlationId, s_allocator_p); + bmqa::QueueId queueId = bmqa::QueueId(correlationId, + bmqtst::TestHelperUtil::allocator()); const bmqt::OpenQueueResult::Enum result = bmqt::OpenQueueResult::e_SUCCESS; - const bsl::string errorDescription = bsl::string("ERROR", s_allocator_p); + const bsl::string errorDescription = + bsl::string("ERROR", bmqtst::TestHelperUtil::allocator()); // Set URI on the queueId bsl::shared_ptr& queue = reinterpret_cast&>(queueId); - queue->setUri(bmqt::Uri("bmq://bmq.test.mem.priority/q1", s_allocator_p)); + queue->setUri(bmqt::Uri("bmq://bmq.test.mem.priority/q1", + bmqtst::TestHelperUtil::allocator())); bmqa::OpenQueueStatus obj(queueId, result, errorDescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); PVV(obj); const char* expected = "[ queueId = [ uri = bmq://bmq.test.mem.priority/q1" @@ -245,7 +249,7 @@ static void test3_print() " result = \"SUCCESS (0)\"" " errorDescription = \"ERROR\" ]"; - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); // operator<< out << obj; @@ -266,7 +270,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -275,7 +279,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqa/bmqa_queueid.t.cpp b/src/groups/bmq/bmqa/bmqa_queueid.t.cpp index 24c8514a0..fdfc9cf59 100644 --- a/src/groups/bmq/bmqa/bmqa_queueid.t.cpp +++ b/src/groups/bmq/bmqa/bmqa_queueid.t.cpp @@ -63,7 +63,7 @@ static void test1_breathingTest() PV("Default Constructor"); { - bmqa::QueueId obj(s_allocator_p); + bmqa::QueueId obj(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.isValid(), false); } @@ -72,10 +72,10 @@ static void test1_breathingTest() const bsls::Types::Int64 id = 5; const bmqt::CorrelationId corrId(id); - bmqa::QueueId obj(corrId, s_allocator_p); + bmqa::QueueId obj(corrId, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.correlationId(), corrId); ASSERT_EQ(obj.flags(), bmqt::QueueFlagsUtil::empty()); - ASSERT_EQ(obj.uri(), bmqt::Uri(s_allocator_p)); + ASSERT_EQ(obj.uri(), bmqt::Uri(bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.options(), k_NULL_OPTIONS); ASSERT_EQ(obj.isValid(), false); } @@ -84,10 +84,10 @@ static void test1_breathingTest() { const bsls::Types::Int64 id = 5; - bmqa::QueueId obj(id, s_allocator_p); + bmqa::QueueId obj(id, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.correlationId(), bmqt::CorrelationId(id)); ASSERT_EQ(obj.flags(), bmqt::QueueFlagsUtil::empty()); - ASSERT_EQ(obj.uri(), bmqt::Uri(s_allocator_p)); + ASSERT_EQ(obj.uri(), bmqt::Uri(bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.options(), k_NULL_OPTIONS); ASSERT_EQ(obj.isValid(), false); } @@ -97,10 +97,10 @@ static void test1_breathingTest() const char* buffer = "1234"; void* ptr = static_cast(const_cast(buffer)); - bmqa::QueueId obj(ptr, s_allocator_p); + bmqa::QueueId obj(ptr, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.correlationId(), bmqt::CorrelationId(ptr)); ASSERT_EQ(obj.flags(), bmqt::QueueFlagsUtil::empty()); - ASSERT_EQ(obj.uri(), bmqt::Uri(s_allocator_p)); + ASSERT_EQ(obj.uri(), bmqt::Uri(bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.options(), k_NULL_OPTIONS); ASSERT_EQ(obj.isValid(), false); } @@ -110,12 +110,12 @@ static void test1_breathingTest() const int k_VALUE = 11; bsl::shared_ptr sptr; - sptr.createInplace(s_allocator_p, k_VALUE); + sptr.createInplace(bmqtst::TestHelperUtil::allocator(), k_VALUE); - bmqa::QueueId obj(sptr, s_allocator_p); + bmqa::QueueId obj(sptr, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.correlationId(), bmqt::CorrelationId(sptr)); ASSERT_EQ(obj.flags(), bmqt::QueueFlagsUtil::empty()); - ASSERT_EQ(obj.uri(), bmqt::Uri(s_allocator_p)); + ASSERT_EQ(obj.uri(), bmqt::Uri(bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.options(), k_NULL_OPTIONS); ASSERT_EQ(obj.isValid(), false); } @@ -124,8 +124,8 @@ static void test1_breathingTest() { const bsls::Types::Int64 id = 5; - bmqa::QueueId obj1(id, s_allocator_p); - bmqa::QueueId obj2(obj1, s_allocator_p); + bmqa::QueueId obj1(id, bmqtst::TestHelperUtil::allocator()); + bmqa::QueueId obj2(obj1, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj1.correlationId(), obj2.correlationId()); ASSERT_EQ(obj1.flags(), obj2.flags()); ASSERT_EQ(obj1.uri(), obj2.uri()); @@ -137,8 +137,8 @@ static void test1_breathingTest() { const bsls::Types::Int64 id = 5; - bmqa::QueueId obj1(id, s_allocator_p); - bmqa::QueueId obj2(s_allocator_p); + bmqa::QueueId obj1(id, bmqtst::TestHelperUtil::allocator()); + bmqa::QueueId obj2(bmqtst::TestHelperUtil::allocator()); obj2 = obj1; ASSERT_EQ(obj1.correlationId(), obj2.correlationId()); ASSERT_EQ(obj1.flags(), obj2.flags()); @@ -152,10 +152,10 @@ static void test1_breathingTest() const bsls::Types::Int64 id = 5; const char k_QUEUE_URL[] = "bmq://ts.trades.myapp.~bt/my.queue?id=foo"; - bmqa::QueueId obj(id, s_allocator_p); + bmqa::QueueId obj(id, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.correlationId(), bmqt::CorrelationId(id)); ASSERT_EQ(obj.flags(), bmqt::QueueFlagsUtil::empty()); - ASSERT_EQ(obj.uri(), bmqt::Uri(s_allocator_p)); + ASSERT_EQ(obj.uri(), bmqt::Uri(bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.options(), k_NULL_OPTIONS); ASSERT_EQ(obj.isValid(), false); @@ -164,7 +164,7 @@ static void test1_breathingTest() reinterpret_cast&>(obj); // Set uri to impl object - const bmqt::Uri uri(k_QUEUE_URL, s_allocator_p); + const bmqt::Uri uri(k_QUEUE_URL, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(uri.isValid(), true); queue->setUri(uri); @@ -198,22 +198,23 @@ static void test2_comparison() { const bsls::Types::Int64 k_ID = 18; - bmqa::QueueId obj1(k_ID, s_allocator_p); - bmqa::QueueId obj2(k_ID, s_allocator_p); + bmqa::QueueId obj1(k_ID, bmqtst::TestHelperUtil::allocator()); + bmqa::QueueId obj2(k_ID, bmqtst::TestHelperUtil::allocator()); ASSERT_NE(obj1, obj2); } PV("Equality"); { // Different defaults are never equal - ASSERT_NE(bmqa::QueueId(s_allocator_p), bmqa::QueueId(s_allocator_p)); + ASSERT_NE(bmqa::QueueId(bmqtst::TestHelperUtil::allocator()), + bmqa::QueueId(bmqtst::TestHelperUtil::allocator())); // Assignment makes equal const bsls::Types::Int64 k_ID1 = 5; const bsls::Types::Int64 k_ID2 = 11; - bmqa::QueueId obj1(k_ID1, s_allocator_p); - bmqa::QueueId obj2(k_ID2, s_allocator_p); + bmqa::QueueId obj1(k_ID1, bmqtst::TestHelperUtil::allocator()); + bmqa::QueueId obj2(k_ID2, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(obj1 != obj2); obj1 = obj2; @@ -235,7 +236,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqa/bmqa_sessionevent.t.cpp b/src/groups/bmq/bmqa/bmqa_sessionevent.t.cpp index da35781b8..a6a453ba4 100644 --- a/src/groups/bmq/bmqa/bmqa_sessionevent.t.cpp +++ b/src/groups/bmq/bmqa/bmqa_sessionevent.t.cpp @@ -47,7 +47,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqc/bmqc_array.t.cpp b/src/groups/bmq/bmqc/bmqc_array.t.cpp index 8678d20d4..00b91d679 100644 --- a/src/groups/bmq/bmqc/bmqc_array.t.cpp +++ b/src/groups/bmq/bmqc/bmqc_array.t.cpp @@ -140,12 +140,13 @@ static void test1_breathingTest() { PV("Basic accessors and manipulators"); - ObjType obj(s_allocator_p); + ObjType obj(bmqtst::TestHelperUtil::allocator()); const ObjType& constObj = obj; ASSERT_EQ(true, obj.empty()); ASSERT_EQ(0UL, obj.size()); - ASSERT_EQ(s_allocator_p, obj.get_allocator().mechanism()); + ASSERT_EQ(bmqtst::TestHelperUtil::allocator(), + obj.get_allocator().mechanism()); ASSERT_EQ(true, obj.begin() == obj.end()); ASSERT_EQ(true, constObj.begin() == constObj.end()); } @@ -153,12 +154,12 @@ static void test1_breathingTest() { PV("'push_back' and iteration via 'begin' & 'end'"); - ObjType obj(s_allocator_p); + ObjType obj(bmqtst::TestHelperUtil::allocator()); const ObjType& constObj = obj; const int k_NB_ITEMS = 50; for (int i = 1; i <= k_NB_ITEMS; ++i) { - obj.push_back(TestType(i, s_allocator_p)); + obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); } ASSERT_EQ(false, obj.empty()); @@ -187,11 +188,11 @@ static void test1_breathingTest() { PV("Random access iterator"); - ObjType obj(s_allocator_p); + ObjType obj(bmqtst::TestHelperUtil::allocator()); const int k_NB_ITEMS = 50; for (int i = 1; i <= k_NB_ITEMS; ++i) { - obj.push_back(TestType(i, s_allocator_p)); + obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); } // Iterator operator+= @@ -269,12 +270,16 @@ static void test1_breathingTest() const int k_NB_ITEMS = 100; - ObjType obj(k_NB_ITEMS, TestType(1, s_allocator_p), s_allocator_p); + ObjType obj(k_NB_ITEMS, + TestType(1, bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, obj.empty()); ASSERT_EQ(static_cast(k_NB_ITEMS), obj.size()); ASSERT_EQ( k_NB_ITEMS, - bsl::count(obj.begin(), obj.end(), TestType(1, s_allocator_p))); + bsl::count(obj.begin(), + obj.end(), + TestType(1, bmqtst::TestHelperUtil::allocator()))); } { @@ -282,29 +287,32 @@ static void test1_breathingTest() const int k_NB_ITEMS = 100; bsl::vector v(k_NB_ITEMS, - TestType(1, s_allocator_p), - s_allocator_p); + TestType(1, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); - ObjType obj(v.begin(), v.end(), s_allocator_p); + ObjType obj(v.begin(), v.end(), bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, obj.empty()); ASSERT_EQ(static_cast(k_NB_ITEMS), obj.size()); ASSERT_EQ( k_NB_ITEMS, - bsl::count(obj.begin(), obj.end(), TestType(1, s_allocator_p))); + bsl::count(obj.begin(), + obj.end(), + TestType(1, bmqtst::TestHelperUtil::allocator()))); } { PV("Copy constructor"); - ObjType obj(s_allocator_p); + ObjType obj(bmqtst::TestHelperUtil::allocator()); const int k_NB_ITEMS = 100; for (int i = 1; i <= k_NB_ITEMS; ++i) { - obj.push_back(TestType(i, s_allocator_p)); + obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); } - ObjType objCopy(obj, s_allocator_p); + ObjType objCopy(obj, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, objCopy.empty()); ASSERT_EQ(static_cast(k_NB_ITEMS), objCopy.size()); ASSERT_EQ(true, objCopy.begin() != objCopy.end()); @@ -327,18 +335,18 @@ static void test1_breathingTest() { PV("Assignment operator"); - ObjType obj1(s_allocator_p); - ObjType obj2(s_allocator_p); + ObjType obj1(bmqtst::TestHelperUtil::allocator()); + ObjType obj2(bmqtst::TestHelperUtil::allocator()); const int k_NB_ITEMS_1 = 100; const int k_NB_ITEMS_2 = 500; for (int i = 1; i <= k_NB_ITEMS_1; ++i) { - obj1.push_back(TestType(i, s_allocator_p)); + obj1.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); } for (int i = 1; i <= k_NB_ITEMS_2; ++i) { - obj2.push_back(TestType(i, s_allocator_p)); + obj2.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); } ASSERT_EQ(false, obj2.empty()); @@ -361,11 +369,11 @@ static void test1_breathingTest() { PV("front() and back()"); - ObjType obj(s_allocator_p); + ObjType obj(bmqtst::TestHelperUtil::allocator()); const ObjType& constObj = obj; for (int i = 1; i <= 2 * k_STATIC_LEN; ++i) { - obj.push_back(TestType(i, s_allocator_p)); + obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(1, obj.front().valueAsInt()); ASSERT_EQ(i, obj.back().valueAsInt()); @@ -378,12 +386,13 @@ static void test1_breathingTest() PV("'clear', 'operator=' and 'destructor' invoke ~TYPE"); { - ObjType obj(s_allocator_p); + ObjType obj(bmqtst::TestHelperUtil::allocator()); const int k_NB_ITEMS = 50; for (int i = 0; i < k_NB_ITEMS; ++i) { - obj.push_back(TestType("a", s_allocator_p)); + obj.push_back( + TestType("a", bmqtst::TestHelperUtil::allocator())); } ASSERT_EQ(k_NB_ITEMS, TestType::s_numAliveInstances); @@ -394,15 +403,17 @@ static void test1_breathingTest() } { - ObjType obj1(s_allocator_p); - ObjType obj2(s_allocator_p); + ObjType obj1(bmqtst::TestHelperUtil::allocator()); + ObjType obj2(bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < 50; ++i) { - obj1.push_back(TestType("a", s_allocator_p)); + obj1.push_back( + TestType("a", bmqtst::TestHelperUtil::allocator())); } for (int i = 0; i < 100; ++i) { - obj2.push_back(TestType("b", s_allocator_p)); + obj2.push_back( + TestType("b", bmqtst::TestHelperUtil::allocator())); } ASSERT_EQ(150, TestType::s_numAliveInstances); @@ -413,15 +424,17 @@ static void test1_breathingTest() } { - ObjType obj1(s_allocator_p); - ObjType obj2(s_allocator_p); + ObjType obj1(bmqtst::TestHelperUtil::allocator()); + ObjType obj2(bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < 50; ++i) { - obj1.push_back(TestType("a", s_allocator_p)); + obj1.push_back( + TestType("a", bmqtst::TestHelperUtil::allocator())); } for (int i = 0; i < 100; ++i) { - obj2.push_back(TestType("b", s_allocator_p)); + obj2.push_back( + TestType("b", bmqtst::TestHelperUtil::allocator())); } ASSERT_EQ(150, TestType::s_numAliveInstances); @@ -432,15 +445,17 @@ static void test1_breathingTest() } { - ObjType* obj = new (*s_allocator_p) ObjType(s_allocator_p); + ObjType* obj = new (*bmqtst::TestHelperUtil::allocator()) + ObjType(bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < 50; ++i) { - obj->push_back(TestType("a", s_allocator_p)); + obj->push_back( + TestType("a", bmqtst::TestHelperUtil::allocator())); } ASSERT_EQ(50, TestType::s_numAliveInstances); - s_allocator_p->deleteObject(obj); + bmqtst::TestHelperUtil::allocator()->deleteObject(obj); ASSERT_EQ(0, TestType::s_numAliveInstances); } @@ -462,7 +477,7 @@ static void test2_outOfBoundValidation() { PV("front, back and []"); - ObjType obj(s_allocator_p); + ObjType obj(bmqtst::TestHelperUtil::allocator()); const ObjType& constObj = obj; // non-const @@ -478,7 +493,7 @@ static void test2_outOfBoundValidation() // insert some items const int k_NB_ITEMS = 5; for (int i = 1; i <= k_NB_ITEMS; ++i) { - obj.push_back(TestType(i, s_allocator_p)); + obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); } ASSERT_SAFE_FAIL(constObj[k_NB_ITEMS + 1]); @@ -507,12 +522,12 @@ static void test3_noMemoryAllocation() // Add up to k_STATIC_LEN, no allocations for (int i = 1; i <= k_STATIC_LEN; ++i) { - obj.push_back(TestType(i, s_allocator_p)); + obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(ta.numBlocksInUse(), 0); } // Adding one more, allocation" - obj.push_back(TestType(0, s_allocator_p)); + obj.push_back(TestType(0, bmqtst::TestHelperUtil::allocator())); ASSERT_NE(ta.numBlocksInUse(), 0); } @@ -539,7 +554,7 @@ static void test4_reserve() // Add up to k_CAPACITY items, no allocations for (int i = 1; i <= k_CAPACITY; ++i) { - obj.push_back(TestType(i, s_allocator_p)); + obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); } ASSERT_EQ(ta.numAllocations(), numAllocations); } @@ -562,14 +577,15 @@ static void test5_resize() const bsls::Types::Int64 numAllocations = ta.numAllocations(); // 1) Resize to static length - obj.resize(k_STATIC_LEN, TestType(1, s_allocator_p)); + obj.resize(k_STATIC_LEN, TestType(1, bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.size(), static_cast(k_STATIC_LEN)); ASSERT_EQ(TestType::s_numAliveInstances, k_STATIC_LEN); ASSERT_EQ(ta.numAllocations(), numAllocations); // 2) Resize to half the static length - obj.resize(k_STATIC_LEN / 2, TestType(2, s_allocator_p)); + obj.resize(k_STATIC_LEN / 2, + TestType(2, bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.size(), static_cast(k_STATIC_LEN / 2)); ASSERT_EQ(TestType::s_numAliveInstances, k_STATIC_LEN / 2); @@ -583,7 +599,8 @@ static void test5_resize() const size_t k_FULL_LEN = 2 * k_STATIC_LEN; // 3) Resize to twice the static length - obj.resize(2 * k_STATIC_LEN, TestType(3, s_allocator_p)); + obj.resize(2 * k_STATIC_LEN, + TestType(3, bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.size(), static_cast(k_FULL_LEN)); ASSERT_EQ(TestType::s_numAliveInstances, 2 * k_STATIC_LEN); @@ -595,7 +612,7 @@ static void test5_resize() } // 4) Again resize to twice the static length (i.e. same size) - obj.resize(k_FULL_LEN, TestType(4, s_allocator_p)); + obj.resize(k_FULL_LEN, TestType(4, bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.size(), static_cast(k_FULL_LEN)); ASSERT_EQ(TestType::s_numAliveInstances, 2 * k_STATIC_LEN); @@ -607,7 +624,7 @@ static void test5_resize() } // 5) Resize to zero - obj.resize(0, TestType(5, s_allocator_p)); + obj.resize(0, TestType(5, bmqtst::TestHelperUtil::allocator())); ASSERT(obj.empty()); ASSERT_EQ(obj.size(), 0UL); @@ -630,12 +647,13 @@ static void test6_assign() ObjType obj(&ta); for (int i = 0; i < k_STATIC_LEN + 5; ++i) { - obj.push_back(TestType(i, s_allocator_p)); + obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); } - bsl::vector srcVec(s_allocator_p); + bsl::vector srcVec(bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < 2 * k_STATIC_LEN; ++i) { - srcVec.push_back(TestType(10 * i, s_allocator_p)); + srcVec.push_back( + TestType(10 * i, bmqtst::TestHelperUtil::allocator())); } // Assign to 'obj' from 'srcVec' @@ -662,11 +680,11 @@ static void test7_algorithms() { PV("SORT"); - ObjType obj(s_allocator_p); + ObjType obj(bmqtst::TestHelperUtil::allocator()); // Populate array: {30, 29, ..., 1} for (int i = 30; i >= 0; --i) { - obj.push_back(TestType(i, s_allocator_p)); + obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); } // Apply 'bsl::sort' @@ -840,10 +858,10 @@ static void test10_pushBackSelfRef() { const int k_SIZE = k_STATIC_LEN * 2; - ObjType obj(s_allocator_p); + ObjType obj(bmqtst::TestHelperUtil::allocator()); obj.reserve(k_SIZE); for (int i = 0; i < k_SIZE; ++i) { - obj.push_back(TestType(i, s_allocator_p)); + obj.push_back(TestType(i, bmqtst::TestHelperUtil::allocator())); } ASSERT_PASS(obj.push_back(obj[k_STATIC_LEN])); ASSERT_EQ(k_STATIC_LEN, obj[k_STATIC_LEN].valueAsInt()); @@ -939,7 +957,7 @@ int main(int argc, char* argv[]) #endif // BSLS_PLATFORM_OS_LINUX default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } TEST_EPILOG(bmqtst::TestHelper::e_CHECK_DEF_GBL_ALLOC); diff --git a/src/groups/bmq/bmqc/bmqc_monitoredqueue.t.cpp b/src/groups/bmq/bmqc/bmqc_monitoredqueue.t.cpp index f85a3b0de..eb61862bb 100644 --- a/src/groups/bmq/bmqc/bmqc_monitoredqueue.t.cpp +++ b/src/groups/bmq/bmqc/bmqc_monitoredqueue.t.cpp @@ -83,7 +83,7 @@ static void test1_MonitoredQueueState_toAscii() PVV(test.d_line << ": Testing: toAscii(" << test.d_value << ") == " << test.d_expected); - bsl::string ascii(s_allocator_p); + bsl::string ascii(bmqtst::TestHelperUtil::allocator()); ascii = bmqc::MonitoredQueueState::toAscii( bmqc::MonitoredQueueState::Enum(test.d_value)); @@ -133,7 +133,7 @@ static void test2_MonitoredQueueState_print() << ") == " << test.d_expected); // 1. - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); bmqc::MonitoredQueueState::Enum obj( static_cast(test.d_value)); @@ -142,7 +142,7 @@ static void test2_MonitoredQueueState_print() PVV(test.d_line << ": '" << out.str()); - bsl::string expected(s_allocator_p); + bsl::string expected(bmqtst::TestHelperUtil::allocator()); expected.assign(test.d_expected); expected.append("\n"); ASSERT_EQ_D(test.d_line, out.str(), expected); @@ -176,7 +176,7 @@ int main(int argc, char* argv[]) case 1: test1_MonitoredQueueState_toAscii(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqc/bmqc_monitoredqueue_bdlccfixedqueue.t.cpp b/src/groups/bmq/bmqc/bmqc_monitoredqueue_bdlccfixedqueue.t.cpp index 3482ec895..74cfd3d49 100644 --- a/src/groups/bmq/bmqc/bmqc_monitoredqueue_bdlccfixedqueue.t.cpp +++ b/src/groups/bmq/bmqc/bmqc_monitoredqueue_bdlccfixedqueue.t.cpp @@ -163,8 +163,9 @@ static void test1_MonitoredQueue_breathingTest() { PV("Constructor without 'timedOpertions' flag"); - bmqc::MonitoredQueue > queue(k_QUEUE_SIZE, - s_allocator_p); + bmqc::MonitoredQueue > queue( + k_QUEUE_SIZE, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(queue.capacity(), k_QUEUE_SIZE); ASSERT_EQ(queue.numElements(), 0); @@ -230,7 +231,7 @@ static void test1_MonitoredQueue_breathingTest() bmqc::MonitoredQueue > queue( k_QUEUE_SIZE, true, // supportTimedOperations - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(queue.capacity(), k_QUEUE_SIZE); ASSERT_EQ(queue.numElements(), 0); @@ -308,8 +309,9 @@ static void test2_MonitoredQueue_reset() const int k_HIGH_WATERMARK = 6; const int k_HIGH_WATERMARK2 = 9; - bmqc::MonitoredQueue > queue(k_QUEUE_SIZE, - s_allocator_p); + bmqc::MonitoredQueue > queue( + k_QUEUE_SIZE, + bmqtst::TestHelperUtil::allocator()); queue.setWatermarks(k_LOW_WATERMARK, k_HIGH_WATERMARK, k_HIGH_WATERMARK2); // 1. Enqueue items until the queue is full @@ -359,7 +361,7 @@ static void testN1_MonitoredQueue_performance() // Performance // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("MONITORED QUEUE " "- PERFORMANCE TEST"); @@ -372,8 +374,11 @@ static void testN1_MonitoredQueue_performance() PRINT("==================="); PRINT("MonitoredFixedQueue"); PRINT("==================="); - PerformanceTestObjectPool objectPool1(-1, s_allocator_p); - PerformanceTestObjectQueue monitoredQueue(k_QUEUE_SIZE, s_allocator_p); + PerformanceTestObjectPool objectPool1(-1, + bmqtst::TestHelperUtil::allocator()); + PerformanceTestObjectQueue monitoredQueue( + k_QUEUE_SIZE, + bmqtst::TestHelperUtil::allocator()); // #1 { @@ -382,11 +387,11 @@ static void testN1_MonitoredQueue_performance() 1, // minThreads 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &monitoredQueue, &objectPool1)); @@ -416,11 +421,11 @@ static void testN1_MonitoredQueue_performance() k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &monitoredQueue, &objectPool1)); @@ -433,7 +438,7 @@ static void testN1_MonitoredQueue_performance() for (int i = 0; i < k_NUM_PUSHERS; ++i) { threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPusher, k_NUM_ITERATIONS / k_NUM_PUSHERS, &monitoredQueue, @@ -461,9 +466,10 @@ static void testN1_MonitoredQueue_performance() PRINT("bdlcc::FixedQueue"); PRINT("================="); - PerformanceTestObjectPool objectPool2(-1, s_allocator_p); + PerformanceTestObjectPool objectPool2(-1, + bmqtst::TestHelperUtil::allocator()); typedef bdlcc::FixedQueue UnmonitoredQueue; - UnmonitoredQueue queue(k_QUEUE_SIZE, s_allocator_p); + UnmonitoredQueue queue(k_QUEUE_SIZE, bmqtst::TestHelperUtil::allocator()); // #1 { @@ -472,11 +478,11 @@ static void testN1_MonitoredQueue_performance() k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &queue, &objectPool2)); @@ -506,10 +512,10 @@ static void testN1_MonitoredQueue_performance() k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &queue, &objectPool2)); @@ -522,7 +528,7 @@ static void testN1_MonitoredQueue_performance() for (int i = 0; i < k_NUM_PUSHERS; ++i) { threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestPusher, k_NUM_ITERATIONS / k_NUM_PUSHERS, &queue, @@ -565,7 +571,7 @@ testN1_MonitoredQueue_performance_GoogleBenchmark(benchmark::State& state) // Performance // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("MONITORED QUEUE " "- PERFORMANCE TEST"); @@ -577,8 +583,11 @@ testN1_MonitoredQueue_performance_GoogleBenchmark(benchmark::State& state) PRINT("==================="); PRINT("MonitoredFixedQueue"); PRINT("==================="); - PerformanceTestObjectPool objectPool1(-1, s_allocator_p); - PerformanceTestObjectQueue monitoredQueue(k_QUEUE_SIZE, s_allocator_p); + PerformanceTestObjectPool objectPool1(-1, + bmqtst::TestHelperUtil::allocator()); + PerformanceTestObjectQueue monitoredQueue( + k_QUEUE_SIZE, + bmqtst::TestHelperUtil::allocator()); // #1 { @@ -587,11 +596,11 @@ testN1_MonitoredQueue_performance_GoogleBenchmark(benchmark::State& state) 1, // minThreads 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &monitoredQueue, &objectPool1)); @@ -626,7 +635,7 @@ static void testN1_MonitoredQueueThreaded_performance_GoogleBenchmark( // Performance // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("MONITORED QUEUE " "- PERFORMANCE TEST"); @@ -636,8 +645,11 @@ static void testN1_MonitoredQueueThreaded_performance_GoogleBenchmark( const int k_QUEUE_SIZE = 250 * 1000; // 250K const int k_NUM_PUSHERS = 5; - PerformanceTestObjectPool objectPool1(-1, s_allocator_p); - PerformanceTestObjectQueue monitoredQueue(k_QUEUE_SIZE, s_allocator_p); + PerformanceTestObjectPool objectPool1(-1, + bmqtst::TestHelperUtil::allocator()); + PerformanceTestObjectQueue monitoredQueue( + k_QUEUE_SIZE, + bmqtst::TestHelperUtil::allocator()); // #2 .. using multiple producer threads { bdlmt::ThreadPool threadPool( @@ -645,11 +657,11 @@ static void testN1_MonitoredQueueThreaded_performance_GoogleBenchmark( k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &monitoredQueue, &objectPool1)); @@ -658,7 +670,7 @@ static void testN1_MonitoredQueueThreaded_performance_GoogleBenchmark( for (int i = 0; i < k_NUM_PUSHERS; ++i) { threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPusher, k_NUM_ITERATIONS / k_NUM_PUSHERS, &monitoredQueue, @@ -703,9 +715,10 @@ testN1_bdlccFixedQueue_performance_GoogleBenchmark(benchmark::State& state) PRINT("bdlcc::FixedQueue"); PRINT("================="); - PerformanceTestObjectPool objectPool2(-1, s_allocator_p); + PerformanceTestObjectPool objectPool2(-1, + bmqtst::TestHelperUtil::allocator()); typedef bdlcc::FixedQueue UnmonitoredQueue; - UnmonitoredQueue queue(k_QUEUE_SIZE, s_allocator_p); + UnmonitoredQueue queue(k_QUEUE_SIZE, bmqtst::TestHelperUtil::allocator()); // #1 { @@ -714,11 +727,11 @@ testN1_bdlccFixedQueue_performance_GoogleBenchmark(benchmark::State& state) k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &queue, &objectPool2)); @@ -758,9 +771,10 @@ static void testN1_bdlccFixedQueueThreaded_performance_GoogleBenchmark( const int k_NUM_ITERATIONS = 10 * 1000 * 1000; // 10 M const int k_QUEUE_SIZE = 250 * 1000; // 250K const int k_NUM_PUSHERS = 5; - PerformanceTestObjectPool objectPool2(-1, s_allocator_p); + PerformanceTestObjectPool objectPool2(-1, + bmqtst::TestHelperUtil::allocator()); typedef bdlcc::FixedQueue UnmonitoredQueue; - UnmonitoredQueue queue(k_QUEUE_SIZE, s_allocator_p); + UnmonitoredQueue queue(k_QUEUE_SIZE, bmqtst::TestHelperUtil::allocator()); // #2 .. again { bdlmt::ThreadPool threadPool( @@ -768,10 +782,10 @@ static void testN1_bdlccFixedQueueThreaded_performance_GoogleBenchmark( k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &queue, &objectPool2)); @@ -780,7 +794,7 @@ static void testN1_bdlccFixedQueueThreaded_performance_GoogleBenchmark( for (auto _ : state) { for (int i = 0; i < k_NUM_PUSHERS; ++i) { threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPusher, k_NUM_ITERATIONS / k_NUM_PUSHERS, &queue, @@ -832,7 +846,7 @@ int main(int argc, char* argv[]) break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqc/bmqc_monitoredqueue_bdlccsingleconsumerqueue.t.cpp b/src/groups/bmq/bmqc/bmqc_monitoredqueue_bdlccsingleconsumerqueue.t.cpp index 4f2038eb7..5187413e3 100644 --- a/src/groups/bmq/bmqc/bmqc_monitoredqueue_bdlccsingleconsumerqueue.t.cpp +++ b/src/groups/bmq/bmqc/bmqc_monitoredqueue_bdlccsingleconsumerqueue.t.cpp @@ -168,7 +168,7 @@ static void test1_MonitoredSingleConsumerQueue_breathingTest() bmqc::MonitoredQueue > queue( k_QUEUE_SIZE, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(queue.numElements(), 0); ASSERT_EQ(queue.isEmpty(), true); @@ -219,7 +219,7 @@ static void test1_MonitoredSingleConsumerQueue_breathingTest() k_QUEUE_SIZE, true, // supportTimedOperations - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(queue.numElements(), 0); ASSERT_EQ(queue.isEmpty(), true); @@ -294,7 +294,7 @@ static void test2_MonitoredSingleConsumerQueue_exceed_reset() bmqc::MonitoredQueue > queue( k_QUEUE_SIZE, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); queue.setWatermarks(k_LOW_WATERMARK, k_HIGH_WATERMARK, k_HIGH_WATERMARK2); // 1. Enqueue items until the queue is full @@ -341,7 +341,7 @@ static void testN1_MonitoredSingleConsumerQueue_performance() // Performance // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("MONITORED SINGLE CONSUMER QUEUE " "- PERFORMANCE TEST"); @@ -354,10 +354,11 @@ static void testN1_MonitoredSingleConsumerQueue_performance() PRINT("============================"); PRINT("MonitoredSingleConsumerQueue"); PRINT("============================"); - PerformanceTestObjectPool objectPool1(-1, s_allocator_p); + PerformanceTestObjectPool objectPool1(-1, + bmqtst::TestHelperUtil::allocator()); PerformanceTestObjectQueue monitoredSingleConsumerQueue( k_SINGLE_CONSUMER_QUEUE_SIZE, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // #1 { @@ -366,11 +367,11 @@ static void testN1_MonitoredSingleConsumerQueue_performance() 1, // minThreads 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &monitoredSingleConsumerQueue, &objectPool1)); @@ -400,11 +401,11 @@ static void testN1_MonitoredSingleConsumerQueue_performance() k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &monitoredSingleConsumerQueue, &objectPool1)); @@ -417,7 +418,7 @@ static void testN1_MonitoredSingleConsumerQueue_performance() for (int i = 0; i < k_NUM_PUSHERS; ++i) { threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPusher, k_NUM_ITERATIONS / k_NUM_PUSHERS, &monitoredSingleConsumerQueue, @@ -445,12 +446,13 @@ static void testN1_MonitoredSingleConsumerQueue_performance() PRINT("bdlcc::SingleConsumerQueue"); PRINT("=========================="); - PerformanceTestObjectPool objectPool2(-1, s_allocator_p); + PerformanceTestObjectPool objectPool2(-1, + bmqtst::TestHelperUtil::allocator()); typedef bdlcc::SingleConsumerQueue UnmonitoredQueue; UnmonitoredQueue singleConsumerQueue(k_SINGLE_CONSUMER_QUEUE_SIZE, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // #1 { @@ -459,11 +461,11 @@ static void testN1_MonitoredSingleConsumerQueue_performance() k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &singleConsumerQueue, &objectPool2)); @@ -493,10 +495,10 @@ static void testN1_MonitoredSingleConsumerQueue_performance() k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &singleConsumerQueue, &objectPool2)); @@ -509,7 +511,7 @@ static void testN1_MonitoredSingleConsumerQueue_performance() for (int i = 0; i < k_NUM_PUSHERS; ++i) { threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestPusher, k_NUM_ITERATIONS / k_NUM_PUSHERS, &singleConsumerQueue, @@ -553,7 +555,7 @@ static void testN1_MonitoredSingleConsumerQueue_performance_GoogleBenchmark( // Performance // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("MONITORED SINGLE CONSUMER QUEUE " "- PERFORMANCE TEST"); @@ -565,10 +567,11 @@ static void testN1_MonitoredSingleConsumerQueue_performance_GoogleBenchmark( PRINT("============================"); PRINT("MonitoredSingleConsumerQueue"); PRINT("============================"); - PerformanceTestObjectPool objectPool1(-1, s_allocator_p); + PerformanceTestObjectPool objectPool1(-1, + bmqtst::TestHelperUtil::allocator()); PerformanceTestObjectQueue monitoredSingleConsumerQueue( k_SINGLE_CONSUMER_QUEUE_SIZE, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // #1 { @@ -577,11 +580,11 @@ static void testN1_MonitoredSingleConsumerQueue_performance_GoogleBenchmark( 1, // minThreads 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &monitoredSingleConsumerQueue, &objectPool1)); @@ -622,21 +625,22 @@ testN1_MonitoredSingleConsumerQueueThreaded_performance_GoogleBenchmark( const int k_SINGLE_CONSUMER_QUEUE_SIZE = 250 * 1000; // 250K const int k_NUM_PUSHERS = 5; - PerformanceTestObjectPool objectPool1(-1, s_allocator_p); + PerformanceTestObjectPool objectPool1(-1, + bmqtst::TestHelperUtil::allocator()); PerformanceTestObjectQueue monitoredSingleConsumerQueue( k_SINGLE_CONSUMER_QUEUE_SIZE, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); { bdlmt::ThreadPool threadPool( bslmt::ThreadAttributes(), // default k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &monitoredSingleConsumerQueue, &objectPool1)); @@ -646,7 +650,7 @@ testN1_MonitoredSingleConsumerQueueThreaded_performance_GoogleBenchmark( for (int i = 0; i < k_NUM_PUSHERS; ++i) { threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPusher, k_NUM_ITERATIONS / k_NUM_PUSHERS, &monitoredSingleConsumerQueue, @@ -691,12 +695,13 @@ static void testN1_bdlccSingleConsumerQueue_performance_GoogleBenchmark( const int k_NUM_ITERATIONS = 10 * 1000 * 1000; // 10 M const int k_SINGLE_CONSUMER_QUEUE_SIZE = 250 * 1000; // 250K const int k_NUM_PUSHERS = 5; - PerformanceTestObjectPool objectPool2(-1, s_allocator_p); + PerformanceTestObjectPool objectPool2(-1, + bmqtst::TestHelperUtil::allocator()); typedef bdlcc::SingleConsumerQueue UnmonitoredQueue; UnmonitoredQueue singleConsumerQueue(k_SINGLE_CONSUMER_QUEUE_SIZE, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // #1 { @@ -705,11 +710,11 @@ static void testN1_bdlccSingleConsumerQueue_performance_GoogleBenchmark( k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &singleConsumerQueue, &objectPool2)); @@ -749,12 +754,13 @@ testN1_bdlccSingleConsumerQueueThreaded_performance_GoogleBenchmark( const int k_NUM_ITERATIONS = 10 * 1000 * 1000; // 10 M const int k_SINGLE_CONSUMER_QUEUE_SIZE = 250 * 1000; // 250K const int k_NUM_PUSHERS = 5; - PerformanceTestObjectPool objectPool2(-1, s_allocator_p); + PerformanceTestObjectPool objectPool2(-1, + bmqtst::TestHelperUtil::allocator()); typedef bdlcc::SingleConsumerQueue UnmonitoredQueue; UnmonitoredQueue singleConsumerQueue(k_SINGLE_CONSUMER_QUEUE_SIZE, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // #2 .. again { bdlmt::ThreadPool threadPool( @@ -762,10 +768,10 @@ testN1_bdlccSingleConsumerQueueThreaded_performance_GoogleBenchmark( k_NUM_PUSHERS + 1, // minThreads k_NUM_PUSHERS + 1, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestPopper, &singleConsumerQueue, &objectPool2)); @@ -774,7 +780,7 @@ testN1_bdlccSingleConsumerQueueThreaded_performance_GoogleBenchmark( for (auto _ : state) { for (int i = 0; i < k_NUM_PUSHERS; ++i) { threadPool.enqueueJob(bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &performanceTestPusher, k_NUM_ITERATIONS / k_NUM_PUSHERS, &singleConsumerQueue, @@ -830,7 +836,7 @@ int main(int argc, char* argv[]) break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqc/bmqc_multiqueuethreadpool.t.cpp b/src/groups/bmq/bmqc/bmqc_multiqueuethreadpool.t.cpp index 35d34e3ee..33af002bb 100644 --- a/src/groups/bmq/bmqc/bmqc_multiqueuethreadpool.t.cpp +++ b/src/groups/bmq/bmqc/bmqc_multiqueuethreadpool.t.cpp @@ -144,7 +144,7 @@ static void test1_breathingTest() // Basic functionality. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Ignore default allocator check for now because instantiating the // 'MQTP::Config' object fails the default allocator check for a // reason yet to be identified (the source appears to be in @@ -156,25 +156,26 @@ static void test1_breathingTest() const int k_NUM_QUEUES = 3; const int k_FIXED_QUEUE_SIZE = 10; - bsl::map > queueContextMap(s_allocator_p); + bsl::map > queueContextMap( + bmqtst::TestHelperUtil::allocator()); bdlmt::ThreadPool threadPool( bslmt::ThreadAttributes(), // default 3, // minThreads 3, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); MQTP::Config config( k_NUM_QUEUES, &threadPool, - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &eventCb, bdlf::PlaceHolders::_1, // queueId bdlf::PlaceHolders::_2, // context bdlf::PlaceHolders::_3), // event - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &queueCreator, bdlf::PlaceHolders::_1, // ret bdlf::PlaceHolders::_2, // queueId @@ -183,9 +184,9 @@ static void test1_breathingTest() &queueContextMap), bmqc::MultiQueueThreadPoolUtil::defaultCreator(), bmqc::MultiQueueThreadPoolUtil::noOpResetter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - MQTP mfqtp(config, s_allocator_p); + MQTP mfqtp(config, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(mfqtp.isStarted(), false); ASSERT_EQ(mfqtp.numQueues(), k_NUM_QUEUES); ASSERT_EQ(mfqtp.isSingleThreaded(), false); @@ -244,7 +245,7 @@ static void testN1_performance() // Performance // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("PERFORMANCE TEST"); @@ -258,7 +259,7 @@ static void testN1_performance() 3, // minThreads 3, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); // Test with MQTP @@ -266,19 +267,20 @@ static void testN1_performance() PRINT("MQTP"); PRINT("===="); - MQTP::Config config(k_NUM_QUEUES, - &threadPool, - bdlf::BindUtil::bindS(s_allocator_p, - &performanceTestEventCb), - bdlf::BindUtil::bindS(s_allocator_p, - &performanceTestQueueCreator, - bdlf::PlaceHolders::_3, - k_FIXED_QUEUE_SIZE), - bmqc::MultiQueueThreadPoolUtil::defaultCreator(), - bmqc::MultiQueueThreadPoolUtil::noOpResetter(), - s_allocator_p); - - MQTP mfqtp(config, s_allocator_p); + MQTP::Config config( + k_NUM_QUEUES, + &threadPool, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), + &performanceTestEventCb), + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), + &performanceTestQueueCreator, + bdlf::PlaceHolders::_3, + k_FIXED_QUEUE_SIZE), + bmqc::MultiQueueThreadPoolUtil::defaultCreator(), + bmqc::MultiQueueThreadPoolUtil::noOpResetter(), + bmqtst::TestHelperUtil::allocator()); + + MQTP mfqtp(config, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(mfqtp.start() == 0); // 1. @@ -319,13 +321,15 @@ static void testN1_performance() PRINT("bdlcc::FixedQueue"); PRINT("================="); - PerformanceTestObjectPool objectPool(-1, s_allocator_p); - bdlcc::FixedQueue fixedQueue(k_FIXED_QUEUE_SIZE, - s_allocator_p); + PerformanceTestObjectPool objectPool(-1, + bmqtst::TestHelperUtil::allocator()); + bdlcc::FixedQueue fixedQueue( + k_FIXED_QUEUE_SIZE, + bmqtst::TestHelperUtil::allocator()); // #1 threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestFixedQueuePopper, &fixedQueue, &objectPool)); @@ -349,7 +353,7 @@ static void testN1_performance() // #2 .. again threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestFixedQueuePopper, &fixedQueue, &objectPool)); @@ -388,7 +392,7 @@ static void testN1_performance_GoogleBenchmark(benchmark::State& state) // Performance // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("PERFORMANCE TEST"); @@ -402,7 +406,7 @@ static void testN1_performance_GoogleBenchmark(benchmark::State& state) 3, // minThreads 3, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); // Test with MQTP @@ -410,19 +414,20 @@ static void testN1_performance_GoogleBenchmark(benchmark::State& state) PRINT("MQTP"); PRINT("===="); - MQTP::Config config(k_NUM_QUEUES, - &threadPool, - bdlf::BindUtil::bindS(s_allocator_p, - &performanceTestEventCb), - bdlf::BindUtil::bindS(s_allocator_p, - &performanceTestQueueCreator, - bdlf::PlaceHolders::_3, - k_FIXED_QUEUE_SIZE), - bmqc::MultiQueueThreadPoolUtil::defaultCreator(), - bmqc::MultiQueueThreadPoolUtil::noOpResetter(), - s_allocator_p); - - MQTP mfqtp(config, s_allocator_p); + MQTP::Config config( + k_NUM_QUEUES, + &threadPool, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), + &performanceTestEventCb), + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), + &performanceTestQueueCreator, + bdlf::PlaceHolders::_3, + k_FIXED_QUEUE_SIZE), + bmqc::MultiQueueThreadPoolUtil::defaultCreator(), + bmqc::MultiQueueThreadPoolUtil::noOpResetter(), + bmqtst::TestHelperUtil::allocator()); + + MQTP mfqtp(config, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(mfqtp.start() == 0); // 1. @@ -457,7 +462,7 @@ static void testN1_fixedPerformance_GoogleBenchmark(benchmark::State& state) // Performance // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("FIXED PERFORMANCE TEST"); @@ -470,20 +475,22 @@ static void testN1_fixedPerformance_GoogleBenchmark(benchmark::State& state) 3, // minThreads 3, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); // Now test with fixedQueue PRINT("================="); PRINT("bdlcc::FixedQueue"); PRINT("================="); - PerformanceTestObjectPool objectPool(-1, s_allocator_p); - bdlcc::FixedQueue fixedQueue(k_FIXED_QUEUE_SIZE, - s_allocator_p); + PerformanceTestObjectPool objectPool(-1, + bmqtst::TestHelperUtil::allocator()); + bdlcc::FixedQueue fixedQueue( + k_FIXED_QUEUE_SIZE, + bmqtst::TestHelperUtil::allocator()); // #1 threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestFixedQueuePopper, &fixedQueue, &objectPool)); @@ -528,7 +535,7 @@ int main(int argc, char* argv[]) break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqc/bmqc_orderedhashmap.t.cpp b/src/groups/bmq/bmqc/bmqc_orderedhashmap.t.cpp index d276f2111..26adbfa8f 100644 --- a/src/groups/bmq/bmqc/bmqc_orderedhashmap.t.cpp +++ b/src/groups/bmq/bmqc/bmqc_orderedhashmap.t.cpp @@ -125,9 +125,9 @@ static void test1_breathingTest() typedef MyMapType::iterator IterType; typedef MyMapType::const_iterator ConstIterType; - const bsl::string s("foo", s_allocator_p); + const bsl::string s("foo", bmqtst::TestHelperUtil::allocator()); - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); const MyMapType& cmap = map; ASSERT_EQ(true, map.begin() == map.end()); ASSERT_EQ(true, cmap.begin() == cmap.end()); @@ -209,7 +209,7 @@ static void test3_insert() typedef MyMapType::const_iterator ConstIterType; typedef bsl::pair RcType; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); #if defined(BSLS_PLATFORM_OS_SOLARIS) // Avoid timeout on Solaris @@ -280,7 +280,7 @@ static void test4_rinsert() typedef MyMapType::const_iterator ConstIterType; typedef bsl::pair RcType; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); #if defined(BSLS_PLATFORM_OS_SOLARIS) // Avoid timeout on Solaris @@ -350,7 +350,7 @@ static void test5_insertEraseInsert() typedef MyMapType::const_iterator ConstIterType; typedef bsl::pair RcType; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); const size_t k_NUM_ELEMENTS = 100 * 1000; // 100K const size_t k_STEP = 10; @@ -454,7 +454,7 @@ static void test6_clear() typedef MyMapType::iterator IterType; typedef bsl::pair RcType; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, map.empty()); ASSERT_EQ(true, map.begin() == map.end()); ASSERT_EQ(0U, map.size()); @@ -502,7 +502,7 @@ static void test7_erase() typedef bsl::pair RcType; const int k_NUM_ELEMENTS = 100; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); // Insert elements for (int i = 0; i < k_NUM_ELEMENTS; ++i) { @@ -539,7 +539,7 @@ static void test8_eraseClear() typedef bsl::pair RcType; const size_t k_NUM_ELEMENTS = 100; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); // Insert elements for (size_t i = 0; i < k_NUM_ELEMENTS; ++i) { @@ -581,7 +581,7 @@ static void test9_insertFailure() typedef bsl::pair RcType; const size_t k_NUM_ELEMENTS = 100000; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); // Insert elements for (size_t i = 0; i < k_NUM_ELEMENTS; ++i) { @@ -614,7 +614,7 @@ static void test10_erasureIterator() typedef bsl::pair RcType; const size_t k_NUM_ELEMENTS = 10000; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); // Insert elements for (size_t i = 0; i < k_NUM_ELEMENTS; ++i) { @@ -662,7 +662,8 @@ static void test11_copyConstructor() const size_t k_NUM_ELEMENTS = 10000; - MyMapType* m1p = new (*s_allocator_p) MyMapType(s_allocator_p); + MyMapType* m1p = new (*bmqtst::TestHelperUtil::allocator()) + MyMapType(bmqtst::TestHelperUtil::allocator()); // Insert elements for (size_t i = 0; i < k_NUM_ELEMENTS; ++i) { @@ -671,7 +672,7 @@ static void test11_copyConstructor() ASSERT_EQ_D(i, true, rc.first != m1p->end()); } - MyMapType m2(*m1p, s_allocator_p); + MyMapType m2(*m1p, bmqtst::TestHelperUtil::allocator()); // Iterate and confirm size_t i = 0; @@ -682,7 +683,7 @@ static void test11_copyConstructor() } // Delete object 1 and check object 2 again - s_allocator_p->deleteObject(m1p); + bmqtst::TestHelperUtil::allocator()->deleteObject(m1p); i = 0; for (ConstIterType cit = m2.begin(); cit != m2.end(); ++cit) { @@ -715,7 +716,8 @@ static void test12_assignmentOperator() const size_t k_NUM_ELEMENTS = 10000; - MyMapType* m1p = new (*s_allocator_p) MyMapType(s_allocator_p); + MyMapType* m1p = new (*bmqtst::TestHelperUtil::allocator()) + MyMapType(bmqtst::TestHelperUtil::allocator()); // Insert elements for (size_t i = 0; i < k_NUM_ELEMENTS; ++i) { @@ -724,7 +726,7 @@ static void test12_assignmentOperator() ASSERT_EQ_D(i, true, rc.first != m1p->end()); } - MyMapType m2(s_allocator_p); + MyMapType m2(bmqtst::TestHelperUtil::allocator()); // Insert elements for (size_t i = k_NUM_ELEMENTS; i > 0; --i) { @@ -744,7 +746,7 @@ static void test12_assignmentOperator() } // Delete object 1 and check object 2 again - s_allocator_p->deleteObject(m1p); + bmqtst::TestHelperUtil::allocator()->deleteObject(m1p); i = 0; for (ConstIterType cit = m2.begin(); cit != m2.end(); ++cit) { ASSERT_EQ_D(i, cit->first, i); @@ -769,7 +771,7 @@ static void test13_previousEndIterator() typedef MyMapType::iterator IterType; typedef MyMapType::const_iterator ConstIterType; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); const MyMapType& cmap = map; ASSERT_EQ(true, map.begin() == map.end()); ASSERT_EQ(true, cmap.begin() == cmap.end()); @@ -837,7 +839,7 @@ static void test14_localIterator() typedef MyMapType::local_iterator LocalIterType; typedef MyMapType::const_local_iterator ConstLocalIterType; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); const MyMapType& cmap = map; const size_t bucketCount = map.bucket_count(); @@ -910,7 +912,7 @@ static void test15_eraseRange() typedef bsl::pair RcType; const size_t k_NUM_ELEMENTS = 100; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); // Insert elements for (size_t i = 0; i < k_NUM_ELEMENTS; ++i) { @@ -964,7 +966,7 @@ static void testN1_insertPerformanceOrdered() // OrderedHashMap typedef bmqc::OrderedHashMap MyMapType; - MyMapType map(k_NUM_ELEMENTS, s_allocator_p); + MyMapType map(k_NUM_ELEMENTS, bmqtst::TestHelperUtil::allocator()); bsls::Types::Int64 begin = bsls::TimeUtil::getTimer(); for (size_t i = 0; i < k_NUM_ELEMENTS; ++i) { @@ -991,7 +993,7 @@ static void testN1_insertPerformanceUnordered() // bsl::unordered_map typedef bsl::unordered_map MyMapType; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); map.reserve(k_NUM_ELEMENTS); bsls::Types::Int64 begin = bsls::TimeUtil::getTimer(); @@ -1022,7 +1024,7 @@ BSLA_MAYBE_UNUSED static void testN2_erasePerformanceOrdered() typedef MyMapType::iterator IterType; typedef bsl::pair RcType; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); // Insert 1M elements for (size_t i = 0; i < k_NUM_ELEMENTS; ++i) { RcType rc = map.insert(bsl::make_pair(i, i)); @@ -1060,7 +1062,7 @@ BSLA_MAYBE_UNUSED static void testN2_erasePerformanceUnordered() typedef MyMapType::iterator IterType; typedef bsl::pair RcType; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); // Insert 1M elements for (size_t i = 0; i < k_NUM_ELEMENTS; ++i) { RcType rc = map.insert(bsl::make_pair(i, i)); @@ -1092,7 +1094,7 @@ BSLA_MAYBE_UNUSED static void testN3_profile() const size_t k_NUM_ELEMENTS = 5000000; typedef bmqc::OrderedHashMap MyMapType; - MyMapType map(k_NUM_ELEMENTS, s_allocator_p); + MyMapType map(k_NUM_ELEMENTS, bmqtst::TestHelperUtil::allocator()); // Insert elements. for (size_t i = 0; i < k_NUM_ELEMENTS; ++i) { @@ -1112,7 +1114,7 @@ testN1_insertPerformanceUnordered_GoogleBenchmark(benchmark::State& state) { // UnorderedMap typedef bsl::unordered_map MyMapType; - MyMapType map(state.range(0), s_allocator_p); + MyMapType map(state.range(0), bmqtst::TestHelperUtil::allocator()); for (auto _ : state) { for (size_t i = 0; i < static_cast(state.range(0)); ++i) { map.insert(bsl::make_pair(i, i)); @@ -1131,7 +1133,8 @@ testN1_insertPerformanceOrdered_GoogleBenchmark(benchmark::State& state) // OrderedHashMap typedef bmqc::OrderedHashMap MyMapType; - MyMapType map(static_cast(state.range(0)), s_allocator_p); + MyMapType map(static_cast(state.range(0)), + bmqtst::TestHelperUtil::allocator()); for (auto _ : state) { for (size_t i = 0; i < static_cast(state.range(0)); ++i) { map.insert(bsl::make_pair(i, i)); @@ -1148,7 +1151,7 @@ testN2_erasePerformanceUnordered_GoogleBenchmark(benchmark::State& state) typedef MyMapType::iterator IterType; typedef bsl::pair RcType; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); for (auto _ : state) { state.PauseTiming(); for (size_t i = 0; i < static_cast(state.range(0)); ++i) { @@ -1177,7 +1180,7 @@ testN2_erasePerformanceOrdered_GoogleBenchmark(benchmark::State& state) typedef MyMapType::iterator IterType; typedef bsl::pair RcType; - MyMapType map(s_allocator_p); + MyMapType map(bmqtst::TestHelperUtil::allocator()); // Insert 1M elements for (auto _ : state) { state.PauseTiming(); @@ -1206,7 +1209,8 @@ static void testN3_profile_GoogleBenchmark(benchmark::State& state) // This case can be used to profile the component. typedef bmqc::OrderedHashMap MyMapType; - MyMapType map(static_cast(state.range(0)), s_allocator_p); + MyMapType map(static_cast(state.range(0)), + bmqtst::TestHelperUtil::allocator()); // Insert elements. for (auto _ : state) { @@ -1272,7 +1276,7 @@ int main(int argc, char* argv[]) break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } #ifdef BSLS_PLATFORM_OS_LINUX diff --git a/src/groups/bmq/bmqc/bmqc_orderedhashmapwithhistory.t.cpp b/src/groups/bmq/bmqc/bmqc_orderedhashmapwithhistory.t.cpp index e180113e1..d034bd813 100644 --- a/src/groups/bmq/bmqc/bmqc_orderedhashmapwithhistory.t.cpp +++ b/src/groups/bmq/bmqc/bmqc_orderedhashmapwithhistory.t.cpp @@ -66,7 +66,7 @@ static void test1_insert() bmqtst::TestHelper::printTestName("HISTORY"); int timeout = 1; - ObjectUnderTest obj(timeout, s_allocator_p); + ObjectUnderTest obj(timeout, bmqtst::TestHelperUtil::allocator()); setup(obj, 10, timeout); } @@ -90,7 +90,7 @@ static void test2_eraseMiddleToEnd() bmqtst::TestHelper::printTestName("ERASE_MIDDLE_TO_END"); int timeout = 1; - ObjectUnderTest obj(timeout, s_allocator_p); + ObjectUnderTest obj(timeout, bmqtst::TestHelperUtil::allocator()); size_t TOTAL = 10; size_t HALF = TOTAL / 2; @@ -144,7 +144,7 @@ static void test3_eraseMiddleToBegin() bmqtst::TestHelper::printTestName("ERASE_MIDDLE_TO_BEGIN"); int timeout = 1; - ObjectUnderTest obj(timeout, s_allocator_p); + ObjectUnderTest obj(timeout, bmqtst::TestHelperUtil::allocator()); size_t TOTAL = 10; size_t HALF = TOTAL / 2; @@ -199,7 +199,7 @@ static void test4_gc() bmqtst::TestHelper::printTestName("ERASE_AND_GC"); int timeout = 1; - ObjectUnderTest obj(timeout, s_allocator_p); + ObjectUnderTest obj(timeout, bmqtst::TestHelperUtil::allocator()); size_t TOTAL = 10; size_t HALF = TOTAL / 2; @@ -269,7 +269,7 @@ static void test5_insertAfterEnd() bmqtst::TestHelper::printTestName("INSERT_AFTER_END"); int timeout = 1; - ObjectUnderTest obj(timeout, s_allocator_p); + ObjectUnderTest obj(timeout, bmqtst::TestHelperUtil::allocator()); Iterator begin = obj.begin(); Iterator end = obj.end(); @@ -307,7 +307,7 @@ static void test6_eraseThenGc() bmqtst::TestHelper::printTestName("INSERT_AFTER_END"); int timeout = 1; - ObjectUnderTest obj(timeout, s_allocator_p); + ObjectUnderTest obj(timeout, bmqtst::TestHelperUtil::allocator()); const int BATCH_SIZE = 1000; const int ADDITIONS = 100; @@ -350,7 +350,7 @@ int main(int argc, char* argv[]) case 6: test6_eraseThenGc(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqc/bmqc_twokeyhashmap.t.cpp b/src/groups/bmq/bmqc/bmqc_twokeyhashmap.t.cpp index 146820e97..04b440d2b 100644 --- a/src/groups/bmq/bmqc/bmqc_twokeyhashmap.t.cpp +++ b/src/groups/bmq/bmqc/bmqc_twokeyhashmap.t.cpp @@ -1927,7 +1927,7 @@ int main(int argc, char** argv) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h index 2362b340b..4a44542a3 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.h @@ -50,8 +50,9 @@ // } // // MockPropertiesReader reader(s_allocator_p); -// EvaluationContext evaluationContext(&reader, s_allocator_p); -// bool result = evaluator.evaluate(evaluationContext); +// EvaluationContext evaluationContext(&reader, +// bmqtst::TestHelperUtil::allocator()); bool result = +// evaluator.evaluate(evaluationContext); //.. // BDE diff --git a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp index 307c585cd..a2f97a630 100644 --- a/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp +++ b/src/groups/bmq/bmqeval/bmqeval_simpleevaluator.t.cpp @@ -113,7 +113,7 @@ static void testN1_SimpleEvaluator() static bsl::string makeTooManyOperators() { - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); for (size_t i = 0; i < SimpleEvaluator::k_MAX_OPERATORS + 1; ++i) { os << "!"; @@ -126,7 +126,7 @@ static bsl::string makeTooManyOperators() static bsl::string makeTooLongExpression() { - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); // Note that we want to create `k_STACK_SIZE` nested NOT objects in AST, // and when we call destructor chain for all these objects, we'll need @@ -216,7 +216,8 @@ static void test1_compilationErrors() PV(bsl::string("TESTING ") + parameters->expression); { - CompilationContext compilationContext(s_allocator_p); + CompilationContext compilationContext( + bmqtst::TestHelperUtil::allocator()); SimpleEvaluator evaluator; evaluator.compile(parameters->expression, compilationContext); @@ -355,7 +356,7 @@ static void test2_propertyNames() const TestParameters* testParametersEnd = testParameters + sizeof(testParameters) / sizeof(*testParameters); - CompilationContext compilationContext(s_allocator_p); + CompilationContext compilationContext(bmqtst::TestHelperUtil::allocator()); for (const TestParameters* parameters = testParameters; parameters < testParametersEnd; @@ -371,8 +372,9 @@ static void test2_propertyNames() static void test3_evaluation() { - MockPropertiesReader reader(s_allocator_p); - EvaluationContext evaluationContext(&reader, s_allocator_p); + MockPropertiesReader reader(bmqtst::TestHelperUtil::allocator()); + EvaluationContext evaluationContext(&reader, + bmqtst::TestHelperUtil::allocator()); const bool runtimeErrorResult = false; @@ -528,7 +530,8 @@ static void test3_evaluation() ++parameters) { PV(bsl::string("TESTING ") + parameters->expression); - CompilationContext compilationContext(s_allocator_p); + CompilationContext compilationContext( + bmqtst::TestHelperUtil::allocator()); SimpleEvaluator evaluator; ASSERT(!evaluator.isValid()); @@ -562,7 +565,7 @@ int main(int argc, char* argv[]) case -1: BMQTST_BENCHMARK(testN1_SimpleEvaluator); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_bdlmteventschedulerexecutor.t.cpp b/src/groups/bmq/bmqex/bmqex_bdlmteventschedulerexecutor.t.cpp index 4e78c4330..c5cffb7e4 100644 --- a/src/groups/bmq/bmqex/bmqex_bdlmteventschedulerexecutor.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_bdlmteventschedulerexecutor.t.cpp @@ -382,7 +382,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_bdlmtfixedthreadpoolexecutor.t.cpp b/src/groups/bmq/bmqex/bmqex_bdlmtfixedthreadpoolexecutor.t.cpp index 279430836..ed78cf8ee 100644 --- a/src/groups/bmq/bmqex/bmqex_bdlmtfixedthreadpoolexecutor.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_bdlmtfixedthreadpoolexecutor.t.cpp @@ -260,7 +260,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_bdlmtmultiprioritythreadpoolexecutor.t.cpp b/src/groups/bmq/bmqex/bmqex_bdlmtmultiprioritythreadpoolexecutor.t.cpp index a10a0dc98..f7a922541 100644 --- a/src/groups/bmq/bmqex/bmqex_bdlmtmultiprioritythreadpoolexecutor.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_bdlmtmultiprioritythreadpoolexecutor.t.cpp @@ -354,7 +354,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_bdlmtmultiqueuethreadpoolexecutor.t.cpp b/src/groups/bmq/bmqex/bmqex_bdlmtmultiqueuethreadpoolexecutor.t.cpp index 35c33d90a..a0ea777a1 100644 --- a/src/groups/bmq/bmqex/bmqex_bdlmtmultiqueuethreadpoolexecutor.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_bdlmtmultiqueuethreadpoolexecutor.t.cpp @@ -107,11 +107,11 @@ static void test2_postDispatch() // bmqex::BdlmtMultiQueueThreadPoolExecutor::dispatch // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // MultiQueueThreadPool_Queue::executeFront() creates a vector on the // stack, so uses the default allocator. - s_ignoreCheckGblAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckGblAlloc() = true; // MultiQueueThreadPool::start() implementation uses the global // allocator. @@ -409,7 +409,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_bdlmtthreadpoolexecutor.t.cpp b/src/groups/bmq/bmqex/bmqex_bdlmtthreadpoolexecutor.t.cpp index 0632a4f48..521b5f99d 100644 --- a/src/groups/bmq/bmqex/bmqex_bdlmtthreadpoolexecutor.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_bdlmtthreadpoolexecutor.t.cpp @@ -277,7 +277,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_bindutil.t.cpp b/src/groups/bmq/bmqex/bmqex_bindutil.t.cpp index 1f64af4fe..7442293c9 100644 --- a/src/groups/bmq/bmqex/bmqex_bindutil.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_bindutil.t.cpp @@ -441,7 +441,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_executionpolicy.t.cpp b/src/groups/bmq/bmqex/bmqex_executionpolicy.t.cpp index e11fe746c..0bd01f802 100644 --- a/src/groups/bmq/bmqex/bmqex_executionpolicy.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_executionpolicy.t.cpp @@ -454,7 +454,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_executionutil.t.cpp b/src/groups/bmq/bmqex/bmqex_executionutil.t.cpp index 8bf824ada..ac55ea448 100644 --- a/src/groups/bmq/bmqex/bmqex_executionutil.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_executionutil.t.cpp @@ -1685,7 +1685,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_executor.t.cpp b/src/groups/bmq/bmqex/bmqex_executor.t.cpp index 9d1fe242f..00208b483 100644 --- a/src/groups/bmq/bmqex/bmqex_executor.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_executor.t.cpp @@ -874,7 +874,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_executortraits.t.cpp b/src/groups/bmq/bmqex/bmqex_executortraits.t.cpp index 1ae889664..ab9d5a49c 100644 --- a/src/groups/bmq/bmqex/bmqex_executortraits.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_executortraits.t.cpp @@ -232,7 +232,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_future.t.cpp b/src/groups/bmq/bmqex/bmqex_future.t.cpp index 8add9fd82..ca3b23ca2 100644 --- a/src/groups/bmq/bmqex/bmqex_future.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_future.t.cpp @@ -1805,7 +1805,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_job.t.cpp b/src/groups/bmq/bmqex/bmqex_job.t.cpp index 5fcf2abb1..c93027ace 100644 --- a/src/groups/bmq/bmqex/bmqex_job.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_job.t.cpp @@ -166,7 +166,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_promise.t.cpp b/src/groups/bmq/bmqex/bmqex_promise.t.cpp index 3ff64cf62..d8267f7e6 100644 --- a/src/groups/bmq/bmqex/bmqex_promise.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_promise.t.cpp @@ -245,7 +245,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_sequentialcontext.t.cpp b/src/groups/bmq/bmqex/bmqex_sequentialcontext.t.cpp index c2a03c357..b2641fd79 100644 --- a/src/groups/bmq/bmqex/bmqex_sequentialcontext.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_sequentialcontext.t.cpp @@ -909,7 +909,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_strand.t.cpp b/src/groups/bmq/bmqex/bmqex_strand.t.cpp index 196040e77..335c58b1b 100644 --- a/src/groups/bmq/bmqex/bmqex_strand.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_strand.t.cpp @@ -1218,7 +1218,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqex/bmqex_systemexecutor.t.cpp b/src/groups/bmq/bmqex/bmqex_systemexecutor.t.cpp index 57d8b266f..3e6025193 100644 --- a/src/groups/bmq/bmqex/bmqex_systemexecutor.t.cpp +++ b/src/groups/bmq/bmqex/bmqex_systemexecutor.t.cpp @@ -434,7 +434,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqimp/bmqimp_application.t.cpp b/src/groups/bmq/bmqimp/bmqimp_application.t.cpp index 69132ba9a..3ce95236a 100644 --- a/src/groups/bmq/bmqimp/bmqimp_application.t.cpp +++ b/src/groups/bmq/bmqimp/bmqimp_application.t.cpp @@ -44,14 +44,15 @@ static void test1_breathingTest() bmqtst::TestHelper::printTestName("BREATHING TEST"); // Create a default application - bmqt::SessionOptions options(s_allocator_p); - bmqp_ctrlmsg::NegotiationMessage negotiationMessage(s_allocator_p); + bmqt::SessionOptions options(bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::NegotiationMessage negotiationMessage( + bmqtst::TestHelperUtil::allocator()); bmqimp::EventQueue::EventHandlerCallback emptyEventHandler; bmqimp::Application obj(options, negotiationMessage, emptyEventHandler, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); } static void test2_startStopTest() @@ -76,14 +77,15 @@ static void test2_startStopTest() bmqtst::TestHelper::printTestName("START STOP TEST"); // Create a default application, make sure it can start/stop - bmqt::SessionOptions options(s_allocator_p); - bmqp_ctrlmsg::NegotiationMessage negotiationMessage(s_allocator_p); + bmqt::SessionOptions options(bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::NegotiationMessage negotiationMessage( + bmqtst::TestHelperUtil::allocator()); bmqimp::EventQueue::EventHandlerCallback emptyEventHandler; bmqimp::Application obj(options, negotiationMessage, emptyEventHandler, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Stop without previous start obj.stop(); @@ -126,14 +128,15 @@ static void test3_startStopAsyncTest() bmqtst::TestHelper::printTestName("START STOP TEST"); // Create a default application, make sure it can start/stop - bmqt::SessionOptions options(s_allocator_p); - bmqp_ctrlmsg::NegotiationMessage negotiationMessage(s_allocator_p); + bmqt::SessionOptions options(bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::NegotiationMessage negotiationMessage( + bmqtst::TestHelperUtil::allocator()); bmqimp::EventQueue::EventHandlerCallback emptyEventHandler; bmqimp::Application obj(options, negotiationMessage, emptyEventHandler, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Stop without previous start obj.stopAsync(); @@ -185,7 +188,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp b/src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp index 1f978e03d..406a5d952 100644 --- a/src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp +++ b/src/groups/bmq/bmqimp/bmqimp_brokersession.t.cpp @@ -431,17 +431,19 @@ struct TestSession BSLS_CPP11_FINAL { /// Create a `TestSession` object using the specified `sessionOptions`, /// `scheduler`, and `allocator` to supply memory. - explicit TestSession(const bmqt::SessionOptions& sessionOptions, - bdlmt::EventScheduler& scheduler, - bool useEventHandler = true, - bslma::Allocator* allocator = s_allocator_p); + explicit TestSession( + const bmqt::SessionOptions& sessionOptions, + bdlmt::EventScheduler& scheduler, + bool useEventHandler = true, + bslma::Allocator* allocator = bmqtst::TestHelperUtil::allocator()); /// Create a `TestSession` object using the specified `sessionOptions`, /// `clockPtr`, and `allocator` to supply memory. - explicit TestSession(const bmqt::SessionOptions& sessionOptions, - TestClock& testClock, - bool useEventHandler = true, - bslma::Allocator* allocator = s_allocator_p); + explicit TestSession( + const bmqt::SessionOptions& sessionOptions, + TestClock& testClock, + bool useEventHandler = true, + bslma::Allocator* allocator = bmqtst::TestHelperUtil::allocator()); ~TestSession(); @@ -1008,7 +1010,8 @@ void TestSession::openQueueWithError(bsl::shared_ptr queue, ASSERT_EQ(queue->state(), bmqimp::QueueState::e_CLOSED); ASSERT_EQ(queue->isValid(), false); - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); // open queue request is not sent if (requestType == e_REQ_OPEN_QUEUE && errorResult == e_ERR_NOT_SENT) { @@ -1227,7 +1230,8 @@ void TestSession::closeQueueWithError(bsl::shared_ptr queue, ASSERT(queue->isValid()); ASSERT_EQ(queue->state(), bmqimp::QueueState::e_OPENED); - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); // configure queue request is not sent if (requestType == e_REQ_CONFIG_QUEUE && errorResult == e_ERR_NOT_SENT) { @@ -1408,7 +1412,8 @@ TestSession::openQueueFirstStep(bsl::shared_ptr queue, ASSERT_EQ(queue->state(), bmqimp::QueueState::e_CLOSED); ASSERT_EQ(queue->isValid(), false); - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); PVVV_SAFE(L_ << " Open the queue async"); int rc = d_brokerSession.openQueueAsync(queue, timeout); @@ -1428,7 +1433,8 @@ bmqp_ctrlmsg::ControlMessage TestSession::openQueueFirstStepExpired(bsl::shared_ptr queue, const bsls::TimeInterval& timeout) { - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); // Start with a queue in OPENING state and pending open request currentRequest = arriveAtStep(queue, e_OPEN_OPENING, timeout); @@ -1459,7 +1465,8 @@ bmqp_ctrlmsg::ControlMessage TestSession::reopenQueueFirstStepExpired(bsl::shared_ptr queue, const bsls::TimeInterval& timeout) { - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); // Go to the state with pending reopen request currentRequest = arriveAtStep(queue, e_REOPEN_OPENING, timeout); @@ -1497,7 +1504,8 @@ TestSession::reopenQueueFirstStep(bsl::shared_ptr queue) ASSERT_EQ(queue->state(), bmqimp::QueueState::e_OPENED); ASSERT(queue->isValid()); - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); PVVV_SAFE(L_ << " Trigger channel drop"); session().setChannel(bsl::shared_ptr()); @@ -1547,7 +1555,8 @@ bmqp_ctrlmsg::ControlMessage TestSession::closeQueueSecondStepExpired(bsl::shared_ptr queue, const bsls::TimeInterval& timeout) { - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); // Go to the step with pending 2nd phase close request currentRequest = arriveAtStep(queue, e_CLOSE_CLOSING, timeout); @@ -1586,7 +1595,8 @@ TestSession::arriveAtStepWithCfgs(bsl::shared_ptr queue, { BSLS_ASSERT_OPT(bmqt::QueueFlagsUtil::isReader(queue->flags())); - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); int currentStep = e_OPEN_OPENING; while (currentStep <= step) { @@ -1739,7 +1749,8 @@ TestSession::arriveAtStepWithoutCfgs(bsl::shared_ptr queue, const QueueTestStep step, const bsls::TimeInterval& timeout) { - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); int currentStep = e_OPEN_OPENING; while (currentStep <= step) { @@ -1875,7 +1886,8 @@ void TestSession::arriveAtLateResponseStepReader( const LateResponseTestStep step, const bsls::TimeInterval& timeout) { - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); int currentStep = e_LATE_OPEN_OPENING; while (currentStep <= step) { @@ -2068,7 +2080,8 @@ void TestSession::arriveAtLateResponseStepWriter( const LateResponseTestStep step, const bsls::TimeInterval& timeout) { - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); int currentStep = e_LATE_OPEN_OPENING; while (currentStep <= step) { @@ -2146,10 +2159,11 @@ TestSession::createQueue(const char* name, { ASSERT(name); - bmqt::Uri uri(name, s_allocator_p); + bmqt::Uri uri(name, bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue; - pQueue.createInplace(s_allocator_p, s_allocator_p); + pQueue.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); pQueue->setUri(uri); pQueue->setFlags(flags); pQueue->setOptions(options); @@ -2255,14 +2269,16 @@ void TestSession::stopGracefully(bool waitForDisconnected) session().stopAsync(); PVVV_SAFE("Stopping: Verify disconnect request is sent"); - bmqp_ctrlmsg::ControlMessage disconnectMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage disconnectMessage( + bmqtst::TestHelperUtil::allocator()); getOutboundControlMessage(&disconnectMessage); ASSERT(!disconnectMessage.rId().isNull()); ASSERT(disconnectMessage.choice().isDisconnectValue()); PVVV_SAFE("Stopping: Prepare and send disconnect response message"); - bmqp_ctrlmsg::ControlMessage disconnectResponseMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage disconnectResponseMessage( + bmqtst::TestHelperUtil::allocator()); disconnectResponseMessage.rId().makeValue(disconnectMessage.rId().value()); disconnectResponseMessage.choice().makeDisconnectResponse(); @@ -2388,7 +2404,7 @@ void TestSession::getOutboundEvent(bmqp::Event* rawEvent) ASSERT(d_testChannel.waitFor(1, true, bsls::TimeInterval(1))); bmqio::TestChannel::WriteCall wc = d_testChannel.popWriteCall(); - bmqp::Event ev(&wc.d_blob, s_allocator_p, true); + bmqp::Event ev(&wc.d_blob, bmqtst::TestHelperUtil::allocator(), true); *rawEvent = ev; } @@ -2399,7 +2415,7 @@ void TestSession::getOutboundControlMessage( ASSERT(d_testChannel.waitFor(1, true, k_EVENT_TIMEOUT)); bmqio::TestChannel::WriteCall wc = d_testChannel.popWriteCall(); - bmqp::Event ev(&wc.d_blob, s_allocator_p); + bmqp::Event ev(&wc.d_blob, bmqtst::TestHelperUtil::allocator()); ASSERT(ev.isControlEvent()); @@ -2422,7 +2438,8 @@ void TestSession::sendControlMessage( void TestSession::sendResponse(const bmqp_ctrlmsg::ControlMessage& request) { - bmqp_ctrlmsg::ControlMessage responseMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage responseMessage( + bmqtst::TestHelperUtil::allocator()); responseMessage.rId() = request.rId(); if (request.choice().isOpenQueueValue()) { @@ -2441,7 +2458,8 @@ void TestSession::sendResponse(const bmqp_ctrlmsg::ControlMessage& request) void TestSession::sendStatus(const bmqp_ctrlmsg::ControlMessage& request) { - bmqp_ctrlmsg::ControlMessage statusMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage statusMessage( + bmqtst::TestHelperUtil::allocator()); statusMessage.rId() = request.rId(); statusMessage.choice().makeStatus(); statusMessage.choice().status().category() = @@ -2455,7 +2473,8 @@ void TestSession::sendStatus(const bmqp_ctrlmsg::ControlMessage& request) bmqp_ctrlmsg::ControlMessage TestSession::getNextOutboundRequest(const RequestType requestType) { - bmqp_ctrlmsg::ControlMessage controlMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage controlMessage( + bmqtst::TestHelperUtil::allocator()); getOutboundControlMessage(&controlMessage); PVVV_SAFE("Outbound request: " << controlMessage); @@ -2608,11 +2627,13 @@ static void test_disconnectRequestErr(bmqio::StatusCategory::Enum category) { bmqt::SessionOptions sessionOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1).setDisconnectTimeout( bsls::TimeInterval(0.01)); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); obj.startAndConnect(); @@ -2793,10 +2814,12 @@ static void test1_breathingTest() bmqtst::TestHelper::printTestName("BREATHING TEST"); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); scheduler.start(); - bdlbb::PooledBlobBufferFactory blobBufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bmqt::SessionOptions sessionOptions; sessionOptions.setNumProcessingThreads(1); @@ -2814,7 +2837,7 @@ static void test1_breathingTest() bdlf::PlaceHolders::_2, // new state &startCounter, &stopCounter), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); PVV_SAFE("Starting session..."); int rc = session.startAsync(); ASSERT_EQ(rc, 0); @@ -2855,14 +2878,16 @@ static void test2_basicAccessorsTest() { bmqtst::TestHelper::printTestName("BASIC ACCESSORS"); - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); const bmqp::QueueId k_QUEUE_ID(0, 0); const bmqt::CorrelationId corrId(bmqt::CorrelationId::autoValue()); - bdlbb::PooledBlobBufferFactory blobBufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bmqt::SessionOptions sessionOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqimp::EventQueue::EventHandlerCallback emptyEventHandler; bmqimp::BrokerSession::StateFunctor emptyStateCb; @@ -2872,7 +2897,7 @@ static void test2_basicAccessorsTest() sessionOptions, emptyEventHandler, emptyStateCb, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT(!obj.isUsingSessionEventHandler()); @@ -2902,7 +2927,9 @@ static void test3_nullChannelTest() bmqtst::TestHelper::printTestName("NULL CHANNEL"); const int k_NUM_EVENTS = 3; - bdlbb::PooledBlobBufferFactory blobBufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bmqt::SessionOptions sessionOptions; bsls::AtomicInt eventCounter(0); bsls::AtomicInt startCounter(0); @@ -2910,7 +2937,7 @@ static void test3_nullChannelTest() bslmt::TimedSemaphore eventSemaphore; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqimp::BrokerSession obj( &scheduler, @@ -2924,7 +2951,7 @@ static void test3_nullChannelTest() bdlf::PlaceHolders::_2, // new state &startCounter, &stopCounter), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.isUsingSessionEventHandler(), true); @@ -2992,9 +3019,11 @@ static void test4_createEventTest() bmqtst::TestHelper::printTestName("CREATE EVENT TEST"); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - bdlbb::PooledBlobBufferFactory blobBufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bmqt::SessionOptions sessionOptions; bmqimp::EventQueue::EventHandlerCallback emptyEventHandler; @@ -3005,7 +3034,7 @@ static void test4_createEventTest() sessionOptions, emptyEventHandler, emptyStateCb, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr ev = obj.createEvent(); ASSERT_EQ(bmqimp::Event::EventType::e_UNINITIALIZED, ev->type()); @@ -3013,10 +3042,12 @@ static void test4_createEventTest() static void queueErrorsTest(bsls::Types::Uint64 queueFlags) { - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); const bsls::TimeInterval& timeout = bsls::TimeInterval(); bsl::shared_ptr pQueue; - bdlbb::PooledBlobBufferFactory blobBufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bsl::shared_ptr eventSp; @@ -3024,13 +3055,14 @@ static void queueErrorsTest(bsls::Types::Uint64 queueFlags) bsls::AtomicInt stopCounter(0); bslmt::TimedSemaphore semaphore; - pQueue.createInplace(s_allocator_p, s_allocator_p); + pQueue.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); pQueue->setUri(uri); pQueue->setFlags(queueFlags); pQueue->setOptions(queueOptions); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); scheduler.start(); @@ -3052,7 +3084,7 @@ static void queueErrorsTest(bsls::Types::Uint64 queueFlags) bdlf::PlaceHolders::_2, // new state &startCounter, &stopCounter), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); PVV_SAFE("Step 1. Starting session..."); int rc = session.startAsync(); @@ -3244,16 +3276,18 @@ static void test6_setChannelTest() // - CONNECTION_LOST const int k_NUM_CALLS = 4; const int k_NUM_EVENTS = 2 + 3 * (k_NUM_CALLS - 1); - bdlbb::PooledBlobBufferFactory blobBufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bmqt::SessionOptions sessionOptions; bsls::AtomicInt eventCounter(0); bsls::AtomicInt startCounter(0); bsls::AtomicInt stopCounter(0); - bmqio::TestChannel testChannel(s_allocator_p); + bmqio::TestChannel testChannel(bmqtst::TestHelperUtil::allocator()); bslmt::TimedSemaphore eventSemaphore; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqimp::BrokerSession obj( &scheduler, @@ -3269,7 +3303,7 @@ static void test6_setChannelTest() bdlf::PlaceHolders::_2, // new state &startCounter, &stopCounter), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); PVV_SAFE("Starting session..."); int rc = obj.startAsync(); @@ -3302,12 +3336,14 @@ static void queueOpenTimeoutTest(bsls::Types::Uint64 queueFlags) bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, queueFlags, @@ -3459,11 +3495,13 @@ static void test8_queueWriterConfigureTest() const bsls::TimeInterval timeout = bsls::TimeInterval(15); bmqt::SessionOptions sessionOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, bmqt::QueueFlags::e_WRITE); @@ -3548,11 +3586,13 @@ static void queueOpenErrorTest(bsls::Types::Uint64 queueFlags) bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, queueFlags, @@ -3576,7 +3616,8 @@ static void queueOpenErrorTest(bsls::Types::Uint64 queueFlags) ASSERT_EQ(pQueue->isValid(), false); PVV_SAFE("Step 4. Send open queue response with error"); - bmqp_ctrlmsg::ControlMessage responseMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage responseMessage( + bmqtst::TestHelperUtil::allocator()); responseMessage.rId().makeValue(openReqId1); responseMessage.choice().makeStatus(); responseMessage.choice().status().category() = @@ -3683,11 +3724,13 @@ static void queueOpenCloseAsync(bsls::Types::Uint64 queueFlags) bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, queueFlags, @@ -3725,14 +3768,17 @@ static void queueOpenCloseAsync(bsls::Types::Uint64 queueFlags) // Prepare and process open queue response PVV_SAFE("Prepare and send back open queue response"); - bmqp_ctrlmsg::ControlMessage openQueueResponse(s_allocator_p); + bmqp_ctrlmsg::ControlMessage openQueueResponse( + bmqtst::TestHelperUtil::allocator()); openQueueResponse.rId().makeValue(openId); openQueueResponse.choice().makeOpenQueueResponse(); obj.sendControlMessage(openQueueResponse); - bmqp_ctrlmsg::ControlMessage configureQueueMessage(s_allocator_p); - bmqp_ctrlmsg::ControlMessage configureQueueResponse(s_allocator_p); + bmqp_ctrlmsg::ControlMessage configureQueueMessage( + bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::ControlMessage configureQueueResponse( + bmqtst::TestHelperUtil::allocator()); // For reader queue there is a configuring phase if (bmqt::QueueFlagsUtil::isReader(queueFlags)) { @@ -3790,7 +3836,8 @@ static void queueOpenCloseAsync(bsls::Types::Uint64 queueFlags) // Verify close request (todo: check handle queue parameters) PVV_SAFE("Ensure close queue request has been sent"); - bmqp_ctrlmsg::ControlMessage closeQueueMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage closeQueueMessage( + bmqtst::TestHelperUtil::allocator()); obj.getOutboundControlMessage(&closeQueueMessage); ASSERT(!closeQueueMessage.rId().isNull()); @@ -3799,7 +3846,8 @@ static void queueOpenCloseAsync(bsls::Types::Uint64 queueFlags) // Prepare and process close queue response PVV_SAFE("Prepare and send back close queue response"); - bmqp_ctrlmsg::ControlMessage closeQueueResponse(s_allocator_p); + bmqp_ctrlmsg::ControlMessage closeQueueResponse( + bmqtst::TestHelperUtil::allocator()); closeQueueResponse.rId().makeValue(closeQueueMessage.rId().value()); closeQueueResponse.choice().makeCloseQueueResponse(); @@ -3893,12 +3941,14 @@ static void test11_disconnect() bmqtst::TestHelper::printTestName("DISCONNECT"); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); - bdlbb::PooledBlobBufferFactory blobBufferFactory(1024, s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bdlcc::Deque > eventQueue( bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); - bmqio::TestChannel testChannel(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqio::TestChannel testChannel(bmqtst::TestHelperUtil::allocator()); bsls::AtomicInt startCounter(0); bsls::AtomicInt stopCounter(0); @@ -3926,7 +3976,7 @@ static void test11_disconnect() bdlf::PlaceHolders::_2, // new state &startCounter, &stopCounter), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Start the session PVV_SAFE("Starting session"); @@ -3965,22 +4015,25 @@ static void test11_disconnect() ASSERT(!event); PVV_SAFE("Ensure a disconnectMessage was sent to the broker"); - bmqp_ctrlmsg::ControlMessage disconnectMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage disconnectMessage( + bmqtst::TestHelperUtil::allocator()); ASSERT(testChannel.waitFor(1, true, bsls::TimeInterval(5))); bmqio::TestChannel::WriteCall wc = testChannel.popWriteCall(); - bmqp::Event ev(&wc.d_blob, s_allocator_p); + bmqp::Event ev(&wc.d_blob, bmqtst::TestHelperUtil::allocator()); ASSERT(ev.isControlEvent()); rc = ev.loadControlEvent(&disconnectMessage); ASSERT_EQ(rc, 0); PVV_SAFE("Send the disconnect response"); - bmqp_ctrlmsg::ControlMessage disconnectResponseMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage disconnectResponseMessage( + bmqtst::TestHelperUtil::allocator()); disconnectResponseMessage.rId().makeValue( disconnectMessage.rId().value()); disconnectResponseMessage.choice().makeDisconnectResponse(); - bmqp::SchemaEventBuilder builder(&blobBufferFactory, s_allocator_p); + bmqp::SchemaEventBuilder builder(&blobBufferFactory, + bmqtst::TestHelperUtil::allocator()); rc = builder.setMessage(disconnectResponseMessage, bmqp::EventType::e_CONTROL); ASSERT_EQ(rc, 0); @@ -4026,7 +4079,7 @@ static void test11_disconnect() bdlf::PlaceHolders::_2, // new state &startCounter, &stopCounter), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Start the session PVV_SAFE("Starting session"); @@ -4062,22 +4115,25 @@ static void test11_disconnect() bmqt::SessionEventType::e_TIMEOUT); PVV_SAFE("Ensure a disconnectMessage was sent to the broker"); - bmqp_ctrlmsg::ControlMessage disconnectMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage disconnectMessage( + bmqtst::TestHelperUtil::allocator()); ASSERT(testChannel.waitFor(1, true, bsls::TimeInterval(5))); bmqio::TestChannel::WriteCall wc = testChannel.popWriteCall(); - bmqp::Event ev(&wc.d_blob, s_allocator_p); + bmqp::Event ev(&wc.d_blob, bmqtst::TestHelperUtil::allocator()); ASSERT(ev.isControlEvent()); rc = ev.loadControlEvent(&disconnectMessage); ASSERT_EQ(rc, 0); PVV_SAFE("Send the disconnect response"); - bmqp_ctrlmsg::ControlMessage disconnectResponseMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage disconnectResponseMessage( + bmqtst::TestHelperUtil::allocator()); disconnectResponseMessage.rId().makeValue( disconnectMessage.rId().value()); disconnectResponseMessage.choice().makeDisconnectResponse(); - bmqp::SchemaEventBuilder builder(&blobBufferFactory, s_allocator_p); + bmqp::SchemaEventBuilder builder(&blobBufferFactory, + bmqtst::TestHelperUtil::allocator()); rc = builder.setMessage(disconnectResponseMessage, bmqp::EventType::e_CONTROL); ASSERT_EQ(rc, 0); @@ -4134,25 +4190,29 @@ static void test12_disconnectStatus() bmqtst::TestHelper::printTestName("DISCONNECT STATUS MESSAGE"); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqt::SessionOptions sessionOptions; sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); obj.startAndConnect(); PVV_SAFE("Stopping session..."); obj.session().stopAsync(); - bmqp_ctrlmsg::ControlMessage disconnectMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage disconnectMessage( + bmqtst::TestHelperUtil::allocator()); obj.getOutboundControlMessage(&disconnectMessage); ASSERT(!disconnectMessage.rId().isNull()); ASSERT(disconnectMessage.choice().isDisconnectValue()); // prepare status message - bmqp_ctrlmsg::ControlMessage statusMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage statusMessage( + bmqtst::TestHelperUtil::allocator()); statusMessage.rId().makeValue(disconnectMessage.rId().value()); statusMessage.choice().makeStatus(); statusMessage.choice().status().category() = @@ -4198,18 +4258,21 @@ static void test13_disconnectTimeout() const bsls::TimeInterval timeout = bsls::TimeInterval(5); bmqt::SessionOptions sessionOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); sessionOptions.setNumProcessingThreads(1).setDisconnectTimeout(timeout); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); obj.startAndConnect(); PVV_SAFE("Stopping session..."); obj.session().stopAsync(); - bmqp_ctrlmsg::ControlMessage disconnectMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage disconnectMessage( + bmqtst::TestHelperUtil::allocator()); obj.getOutboundControlMessage(&disconnectMessage); ASSERT(!disconnectMessage.rId().isNull()); @@ -4372,12 +4435,14 @@ static void lateOpenQueueResponse(bsls::Types::Uint64 queueFlags) const bsls::TimeInterval timeout = bsls::TimeInterval(15); bmqt::SessionOptions sessionOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, queueFlags); @@ -4490,17 +4555,20 @@ static void test20_queueOpen_LateConfigureQueueResponse() { bmqtst::TestHelper::printTestName("QUEUE LATE CONFIGURE RESPONSE TEST"); - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); const bsls::TimeInterval timeout = bsls::TimeInterval(15); bmqt::SessionOptions sessionOptions; - bmqp_ctrlmsg::ControlMessage responseMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage responseMessage( + bmqtst::TestHelperUtil::allocator()); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); // The test case is applicable only for the reader queue bsl::shared_ptr pQueue = @@ -4601,12 +4669,14 @@ static void test21_post_Limit() bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); // Create test session with the system time source - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, bmqt::QueueFlags::e_WRITE, queueOptions); @@ -4642,7 +4712,7 @@ static void test21_post_Limit() ASSERT_EQ(obj.session().start(bsls::TimeInterval(1)), 0); // Check PUT event is sent - bmqp::Event rawEvent(s_allocator_p); + bmqp::Event rawEvent(bmqtst::TestHelperUtil::allocator()); obj.getOutboundEvent(&rawEvent); ASSERT(rawEvent.isPutEvent()); @@ -4738,11 +4808,13 @@ static void test22_confirm_Limit() bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, bmqt::QueueFlags::e_WRITE, queueOptions); @@ -4835,11 +4907,13 @@ static void queueCloseSync(bsls::Types::Uint64 queueFlags) bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, queueFlags, @@ -4938,12 +5012,14 @@ queueAsyncCanceled(int lineNum, const bsls::TimeInterval timeout = bsls::TimeInterval(15); bmqt::SessionOptions sessionOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); PVV_SAFE("==================\n" << "Starting test " << lineNum << "\n" @@ -5623,16 +5699,20 @@ static void test25_sessionFsmTable() bmqtst::TestHelper::printTestName("SESSION FSM TRANSITION TABLE TEST"); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); scheduler.start(); - ManualHostHealthMonitor* monitor = new (*s_allocator_p) + ManualHostHealthMonitor* monitor = new ( + *bmqtst::TestHelperUtil::allocator()) ManualHostHealthMonitor(bmqt::HostHealthState::e_HEALTHY, - s_allocator_p); - bsl::shared_ptr monitor_sp(monitor, - s_allocator_p); - - bdlbb::PooledBlobBufferFactory blobBufferFactory(1024, s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::shared_ptr monitor_sp( + monitor, + bmqtst::TestHelperUtil::allocator()); + + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bmqt::SessionOptions sessionOptions; sessionOptions.setNumProcessingThreads(1).setHostHealthMonitor(monitor_sp); @@ -5641,7 +5721,7 @@ static void test25_sessionFsmTable() bslmt::TimedSemaphore doneSemaphore; bsls::AtomicInt tcpRc(0); - bmqio::TestChannel testChannel(s_allocator_p); + bmqio::TestChannel testChannel(bmqtst::TestHelperUtil::allocator()); testChannel.setPeerUri("tcp://testHost:1234"); // for better logging bmqimp::BrokerSession obj( @@ -5655,7 +5735,7 @@ static void test25_sessionFsmTable() &table, &tcpRc, &doneSemaphore), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); table = obj.getSessionFsmTransitionTable(); @@ -5891,11 +5971,13 @@ static void test26_openCloseMultipleSubqueues() const bsls::TimeInterval timeout = bsls::TimeInterval(15); bmqt::SessionOptions sessionOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr queueFoo = obj.createQueue( "bmq://ts.trades.myapp/my.queue?id=foo", @@ -5967,12 +6049,14 @@ static void test27_openCloseMultipleSubqueuesWithErrors() const bsls::TimeInterval timeout = bsls::TimeInterval(15); bmqt::SessionOptions sessionOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr queueValid = obj.createQueue( "bmq://ts.trades.myapp/my.queue?id=valid", @@ -6163,7 +6247,7 @@ queueLateAsyncCanceled(int testId, const bsls::TimeInterval timeout = bsls::TimeInterval(15); bmqt::SessionOptions sessionOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); // Set timeouts used for implicit reopening, reconfiguring and closing @@ -6172,7 +6256,9 @@ queueLateAsyncCanceled(int testId, .setConfigureQueueTimeout(timeout) .setCloseQueueTimeout(timeout); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); PVV_SAFE(testId << ": Step 1. Starting session..."); obj.startAndConnect(); @@ -6352,11 +6438,13 @@ static void queueDoubleOpenUri(bsls::Types::Uint64 queueFlags) bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue1 = obj.createQueue(k_URI, queueFlags, @@ -6437,11 +6525,13 @@ static void queueDoubleOpenCorrelationId(bsls::Types::Uint64 queueFlags) bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue1 = obj.createQueue(k_URI1, queueFlags, @@ -6548,16 +6638,21 @@ static void test33_queueNackTest() const bsls::TimeInterval timeout = bsls::TimeInterval(5); bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PutEventBuilder eventBuilder(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutEventBuilder eventBuilder(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); const bmqt::CorrelationId corrId(243); bmqt::MessageGUID guid = bmqp::MessageGUIDGenerator::testGUID(); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, bmqt::QueueFlags::e_WRITE, queueOptions); @@ -6600,7 +6695,7 @@ static void test33_queueNackTest() ASSERT_EQ(res, bmqt::PostResult::e_SUCCESS); PVV_SAFE("Step 4. Verify PUT event is sent"); - bmqp::Event rawEvent(s_allocator_p); + bmqp::Event rawEvent(bmqtst::TestHelperUtil::allocator()); obj.getOutboundEvent(&rawEvent); ASSERT(rawEvent.isPutEvent()); @@ -6669,11 +6764,13 @@ static void reopenError(bsls::Types::Uint64 queueFlags) bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr queue = obj.createQueue(k_URI, queueFlags, @@ -6859,20 +6956,24 @@ static void test35_hostHealthMonitoring() { bmqtst::TestHelper::printTestName("HOST HEALTH MONITORING TEST"); - ManualHostHealthMonitor* monitor = new (*s_allocator_p) + ManualHostHealthMonitor* monitor = new ( + *bmqtst::TestHelperUtil::allocator()) ManualHostHealthMonitor(bmqt::HostHealthState::e_HEALTHY, - s_allocator_p); - bsl::shared_ptr monitor_sp(monitor, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::shared_ptr monitor_sp( + monitor, + bmqtst::TestHelperUtil::allocator()); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqt::SessionOptions sessionOptions; sessionOptions.setNumProcessingThreads(1).setHostHealthMonitor(monitor_sp); PVV_SAFE("Step 1. Set up bmqimp::BrokerSession with " "bmqpi::HostHealthMonitor"); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(monitor->numRegistrants(), 0u); PVV_SAFE("Step 2. Start the session"); @@ -6939,7 +7040,7 @@ static void test35_hostHealthMonitoring() "Verify that queue resumes when the host becomes healthy"); monitor->setState(bmqt::HostHealthState::e_HEALTHY); - bmqp_ctrlmsg::ControlMessage request(s_allocator_p); + bmqp_ctrlmsg::ControlMessage request(bmqtst::TestHelperUtil::allocator()); request = obj.getNextOutboundRequest(TestSession::e_REQ_CONFIG_QUEUE); bmqp_ctrlmsg::ConsumerInfo ci; @@ -7069,14 +7170,17 @@ static void test36_closingAfterConfigTimeout() const bsls::TimeInterval timeout = bsls::TimeInterval(15); bmqt::QueueOptions queueOptions; bmqt::SessionOptions sessionOptions; - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); PVV_SAFE("Test step: Start the session"); obj.startAndConnect(); @@ -7170,13 +7274,16 @@ static void test37_closingPendingConfig() const bsls::TimeInterval timeout = bsls::TimeInterval(15); bmqt::QueueOptions queueOptions; bmqt::SessionOptions sessionOptions; - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); - bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); + bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); PVV_SAFE("Test step: Start the session"); obj.startAndConnect(); @@ -7267,7 +7374,8 @@ static void responderMockup(TestSession* obj, bmqp_ctrlmsg::ControlMessage request = obj->getNextOutboundRequest( type[i]); if (TestSession::e_REQ_DISCONNECT == type[i]) { - bmqp_ctrlmsg::ControlMessage response(s_allocator_p); + bmqp_ctrlmsg::ControlMessage response( + bmqtst::TestHelperUtil::allocator()); response.rId().makeValue(request.rId().value()); response.choice().makeDisconnectResponse(); @@ -7304,9 +7412,10 @@ static void test_syncOpenConfigureClose(bool withHandler) bmqt::QueueOptions queueOptions; bsl::shared_ptr eventSp; bmqt::SessionOptions sessionOptions; - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestSession obj(sessionOptions, scheduler, withHandler); sessionOptions.setNumProcessingThreads(1); @@ -7336,7 +7445,7 @@ static void test_syncOpenConfigureClose(bool withHandler) bslmt::ThreadUtil::createWithAllocator( &threadHandle, bdlf::BindUtil::bind(&responderMockup, &obj, 6, requestType), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); obj.session().openQueueSync(queueSp, timeout, cb); @@ -7415,11 +7524,14 @@ static void test_asyncOpenConfigureClose(bool withHandler) bsl::shared_ptr eventSp; bsl::shared_ptr dummy; bmqt::SessionOptions sessionOptions; - bmqp_ctrlmsg::ControlMessage currentRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage currentRequest( + bmqtst::TestHelperUtil::allocator()); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestSession obj(sessionOptions, scheduler, withHandler); - bdlbb::PooledBlobBufferFactory blobBufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); @@ -7440,7 +7552,7 @@ static void test_asyncOpenConfigureClose(bool withHandler) &obj.session(), bdlf::PlaceHolders::_1); // event - bmqp_ctrlmsg::ControlMessage request(s_allocator_p); + bmqp_ctrlmsg::ControlMessage request(bmqtst::TestHelperUtil::allocator()); obj.session().openQueueAsync(queueSp, timeout, cb); @@ -7613,10 +7725,12 @@ static void test40_syncCalledFromEventHandler() bmqtst::TestHelper::printTestName( "SYNC API CALLED FROM EVENT HANDLER TEST"); - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); const bsls::TimeInterval& timeout = bsls::TimeInterval(); bsl::shared_ptr pQueue; - bdlbb::PooledBlobBufferFactory blobBufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bsl::shared_ptr eventSp; @@ -7624,13 +7738,14 @@ static void test40_syncCalledFromEventHandler() bsls::AtomicInt stopCounter(0); bslmt::TimedSemaphore semaphore; - pQueue.createInplace(s_allocator_p, s_allocator_p); + pQueue.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); pQueue->setUri(uri); pQueue->setFlags(bmqt::QueueFlags::e_WRITE); pQueue->setOptions(queueOptions); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); scheduler.start(); @@ -7651,7 +7766,7 @@ static void test40_syncCalledFromEventHandler() bdlf::PlaceHolders::_2, // new state &startCounter, &stopCounter), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); PVV_SAFE("Step 1. Starting session..."); int rc = session.startAsync(); @@ -7778,14 +7893,16 @@ static void test43_hostHealthMonitoringErrors() { bmqtst::TestHelper::printTestName("HOST HEALTH MONITORING ERRORS TEST"); - ManualHostHealthMonitor* monitor = new (*s_allocator_p) + ManualHostHealthMonitor* monitor = new ( + *bmqtst::TestHelperUtil::allocator()) ManualHostHealthMonitor(bmqt::HostHealthState::e_HEALTHY, - s_allocator_p); - bsl::shared_ptr monitor_sp(monitor, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::shared_ptr monitor_sp( + monitor, + bmqtst::TestHelperUtil::allocator()); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); const bsls::TimeInterval timeout = bsls::TimeInterval(15); bmqt::SessionOptions sessionOptions; @@ -7795,7 +7912,9 @@ static void test43_hostHealthMonitoringErrors() PVV_SAFE("Step 1. Set up bmqimp::BrokerSession with " "bmqpi::HostHealthMonitor"); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(monitor->numRegistrants(), 0u); PVV_SAFE("Step 2. Start the session"); @@ -7818,7 +7937,7 @@ static void test43_hostHealthMonitoringErrors() ASSERT(obj.waitHostUnhealthyEvent()); PVV_SAFE("Step 5. Provide an error response from the broker"); - bmqp_ctrlmsg::ControlMessage request(s_allocator_p); + bmqp_ctrlmsg::ControlMessage request(bmqtst::TestHelperUtil::allocator()); request = obj.getNextOutboundRequest(TestSession::e_REQ_CONFIG_QUEUE); obj.sendStatus(request); @@ -7939,7 +8058,7 @@ static void testHostHealthWithMultipleQueues( ASSERT(testSession->waitHostUnhealthyEvent()); PVV_SAFE("Step 2. Verify that only two queues are suspended"); - bmqp_ctrlmsg::ControlMessage request(s_allocator_p); + bmqp_ctrlmsg::ControlMessage request(bmqtst::TestHelperUtil::allocator()); for (size_t k = 0; k < numSensitiveReaders; k++) { request = testSession->getNextOutboundRequest( TestSession::e_REQ_CONFIG_QUEUE); @@ -8038,14 +8157,16 @@ static void test44_hostHealthMonitoringMultipleQueues() bmqtst::TestHelper::printTestName( "HOST HEALTH MONITORING MULTIPLE QUEUES TEST"); - ManualHostHealthMonitor* monitor = new (*s_allocator_p) + ManualHostHealthMonitor* monitor = new ( + *bmqtst::TestHelperUtil::allocator()) ManualHostHealthMonitor(bmqt::HostHealthState::e_HEALTHY, - s_allocator_p); - bsl::shared_ptr monitor_sp(monitor, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::shared_ptr monitor_sp( + monitor, + bmqtst::TestHelperUtil::allocator()); const bsls::TimeInterval timeout = bsls::TimeInterval(15); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); bmqt::SessionOptions sessionOptions; sessionOptions.setNumProcessingThreads(1) @@ -8054,7 +8175,9 @@ static void test44_hostHealthMonitoringMultipleQueues() PVV_SAFE("Step 1. " "Set up bmqimp::BrokerSession with bmqpi::HostHealthMonitor"); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(monitor->numRegistrants(), 0u); PVV_SAFE("Step 2. Start the session"); @@ -8205,21 +8328,25 @@ static void test45_hostHealthMonitoringPendingStandalone() bmqtst::TestHelper::printTestName( "HOST HEALTH MONITORING PENDING STANDALONE TEST"); - ManualHostHealthMonitor* monitor = new (*s_allocator_p) + ManualHostHealthMonitor* monitor = new ( + *bmqtst::TestHelperUtil::allocator()) ManualHostHealthMonitor(bmqt::HostHealthState::e_HEALTHY, - s_allocator_p); - bsl::shared_ptr monitor_sp(monitor, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::shared_ptr monitor_sp( + monitor, + bmqtst::TestHelperUtil::allocator()); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); bmqt::SessionOptions sessionOptions; sessionOptions.setNumProcessingThreads(1).setHostHealthMonitor(monitor_sp); PVV_SAFE("Step 1. " "Set up bmqimp::BrokerSession with bmqpi::HostHealthMonitor"); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(monitor->numRegistrants(), 0u); PVV_SAFE("Step 2. Start the session"); @@ -8246,7 +8373,8 @@ static void test45_hostHealthMonitoringPendingStandalone() timeout); ASSERT_EQ(rc, bmqp_ctrlmsg::StatusCategory::E_SUCCESS); - bmqp_ctrlmsg::ControlMessage configureRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage configureRequest( + bmqtst::TestHelperUtil::allocator()); configureRequest = obj.getNextOutboundRequest( TestSession::e_REQ_CONFIG_QUEUE); @@ -8322,21 +8450,25 @@ static void test46_hostHealthMonitoringDeferredResumeClose() bmqtst::TestHelper::printTestName( "HOST HEALTH MONITORING DEFERRED SUSPEND RESUME TEST"); - ManualHostHealthMonitor* monitor = new (*s_allocator_p) + ManualHostHealthMonitor* monitor = new ( + *bmqtst::TestHelperUtil::allocator()) ManualHostHealthMonitor(bmqt::HostHealthState::e_HEALTHY, - s_allocator_p); - bsl::shared_ptr monitor_sp(monitor, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::shared_ptr monitor_sp( + monitor, + bmqtst::TestHelperUtil::allocator()); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); bmqt::SessionOptions sessionOptions; sessionOptions.setNumProcessingThreads(1).setHostHealthMonitor(monitor_sp); PVV_SAFE("Step 1. " "Set up bmqimp::BrokerSession with bmqpi::HostHealthMonitor"); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(monitor->numRegistrants(), 0u); PVV_SAFE("Step 2. Start the session"); @@ -8371,7 +8503,8 @@ static void test46_hostHealthMonitoringDeferredResumeClose() ASSERT(obj.waitHostUnhealthyEvent()); PVVV_SAFE("The queue should send suspend request."); - bmqp_ctrlmsg::ControlMessage suspendRequest(s_allocator_p); + bmqp_ctrlmsg::ControlMessage suspendRequest( + bmqtst::TestHelperUtil::allocator()); suspendRequest = obj.getNextOutboundRequest( TestSession::e_REQ_CONFIG_QUEUE); suspendRequest = obj.getNextOutboundRequest( @@ -8401,8 +8534,10 @@ static void test46_hostHealthMonitoringDeferredResumeClose() ASSERT_EQ(rc, bmqp_ctrlmsg::StatusCategory::E_SUCCESS); PVVV_SAFE("Closing: Check configure request was sent"); - bmqp_ctrlmsg::ControlMessage request1(s_allocator_p); - bmqp_ctrlmsg::ControlMessage request2(s_allocator_p); + bmqp_ctrlmsg::ControlMessage request1( + bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::ControlMessage request2( + bmqtst::TestHelperUtil::allocator()); request1 = obj.getNextOutboundRequest(TestSession::e_REQ_CONFIG_QUEUE); request2 = obj.getNextOutboundRequest(TestSession::e_REQ_CONFIG_QUEUE); @@ -8469,13 +8604,15 @@ static void test47_configureMergesQueueOptions() bmqtst::TestHelper::printTestName("CONFIGURE MERGED QUEUE OPTIONS TEST"); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); bmqt::SessionOptions sessionOptions; sessionOptions.setNumProcessingThreads(1); PVV_SAFE("Step 1. Set up bmqimp::BrokerSession"); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); PVV_SAFE("Step 2. Start the session"); obj.startAndConnect(); @@ -8506,7 +8643,7 @@ static void test47_configureMergesQueueOptions() PVV_SAFE("Step 5. " "Verify that request and queue finish with merged options"); - bmqp_ctrlmsg::ControlMessage request(s_allocator_p); + bmqp_ctrlmsg::ControlMessage request(bmqtst::TestHelperUtil::allocator()); request = obj.getNextOutboundRequest(TestSession::e_REQ_CONFIG_QUEUE); bmqp_ctrlmsg::ConsumerInfo ci; @@ -8565,21 +8702,25 @@ static void test48_hostHealthSensitivityReconfiguration() bmqtst::TestHelper::printTestName( "HOST HEALTH SENSITIVITY RECONFIGURATION TEST"); - ManualHostHealthMonitor* monitor = new (*s_allocator_p) + ManualHostHealthMonitor* monitor = new ( + *bmqtst::TestHelperUtil::allocator()) ManualHostHealthMonitor(bmqt::HostHealthState::e_HEALTHY, - s_allocator_p); - bsl::shared_ptr monitor_sp(monitor, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::shared_ptr monitor_sp( + monitor, + bmqtst::TestHelperUtil::allocator()); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); bmqt::SessionOptions sessionOptions; sessionOptions.setNumProcessingThreads(1).setHostHealthMonitor(monitor_sp); PVV_SAFE("Step 1. " "Set up bmqimp::BrokerSession with bmqpi::HostHealthMonitor"); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(monitor->numRegistrants(), 0u); PVV_SAFE("Step 2. Start the session"); @@ -8615,7 +8756,7 @@ static void test48_hostHealthSensitivityReconfiguration() // Writer should suspend immediately without configure request. obj.waitQueueSuspendedEvent(); // Reader needs to wait for the configure-roundtrip. - bmqp_ctrlmsg::ControlMessage request(s_allocator_p); + bmqp_ctrlmsg::ControlMessage request(bmqtst::TestHelperUtil::allocator()); request = obj.getNextOutboundRequest(TestSession::e_REQ_CONFIG_QUEUE); bmqp_ctrlmsg::ConsumerInfo ci; @@ -8740,12 +8881,14 @@ static void test49_controlsBuffering() bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); sessionOptions.setNumProcessingThreads(1); // Create test session with the system time source - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr queueFoo = obj.createQueue( "bmq://ts.trades.myapp/my.queue?id=foo", @@ -8882,17 +9025,22 @@ static void test50_putRetransmittingTest() int phFlags = 0; bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PutEventBuilder putEventBuilder(&bufferFactory, s_allocator_p); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); - bmqp::AckEventBuilder ackEventBuilder(&bufferFactory, s_allocator_p); - bmqp::Event rawEvent(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutEventBuilder putEventBuilder(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqp::AckEventBuilder ackEventBuilder(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqp::Event rawEvent(bmqtst::TestHelperUtil::allocator()); const bmqt::CorrelationId corrIdFirst(243); const bmqt::CorrelationId corrIdSecond(987); const bmqt::CorrelationId corrIdThird(591); const bmqt::CorrelationId corrIdFourth(193); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); bmqt::MessageGUID guidFirst = bmqp::MessageGUIDGenerator::testGUID(); @@ -8902,7 +9050,9 @@ static void test50_putRetransmittingTest() sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, bmqt::QueueFlags::e_WRITE, queueOptions); @@ -9164,20 +9314,26 @@ static void test51_putRetransmittingNoAckTest() int phFlags = 0; bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PutEventBuilder putEventBuilder(&bufferFactory, s_allocator_p); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); - bmqp::Event rawEvent(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutEventBuilder putEventBuilder(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqp::Event rawEvent(bmqtst::TestHelperUtil::allocator()); const bmqt::CorrelationId corrId(243); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqt::MessageGUID guid1 = bmqp::MessageGUIDGenerator::testGUID(); bmqt::MessageGUID guid2 = bmqp::MessageGUIDGenerator::testGUID(); bmqt::MessageGUID guid3 = bmqp::MessageGUIDGenerator::testGUID(); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, scheduler, s_allocator_p); + TestSession obj(sessionOptions, + scheduler, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, bmqt::QueueFlags::e_WRITE, queueOptions); @@ -9378,12 +9534,14 @@ static void test52_controlRetransmission() bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, bmqt::QueueFlags::e_READ, queueOptions); @@ -9531,12 +9689,14 @@ static void queueExpired(bsls::Types::Uint64 queueFlags) bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); sessionOptions.setNumProcessingThreads(1); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, queueFlags, @@ -9776,7 +9936,7 @@ static void test54_distributedTrace() static void getSpacer(bdlcc::Deque& events) { - bsl::string spacer(s_allocator_p); + bsl::string spacer(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(events.tryPopFront(&spacer), 0); ASSERT_EQ(spacer, "spacer"); } @@ -9806,7 +9966,7 @@ static void test54_distributedTrace() getSpacer(events); // Make sure no other events arrive with the given default timeout. - bsl::string emptyStr(s_allocator_p); + bsl::string emptyStr(bmqtst::TestHelperUtil::allocator()); ASSERT_NE(events.timedPopFront(&emptyStr, bdlt::CurrentTime::now() + bsls::TimeInterval(0.01)), @@ -9814,8 +9974,9 @@ static void test54_distributedTrace() } }; - bsl::vector dtEvents(s_allocator_p); - bdlcc::Deque dtEventsQueue(s_allocator_p); + bsl::vector dtEvents(bmqtst::TestHelperUtil::allocator()); + bdlcc::Deque dtEventsQueue( + bmqtst::TestHelperUtil::allocator()); // Contract. Each event buffer fill is surrounded by spacers: // > addSpacer (first spacer for convenience) @@ -9829,23 +9990,27 @@ static void test54_distributedTrace() localFns::addSpacer(dtEventsQueue); bsl::shared_ptr dtContext( - new (*s_allocator_p) DTTestContext(s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + DTTestContext(bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr dtTracer( - new (*s_allocator_p) DTTestTracer(&dtEventsQueue, s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + DTTestTracer(&dtEventsQueue, bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); const bsls::TimeInterval timeout = bsls::TimeInterval(15); bmqt::SessionOptions sessionOptions; bmqt::QueueOptions queueOptions; bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); TestClock testClock(scheduler); sessionOptions.setNumProcessingThreads(1).setTraceOptions(dtContext, dtTracer); - TestSession obj(sessionOptions, testClock, s_allocator_p); + TestSession obj(sessionOptions, + testClock, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr pQueue = obj.createQueue(k_URI, bmqt::QueueFlags::e_READ, queueOptions); @@ -9859,13 +10024,16 @@ static void test54_distributedTrace() ASSERT_EQ(dtEvents[1], "END bmq.session.start"); dtEvents.clear(); { - bmqpi::DTSpan::Baggage baggage(s_allocator_p); + bmqpi::DTSpan::Baggage baggage(bmqtst::TestHelperUtil::allocator()); baggage.put("tag", "value"); bsl::shared_ptr span( - new (*s_allocator_p) - DTTestSpan("test54", baggage, &dtEventsQueue, s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + DTTestSpan("test54", + baggage, + &dtEventsQueue, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr scopeGuard(dtContext->scope(span)); PVV_SAFE("Step 2. Open a queue..."); @@ -10212,8 +10380,8 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); bmqsys::Time::initialize(); - bmqt::UriParser::initialize(s_allocator_p); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); bmqp::Crc32c::initialize(); switch (_testCase) { @@ -10290,7 +10458,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqimp/bmqimp_event.t.cpp b/src/groups/bmq/bmqimp/bmqimp_event.t.cpp index 4ddff4724..46ee37ad5 100644 --- a/src/groups/bmq/bmqimp/bmqimp_event.t.cpp +++ b/src/groups/bmq/bmqimp/bmqimp_event.t.cpp @@ -202,7 +202,8 @@ static unsigned int findExpectedCrc32( bslma::Allocator* allocator, bmqt::CompressionAlgorithmType::Enum compressionAlgorithmType) { - bdlbb::Blob testApplicationData(bufferFactory, s_allocator_p); + bdlbb::Blob testApplicationData(bufferFactory, + bmqtst::TestHelperUtil::allocator()); if (hasProperties) { bdlbb::BlobUtil::append( @@ -234,9 +235,11 @@ static unsigned int findExpectedCrc32( static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqimp::Event obj(&bufferFactory, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; bmqt::MessageGUID guid; guid.fromHex(k_HEX_REP); @@ -259,7 +262,7 @@ static void test1_breathingTest() &eventBlob, &guid, bmqp::EventType::e_ACK); - bmqp::Event event(&eventBlob, s_allocator_p); + bmqp::Event event(&eventBlob, bmqtst::TestHelperUtil::allocator()); // Fails to configure initialized event ASSERT_OPT_FAIL(obj.configureAsMessageEvent(event)); @@ -283,7 +286,7 @@ static void test1_breathingTest() // Fails to configure as raw event with not cloned underlying event ASSERT_OPT_FAIL(obj.configureAsRawEvent(event)); - obj.configureAsRawEvent(event.clone(s_allocator_p)); + obj.configureAsRawEvent(event.clone(bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.type(), bmqimp::Event::EventType::e_RAW); @@ -317,8 +320,10 @@ static void test2_setterGetterTest() // ---------------------------------------------------------------------- bmqtst::TestHelper::printTestName("GENERAL SETTER GETTER TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.type(), bmqimp::Event::EventType::e_UNINITIALIZED); @@ -347,10 +352,11 @@ static void test2_setterGetterTest() // insertQueue / queues bsl::shared_ptr queue = - bsl::allocate_shared(s_allocator_p); + bsl::allocate_shared( + bmqtst::TestHelperUtil::allocator()); const char k_URI[] = "bmq://ts.trades.myapp/my.queue?id=my.app"; - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); const unsigned int k_SQID = 2U; const unsigned int k_ID = 12345; const int k_PENDING_ID = 65432; @@ -362,7 +368,7 @@ static void test2_setterGetterTest() bmqt::QueueFlagsUtil::setWriter(&flags); bmqt::QueueFlagsUtil::setAdmin(&flags); - bmqt::QueueOptions options(s_allocator_p); + bmqt::QueueOptions options(bmqtst::TestHelperUtil::allocator()); options.setMaxUnconfirmedBytes(123); (*queue) @@ -423,8 +429,10 @@ static void test3_sessionEvent_setterGetterTest() // ------------------------------------------------------------------------ bmqtst::TestHelper::printTestName("SETTER GETTER TEST FOR SESSION EVENT"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.type(), bmqimp::Event::EventType::e_UNINITIALIZED) PV("Configure as SessionEvent"); @@ -477,11 +485,13 @@ static void test4_messageEvent_setterGetterTest() bmqt::CorrelationId corrId2(234); // addCorrelationId / correlationId / numCorrrelationIds - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; bmqt::MessageGUID guid; - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.type(), bmqimp::Event::EventType::e_UNINITIALIZED) @@ -490,7 +500,7 @@ static void test4_messageEvent_setterGetterTest() &eventBlob, &guid, bmqp::EventType::e_ACK); - bmqp::Event event(&eventBlob, s_allocator_p); + bmqp::Event event(&eventBlob, bmqtst::TestHelperUtil::allocator()); obj.configureAsMessageEvent(event); obj.addCorrelationId(corrId1); ASSERT_EQ(1, obj.numCorrrelationIds()); @@ -501,7 +511,8 @@ static void test4_messageEvent_setterGetterTest() ASSERT_EQ(corrId2, obj.correlationId(1)); // setMessageCorrelationIdContainer / messageCorrelationIdContainer - bmqimp::MessageCorrelationIdContainer container(s_allocator_p); + bmqimp::MessageCorrelationIdContainer container( + bmqtst::TestHelperUtil::allocator()); obj.setMessageCorrelationIdContainer(&container); bmqimp::MessageCorrelationIdContainer* container_p = obj.messageCorrelationIdContainer(); @@ -547,7 +558,9 @@ static void test5_configureAsMessageEventTest() // Variables bmqt::MessageGUID guid; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); guid.fromHex(k_HEX_REP); // Test data @@ -629,7 +642,8 @@ static void test5_configureAsMessageEventTest() // 1. Create and init blob containing event header, message header of // considered type and also message or padding. - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob eventBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; prepareBlobForMessageEvent(&eventHeader, &eventBlob, @@ -637,11 +651,11 @@ static void test5_configureAsMessageEventTest() test.d_type); // 2. Create raw(bmqp::Event) event over prepared blob - bmqp::Event event(&eventBlob, s_allocator_p); + bmqp::Event event(&eventBlob, bmqtst::TestHelperUtil::allocator()); // 3. Create bmqimp::Event instance and initialize it by // configureAsMessageEvent method taking raw event as argument. - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); obj.configureAsMessageEvent(event); // 4. Verify event fields according to event type. @@ -750,9 +764,11 @@ static void test6_comparisonOperatorTest() // ---------------------------------------------------------------------- bmqtst::TestHelper::printTestName("COMPARISON OPERATORS"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqimp::Event obj1(&bufferFactory, s_allocator_p); - bmqimp::Event obj2(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqimp::Event obj1(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bmqimp::Event obj2(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqt::SessionEventType::Enum sessionType = bmqt::SessionEventType::e_TIMEOUT; bmqimp::Event::EventType::Enum eventType = @@ -760,7 +776,7 @@ static void test6_comparisonOperatorTest() int statusCode = -3; bmqt::CorrelationId correlationId(123); bsl::string errorDescription("testing"); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; bmqt::MessageGUID guid; guid.fromHex(k_HEX_REP); @@ -789,8 +805,8 @@ static void test6_comparisonOperatorTest() ASSERT(obj1 == obj2); PV("Configure as MesageEvent"); - bmqimp::Event obj3(&bufferFactory, s_allocator_p); - bmqimp::Event obj4(&bufferFactory, s_allocator_p); + bmqimp::Event obj3(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bmqimp::Event obj4(&bufferFactory, bmqtst::TestHelperUtil::allocator()); obj3.configureAsMessageEvent(&bufferFactory); obj4.configureAsMessageEvent(&bufferFactory); @@ -802,11 +818,11 @@ static void test6_comparisonOperatorTest() &eventBlob, &guid, bmqp::EventType::e_ACK); - bmqp::Event event(&eventBlob, s_allocator_p); - bmqimp::Event obj5(&bufferFactory, s_allocator_p); - bmqimp::Event obj6(&bufferFactory, s_allocator_p); - obj5.configureAsRawEvent(event.clone(s_allocator_p)); - obj6.configureAsRawEvent(event.clone(s_allocator_p)); + bmqp::Event event(&eventBlob, bmqtst::TestHelperUtil::allocator()); + bmqimp::Event obj5(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bmqimp::Event obj6(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + obj5.configureAsRawEvent(event.clone(bmqtst::TestHelperUtil::allocator())); + obj6.configureAsRawEvent(event.clone(bmqtst::TestHelperUtil::allocator())); // NOTE: Raw event can not be equal ASSERT(obj5 != obj6); @@ -839,13 +855,15 @@ static void test7_printing() // -------------------------------------------------------------------- { // bmqu::PrintUtil::prettyTimeInterval uses default allocator - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("PRINT"); - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; bmqt::MessageGUID guid; guid.fromHex(k_HEX_REP); @@ -913,7 +931,7 @@ static void test7_printing() // Iterate over test data. for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { Test& data = k_DATA[idx]; - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Prepare bmqimp::event object based on data. switch (data.d_eventType) { @@ -924,10 +942,10 @@ static void test7_printing() .setCorrelationId(data.d_correlationId) .setErrorDescription(data.d_errorDescription); - bmqt::Uri uri(data.d_uri, s_allocator_p); + bmqt::Uri uri(data.d_uri, bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr queue = bsl::allocate_shared( - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); queue->setUri(uri); obj.insertQueue(queue); } break; @@ -942,14 +960,15 @@ static void test7_printing() &eventBlob, &guid, bmqp::EventType::e_PUT); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, + bmqtst::TestHelperUtil::allocator()); obj.configureAsMessageEvent(rawEvent); } - bmqt::Uri uri(data.d_uri, s_allocator_p); + bmqt::Uri uri(data.d_uri, bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr queue = bsl::allocate_shared( - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); queue->setUri(uri); obj.insertQueue(queue); } break; @@ -959,8 +978,10 @@ static void test7_printing() &eventBlob, &guid, data.d_rawEventType); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); - obj.configureAsRawEvent(rawEvent.clone(s_allocator_p)); + bmqp::Event rawEvent(&eventBlob, + bmqtst::TestHelperUtil::allocator()); + obj.configureAsRawEvent( + rawEvent.clone(bmqtst::TestHelperUtil::allocator())); break; } case bmqimp::Event::EventType::e_REQUEST: @@ -988,7 +1009,8 @@ static void test7_printing() expected << " errorDescription = \"" << data.d_errorDescription << "\""; } - if (!bsl::string(data.d_uri, s_allocator_p).empty()) { + if (!bsl::string(data.d_uri, bmqtst::TestHelperUtil::allocator()) + .empty()) { expected << " queue = " << data.d_uri; } } break; @@ -1002,7 +1024,8 @@ static void test7_printing() bmqimp::Event::MessageEventMode::e_READ) { expected << " rawEventType = " << data.d_rawEventType; } - if (!bsl::string(data.d_uri, s_allocator_p).empty()) { + if (!bsl::string(data.d_uri, bmqtst::TestHelperUtil::allocator()) + .empty()) { expected << " queue = " << data.d_uri; } } break; @@ -1030,7 +1053,7 @@ static void test7_printing() { PV("Bad stream test"); - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); obj.setType(bmqimp::Event::EventType::e_SESSION); out << "NO LAYOUT"; out.clear(bsl::ios_base::badbit); @@ -1042,7 +1065,7 @@ static void test7_printing() { PV("Bad enum value test"); - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); obj.setType(static_cast( bsl::numeric_limits::min())); @@ -1066,7 +1089,7 @@ static void test8_putEventBuilder() // Testing: // - putEventBuilder // ------------------------------------------------------------------------ - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'putIter.loadMessageProperties' allocates into a temporary blob // using the default allocator @@ -1075,9 +1098,13 @@ static void test8_putEventBuilder() // Initialize Crc32c bmqp::Crc32c::initialize(); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); #ifdef BMQ_ENABLE_MSG_GROUPID - const bmqp::Protocol::MsgGroupId k_MSG_GROUP_ID("gid:0", s_allocator_p); + const bmqp::Protocol::MsgGroupId k_MSG_GROUP_ID( + "gid:0", + bmqtst::TestHelperUtil::allocator()); #endif const int k_PROPERTY_VAL_ENCODING = 3; const bsl::string k_PROPERTY_VAL_ID = "myCoolId"; @@ -1090,7 +1117,7 @@ static void test8_putEventBuilder() const char* k_HEX_GUID2 = "40000000000000000000000000000002"; const char* k_HEX_GUID3 = "40000000000000000000000000000003"; - bmqp::MessageProperties msgProps(s_allocator_p); + bmqp::MessageProperties msgProps(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, msgProps.setPropertyAsInt32("encoding", @@ -1101,7 +1128,7 @@ static void test8_putEventBuilder() ASSERT_EQ(k_NUM_PROPERTIES, msgProps.numProperties()); // Create PutEventBuilder - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); obj.configureAsMessageEvent(&bufferFactory); bmqp::PutEventBuilder& builder = *(obj.putEventBuilder()); @@ -1149,7 +1176,7 @@ static void test8_putEventBuilder() &msgProps, test.d_hasProperties, &bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), bmqt::CompressionAlgorithmType::e_NONE); #ifdef BMQ_ENABLE_MSG_GROUPID @@ -1175,16 +1202,17 @@ static void test8_putEventBuilder() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = builder.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); ASSERT(rawEvent.isValid()); ASSERT(rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); ASSERT(putIter.isValid()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; @@ -1212,7 +1240,7 @@ static void test8_putEventBuilder() ASSERT_EQ(compareResult, 0); bmqt::PropertyType::Enum ptype; - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); if (!test.d_hasProperties) { ASSERT_EQ(false, putIter.hasMessageProperties()); @@ -1238,7 +1266,8 @@ static void test8_putEventBuilder() } #ifdef BMQ_ENABLE_MSG_GROUPID - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(putIter.hasMsgGroupId(), true); ASSERT_EQ(putIter.extractMsgGroupId(&msgGroupId), true); ASSERT_EQ(msgGroupId, k_MSG_GROUP_ID); @@ -1280,23 +1309,25 @@ static void test9_copyTest() bmqtst::TestHelper::printTestName("COPY CONSTRUCTOR TEST"); PV("Configure as MesageEvent"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; bmqt::MessageGUID guid; guid.fromHex(k_HEX_REP); - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.type(), bmqimp::Event::EventType::e_UNINITIALIZED) prepareBlobForMessageEvent(&eventHeader, &eventBlob, &guid, bmqp::EventType::e_ACK); - bmqp::Event event(&eventBlob, s_allocator_p); + bmqp::Event event(&eventBlob, bmqtst::TestHelperUtil::allocator()); obj.configureAsMessageEvent(event); - bmqimp::Event obj2(obj, s_allocator_p); + bmqimp::Event obj2(obj, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj2.type(), bmqimp::Event::EventType::e_MESSAGE); ASSERT_EQ(obj2.rawEvent().type(), bmqp::EventType::e_ACK); ASSERT_EQ(obj2.rawEvent().isAckEvent(), true); @@ -1306,9 +1337,10 @@ static void test9_copyTest() obj.messageCorrelationIdContainer()); // The same steps for cloned event - bmqimp::Event obj3(&bufferFactory, s_allocator_p); - obj3.configureAsMessageEvent(event.clone(s_allocator_p)); - bmqimp::Event obj4(obj3, s_allocator_p); + bmqimp::Event obj3(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + obj3.configureAsMessageEvent( + event.clone(bmqtst::TestHelperUtil::allocator())); + bmqimp::Event obj4(obj3, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj4.rawEvent().type(), bmqp::EventType::e_ACK); ASSERT_EQ(obj4.rawEvent().isAckEvent(), true); ASSERT_EQ(obj4.messageEventMode(), obj.messageEventMode()); @@ -1323,15 +1355,15 @@ static void test9_copyTest() bmqt::CorrelationId(2), "testing"); - bmqimp::Event obj5(obj, s_allocator_p); + bmqimp::Event obj5(obj, bmqtst::TestHelperUtil::allocator()); ASSERT(obj5 == obj); PV("Configure as RawEvent"); obj.reset(); - obj.configureAsRawEvent(event.clone(s_allocator_p)); + obj.configureAsRawEvent(event.clone(bmqtst::TestHelperUtil::allocator())); - bmqimp::Event obj6(obj, s_allocator_p); + bmqimp::Event obj6(obj, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj6.type(), bmqimp::Event::EventType::e_RAW); ASSERT_EQ(obj6.rawEvent().type(), obj.rawEvent().type()); } @@ -1367,24 +1399,26 @@ static void test10_assignmentTest() bmqtst::TestHelper::printTestName("ASSIGNMENT OPERATOR TEST"); PV("ASSIGNMENT OPERATOR - Configure as MesageEvent"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; bmqt::MessageGUID guid; guid.fromHex(k_HEX_REP); - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.type(), bmqimp::Event::EventType::e_UNINITIALIZED) prepareBlobForMessageEvent(&eventHeader, &eventBlob, &guid, bmqp::EventType::e_ACK); - bmqp::Event event(&eventBlob, s_allocator_p); + bmqp::Event event(&eventBlob, bmqtst::TestHelperUtil::allocator()); obj.configureAsMessageEvent(event); PV("ASSIGNMENT OPERATOR - Assign to the empty event"); - bmqimp::Event obj2(&bufferFactory, s_allocator_p); + bmqimp::Event obj2(&bufferFactory, bmqtst::TestHelperUtil::allocator()); obj2 = obj; ASSERT_EQ(obj2.type(), bmqimp::Event::EventType::e_MESSAGE); ASSERT_EQ(obj2.rawEvent().type(), bmqp::EventType::e_ACK); @@ -1395,9 +1429,10 @@ static void test10_assignmentTest() obj.messageCorrelationIdContainer()); PV("ASSIGNMENT OPERATOR - Assign cloned event to the empty event"); - bmqimp::Event obj3(&bufferFactory, s_allocator_p); - obj3.configureAsMessageEvent(event.clone(s_allocator_p)); - bmqimp::Event obj4(&bufferFactory, s_allocator_p); + bmqimp::Event obj3(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + obj3.configureAsMessageEvent( + event.clone(bmqtst::TestHelperUtil::allocator())); + bmqimp::Event obj4(&bufferFactory, bmqtst::TestHelperUtil::allocator()); obj4 = obj3; ASSERT_EQ(obj4.type(), bmqimp::Event::EventType::e_MESSAGE); ASSERT_EQ(obj4.rawEvent().type(), bmqp::EventType::e_ACK); @@ -1417,16 +1452,16 @@ static void test10_assignmentTest() bmqt::CorrelationId(5), "testingAssignment"); - bmqimp::Event obj5(&bufferFactory, s_allocator_p); + bmqimp::Event obj5(&bufferFactory, bmqtst::TestHelperUtil::allocator()); obj5 = obj; ASSERT(obj5 == obj); PV("ASSIGNMENT OPERATOR - Configure as RawEvent"); obj.reset(); - obj.configureAsRawEvent(event.clone(s_allocator_p)); + obj.configureAsRawEvent(event.clone(bmqtst::TestHelperUtil::allocator())); - bmqimp::Event obj6(&bufferFactory, s_allocator_p); + bmqimp::Event obj6(&bufferFactory, bmqtst::TestHelperUtil::allocator()); obj6 = obj; @@ -1459,8 +1494,10 @@ static void test11_doneCallbackTest() // ---------------------------------------------------------------------- bmqtst::TestHelper::printTestName("DONE CALLBACK TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.type(), bmqimp::Event::EventType::e_UNINITIALIZED); @@ -1511,10 +1548,12 @@ static void test12_upgradeDowngradeMessageEvent() // ---------------------------------------------------------------------- bmqtst::TestHelper::printTestName("UPGRADE DOWNGRADE MESSAGE EVENT TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); // 1. Create session event - bmqimp::Event obj(&bufferFactory, s_allocator_p); + bmqimp::Event obj(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // 2. Configure event as message event in WRITE mode. obj.configureAsMessageEvent(&bufferFactory); @@ -1557,8 +1596,8 @@ static void test12_upgradeDowngradeMessageEvent() int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); - bmqt::UriParser::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -1576,7 +1615,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqimp/bmqimp_eventqueue.t.cpp b/src/groups/bmq/bmqimp/bmqimp_eventqueue.t.cpp index f6055c4a7..513ad8f31 100644 --- a/src/groups/bmq/bmqimp/bmqimp_eventqueue.t.cpp +++ b/src/groups/bmq/bmqimp/bmqimp_eventqueue.t.cpp @@ -137,7 +137,7 @@ void queuePerformance(int numReaders, numReaders + numWriters, // minThreads numReaders + numWriters, // maxThreads bsl::numeric_limits::max(), // maxIdleTime - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(threadPool.start() == 0); PRINT_SAFE("==================="); @@ -150,7 +150,7 @@ void queuePerformance(int numReaders, bufferFactory, bdlf::PlaceHolders::_2), // allocator -1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqimp::EventQueue::EventHandlerCallback emptyEventHandler; bmqimp::EventQueue obj(&eventPool, @@ -159,11 +159,11 @@ void queuePerformance(int numReaders, queueSize / 2, // highWatermark emptyEventHandler, 0, // numProcessingThreads - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < numReaders; i++) { threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestQueuePopper, &obj, numIter / numReaders)); @@ -172,7 +172,7 @@ void queuePerformance(int numReaders, bsls::Types::Int64 startTime = bsls::TimeUtil::getTimer(); for (int i = 0; i < numWriters; i++) { threadPool.enqueueJob( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &performanceTestQueuePusher, &obj, numIter / numWriters)); @@ -196,14 +196,16 @@ static void test1_breathingTest() bmqtst::TestHelper::printTestName("BREATHING TEST"); bmqimp::EventQueue::EventHandlerCallback emptyEventHandler; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqimp::EventQueue::EventPool eventPool( + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqimp::EventQueue::EventPool eventPool( bdlf::BindUtil::bind(&poolCreateEvent, bdlf::PlaceHolders::_1, // address &bufferFactory, bdlf::PlaceHolders::_2), // allocator -1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqimp::EventQueue obj(&eventPool, 1, // initialCapacity @@ -211,7 +213,7 @@ static void test1_breathingTest() 6, // highWatermark emptyEventHandler, 0, // numProcessingThreads - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Basic testing.. enqueue one item, pop it out .. bsl::shared_ptr event = eventPool.getObject(); @@ -255,15 +257,18 @@ static void test2_capacityTest() const int k_INITIAL_CAPACITY = 3; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PutEventBuilder builder(&bufferFactory, s_allocator_p); - bmqimp::EventQueue::EventPool eventPool( + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutEventBuilder builder(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqimp::EventQueue::EventPool eventPool( bdlf::BindUtil::bind(&poolCreateEvent, bdlf::PlaceHolders::_1, // address &bufferFactory, bdlf::PlaceHolders::_2), // allocator -1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqimp::EventQueue::EventHandlerCallback emptyEventHandler; @@ -273,12 +278,12 @@ static void test2_capacityTest() k_INITIAL_CAPACITY - 1, // highWatermark emptyEventHandler, 0, // numProcessingThreads - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); builder.startMessage(); const bdlbb::Blob& eventBlob = builder.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr event; // Enqueue k_INITIAL_CAPACITY events @@ -315,14 +320,16 @@ static void test3_watermark() bmqtst::TestHelper::printTestName("WATERMARK"); bmqimp::EventQueue::EventHandlerCallback emptyEventHandler; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqimp::EventQueue::EventPool eventPool( + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqimp::EventQueue::EventPool eventPool( bdlf::BindUtil::bind(&poolCreateEvent, bdlf::PlaceHolders::_1, // address &bufferFactory, bdlf::PlaceHolders::_2), // allocator -1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqimp::EventQueue obj(&eventPool, 1, // initialCapacity @@ -330,7 +337,7 @@ static void test3_watermark() 6, // highWatermark emptyEventHandler, 0, // numProcessingThreads - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr event; @@ -394,14 +401,16 @@ static void test4_basicEventHandlerTest() const int k_NUM_THREADS = 15; bsls::AtomicInt eventCounter; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqimp::EventQueue::EventPool eventPool( + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqimp::EventQueue::EventPool eventPool( bdlf::BindUtil::bind(&poolCreateEvent, bdlf::PlaceHolders::_1, // address &bufferFactory, bdlf::PlaceHolders::_2), // allocator -1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqimp::EventQueue obj(&eventPool, 100, // initialCapacity @@ -411,7 +420,7 @@ static void test4_basicEventHandlerTest() bdlf::PlaceHolders::_1, bsl::ref(eventCounter)), k_NUM_THREADS, // numProcessingThreads - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); obj.start(); @@ -451,8 +460,8 @@ static void test5_emptyStatsTest() { bmqtst::TestHelper::printTestName("EMPTY STATS"); - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); expected << "\n" << " Queue | Queue Time" @@ -465,11 +474,14 @@ static void test5_emptyStatsTest() << "\n" << "\n"; - bmqst::StatContextConfiguration config("stats", s_allocator_p); + bmqst::StatContextConfiguration config( + "stats", + bmqtst::TestHelperUtil::allocator()); config.defaultHistorySize(2); - bmqst::StatContext rootStatContext(config, s_allocator_p); + bmqst::StatContext rootStatContext(config, + bmqtst::TestHelperUtil::allocator()); bmqst::StatValue::SnapshotLocation start; bmqst::StatValue::SnapshotLocation end; @@ -478,14 +490,16 @@ static void test5_emptyStatsTest() end.setLevel(0).setIndex(1); bmqimp::EventQueue::EventHandlerCallback emptyEventHandler; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqimp::EventQueue::EventPool eventPool( + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqimp::EventQueue::EventPool eventPool( bdlf::BindUtil::bind(&poolCreateEvent, bdlf::PlaceHolders::_1, // address &bufferFactory, bdlf::PlaceHolders::_2), // allocator -1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqimp::EventQueue obj(&eventPool, 1, // initialCapacity @@ -493,7 +507,7 @@ static void test5_emptyStatsTest() 6, // highWatermark emptyEventHandler, 0, // numProcessingThreads - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_SAFE_FAIL(obj.printStats(out, false)); @@ -544,27 +558,33 @@ static void test6_workingStatsTest() // HighWatermark and another one for the LowWatermark TestClock testClock; - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PutEventBuilder builder(&bufferFactory, s_allocator_p); - bmqimp::EventQueue::EventPool eventPool( + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutEventBuilder builder(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqimp::EventQueue::EventPool eventPool( bdlf::BindUtil::bind(&poolCreateEvent, bdlf::PlaceHolders::_1, // address &bufferFactory, bdlf::PlaceHolders::_2), // allocator -1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqimp::EventQueue::EventHandlerCallback emptyEventHandler; - bmqst::StatContextConfiguration config("stats", s_allocator_p); + bmqst::StatContextConfiguration config( + "stats", + bmqtst::TestHelperUtil::allocator()); bmqst::StatValue::SnapshotLocation start; bmqst::StatValue::SnapshotLocation end; config.defaultHistorySize(3); - bmqst::StatContext rootStatContext(config, s_allocator_p); + bmqst::StatContext rootStatContext(config, + bmqtst::TestHelperUtil::allocator()); start.setLevel(0).setIndex(0); end.setLevel(0).setIndex(1); @@ -574,7 +594,7 @@ static void test6_workingStatsTest() bdlf::BindUtil::bind(&TestClock::realtimeClock, &testClock), bdlf::BindUtil::bind(&TestClock::monotonicClock, &testClock), bdlf::BindUtil::bind(&TestClock::highResTimer, &testClock), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); expected << "\n" << " Queue | " @@ -593,7 +613,7 @@ static void test6_workingStatsTest() k_QUEUE_HWM, // highWatermark emptyEventHandler, 0, // numProcessingThreads - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // May also call 'start' for the queue without custom event // handler @@ -604,7 +624,7 @@ static void test6_workingStatsTest() builder.startMessage(); const bdlbb::Blob& eventBlob = builder.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr event; // Enqueue events @@ -672,7 +692,9 @@ static void testN1_performance() // CONSTANTS const int k_NUM_ITERATIONS = 10 * 1000 * 1000; // 10 M const int k_FIXED_QUEUE_SIZE = 10 * 1000 * 1000; // 10 M - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); queuePerformance(1, 1, @@ -710,7 +732,7 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); bmqsys::Time::initialize(); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -723,7 +745,7 @@ int main(int argc, char* argv[]) case -1: testN1_performance(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqimp/bmqimp_messagecorrelationidcontainer.t.cpp b/src/groups/bmq/bmqimp/bmqimp_messagecorrelationidcontainer.t.cpp index aab7de883..13bf8519d 100644 --- a/src/groups/bmq/bmqimp/bmqimp_messagecorrelationidcontainer.t.cpp +++ b/src/groups/bmq/bmqimp/bmqimp_messagecorrelationidcontainer.t.cpp @@ -85,7 +85,8 @@ static void test1_addFindRemove() { bmqtst::TestHelper::printTestName("ADD FIND REMOVE"); - bmqimp::MessageCorrelationIdContainer container(s_allocator_p); + bmqimp::MessageCorrelationIdContainer container( + bmqtst::TestHelperUtil::allocator()); bmqt::MessageGUID guid = bmqp::MessageGUIDGenerator::testGUID(); bmqt::MessageGUID emptyGuid; @@ -140,8 +141,9 @@ static void test2_iterateAndInvoke() { bmqtst::TestHelper::printTestName("ITERATE AND INVOKE"); - bmqimp::MessageCorrelationIdContainer container(s_allocator_p); - IterateAndInvokeHelper helper(s_allocator_p); + bmqimp::MessageCorrelationIdContainer container( + bmqtst::TestHelperUtil::allocator()); + IterateAndInvokeHelper helper(bmqtst::TestHelperUtil::allocator()); bmqt::MessageGUID guid1 = bmqp::MessageGUIDGenerator::testGUID(); bmqt::MessageGUID guid2 = bmqp::MessageGUIDGenerator::testGUID(); @@ -177,8 +179,9 @@ static void test3_associate() { bmqtst::TestHelper::printTestName("ASSOCIATE"); - bmqimp::MessageCorrelationIdContainer container(s_allocator_p); - IterateAndInvokeHelper helper(s_allocator_p); + bmqimp::MessageCorrelationIdContainer container( + bmqtst::TestHelperUtil::allocator()); + IterateAndInvokeHelper helper(bmqtst::TestHelperUtil::allocator()); bmqt::MessageGUID guid1 = bmqp::MessageGUIDGenerator::testGUID(); bmqt::MessageGUID guid2 = bmqp::MessageGUIDGenerator::testGUID(); @@ -228,7 +231,7 @@ int main(int argc, char* argv[]) case 1: test1_addFindRemove(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqimp/bmqimp_messagedumper.t.cpp b/src/groups/bmq/bmqimp/bmqimp_messagedumper.t.cpp index 512d1d026..4a99bff97 100644 --- a/src/groups/bmq/bmqimp/bmqimp_messagedumper.t.cpp +++ b/src/groups/bmq/bmqimp/bmqimp_messagedumper.t.cpp @@ -718,7 +718,7 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - Tester tester(s_allocator_p); + Tester tester(bmqtst::TestHelperUtil::allocator()); // Temporary workaround to suppress the 'unused operator // NestedTraitDeclaration' warning/error generated by clang. TBD: @@ -755,7 +755,7 @@ static void test2_parseCommand() // MessageDumper::parseCommand // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1169,7 +1169,7 @@ static void test3_processDumpCommand() const size_t k_NUM_DATA = sizeof(k_DATA) / sizeof(*k_DATA); for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { - Tester tester(s_allocator_p); + Tester tester(bmqtst::TestHelperUtil::allocator()); const Test& test = k_DATA[idx]; // 1. Process various DumpMessages commands and verify that dumping of @@ -1217,7 +1217,7 @@ static void test4_processDumpCommand_invalidDumpMessage() // processDumpCommand // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1241,7 +1241,7 @@ static void test4_processDumpCommand_invalidDumpMessage() const size_t k_NUM_DATA = sizeof(k_DATA) / sizeof(*k_DATA); for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { - Tester tester(s_allocator_p); + Tester tester(bmqtst::TestHelperUtil::allocator()); const Test& test = k_DATA[idx]; // a. Process the command and verify that dumping of the corresponding @@ -1306,7 +1306,7 @@ static void test5_reset() // reset // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1330,7 +1330,7 @@ static void test5_reset() const size_t k_NUM_DATA = sizeof(k_DATA) / sizeof(*k_DATA); for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { - Tester tester(s_allocator_p); + Tester tester(bmqtst::TestHelperUtil::allocator()); const Test& test = k_DATA[idx]; // 1. Process various DumpMessages commands and verify that dumping of @@ -1391,14 +1391,14 @@ static void test6_dumpPushEvent() // dumpPushEvent // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // QueueManager's 'generateQueueAndSubQueueId' method creates a // temporary string using the default allocator when performing queue // lookup by canonical URI bmqtst::TestHelper::printTestName("DUMP PUSH EVENT"); - Tester tester(s_allocator_p); + Tester tester(bmqtst::TestHelperUtil::allocator()); // Insert queues tester.insertQueue("bmq://bmq.test.mmap.fanout/q1?id=foo"); @@ -1410,7 +1410,7 @@ static void test6_dumpPushEvent() tester.processDumpCommand("PUSH 5"); unsigned int subscriptionId = 1; - bmqp_ctrlmsg::StreamParameters config(s_allocator_p); + bmqp_ctrlmsg::StreamParameters config(bmqtst::TestHelperUtil::allocator()); config.subscriptions().resize(1); config.subscriptions()[0].sId() = subscriptionId; @@ -1457,8 +1457,8 @@ static void test6_dumpPushEvent() // 2. Dump the PUSH event and verify that the first five messages were // dumped, and that no additional messages were dumped. - bmqu::MemOutStream out(s_allocator_p); - bmqp::Event event(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqp::Event event(bmqtst::TestHelperUtil::allocator()); tester.pushEvent(&event); tester.dumpPushEvent(out, event); @@ -1469,33 +1469,35 @@ static void test6_dumpPushEvent() "PUSH Message #1:.*" "queue: bmq://bmq.test.mmap.fanout/q1\\?id=foo.*" "abcd.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "PUSH Message #2:.*" "queue: bmq://bmq.test.mmap.fanout/q1\\?id=foo.*" "efgh.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "PUSH Message #3:.*" "queue: bmq://bmq.test.mmap.fanout/q1\\?id=bar.*" "ijkl.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "PUSH Message #4:.*" "queue: bmq://bmq.test.mmap.priority/q1.*" "mnop.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "PUSH Message #5:.*" "queue: bmq://bmq.test.mmap.priority/q1.*" "mnop.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); - ASSERT_EQ(regexMatch(out.str(), "PUSH Message #6:.*", s_allocator_p), + ASSERT_EQ(regexMatch(out.str(), + "PUSH Message #6:.*", + bmqtst::TestHelperUtil::allocator()), false); out.reset(); @@ -1535,14 +1537,14 @@ static void test7_dumpAckEvent() // dumpAckEvent // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // QueueManager's 'generateQueueAndSubQueueId' method creates a // temporary string using the default allocator when performing queue // lookup by canonical URI bmqtst::TestHelper::printTestName("DUMP ACK EVENT"); - Tester tester(s_allocator_p); + Tester tester(bmqtst::TestHelperUtil::allocator()); // Insert queues tester.insertQueue("bmq://bmq.test.mmap.fanout/q1?id=foo"); @@ -1566,8 +1568,8 @@ static void test7_dumpAckEvent() // 2. Dump the ACK event and verify that the messages in the event were // dumped. - bmqu::MemOutStream out(s_allocator_p); - bmqp::Event event(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqp::Event event(bmqtst::TestHelperUtil::allocator()); tester.ackEvent(&event); tester.dumpAckEvent(out, event); @@ -1576,26 +1578,29 @@ static void test7_dumpAckEvent() ASSERT_EQ(regexMatch(out.str(), "ACK Message #1:.* status: SUCCESS", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "ACK Message #2:.* status: LIMIT_MESSAGES", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "ACK Message #3:.* status: LIMIT_BYTES", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "ACK Message #4:.* status: STORAGE_FAILURE", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "ACK Message #5:.* status: UNKNOWN", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); - ASSERT_EQ(regexMatch(out.str(), "ACK Message #6", s_allocator_p), false); + ASSERT_EQ(regexMatch(out.str(), + "ACK Message #6", + bmqtst::TestHelperUtil::allocator()), + false); out.reset(); @@ -1616,7 +1621,7 @@ static void test7_dumpAckEvent() ASSERT_EQ(regexMatch(out.str(), "ACK Message #1:.* status: SUCCESS", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); out.reset(); @@ -1652,14 +1657,14 @@ static void test8_dumpPutEvent() // dumpPushEvent // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // QueueManager's 'generateQueueAndSubQueueId' method creates a // temporary string using the default allocator when performing queue // lookup by canonical URI bmqtst::TestHelper::printTestName("DUMP PUT EVENT"); - Tester tester(s_allocator_p); + Tester tester(bmqtst::TestHelperUtil::allocator()); // Insert queues tester.insertQueue("bmq://bmq.test.mmap.fanout/q1"); @@ -1682,8 +1687,8 @@ static void test8_dumpPutEvent() // 2. Dump the PUT event and verify that the PUT messages were dumped, and // that no additional messages were dumped. - bmqu::MemOutStream out(s_allocator_p); - bmqp::Event event(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqp::Event event(bmqtst::TestHelperUtil::allocator()); tester.putEvent(&event); tester.dumpPutEvent(out, event); @@ -1696,42 +1701,44 @@ static void test8_dumpPutEvent() "queue: bmq://bmq.test.mmap.fanout/q1.*" "msgGroupId: \"Group 1\".*" "abcd.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "PUT Message #2:.*" "queue: bmq://bmq.test.mmap.fanout/q1.*" "msgGroupId: \"Group 2\".*" "abcd.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); #else ASSERT_EQ(regexMatch(out.str(), "PUT Message #1:.*" "queue: bmq://bmq.test.mmap.fanout/q1.*" "abcd.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "PUT Message #2:.*" "queue: bmq://bmq.test.mmap.fanout/q1.*" "abcd.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); #endif ASSERT_EQ(regexMatch(out.str(), "PUT Message #3:.*" "queue: bmq://bmq.test.mmap.priority/q1.*" "efgh.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "PUT Message #4:.*" "queue: bmq://bmq.test.mmap.priority/q2.*" "ijkl.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); - ASSERT_EQ(regexMatch(out.str(), "PUT Message #5:.*", s_allocator_p), + ASSERT_EQ(regexMatch(out.str(), + "PUT Message #5:.*", + bmqtst::TestHelperUtil::allocator()), false); out.reset(); @@ -1777,14 +1784,14 @@ static void test9_dumpConfirmEvent() // dumpConfirmEvent // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // QueueManager's 'generateQueueAndSubQueueId' method creates a // temporary string using the default allocator when performing queue // lookup by canonical URI bmqtst::TestHelper::printTestName("DUMP CONFIRM EVENT"); - Tester tester(s_allocator_p); + Tester tester(bmqtst::TestHelperUtil::allocator()); // CONSTANTS @@ -1806,8 +1813,8 @@ static void test9_dumpConfirmEvent() // 2. Dump the CONFIRM event and verify that the first four messages were // dumped, and that no additional messages were dumped. - bmqu::MemOutStream out(s_allocator_p); - bmqp::Event event(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqp::Event event(bmqtst::TestHelperUtil::allocator()); tester.confirmEvent(&event); tester.dumpConfirmEvent(out, event); @@ -1817,24 +1824,26 @@ static void test9_dumpConfirmEvent() ASSERT_EQ(regexMatch(out.str(), "CONFIRM Message #1:.*" "queue: bmq://bmq.test.mmap.fanout/q1\\?id=foo", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "CONFIRM Message #2:.*" "queue: bmq://bmq.test.mmap.fanout/q1\\?id=foo", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "CONFIRM Message #3:.*" "queue: bmq://bmq.test.mmap.fanout/q1\\?id=bar", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "CONFIRM Message #4:.*" "queue: bmq://bmq.test.mmap.priority/q2", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); - ASSERT_EQ(regexMatch(out.str(), "CONFIRM Message #5:.*", s_allocator_p), + ASSERT_EQ(regexMatch(out.str(), + "CONFIRM Message #5:.*", + bmqtst::TestHelperUtil::allocator()), false); out.reset(); @@ -1862,14 +1871,16 @@ static void test9_dumpConfirmEvent() ASSERT_EQ(regexMatch(out.str(), "CONFIRM Message #1:.*" "queue: bmq://bmq.test.mmap.priority/q1", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); ASSERT_EQ(regexMatch(out.str(), "CONFIRM Message #2:.*" "queue: bmq://bmq.test.mmap.priority/q1", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); - ASSERT_EQ(regexMatch(out.str(), "CONFIRM Message #3:.*", s_allocator_p), + ASSERT_EQ(regexMatch(out.str(), + "CONFIRM Message #3:.*", + bmqtst::TestHelperUtil::allocator()), false); out.reset(); @@ -1888,8 +1899,8 @@ int main(int argc, char** argv) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); - bmqt::UriParser::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); // Initialize Crc32c bmqp::Crc32c::initialize(); @@ -1907,7 +1918,7 @@ int main(int argc, char** argv) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqimp/bmqimp_queue.t.cpp b/src/groups/bmq/bmqimp/bmqimp_queue.t.cpp index ed82e42aa..a2d06356c 100644 --- a/src/groups/bmq/bmqimp/bmqimp_queue.t.cpp +++ b/src/groups/bmq/bmqimp/bmqimp_queue.t.cpp @@ -68,8 +68,8 @@ static void test1_breathingTest() bmqimp::QueueState::Enum k_STATE = bmqimp::QueueState::e_CLOSED; const bmqt::CorrelationId k_CORID; const unsigned int k_SQID = 0U; - bmqimp::Queue obj(s_allocator_p); - bmqt::QueueOptions options(s_allocator_p); + bmqimp::Queue obj(bmqtst::TestHelperUtil::allocator()); + bmqt::QueueOptions options(bmqtst::TestHelperUtil::allocator()); options.setMaxUnconfirmedMessages(0) .setMaxUnconfirmedBytes(0) @@ -119,12 +119,12 @@ static void test2_settersTest() { bmqtst::TestHelper::printTestName("SETTERS TEST"); - bmqimp::Queue obj(s_allocator_p); + bmqimp::Queue obj(bmqtst::TestHelperUtil::allocator()); // Check setters const char k_URI[] = "bmq://ts.trades.myapp/my.queue?id=my.app"; - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); const unsigned int k_SQID = 2U; const unsigned int k_ID = 12345; @@ -137,7 +137,7 @@ static void test2_settersTest() bmqt::QueueFlagsUtil::setWriter(&flags); bmqt::QueueFlagsUtil::setAdmin(&flags); - bmqt::QueueOptions options(s_allocator_p); + bmqt::QueueOptions options(bmqtst::TestHelperUtil::allocator()); options.setMaxUnconfirmedBytes(123); obj.setUri(uri) @@ -228,8 +228,8 @@ static void test3_printQueueStateTest() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); expected << test.d_expected << "\n"; @@ -281,7 +281,7 @@ static void test4_printTest() const char k_URI[] = "bmq://ts.trades.myapp/my.queue?id=my.app"; - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); const unsigned int k_SQID = 2U; const unsigned int k_ID = 12345; @@ -294,12 +294,12 @@ static void test4_printTest() bmqt::QueueFlagsUtil::setReader(&flags); bmqt::QueueFlagsUtil::setWriter(&flags); - bmqt::QueueOptions options(s_allocator_p); + bmqt::QueueOptions options(bmqtst::TestHelperUtil::allocator()); options.setMaxUnconfirmedBytes(123); options.setMaxUnconfirmedMessages(5); options.setConsumerPriority(3); - bmqimp::Queue obj(s_allocator_p); + bmqimp::Queue obj(bmqtst::TestHelperUtil::allocator()); obj.setUri(uri) .setSubQueueId(k_SQID) .setState(k_STATE) @@ -322,8 +322,8 @@ static void test4_printTest() "pendingConfigureId = 65432 requestGroupId = 4091 isSuspended = false " "isSuspendedWithBroker = false ]"; - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); expected << k_PATTERN; @@ -363,15 +363,15 @@ static void test5_comparisionTest() { bmqtst::TestHelper::printTestName("COMPARISION TEST"); - bmqimp::Queue obj1(s_allocator_p); - bmqimp::Queue obj2(s_allocator_p); + bmqimp::Queue obj1(bmqtst::TestHelperUtil::allocator()); + bmqimp::Queue obj2(bmqtst::TestHelperUtil::allocator()); ASSERT(obj1 == obj2); // Check setters const char k_URI[] = "bmq://ts.trades.myapp/my.queue?id=my.app"; - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); const unsigned int k_SQID = 2U; const unsigned int k_ID = 12345; @@ -382,7 +382,7 @@ static void test5_comparisionTest() bsls::Types::Uint64 flags = 0; bmqt::QueueFlagsUtil::setReader(&flags); - bmqt::QueueOptions options(s_allocator_p); + bmqt::QueueOptions options(bmqtst::TestHelperUtil::allocator()); options.setMaxUnconfirmedBytes(123); obj1.setUri(uri) @@ -419,7 +419,7 @@ static void test6_statTest() // bmqimp::QueueStatsUtil and bmqimp::Queue statistic manipulators // -------------------------------------------------------------------- { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Check for default allocator is explicitly disabled as // 'bmqst::TableSchema::addColumn' used in // 'bmqimp::QueueStatsUtil::initializeStats' may allocate @@ -429,15 +429,18 @@ static void test6_statTest() const char k_URI[] = "bmq://ts.trades.myapp/my.queue?id=my.app"; - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); bmqimp::QueueState::Enum k_STATE = bmqimp::QueueState::e_OPENED; - bmqimp::Queue obj(s_allocator_p); + bmqimp::Queue obj(bmqtst::TestHelperUtil::allocator()); - bmqst::StatContextConfiguration config("stats", s_allocator_p); + bmqst::StatContextConfiguration config( + "stats", + bmqtst::TestHelperUtil::allocator()); config.defaultHistorySize(1); - bmqst::StatContext rootStatContext(config, s_allocator_p); + bmqst::StatContext rootStatContext(config, + bmqtst::TestHelperUtil::allocator()); bmqst::StatValue::SnapshotLocation start; bmqst::StatValue::SnapshotLocation end; @@ -445,12 +448,13 @@ static void test6_statTest() start.setLevel(0).setIndex(0); end.setLevel(0).setIndex(1); - bmqimp::Stat queuesStats(s_allocator_p); - bmqimp::QueueStatsUtil::initializeStats(&queuesStats, - &rootStatContext, - start, - end, - s_allocator_p); + bmqimp::Stat queuesStats(bmqtst::TestHelperUtil::allocator()); + bmqimp::QueueStatsUtil::initializeStats( + &queuesStats, + &rootStatContext, + start, + end, + bmqtst::TestHelperUtil::allocator()); bmqst::StatContext* pStatContext = queuesStats.d_statContext_mp.get(); @@ -521,7 +525,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -533,7 +537,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqimp/bmqimp_queuemanager.t.cpp b/src/groups/bmq/bmqimp/bmqimp_queuemanager.t.cpp index 3d31542fc..39cb5afc7 100644 --- a/src/groups/bmq/bmqimp/bmqimp_queuemanager.t.cpp +++ b/src/groups/bmq/bmqimp/bmqimp_queuemanager.t.cpp @@ -54,23 +54,27 @@ void enableQueueStat(bmqimp::QueueManager::QueueSp& queueSp) bmqimp::QueueState::Enum k_STATE = bmqimp::QueueState::e_OPENED; - bmqimp::Stat queuesStats(s_allocator_p); + bmqimp::Stat queuesStats(bmqtst::TestHelperUtil::allocator()); bmqst::StatValue::SnapshotLocation start; bmqst::StatValue::SnapshotLocation end; - bmqst::StatContextConfiguration config("stats", s_allocator_p); + bmqst::StatContextConfiguration config( + "stats", + bmqtst::TestHelperUtil::allocator()); config.defaultHistorySize(2); - bmqst::StatContext rootStatContext(config, s_allocator_p); + bmqst::StatContext rootStatContext(config, + bmqtst::TestHelperUtil::allocator()); start.setLevel(0).setIndex(0); end.setLevel(0).setIndex(1); - bmqimp::QueueStatsUtil::initializeStats(&queuesStats, - &rootStatContext, - start, - end, - s_allocator_p); + bmqimp::QueueStatsUtil::initializeStats( + &queuesStats, + &rootStatContext, + start, + end, + bmqtst::TestHelperUtil::allocator()); bmqst::StatContext* pStatContext = queuesStats.d_statContext_mp.get(); @@ -101,24 +105,25 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bmqimp::QueueManager obj(s_allocator_p); + bmqimp::QueueManager obj(bmqtst::TestHelperUtil::allocator()); const char k_URI[] = "bmq://ts.trades.myapp/my.queue?id=my.app"; - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); const bmqt::CorrelationId k_CORID; const bmqp::QueueId k_QUEUE_ID(0, 0); const bmqimp::QueueState::Enum k_QUEUE_STATE = bmqimp::QueueState::e_OPENING_OPN; - bsl::vector queues(s_allocator_p); + bsl::vector queues( + bmqtst::TestHelperUtil::allocator()); obj.lookupQueuesByState(&queues, k_QUEUE_STATE); ASSERT(obj.lookupQueue(uri).get() == 0); ASSERT(obj.lookupQueue(k_CORID).get() == 0); ASSERT_EQ(queues.size(), 0U); - ASSERT_SAFE_FAIL( - obj.subStreamCount(bsl::string(uri.canonical(), s_allocator_p))); + ASSERT_SAFE_FAIL(obj.subStreamCount( + bsl::string(uri.canonical(), bmqtst::TestHelperUtil::allocator()))); } static void test2_generateQueueIdTest() @@ -157,13 +162,13 @@ static void test2_generateQueueIdTest() const char k_URI[] = "bmq://ts.trades.myapp/my.queue?id=my.app"; - bmqt::Uri uri(k_URI, s_allocator_p); - bmqimp::QueueManager obj(s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); + bmqimp::QueueManager obj(bmqtst::TestHelperUtil::allocator()); PVV("Invalid cases"); { bmqp::QueueId queueId(bmqimp::Queue::k_INVALID_QUEUE_ID); - bmqt::Uri emptyUri(s_allocator_p); + bmqt::Uri emptyUri(bmqtst::TestHelperUtil::allocator()); // NULL output QueueId ASSERT_SAFE_FAIL(obj.generateQueueAndSubQueueId(0, uri, 0)); @@ -192,7 +197,8 @@ static void test2_generateQueueIdTest() PVV("[Uri: unknown] [AppId: not set] [Reader flag: set]"); { - bmqt::Uri uriNoId("bmq://ts.trades.myapp/my.queue", s_allocator_p); + bmqt::Uri uriNoId("bmq://ts.trades.myapp/my.queue", + bmqtst::TestHelperUtil::allocator()); bsls::Types::Uint64 flags = 0; bmqp::QueueId queueId(bmqimp::Queue::k_INVALID_QUEUE_ID); @@ -237,7 +243,8 @@ static void test2_generateQueueIdTest() ASSERT_EQ(queueId.id(), 4); ASSERT_EQ(queueId.subId(), bmqp::QueueId::k_DEFAULT_SUBQUEUE_ID); - queueSp.createInplace(s_allocator_p, s_allocator_p); + queueSp.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); (*queueSp) .setUri(uri) @@ -295,18 +302,19 @@ static void test3_insertQueueTest() { bmqtst::TestHelper::printTestName("INSERT QUEUE TEST"); - bmqimp::QueueManager obj(s_allocator_p); + bmqimp::QueueManager obj(bmqtst::TestHelperUtil::allocator()); const char k_URI[] = "bmq://ts.trades.myapp/my.queue?id=my.app"; - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); const bmqt::CorrelationId k_CORID = bmqt::CorrelationId::autoValue(); bmqimp::QueueManager::QueueSp queueSp; // Cannot insert null object ASSERT_SAFE_FAIL(obj.insertQueue(queueSp)); - queueSp.createInplace(s_allocator_p, s_allocator_p); + queueSp.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); // Cannot insert queue object without queue ID. ASSERT_SAFE_FAIL(obj.insertQueue(queueSp)); @@ -339,7 +347,8 @@ static void test3_insertQueueTest() obj.insertQueue(queueSp); - bsl::vector queues(s_allocator_p); + bsl::vector queues( + bmqtst::TestHelperUtil::allocator()); obj.lookupQueuesByState(&queues, bmqimp::QueueState::e_CLOSED); ASSERT_EQ(queues.size(), 1U); @@ -348,8 +357,9 @@ static void test3_insertQueueTest() ASSERT(obj.lookupQueue(k_CORID) == queueSp); ASSERT(obj.lookupQueue(queueId) == queueSp); - ASSERT(obj.subStreamCount(bsl::string(uri.canonical(), s_allocator_p)) == - 0); + ASSERT(obj.subStreamCount( + bsl::string(uri.canonical(), + bmqtst::TestHelperUtil::allocator())) == 0); // Cannot insert the second queue object with the same queue and subqueue // ID. @@ -379,19 +389,20 @@ static void test4_lookupQueueByUri() { bmqtst::TestHelper::printTestName("LOOKUP QUEUE"); - bmqimp::QueueManager obj(s_allocator_p); + bmqimp::QueueManager obj(bmqtst::TestHelperUtil::allocator()); const char k_URI1[] = "bmq://ts.trades.myapp/my.queue?id=foo"; const char k_URI2[] = "bmq://ts.trades.myapp/my.queue?id=bar"; - bmqt::Uri uri1(k_URI1, s_allocator_p); - bmqt::Uri uri2(k_URI2, s_allocator_p); + bmqt::Uri uri1(k_URI1, bmqtst::TestHelperUtil::allocator()); + bmqt::Uri uri2(k_URI2, bmqtst::TestHelperUtil::allocator()); bmqimp::QueueManager::QueueSp queueSp; bmqp::QueueId queueId(bmqimp::Queue::k_INVALID_QUEUE_ID); bsls::Types::Uint64 flags = 0; const bmqt::CorrelationId k_CORID = bmqt::CorrelationId::autoValue(); - queueSp.createInplace(s_allocator_p, s_allocator_p); + queueSp.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); bmqt::QueueFlagsUtil::setReader(&flags); obj.generateQueueAndSubQueueId(&queueId, uri1, flags); @@ -431,15 +442,16 @@ static void test6_removeQueueTest() { bmqtst::TestHelper::printTestName("REMOVE QUEUE TEST"); - bmqimp::QueueManager obj(s_allocator_p); + bmqimp::QueueManager obj(bmqtst::TestHelperUtil::allocator()); const char k_URI[] = "bmq://ts.trades.myapp/my.queue?id=my.app"; - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); const bmqt::CorrelationId k_CORID = bmqt::CorrelationId::autoValue(); bmqimp::QueueManager::QueueSp queueSp; - queueSp.createInplace(s_allocator_p, s_allocator_p); + queueSp.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); bsls::Types::Uint64 flags = 0; bmqt::QueueFlagsUtil::setReader(&flags); @@ -488,17 +500,18 @@ static void test8_substreamCountTest() { bmqtst::TestHelper::printTestName("RESET STATE TEST"); - bmqimp::QueueManager obj(s_allocator_p); + bmqimp::QueueManager obj(bmqtst::TestHelperUtil::allocator()); const char k_URI[] = "bmq://ts.trades.myapp/my.queue?id=my.app"; - bmqt::Uri uri(k_URI, s_allocator_p); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); bmqimp::QueueManager::QueueSp queueSp; bmqp::QueueId queueId(bmqimp::Queue::k_INVALID_QUEUE_ID); bsls::Types::Uint64 flags = 0; const bmqt::CorrelationId k_CORID = bmqt::CorrelationId::autoValue(); - queueSp.createInplace(s_allocator_p, s_allocator_p); + queueSp.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); bmqt::QueueFlagsUtil::setReader(&flags); obj.generateQueueAndSubQueueId(&queueId, uri, flags); @@ -509,7 +522,8 @@ static void test8_substreamCountTest() .setFlags(flags) .setCorrelationId(k_CORID); - bsl::string uriCanonical(uri.canonical(), s_allocator_p); + bsl::string uriCanonical(uri.canonical(), + bmqtst::TestHelperUtil::allocator()); ASSERT_SAFE_FAIL(obj.incrementSubStreamCount(uriCanonical)); ASSERT_SAFE_FAIL(obj.decrementSubStreamCount(uriCanonical)); @@ -573,20 +587,25 @@ static void test9_pushStatsTest() const bmqt::CorrelationId k_CORID = bmqt::CorrelationId::autoValue(); const bmqt::MessageGUID k_GUID; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); - bdlbb::Blob payload(&bufferFactory, s_allocator_p); - bmqt::Uri uri(k_URI, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); bmqimp::QueueManager::QueueSp queueSp; bmqp::QueueId queueId(bmqimp::Queue::k_INVALID_QUEUE_ID); - bmqp::PushMessageIterator msgIterator(&bufferFactory, s_allocator_p); - bmqimp::QueueManager::EventInfos eventInfos(s_allocator_p); + bmqp::PushMessageIterator msgIterator(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqimp::QueueManager::EventInfos eventInfos( + bmqtst::TestHelperUtil::allocator()); int eventMessageCount = 0; bsls::Types::Uint64 flags = 0; bool hasMessageWithMultipleSubQueueIds = false; - bmqimp::QueueManager obj(s_allocator_p); + bmqimp::QueueManager obj(bmqtst::TestHelperUtil::allocator()); // Fails due to empty iterator ASSERT_SAFE_FAIL(obj.onPushEvent(&eventInfos, @@ -607,7 +626,7 @@ static void test9_pushStatsTest() BSLS_ASSERT_SAFE(rc == bmqt::EventBuilderResult::e_SUCCESS); const bdlbb::Blob& eventBlob = peb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_SAFE(true == rawEvent.isValid()); BSLS_ASSERT_SAFE(true == rawEvent.isPushEvent()); @@ -621,7 +640,8 @@ static void test9_pushStatsTest() msgIterator)); // Add a queue with enabled statistics - queueSp.createInplace(s_allocator_p, s_allocator_p); + queueSp.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); bmqt::QueueFlagsUtil::setReader(&flags); (*queueSp) @@ -681,16 +701,20 @@ static void test10_putStatsTest() const bmqt::CorrelationId k_CORID = bmqt::CorrelationId::autoValue(); const bmqt::MessageGUID k_GUID; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PutEventBuilder peb(&bufferFactory, s_allocator_p); - bmqt::Uri uri(k_URI, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqt::Uri uri(k_URI, bmqtst::TestHelperUtil::allocator()); bmqimp::QueueManager::QueueSp queueSp; bmqp::QueueId queueId(bmqimp::Queue::k_INVALID_QUEUE_ID); - bmqp::PutMessageIterator msgIterator(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator msgIterator(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int eventMessageCount = 0; bsls::Types::Uint64 flags = 0; - bmqimp::QueueManager obj(s_allocator_p); + bmqimp::QueueManager obj(bmqtst::TestHelperUtil::allocator()); // Fails due to empty iterator ASSERT_SAFE_FAIL( @@ -707,7 +731,7 @@ static void test10_putStatsTest() BSLS_ASSERT_SAFE(rc == bmqt::EventBuilderResult::e_SUCCESS); const bdlbb::Blob& eventBlob = peb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_SAFE(true == rawEvent.isValid()); BSLS_ASSERT_SAFE(true == rawEvent.isPutEvent()); @@ -719,7 +743,8 @@ static void test10_putStatsTest() obj.updateStatsOnPutEvent(&eventMessageCount, msgIterator)); // Add a queue with enabled statistics - queueSp.createInplace(s_allocator_p, s_allocator_p); + queueSp.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); bmqt::QueueFlagsUtil::setWriter(&flags); (*queueSp) @@ -749,8 +774,8 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); - bmqt::UriParser::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); // Initialize Crc32c bmqp::Crc32c::initialize(); @@ -767,7 +792,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqio/bmqio_channelutil.t.cpp b/src/groups/bmq/bmqio/bmqio_channelutil.t.cpp index b6971bf12..c91811df2 100644 --- a/src/groups/bmq/bmqio/bmqio_channelutil.t.cpp +++ b/src/groups/bmq/bmqio/bmqio_channelutil.t.cpp @@ -81,7 +81,7 @@ void appendToInputBlob(bdlbb::Blob* out, size_t length, size_t blobSize) sizeof(unsigned int)); // Finally, append some random bytes - bsl::string randomStr(s_allocator_p); + bsl::string randomStr(bmqtst::TestHelperUtil::allocator()); generateRandomString(&randomStr, blobSize - k_MINIMUM_PACKET_LENGTH); bdlbb::BlobUtil::append(out, randomStr.data(), @@ -100,9 +100,12 @@ static void test1_handleRead_singlePacket() { PVV("INVALID BLOB - NO HEADER"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob packet(&bufferFactory, s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob packet(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); int numNeeded = 0; const int rc = bmqio::ChannelUtil::handleRead(&packet, @@ -116,9 +119,12 @@ static void test1_handleRead_singlePacket() { PVV("INVALID BLOB - BOGUS HEADER PACKET TOO SMALL"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob packet(&bufferFactory, s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob packet(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); int numNeeded = 0; const int totalLength = k_MINIMUM_PACKET_LENGTH + 12; @@ -134,9 +140,12 @@ static void test1_handleRead_singlePacket() { PVV("VALID BLOB - INCOMPLETE INPUT BLOB"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob packet(&bufferFactory, s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob packet(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); int numNeeded = 0; const int totalLength = k_MINIMUM_PACKET_LENGTH + 12; @@ -152,9 +161,12 @@ static void test1_handleRead_singlePacket() { PVV("VALID BLOB - HEADER IN ONE BUFFER"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob packet(&bufferFactory, s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob packet(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); int numNeeded = 0; const int totalLength = k_MINIMUM_PACKET_LENGTH + 12; @@ -170,9 +182,12 @@ static void test1_handleRead_singlePacket() { PVV("VALID BLOB - HEADER IN MULTIPLE BUFFERS"); - bdlbb::PooledBlobBufferFactory bufferFactory(2, s_allocator_p); - bdlbb::Blob packet(&bufferFactory, s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 2, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob packet(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); int numNeeded = 0; const int totalLength = k_MINIMUM_PACKET_LENGTH + 12; @@ -193,9 +208,11 @@ static void test2_handleRead_multiplePackets() { PVV("INVALID BLOB - NO HEADER"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bsl::vector packets(s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bsl::vector packets(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); int numNeeded = 0; const int totalLength = k_MINIMUM_PACKET_LENGTH + 12; @@ -212,9 +229,11 @@ static void test2_handleRead_multiplePackets() { PVV("INVALID BLOB - BOGUS HEADER PACKET LENGTH TOO SMALL"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bsl::vector packets(s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bsl::vector packets(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); int numNeeded = 0; const int totalLength = k_MINIMUM_PACKET_LENGTH + 12; @@ -232,9 +251,11 @@ static void test2_handleRead_multiplePackets() { PVV("VALID BLOB - INCOMPLETE INPUT BLOB"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bsl::vector packets(s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bsl::vector packets(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); int numNeeded = 0; const int totalLength = k_MINIMUM_PACKET_LENGTH + 12; @@ -252,9 +273,11 @@ static void test2_handleRead_multiplePackets() { PVV("VALID BLOB - HEADER IN ONE BUFFER"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bsl::vector packets(s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bsl::vector packets(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); int numNeeded = 0; const int totalLength = k_MINIMUM_PACKET_LENGTH + 12; @@ -275,9 +298,11 @@ static void test2_handleRead_multiplePackets() { PVV("VALID BLOB - HEADER IN MULTIPLE BUFFERS"); - bdlbb::PooledBlobBufferFactory bufferFactory(2, s_allocator_p); - bsl::vector packets(s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 2, + bmqtst::TestHelperUtil::allocator()); + bsl::vector packets(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); int numNeeded = 0; const int totalLength = k_MINIMUM_PACKET_LENGTH + 12; @@ -296,9 +321,11 @@ static void test2_handleRead_multiplePackets() { PVV("VALID BLOB - LEFTOVER BYTES"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bsl::vector packets(s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bsl::vector packets(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); int numNeeded = 0; const int totalLength = k_MINIMUM_PACKET_LENGTH + 12; @@ -321,7 +348,7 @@ static void test3_isLocalHost() // bmqio::ChannelUtil::isLocalHost(const ntsa::IpAddress&) internally uses // default allocator - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; { PVV("'LOCALHOST' - TRUE"); @@ -334,7 +361,8 @@ static void test3_isLocalHost() { PVV("'LOCAL IP ADDRESSES' - TRUE"); - bsl::vector localIPs(s_allocator_p); + bsl::vector localIPs( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bmqio::ResolveUtil::getLocalIpAddress(&localIPs).code(), ntsa::Error::e_OK); @@ -362,7 +390,7 @@ int main(int argc, char* argv[]) case 1: test1_handleRead_singlePacket(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqio/bmqio_ntcchannel.t.cpp b/src/groups/bmq/bmqio/bmqio_ntcchannel.t.cpp index 940555331..72c48187d 100644 --- a/src/groups/bmq/bmqio/bmqio_ntcchannel.t.cpp +++ b/src/groups/bmq/bmqio/bmqio_ntcchannel.t.cpp @@ -170,18 +170,20 @@ Tester::Tester(bslma::Allocator* basicAllocator) , d_blobBufferFactory_sp() , d_interface_sp() , d_listener_sp() -, d_listenResultCallback(bdlf::BindUtil::bindS(s_allocator_p, - &Tester::onChannelResult, - this, - bdlf::PlaceHolders::_1, - bdlf::PlaceHolders::_2, - bdlf::PlaceHolders::_3)) -, d_connectResultCallback(bdlf::BindUtil::bindS(s_allocator_p, - &Tester::onChannelResult, - this, - bdlf::PlaceHolders::_1, - bdlf::PlaceHolders::_2, - bdlf::PlaceHolders::_3)) +, d_listenResultCallback( + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), + &Tester::onChannelResult, + this, + bdlf::PlaceHolders::_1, + bdlf::PlaceHolders::_2, + bdlf::PlaceHolders::_3)) +, d_connectResultCallback( + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), + &Tester::onChannelResult, + this, + bdlf::PlaceHolders::_1, + bdlf::PlaceHolders::_2, + bdlf::PlaceHolders::_3)) , d_listenChannels(d_allocator_p) , d_connectChannels(d_allocator_p) , d_semaphore() @@ -237,7 +239,7 @@ void Tester::onAcceptConnection( ntsa::Error error = acceptor->accept( ntca::AcceptOptions(), - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &Tester::onAcceptConnection, this, bdlf::PlaceHolders::_1, @@ -353,27 +355,29 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("Breathing Test"); - Tester tester(s_allocator_p); + Tester tester(bmqtst::TestHelperUtil::allocator()); tester.init(); bsl::shared_ptr channel = tester.connect(); - bdlbb::PooledBlobBufferFactory blobFactory(4096, s_allocator_p); - bdlbb::Blob blob(&blobFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory blobFactory( + 4096, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&blobFactory, bmqtst::TestHelperUtil::allocator()); - bsl::string message("test", s_allocator_p); + bsl::string message("test", bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr messagePtr; messagePtr.reset(message.data(), bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer buffer(messagePtr, message.size()); blob.appendDataBuffer(buffer); - bmqio::Status status(s_allocator_p); + bmqio::Status status(bmqtst::TestHelperUtil::allocator()); channel->write(&status, blob); ASSERT_EQ(status.category(), bmqio::StatusCategory::e_SUCCESS); bmqio::Channel::CloseFn closeCb = bdlf::BindUtil::bindS( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), executeOnClosedChannelFunc, channel.get(), bdlf::PlaceHolders::_1); @@ -395,7 +399,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqio/bmqio_ntcchannelfactory.t.cpp b/src/groups/bmq/bmqio/bmqio_ntcchannelfactory.t.cpp index f0432f46f..d62c410e5 100644 --- a/src/groups/bmq/bmqio/bmqio_ntcchannelfactory.t.cpp +++ b/src/groups/bmq/bmqio/bmqio_ntcchannelfactory.t.cpp @@ -649,13 +649,13 @@ void Tester::connect(int line, const bmqio::ConnectOptions& options, StatusCategory::Enum resultStatus) { - bsl::string handleNameStr(handleName, s_allocator_p); + bsl::string handleNameStr(handleName, bmqtst::TestHelperUtil::allocator()); bslmt::LockGuard guard(&d_mutex); // LOCK HandleInfo& info = d_handleMap[handleNameStr]; - ConnectOptions reqOptions(options, s_allocator_p); + ConnectOptions reqOptions(options, bmqtst::TestHelperUtil::allocator()); reqOptions.setAttemptInterval(bsls::TimeInterval( 0, @@ -775,7 +775,8 @@ void Tester::writeChannel(int line, bsls::Types::Int64 highWatermark, StatusCategory::Enum statusCategory) { - bdlbb::Blob writeData(&d_blobBufferFactory, s_allocator_p); + bdlbb::Blob writeData(&d_blobBufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&writeData, data.data(), data.length()); bslmt::LockGuard guard(&d_mutex); // LOCK @@ -786,7 +787,7 @@ void Tester::writeChannel(int line, return; // RETURN } - Status writeStatus(s_allocator_p); + Status writeStatus(bmqtst::TestHelperUtil::allocator()); info.d_channel->write(&writeStatus, writeData, highWatermark); ASSERT_EQ_D(line, writeStatus.category(), statusCategory); } @@ -817,7 +818,7 @@ void Tester::readChannel(int line, return; // RETURN } - bsl::string readString(s_allocator_p); + bsl::string readString(bmqtst::TestHelperUtil::allocator()); readString.resize(data.length(), '7'); bmqu::BlobUtil::readNBytes(&readString.front(), info.d_readData, @@ -886,14 +887,14 @@ void Tester::checkResultCallback(int line, Channel::ReadCallback readCb( bsl::allocator_arg_t(), - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), bdlf::BindUtil::bind(&Tester::channelReadCb, this, channelName, bdlf::PlaceHolders::_1, bdlf::PlaceHolders::_2, bdlf::PlaceHolders::_3)); - Status readStatus(s_allocator_p); + Status readStatus(bmqtst::TestHelperUtil::allocator()); cbInfo.d_channel->read(&readStatus, 1, readCb); if (readStatus) { // If the read succeeds, then the channel isn't down yet @@ -1004,10 +1005,12 @@ void Tester::checkChannelUri(int line, void Tester::startFilteringLogs(const bsl::string& messageSubstring) { - d_ballObserver.createInplace(s_allocator_p, &bsl::cout, s_allocator_p); + d_ballObserver.createInplace(bmqtst::TestHelperUtil::allocator(), + &bsl::cout, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr filtObserver; - filtObserver.createInplace(s_allocator_p, + filtObserver.createInplace(bmqtst::TestHelperUtil::allocator(), d_ballObserver, bdlf::BindUtil::bind(&ballFilter, messageSubstring, @@ -1053,7 +1056,7 @@ static void test6_preCreationCbTest() { bmqtst::TestHelper::printTestName("Pre Creation Cb Test"); - Tester t(s_allocator_p); + Tester t(bmqtst::TestHelperUtil::allocator()); // Concern 'a' t.setPreCreateCb(true); @@ -1088,7 +1091,7 @@ static void test5_visitChannelsTest() { bmqtst::TestHelper::printTestName("Cancel Handle Test"); - Tester t(s_allocator_p); + Tester t(bmqtst::TestHelperUtil::allocator()); // Concerns 'a' t.init(L_); @@ -1146,7 +1149,7 @@ static void test3_watermarkTest() { bmqtst::TestHelper::printTestName("Watermark Test"); - Tester t(s_allocator_p); + Tester t(bmqtst::TestHelperUtil::allocator()); // Concern 'a' t.init(L_); @@ -1157,7 +1160,9 @@ static void test3_watermarkTest() t.checkResultCallback(L_, "listenHandle", "listenChannel"); t.checkResultCallback(L_, "connectHandle", "connectChannel"); - bsl::string largeMsg(10 * 1024 * 1024, 'a', s_allocator_p); + bsl::string largeMsg(10 * 1024 * 1024, + 'a', + bmqtst::TestHelperUtil::allocator()); // Block the IO thread to make sure our first write doesn't finish // before we get to the second one @@ -1184,7 +1189,7 @@ static void test2_connectListenFailTest() { bmqtst::TestHelper::printTestName("Connect Listen Fail Test"); - Tester t(s_allocator_p); + Tester t(bmqtst::TestHelperUtil::allocator()); t.init(L_); // Concern 'a' @@ -1235,7 +1240,7 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("Breathing Test"); - Tester t(s_allocator_p); + Tester t(bmqtst::TestHelperUtil::allocator()); t.init(L_); // Listen and connect work @@ -1288,7 +1293,7 @@ int main(int argc, char* argv[]) case 6: test6_preCreationCbTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqio/bmqio_reconnectingchannelfactory.t.cpp b/src/groups/bmq/bmqio/bmqio_reconnectingchannelfactory.t.cpp index d520f1b85..f1038d05e 100644 --- a/src/groups/bmq/bmqio/bmqio_reconnectingchannelfactory.t.cpp +++ b/src/groups/bmq/bmqio/bmqio_reconnectingchannelfactory.t.cpp @@ -216,19 +216,20 @@ void Tester::connectResultCb(ChannelFactoryEvent::Enum event, } Tester::Tester() -: d_scheduler(s_allocator_p) +: d_scheduler(bmqtst::TestHelperUtil::allocator()) , d_timeSource(&d_scheduler) -, d_baseFactory(s_allocator_p) -, d_resolverResults(s_allocator_p) -, d_connectResultItems(s_allocator_p) +, d_baseFactory(bmqtst::TestHelperUtil::allocator()) +, d_resolverResults(bmqtst::TestHelperUtil::allocator()) +, d_connectResultItems(bmqtst::TestHelperUtil::allocator()) , d_connectHandle() -, d_channel(s_allocator_p) +, d_channel(bmqtst::TestHelperUtil::allocator()) { d_scheduler.start(); - ReconnectingChannelFactoryConfig config(&d_baseFactory, - &d_scheduler, - s_allocator_p); + ReconnectingChannelFactoryConfig config( + &d_baseFactory, + &d_scheduler, + bmqtst::TestHelperUtil::allocator()); config .setEndpointResolveFn(bdlf::BindUtil::bind(&Tester::resolverFn, this, @@ -242,7 +243,8 @@ Tester::Tester() bdlf::PlaceHolders::_3)); new (d_reconnectingFactory.buffer()) - ReconnectingChannelFactory(config, s_allocator_p); + ReconnectingChannelFactory(config, + bmqtst::TestHelperUtil::allocator()); obj().start(); } @@ -280,7 +282,7 @@ void Tester::setResolverResults(const char** endpoints, size_t count) while (count--) { d_resolverResults.emplace_back( - bsl::string(*endpoints++, s_allocator_p)); + bsl::string(*endpoints++, bmqtst::TestHelperUtil::allocator())); } } @@ -300,10 +302,11 @@ void Tester::connect(const ConnectOptions& options) PVV("Connecting using '" << options << "'"); // Inform the baseFactory how it should respond to the connect. - const Status successStatus(StatusCategory::e_SUCCESS, s_allocator_p); + const Status successStatus(StatusCategory::e_SUCCESS, + bmqtst::TestHelperUtil::allocator()); baseFactory().setConnectStatus(successStatus); - Status status(s_allocator_p); + Status status(bmqtst::TestHelperUtil::allocator()); obj().connect(&status, &d_connectHandle, options, @@ -324,7 +327,8 @@ void Tester::closeChannel() ASSERT_EQ(d_channel.onCloseCalls().size(), 1U); TestChannel::OnCloseCall& call = d_channel.onCloseCalls().front(); - call.d_closeFn(Status(StatusCategory::e_CONNECTION, s_allocator_p)); + call.d_closeFn(Status(StatusCategory::e_CONNECTION, + bmqtst::TestHelperUtil::allocator())); d_channel.onCloseCalls().pop_front(); } @@ -340,7 +344,7 @@ void Tester::ensureConnectAndEmitEvent(int line, d_baseFactory.connectCalls().front(); // Ensure the endpoint matches the expectation ASSERT_EQ_D("Line: " << line, - bsl::string(endpoint, s_allocator_p), + bsl::string(endpoint, bmqtst::TestHelperUtil::allocator()), call.d_options.endpoint()); bsl::shared_ptr channel = bsl::shared_ptr(); @@ -349,7 +353,7 @@ void Tester::ensureConnectAndEmitEvent(int line, } PV("Emiting " << event << " from the testFactory for " << endpoint); - call.d_cb(event, Status(s_allocator_p), channel); + call.d_cb(event, Status(bmqtst::TestHelperUtil::allocator()), channel); d_baseFactory.connectCalls().pop_front(); } @@ -385,7 +389,7 @@ TEST_F(Tester, SingleHost) const char* k_ENDPOINT[] = {"singleHost:123"}; setResolverResults(k_ENDPOINT, 1); - ConnectOptions options(s_allocator_p); + ConnectOptions options(bmqtst::TestHelperUtil::allocator()); options.setEndpoint("dummyWillBeResolved:123") .setNumAttempts(3) .setAttemptInterval(bsls::TimeInterval(k_RECONNECT_INTERVAL)) @@ -465,7 +469,7 @@ TEST_F(Tester, MultipleHosts) const char* k_ENDPOINTS[] = {"first:123", "second:456", "third:789"}; setResolverResults(k_ENDPOINTS, 3); - ConnectOptions options(s_allocator_p); + ConnectOptions options(bmqtst::TestHelperUtil::allocator()); options.setEndpoint("dummyWillBeResolved:123") .setNumAttempts(3) .setAttemptInterval(bsls::TimeInterval(k_RECONNECT_INTERVAL)) @@ -583,7 +587,7 @@ TEST_F(Tester, EmptyAndChangingResolvingList) // the `EndpointResolveFn` was only called at expected time. const char* k_GARBAGE_ENDPOINTS[] = {"garbage:123"}; - ConnectOptions options(s_allocator_p); + ConnectOptions options(bmqtst::TestHelperUtil::allocator()); options.setEndpoint("dummyWillBeResolved:123") .setNumAttempts(99) // 'infinite' retry for this test .setAttemptInterval(bsls::TimeInterval(k_RECONNECT_INTERVAL)) @@ -697,7 +701,7 @@ TEST_F(Tester, NonReconnecting) // to reconnect. // ------------------------------------------------------------------------ { - ConnectOptions options(s_allocator_p); + ConnectOptions options(bmqtst::TestHelperUtil::allocator()); options.setEndpoint("dummyWillBeResolved:123") .setNumAttempts(3) .setAttemptInterval(bsls::TimeInterval(k_RECONNECT_INTERVAL)) @@ -875,7 +879,7 @@ TEST(DefaultConnectIntervalFn) static const bsls::Types::Int64 k_MAX = 50; // maxInterval static const bsls::Types::Int64 k_INTERVAL = 10; // attemptInterval - ConnectOptions options(s_allocator_p); + ConnectOptions options(bmqtst::TestHelperUtil::allocator()); options.setAttemptInterval(bsls::TimeInterval(k_INTERVAL)); // Initialize the random number generator diff --git a/src/groups/bmq/bmqio/bmqio_resolveutil.t.cpp b/src/groups/bmq/bmqio/bmqio_resolveutil.t.cpp index 2c445b007..dd6a8c6a4 100644 --- a/src/groups/bmq/bmqio/bmqio_resolveutil.t.cpp +++ b/src/groups/bmq/bmqio/bmqio_resolveutil.t.cpp @@ -41,7 +41,7 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("RESOLVE UTILITIES - BREATHING TEST"); - bsl::string hostname(s_allocator_p); + bsl::string hostname(bmqtst::TestHelperUtil::allocator()); ntsa::Ipv4Address hostIp; ASSERT(hostname.empty()); @@ -72,7 +72,7 @@ static void test1_breathingTest() { PVV("GET DOMAIN NAME"); - bsl::string domainName(s_allocator_p); + bsl::string domainName(bmqtst::TestHelperUtil::allocator()); ntsa::Error error = bmqio::ResolveUtil::getDomainName( &domainName, ntsa::IpAddress(hostIp)); @@ -85,7 +85,8 @@ static void test1_breathingTest() { PVV("GET ADDRESSES") - bsl::vector addresses(s_allocator_p); + bsl::vector addresses( + bmqtst::TestHelperUtil::allocator()); ntsa::Error error = bmqio::ResolveUtil::getIpAddress(&addresses, "www.wikipedia.org"); @@ -103,7 +104,8 @@ static void test1_breathingTest() { PVV("GET LOCAL ADDRESSES") - bsl::vector addresses(s_allocator_p); + bsl::vector addresses( + bmqtst::TestHelperUtil::allocator()); ntsa::Error error = bmqio::ResolveUtil::getLocalIpAddress(&addresses); ASSERT_EQ(error.code(), ntsa::Error::e_OK); @@ -139,7 +141,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqio/bmqio_resolvingchannelfactory.t.cpp b/src/groups/bmq/bmqio/bmqio_resolvingchannelfactory.t.cpp index 851d964bb..711f4b91f 100644 --- a/src/groups/bmq/bmqio/bmqio_resolvingchannelfactory.t.cpp +++ b/src/groups/bmq/bmqio/bmqio_resolvingchannelfactory.t.cpp @@ -119,8 +119,9 @@ static void test1_defaultResolutionFn() // b) If resolution succeeds, the correct string is returned // ------------------------------------------------------------------------ { - bsl::vector retHosts(s_allocator_p); - bsl::vector expectedAddresses(s_allocator_p); + bsl::vector retHosts(bmqtst::TestHelperUtil::allocator()); + bsl::vector expectedAddresses( + bmqtst::TestHelperUtil::allocator()); using namespace bdlf::PlaceHolders; ResolvingChannelFactoryUtil::ResolveFn resolveFn = bdlf::BindUtil::bind( @@ -130,8 +131,8 @@ static void test1_defaultResolutionFn() &retHosts, &expectedAddresses); - bmqio::TestChannel base(s_allocator_p); - bsl::string ret(s_allocator_p); + bmqio::TestChannel base(bmqtst::TestHelperUtil::allocator()); + bsl::string ret(bmqtst::TestHelperUtil::allocator()); // No ':' base.setPeerUri("127.0.0.1"); @@ -184,10 +185,11 @@ static void test2_channelFactory() // can safely execute. // ------------------------------------------------------------------------ { - TestChannelFactory baseFactory(s_allocator_p); + TestChannelFactory baseFactory(bmqtst::TestHelperUtil::allocator()); - bsl::vector retHosts(s_allocator_p); - bsl::vector expectedAddresses(s_allocator_p); + bsl::vector retHosts(bmqtst::TestHelperUtil::allocator()); + bsl::vector expectedAddresses( + bmqtst::TestHelperUtil::allocator()); using namespace bdlf::PlaceHolders; ResolvingChannelFactoryUtil::ResolveFn resolveFn = bdlf::BindUtil::bind( @@ -197,13 +199,13 @@ static void test2_channelFactory() &retHosts, &expectedAddresses); - TestExecutor::Store execStore(s_allocator_p); + TestExecutor::Store execStore(bmqtst::TestHelperUtil::allocator()); ResolvingChannelFactoryConfig cfg( &baseFactory, bmqex::ExecutionPolicyUtil::oneWay().neverBlocking().useExecutor( TestExecutor(&execStore)), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); cfg.resolutionFn( bdlf::BindUtil::bind(&ResolvingChannelFactoryUtil::defaultResolutionFn, _1, @@ -211,7 +213,9 @@ static void test2_channelFactory() resolveFn, false)); bsl::shared_ptr obj; - obj.createInplace(s_allocator_p, cfg, s_allocator_p); + obj.createInplace(bmqtst::TestHelperUtil::allocator(), + cfg, + bmqtst::TestHelperUtil::allocator()); bsl::deque > channels; @@ -222,7 +226,8 @@ static void test2_channelFactory() bdlf::BindUtil::bind(&testResultCallback, &channels, _1, _2, _3)); bsl::shared_ptr channel; - channel.createInplace(s_allocator_p, s_allocator_p); + channel.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); // Create a Channel and observe its peerUri get updated channel->setPeerUri("1.2.3.4:567"); @@ -279,7 +284,7 @@ int main(int argc, char* argv[]) case 1: test1_defaultResolutionFn(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqma/bmqma_countingallocator.t.cpp b/src/groups/bmq/bmqma/bmqma_countingallocator.t.cpp index 8b2877b35..e5d7c5f75 100644 --- a/src/groups/bmq/bmqma/bmqma_countingallocator.t.cpp +++ b/src/groups/bmq/bmqma/bmqma_countingallocator.t.cpp @@ -103,18 +103,23 @@ static void test1_breathingTest() { PV("Constructor - no 'parentStatContext'"); - bmqma::CountingAllocator obj(k_NAME, s_allocator_p); + bmqma::CountingAllocator obj(k_NAME, + bmqtst::TestHelperUtil::allocator()); ASSERT(obj.context() == 0); } { PV("Constructor - with 'parentStatContext'"); - bmqst::StatContextConfiguration config("test", s_allocator_p); - bmqst::StatContext parentStatContext(config, s_allocator_p); + bmqst::StatContextConfiguration config( + "test", + bmqtst::TestHelperUtil::allocator()); + bmqst::StatContext parentStatContext( + config, + bmqtst::TestHelperUtil::allocator()); bmqma::CountingAllocator obj(k_NAME, &parentStatContext, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); parentStatContext.snapshot(); ASSERT_EQ(parentStatContext.numSubcontexts(), 1); @@ -146,7 +151,7 @@ static void test2_allocate() const bsls::Types::size_type k_SIZE_ALLOC = 1024; char* buf = 0; - bmqma::CountingAllocator obj("Test", s_allocator_p); + bmqma::CountingAllocator obj("Test", bmqtst::TestHelperUtil::allocator()); // 1. Allocate with 'size' of 0 and verify the returned address is 0. buf = static_cast(obj.allocate(0)); @@ -184,7 +189,7 @@ static void test3_deallocate() // allocate // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator and // that is beyond the control of this function bmqtst::TestHelper::printTestName("DEALLOCATE"); @@ -221,9 +226,14 @@ static void test3_deallocate() // CONSTANTS const bsls::Types::size_type k_SIZE_ALLOC = 1024; - bmqst::StatContextConfiguration config("test", s_allocator_p); - bmqst::StatContext parentStatContext(config, s_allocator_p); - bmqma::CountingAllocator obj("Test", &parentStatContext, s_allocator_p); + bmqst::StatContextConfiguration config( + "test", + bmqtst::TestHelperUtil::allocator()); + bmqst::StatContext parentStatContext(config, + bmqtst::TestHelperUtil::allocator()); + bmqma::CountingAllocator obj("Test", + &parentStatContext, + bmqtst::TestHelperUtil::allocator()); char* buf = 0; @@ -238,7 +248,8 @@ static void test3_deallocate() // 3. Deallocate previously deallocated memory and verify failure, as // well as ensure that an error is logged. - bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, s_allocator_p); + bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, + bmqtst::TestHelperUtil::allocator()); ASSERT_SAFE_FAIL(obj.deallocate(buf)); ASSERT_EQ(logObserver.records().size(), 1U); } @@ -259,7 +270,8 @@ static void test4_allocationLimit() { PV("AllocationLimitCB is not enabled when no statContext"); int cbInvocationCount = 0; - bmqma::CountingAllocator obj("Test", s_allocator_p); + bmqma::CountingAllocator obj("Test", + bmqtst::TestHelperUtil::allocator()); obj.setAllocationLimit(10, bdlf::BindUtil::bind(local::incrementInteger, @@ -275,9 +287,11 @@ static void test4_allocationLimit() int cbInvocationCount = 0; bmqst::StatContext statContext( bmqst::StatContextConfiguration("myAllocatorStatContext"), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ; - bmqma::CountingAllocator obj("Test", &statContext, s_allocator_p); + bmqma::CountingAllocator obj("Test", + &statContext, + bmqtst::TestHelperUtil::allocator()); // Note that when using a stat-context enabled counting allocator, // there is an allocation overhead for the Header struct, and the @@ -322,9 +336,11 @@ static void test4_allocationLimit() int cbInvocationCount = 0; bmqst::StatContext statContext( bmqst::StatContextConfiguration("myAllocatorStatContext"), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ; - bmqma::CountingAllocator obj("Test", &statContext, s_allocator_p); + bmqma::CountingAllocator obj("Test", + &statContext, + bmqtst::TestHelperUtil::allocator()); obj.setAllocationLimit( 1024, @@ -350,9 +366,11 @@ static void test4_allocationLimit() int cbInvocationCount = 0; bmqst::StatContext statContext( bmqst::StatContextConfiguration("myAllocatorStatContext"), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ; - bmqma::CountingAllocator obj("Test", &statContext, s_allocator_p); + bmqma::CountingAllocator obj("Test", + &statContext, + bmqtst::TestHelperUtil::allocator()); obj.setAllocationLimit( 1024, @@ -395,9 +413,11 @@ static void test5_allocationLimitHierarchical() // Create the 'top' allocator, with a limit set bmqst::StatContext statContext( bmqst::StatContextConfiguration("myAllocatorStatContext"), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ; - bmqma::CountingAllocator topAlloc("Top", &statContext, s_allocator_p); + bmqma::CountingAllocator topAlloc("Top", + &statContext, + bmqtst::TestHelperUtil::allocator()); // Note that when using a stat-context enabled counting allocator, there is // an allocation overhead for the Header struct, and the allocation size is @@ -450,11 +470,12 @@ static void test6_configureStatContextTableInfoProvider_part1() // bmqst::StatContextTableInfoProvider *tableInfoProvider); // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("configureStatContextTableInfoProvider" " - part 1"); - bmqst::StatContextTableInfoProvider tableInfoProvider(s_allocator_p); + bmqst::StatContextTableInfoProvider tableInfoProvider( + bmqtst::TestHelperUtil::allocator()); bmqma::CountingAllocator::configureStatContextTableInfoProvider( &tableInfoProvider); @@ -466,11 +487,11 @@ static void test6_configureStatContextTableInfoProvider_part1() k_NUM_COLS1); for (int i = 0; i < tableInfoProvider.numColumns(0); ++i) { - bsl::ostringstream out(s_allocator_p); + bsl::ostringstream out(bmqtst::TestHelperUtil::allocator()); tableInfoProvider.printHeader(out, 0, i, 0); const bsl::string col(out.str().data(), out.str().length(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); PV(i << ": " << col); ASSERT_EQ_D(i, col, k_COLS1[i]); } @@ -494,7 +515,7 @@ static void test7_configureStatContextTableInfoProvider_part2() // const bmqst::StatValue::SnapshotLocation& endSnapshot); // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // The method // 'CountingAllocator::configureStatContextTableInfoProvider' allocates // using the default allocator (specifically, because of calls to @@ -504,8 +525,9 @@ static void test7_configureStatContextTableInfoProvider_part2() bmqtst::TestHelper::printTestName("configureStatContextTableInfoProvider" " - part 2"); - bmqst::Table table(s_allocator_p); - bmqst::BasicTableInfoProvider basicTableInfoProvider(s_allocator_p); + bmqst::Table table(bmqtst::TestHelperUtil::allocator()); + bmqst::BasicTableInfoProvider basicTableInfoProvider( + bmqtst::TestHelperUtil::allocator()); bmqst::StatValue::SnapshotLocation start; bmqst::StatValue::SnapshotLocation end; @@ -547,7 +569,7 @@ static void testN1_performance_allocation() // Compare allocation performance of bmqma::CountingAllocator vs // bslma::Default::defaultAllocator. { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // We're microbenching against the default allocator. bmqtst::TestHelper::printTestName("PERFORMANCE - allocation" @@ -559,7 +581,7 @@ static void testN1_performance_allocation() const size_t k_NUM_ALLOCATIONS = k_MAX_ALLOC_SIZE * (k_MILLION / k_MAX_ALLOC_SIZE); - bsl::vector buffers(s_allocator_p); + bsl::vector buffers(bmqtst::TestHelperUtil::allocator()); buffers.resize(k_NUM_ALLOCATIONS); bsls::Types::Int64 timeCountingAlloc = 0; @@ -568,8 +590,12 @@ static void testN1_performance_allocation() PV("bmqma::CountingAllocator"); PV("--------------------------------"); - bmqst::StatContextConfiguration config("test", s_allocator_p); - bmqst::StatContext parentStatContext(config, s_allocator_p); + bmqst::StatContextConfiguration config( + "test", + bmqtst::TestHelperUtil::allocator()); + bmqst::StatContext parentStatContext( + config, + bmqtst::TestHelperUtil::allocator()); bmqma::CountingAllocator countingAlloc("CountingAlloc", &parentStatContext, bslma::Default::allocator()); @@ -651,7 +677,7 @@ testN1_bslmaperformance_allocation_GoogleBenchmark(benchmark::State& state) // Testing: // Allocation performance of bmqma::CountingAllocator { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // We're microbenching against the default allocator. bmqtst::TestHelper::printTestName("PERFORMANCE - allocation" @@ -663,7 +689,7 @@ testN1_bslmaperformance_allocation_GoogleBenchmark(benchmark::State& state) const size_t k_NUM_ALLOCATIONS = k_MAX_ALLOC_SIZE * (k_MILLION / k_MAX_ALLOC_SIZE); - bsl::vector buffers(s_allocator_p); + bsl::vector buffers(bmqtst::TestHelperUtil::allocator()); buffers.resize(k_NUM_ALLOCATIONS); { PV("--------------------------------"); @@ -703,7 +729,7 @@ testN1_defaultperformance_allocation_GoogleBenchmark(benchmark::State& state) // Testing: // Allocation performance of bslma::Default::defaultAllocator. { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // We're microbenching against the default allocator. bmqtst::TestHelper::printTestName("PERFORMANCE - allocation" @@ -715,7 +741,7 @@ testN1_defaultperformance_allocation_GoogleBenchmark(benchmark::State& state) const size_t k_NUM_ALLOCATIONS = k_MAX_ALLOC_SIZE * (k_MILLION / k_MAX_ALLOC_SIZE); - bsl::vector buffers(s_allocator_p); + bsl::vector buffers(bmqtst::TestHelperUtil::allocator()); buffers.resize(k_NUM_ALLOCATIONS); { @@ -723,8 +749,12 @@ testN1_defaultperformance_allocation_GoogleBenchmark(benchmark::State& state) PV("bmqma::CountingAllocator"); PV("--------------------------------"); - bmqst::StatContextConfiguration config("test", s_allocator_p); - bmqst::StatContext parentStatContext(config, s_allocator_p); + bmqst::StatContextConfiguration config( + "test", + bmqtst::TestHelperUtil::allocator()); + bmqst::StatContext parentStatContext( + config, + bmqtst::TestHelperUtil::allocator()); bmqma::CountingAllocator countingAlloc("CountingAlloc", &parentStatContext, bslma::Default::allocator()); @@ -777,7 +807,7 @@ int main(int argc, char** argv) break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqma/bmqma_countingallocatorstore.t.cpp b/src/groups/bmq/bmqma/bmqma_countingallocatorstore.t.cpp index 3c931222b..9dd0b0f72 100644 --- a/src/groups/bmq/bmqma/bmqma_countingallocatorstore.t.cpp +++ b/src/groups/bmq/bmqma/bmqma_countingallocatorstore.t.cpp @@ -70,7 +70,8 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bmqma::CountingAllocator topAllocator("Top Allocator", s_allocator_p); + bmqma::CountingAllocator topAllocator("Top Allocator", + bmqtst::TestHelperUtil::allocator()); bmqma::CountingAllocatorStore allocatorStore(&topAllocator); ASSERT_EQ(allocatorStore.baseAllocator(), &topAllocator); @@ -106,11 +107,12 @@ static void test2_ancestorNotCountingAllocator() { bmqtst::TestHelper::printTestName("ANCESTOR NOT COUNTING ALLOCATOR"); - BSLS_ASSERT_OPT(!dynamic_cast(s_allocator_p) && + BSLS_ASSERT_OPT(!dynamic_cast( + bmqtst::TestHelperUtil::allocator()) && "Test allocator is assumed to not be a" " 'bmqma::CountingAllocator'"); - bslma::Allocator* topAllocator_p = s_allocator_p; + bslma::Allocator* topAllocator_p = bmqtst::TestHelperUtil::allocator(); bmqma::CountingAllocatorStore allocatorStore(topAllocator_p); ASSERT_EQ(allocatorStore.baseAllocator(), topAllocator_p); @@ -136,7 +138,7 @@ int main(int argc, char** argv) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqma/bmqma_countingallocatorutil.t.cpp b/src/groups/bmq/bmqma/bmqma_countingallocatorutil.t.cpp index 0a4913c32..73e8ab413 100644 --- a/src/groups/bmq/bmqma/bmqma_countingallocatorutil.t.cpp +++ b/src/groups/bmq/bmqma/bmqma_countingallocatorutil.t.cpp @@ -154,7 +154,7 @@ int main(int argc, char** argv) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_ackeventbuilder.t.cpp b/src/groups/bmq/bmqp/bmqp_ackeventbuilder.t.cpp index 1fdb67dc9..499b00019 100644 --- a/src/groups/bmq/bmqp/bmqp_ackeventbuilder.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_ackeventbuilder.t.cpp @@ -100,7 +100,7 @@ static void verifyContent(const bmqp::AckEventBuilder& builder, ASSERT_EQ(static_cast(builder.blob().length()), expectedSize); PVV("Iterating over messages"); - bmqp::Event event(&builder.blob(), s_allocator_p); + bmqp::Event event(&builder.blob(), bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(event.isValid(), true); ASSERT_EQ(event.isAckEvent(), true); @@ -137,9 +137,12 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::AckEventBuilder obj(&bufferFactory, s_allocator_p); - bsl::vector messages(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::AckEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector messages(bmqtst::TestHelperUtil::allocator()); PVV("Verifying accessors"); ASSERT_EQ(obj.messageCount(), 0); @@ -161,9 +164,12 @@ static void test2_multiMessage() const int k_NUM_MSGS = 1000; - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::AckEventBuilder obj(&bufferFactory, s_allocator_p); - bsl::vector messages(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::AckEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector messages(bmqtst::TestHelperUtil::allocator()); PVV("Appending messages"); appendMessages(&obj, &messages, k_NUM_MSGS); @@ -177,9 +183,12 @@ static void test3_reset() bmqtst::TestHelper::printTestName("RESET"); // Verifying reset: add two messages, reset, and add another message. - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::AckEventBuilder obj(&bufferFactory, s_allocator_p); - bsl::vector messages(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::AckEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector messages(bmqtst::TestHelperUtil::allocator()); PV("Appending 3 messages"); appendMessages(&obj, &messages, 3); @@ -206,8 +215,11 @@ static void test4_capacity() // Verify that once the event is full, AppendMessage returns error. int rc; - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::AckEventBuilder obj(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::AckEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); PVV("Computing max message"); // Compute max message using a different logic than how it is done in @@ -257,11 +269,14 @@ static void testN1_decodeFromFile() { bmqtst::TestHelper::printTestName("DECODE FROM FILE"); - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::AckEventBuilder obj(&bufferFactory, s_allocator_p); - bsl::vector messages(s_allocator_p); - bdlbb::Blob outBlob(&bufferFactory, s_allocator_p); - bmqu::MemOutStream os(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::AckEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector messages(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob outBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); bdlb::Guid guid = bdlb::GuidUtil::generate(); const int k_NUM_MSGS = 10; const int k_SIZE = 256; @@ -303,7 +318,7 @@ static void testN1_decodeFromFile() bsl::shared_ptr dataBufferSp(buf, bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer dataBlobBuffer(dataBufferSp, k_SIZE); outBlob.appendDataBuffer(dataBlobBuffer); @@ -312,7 +327,7 @@ static void testN1_decodeFromFile() ASSERT_EQ(bdlbb::BlobUtil::compare(obj.blob(), outBlob), 0); // Decode event - bmqp::Event event(&outBlob, s_allocator_p); + bmqp::Event event(&outBlob, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(event.isValid(), true); ASSERT_EQ(event.isAckEvent(), true); @@ -358,7 +373,7 @@ int main(int argc, char* argv[]) case -1: testN1_decodeFromFile(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_ackmessageiterator.t.cpp b/src/groups/bmq/bmqp/bmqp_ackmessageiterator.t.cpp index bd519b7e4..6f7acdc3a 100644 --- a/src/groups/bmq/bmqp/bmqp_ackmessageiterator.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_ackmessageiterator.t.cpp @@ -183,7 +183,9 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { PVV("Create invalid iter"); @@ -216,7 +218,7 @@ static void test1_breathingTest() PVV("Valid iter"); // Create valid iter - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob const bmqt::MessageGUID GUID; @@ -313,7 +315,7 @@ static void test1_breathingTest() // Verify dumping the blob const char* k_NO_BLOB_STR = "/no blob/"; - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); iter2.dumpBlob(out); ASSERT_NE(out.str(), k_NO_BLOB_STR); @@ -342,10 +344,12 @@ static void test2_ackEventWithMultipleMessages() { bmqtst::TestHelper::printTestName("ACK EVENT WITH MULTIPLE MESSAGES"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; const size_t k_NUM_MSGS = 1000; @@ -412,8 +416,10 @@ static void test3_nextMethod() // Next method. Iterator is in invalid state case. { // Create buffer factory and blob - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, @@ -437,8 +443,10 @@ static void test3_nextMethod() // Next method. Not enough bytes case. { // Create buffer factory and blob - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, @@ -500,10 +508,12 @@ static void test4_resetMethod() // Reset method. Invalid event header case. { - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); // Create buffer factory and blob - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob and manually set length populateBlob(&blob, @@ -535,8 +545,10 @@ static void test4_resetMethod() // Reset method. Not enough bytes case. { // Create buffer factory and blob - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob and manually set length populateBlob(&blob, @@ -592,10 +604,12 @@ static void test5_dumpBlob() const int k_STATUS = 3; const int k_QUEUE_ID = 9876; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, @@ -613,14 +627,14 @@ static void test5_dumpBlob() // Dump blob iter.dumpBlob(stream); - bsl::string str1(stream.str(), s_allocator_p); + bsl::string str1(stream.str(), bmqtst::TestHelperUtil::allocator()); bsl::string str2(" 0: 00000024 45020000 163E0000 0300D431 " "|...$E....>.....1|\n" " 16: 00000000 00000000 00000000 00000000 " "|................|\n" " 32: 00002694 " "|..&. |\n", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Verify that dump contains expected value ASSERT_EQ(str1, str2); @@ -633,8 +647,8 @@ static void test5_dumpBlob() // Dump blob iter.dumpBlob(stream); - bsl::string str1(stream.str(), s_allocator_p); - bsl::string str2("/no blob/", s_allocator_p); + bsl::string str1(stream.str(), bmqtst::TestHelperUtil::allocator()); + bsl::string str2("/no blob/", bmqtst::TestHelperUtil::allocator()); // Verify that dump contains expected value ASSERT_EQ(str1, str2); @@ -658,7 +672,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_compression.t.cpp b/src/groups/bmq/bmqp/bmqp_compression.t.cpp index 427694738..7b546c395 100644 --- a/src/groups/bmq/bmqp/bmqp_compression.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_compression.t.cpp @@ -233,7 +233,7 @@ static void populateData(bsl::vector* data) // start with string of length 2 and go till length 2^30 size_t length = 2; for (size_t i = 0; i < 30; ++i) { - bsl::string str("", s_allocator_p); + bsl::string str("", bmqtst::TestHelperUtil::allocator()); generateRandomString(&str, length); data->push_back(str); length *= 2; @@ -248,11 +248,15 @@ static void eZlibCompressDecompressHelper( const char* expectedCompressed, const bmqt::CompressionAlgorithmType::Enum& algorithm) { - bmqu::MemOutStream error(s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); - bdlbb::Blob compressed(&bufferFactory, s_allocator_p); - bdlbb::Blob decompressed(&bufferFactory, s_allocator_p); + bmqu::MemOutStream error(bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob compressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob decompressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&input, data.data(), data.length()); @@ -263,7 +267,7 @@ static void eZlibCompressDecompressHelper( data.data(), data.length(), &error, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); *compressionTime = bsls::TimeUtil::getTimer() - startTime; ASSERT_EQ(rc, 0); @@ -281,7 +285,7 @@ static void eZlibCompressDecompressHelper( algorithm, compressed, &error, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); *decompressionTime = bsls::TimeUtil::getTimer() - startTime; ASSERT_EQ(rc, 0); @@ -294,31 +298,37 @@ eZlibCompressDecompressHelper(bsls::Types::Int64* compressionTime, bsls::Types::Int64* decompressionTime, const D& data) { - bmqu::MemOutStream error(s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); - bdlbb::Blob compressed(&bufferFactory, s_allocator_p); - bdlbb::Blob decompressed(&bufferFactory, s_allocator_p); + bmqu::MemOutStream error(bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob compressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob decompressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&input, data.data(), data.length()); bsls::Types::Int64 startTime = bsls::TimeUtil::getTimer(); - int rc = bmqp::Compression_Impl::compressZlib(&compressed, - &bufferFactory, - input, - -1, - &error, - s_allocator_p); + int rc = bmqp::Compression_Impl::compressZlib( + &compressed, + &bufferFactory, + input, + -1, + &error, + bmqtst::TestHelperUtil::allocator()); *compressionTime = bsls::TimeUtil::getTimer() - startTime; ASSERT_EQ(rc, 0); startTime = bsls::TimeUtil::getTimer(); - rc = bmqp::Compression_Impl::decompressZlib(&decompressed, - &bufferFactory, - compressed, - &error, - s_allocator_p); + rc = bmqp::Compression_Impl::decompressZlib( + &decompressed, + &bufferFactory, + compressed, + &error, + bmqtst::TestHelperUtil::allocator()); *decompressionTime = bsls::TimeUtil::getTimer() - startTime; ASSERT_EQ(rc, 0); @@ -331,29 +341,35 @@ static void eZlibCompressionRatioHelper(bsls::Types::Int64* inputSize, const D& data, int level) { - bmqu::MemOutStream error(s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); - bdlbb::Blob compressed(&bufferFactory, s_allocator_p); - bdlbb::Blob decompressed(&bufferFactory, s_allocator_p); + bmqu::MemOutStream error(bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob compressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob decompressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&input, data.data(), data.length()); *inputSize = input.length(); - int rc = bmqp::Compression_Impl::compressZlib(&compressed, - &bufferFactory, - input, - level, - &error, - s_allocator_p); + int rc = bmqp::Compression_Impl::compressZlib( + &compressed, + &bufferFactory, + input, + level, + &error, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); *compressedSize = compressed.length(); - rc = bmqp::Compression_Impl::decompressZlib(&decompressed, - &bufferFactory, - compressed, - &error, - s_allocator_p); + rc = bmqp::Compression_Impl::decompressZlib( + &decompressed, + &bufferFactory, + compressed, + &error, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); ASSERT_EQ(bdlbb::BlobUtil::compare(decompressed, input), 0); } @@ -456,7 +472,8 @@ static void test1_breathingTest() bsl::cout << test.d_line << "'" << test.d_data << "'" << bsl::endl; bsls::Types::Int64 compressionTime = 0; bsls::Types::Int64 decompressionTime = 0; - bsl::string inputString(test.d_data, s_allocator_p); + bsl::string inputString(test.d_data, + bmqtst::TestHelperUtil::allocator()); eZlibCompressDecompressHelper( &compressionTime, &decompressionTime, @@ -470,7 +487,7 @@ static void test1_breathingTest() PV("BUFFER WITH EMPTY STRING"); // Test edge case of empty string in buffer - const bsl::string data("", s_allocator_p); + const bsl::string data("", bmqtst::TestHelperUtil::allocator()); bsls::Types::Int64 compressionTime = 0; bsls::Types::Int64 decompressionTime = 0; eZlibCompressDecompressHelper(&compressionTime, @@ -484,20 +501,25 @@ static void test1_breathingTest() PV("NULL BUFFER"); // Test edge case of null buffer - bmqu::MemOutStream error(s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); - bdlbb::Blob compressed(&bufferFactory, s_allocator_p); - bdlbb::Blob decompressed(&bufferFactory, s_allocator_p); + bmqu::MemOutStream error(bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob compressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob decompressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); const char* expectedCompressed = "\x78\x9c\x3\x0\x0" "\x0\x0\x1"; - int rc = bmqp::Compression_Impl::compressZlib(&compressed, - &bufferFactory, - input, - -1, - &error, - s_allocator_p); + int rc = bmqp::Compression_Impl::compressZlib( + &compressed, + &bufferFactory, + input, + -1, + &error, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); // get compressed data and compare with expected_compressed @@ -508,11 +530,12 @@ static void test1_breathingTest() ASSERT_EQ(bsl::memcmp(expectedCompressed, receivedBuffer, bufferSize), 0); - rc = bmqp::Compression_Impl::decompressZlib(&decompressed, - &bufferFactory, - compressed, - &error, - s_allocator_p); + rc = bmqp::Compression_Impl::decompressZlib( + &decompressed, + &bufferFactory, + compressed, + &error, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); ASSERT_EQ(bdlbb::BlobUtil::compare(decompressed, input), 0); } @@ -521,26 +544,36 @@ static void test1_breathingTest() PV("MULTIPLE BUFFERS"); // Test edge case of multiple buffers appended to a blob - bmqu::MemOutStream error(s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); - bdlbb::Blob compressed(&bufferFactory, s_allocator_p); - bdlbb::Blob decompressed(&bufferFactory, s_allocator_p); + bmqu::MemOutStream error(bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob compressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob decompressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); char one[] = "one"; bsl::shared_ptr onePtr; - onePtr.reset(one, bslstl::SharedPtrNilDeleter(), s_allocator_p); + onePtr.reset(one, + bslstl::SharedPtrNilDeleter(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer buf1(onePtr, bsl::strlen(one)); input.appendDataBuffer(buf1); char two[] = "two"; bsl::shared_ptr twoPtr; - twoPtr.reset(two, bslstl::SharedPtrNilDeleter(), s_allocator_p); + twoPtr.reset(two, + bslstl::SharedPtrNilDeleter(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer buf2(twoPtr, bsl::strlen(two)); input.appendDataBuffer(buf2); char three[] = "three"; bsl::shared_ptr threePtr; - threePtr.reset(three, bslstl::SharedPtrNilDeleter(), s_allocator_p); + threePtr.reset(three, + bslstl::SharedPtrNilDeleter(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer buf3(threePtr, bsl::strlen(three)); input.appendDataBuffer(buf3); @@ -548,12 +581,13 @@ static void test1_breathingTest() "\xc9\x28\x4a\x4d\x5\x0\x1c\x8d\x4" "\xb5"; - int rc = bmqp::Compression_Impl::compressZlib(&compressed, - &bufferFactory, - input, - -1, - &error, - s_allocator_p); + int rc = bmqp::Compression_Impl::compressZlib( + &compressed, + &bufferFactory, + input, + -1, + &error, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); // get compressed data and compare with expected_compressed @@ -564,11 +598,12 @@ static void test1_breathingTest() ASSERT_EQ(bsl::memcmp(expectedCompressed, receivedBuffer, bufferSize), 0); - rc = bmqp::Compression_Impl::decompressZlib(&decompressed, - &bufferFactory, - compressed, - &error, - s_allocator_p); + rc = bmqp::Compression_Impl::decompressZlib( + &decompressed, + &bufferFactory, + compressed, + &error, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); ASSERT_EQ(bdlbb::BlobUtil::compare(decompressed, input), 0); } @@ -589,7 +624,7 @@ static void test2_compression_cluster_message() // Compression/Decompression functionality for non-string input // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // The default allocator check fails in this test case because the // 'loggedMessages' methods of Encoder returns a memory-aware // object without utilizing the parameter allocator. @@ -597,13 +632,18 @@ static void test2_compression_cluster_message() PV("BUFFER WITH CLUSTER MESSAGE"); // Test case with cluster message as input data - bmqu::MemOutStream error(s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob input(&bufferFactory, s_allocator_p); - bdlbb::Blob compressed(&bufferFactory, s_allocator_p); - bdlbb::Blob decompressed(&bufferFactory, s_allocator_p); - - bmqp_ctrlmsg::ClusterMessage clusterMessage(s_allocator_p); + bmqu::MemOutStream error(bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob input(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob compressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob decompressed(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + + bmqp_ctrlmsg::ClusterMessage clusterMessage( + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::LeaderAdvisoryCommit commit; // Create an update message @@ -617,29 +657,32 @@ static void test2_compression_cluster_message() clusterMessage.choice().makeLeaderAdvisoryCommit(commit); - int rc = bmqp::ProtocolUtil::encodeMessage(error, - &input, - clusterMessage, - bmqp::EncodingType::e_JSON, - s_allocator_p); + int rc = bmqp::ProtocolUtil::encodeMessage( + error, + &input, + clusterMessage, + bmqp::EncodingType::e_JSON, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); bsl::cout << "Input size: " << input.length() << endl; - rc = bmqp::Compression_Impl::compressZlib(&compressed, - &bufferFactory, - input, - -1, - &error, - s_allocator_p); + rc = bmqp::Compression_Impl::compressZlib( + &compressed, + &bufferFactory, + input, + -1, + &error, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); bsl::cout << "Compressed size: " << compressed.length() << endl; - rc = bmqp::Compression_Impl::decompressZlib(&decompressed, - &bufferFactory, - compressed, - &error, - s_allocator_p); + rc = bmqp::Compression_Impl::decompressZlib( + &decompressed, + &bufferFactory, + compressed, + &error, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); ASSERT_EQ(bdlbb::BlobUtil::compare(decompressed, input), 0); bsl::cout << "Decompressed size: " << decompressed.length() << endl; @@ -686,7 +729,8 @@ static void test3_compression_decompression_none() PVV(test.d_line << "'" << test.d_data << "'"); bsls::Types::Int64 compressionTime = 0; bsls::Types::Int64 decompressionTime = 0; - bsl::string inputString(test.d_data, s_allocator_p); + bsl::string inputString(test.d_data, + bmqtst::TestHelperUtil::allocator()); eZlibCompressDecompressHelper( &compressionTime, &decompressionTime, @@ -732,7 +776,7 @@ static void testN1_performanceCompressionDecompressionDefault() // implementation. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // The default allocator check fails in this test case because the // printTable method utilizes the global allocator. @@ -741,11 +785,11 @@ static void testN1_performanceCompressionDecompressionDefault() const int k_NUM_ITERS = 1; - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); populateData(&data); // Measure calculation time and report - bsl::vector tableRecords(s_allocator_p); + bsl::vector tableRecords(bmqtst::TestHelperUtil::allocator()); for (unsigned i = 0; i < data.size(); ++i) { const int length = data[i].size(); @@ -790,7 +834,7 @@ static void testN1_performanceCompressionDecompressionDefault() } // Print performance comparison table - bsl::vector headerCols(s_allocator_p); + bsl::vector headerCols(bmqtst::TestHelperUtil::allocator()); headerCols.emplace_back("Payload Size"); headerCols.emplace_back("Compression"); headerCols.emplace_back("Decompression"); @@ -820,7 +864,7 @@ static void testN2_calculateThroughput() size_t length = 1024; // 1 Ki const bsls::Types::Uint64 k_NUM_ITERS = 1000000; // 1 M - bsl::string buffer_data("", s_allocator_p); + bsl::string buffer_data("", bmqtst::TestHelperUtil::allocator()); generateRandomString(&buffer_data, length); // - s_allocator_p->deallocate(buf); + bmqtst::TestHelperUtil::allocator()->deallocate(buf); } static void @@ -2313,7 +2350,8 @@ testN4_calculateSerialDefault_GoogleBenchmark(benchmark::State& state) const int k_MAX_SIZE = 67108864; // 64 Mi // Read in random input - char* buffer = static_cast(s_allocator_p->allocate(k_MAX_SIZE)); + char* buffer = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(k_MAX_SIZE)); bsl::generate_n(buffer, k_MAX_SIZE, bsl::rand); // Measure calculation time and report @@ -2328,7 +2366,7 @@ testN4_calculateSerialDefault_GoogleBenchmark(benchmark::State& state) } } // - s_allocator_p->deallocate(buffer); + bmqtst::TestHelperUtil::allocator()->deallocate(buffer); } static void @@ -2356,7 +2394,8 @@ testN4_calculateHardwareSerial_GoogleBenchmark(benchmark::State& state) const int k_MAX_SIZE = 67108864; // 64 Mi // Read in random input - char* buffer = static_cast(s_allocator_p->allocate(k_MAX_SIZE)); + char* buffer = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(k_MAX_SIZE)); bsl::generate_n(buffer, k_MAX_SIZE, bsl::rand); // Measure calculation time and report @@ -2369,7 +2408,7 @@ testN4_calculateHardwareSerial_GoogleBenchmark(benchmark::State& state) } } // - s_allocator_p->deallocate(buffer); + bmqtst::TestHelperUtil::allocator()->deallocate(buffer); } static void @@ -2396,11 +2435,12 @@ testN5_bmqpPerformanceSoftware_GoogleBenchmark(benchmark::State& state) const int k_MAX_SIZE = 67108864; // 64 Mi // Read in random input - char* buffer = static_cast(s_allocator_p->allocate(k_MAX_SIZE)); + char* buffer = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(k_MAX_SIZE)); bsl::generate_n(buffer, k_MAX_SIZE, bsl::rand); // Measure calculation time and report - bsl::vector tableRecords(s_allocator_p); + bsl::vector tableRecords(bmqtst::TestHelperUtil::allocator()); //===================================================================// // [1] Crc32c (software) @@ -2410,7 +2450,7 @@ testN5_bmqpPerformanceSoftware_GoogleBenchmark(benchmark::State& state) bmqp::Crc32c_Impl::calculateSoftware(buffer, length); } // - s_allocator_p->deallocate(buffer); + bmqtst::TestHelperUtil::allocator()->deallocate(buffer); } static void @@ -2438,7 +2478,8 @@ testN5_bdldPerformanceSoftware_GoogleBenchmark(benchmark::State& state) const int k_MAX_SIZE = 67108864; // 64 Mi // Read in random input - char* buffer = static_cast(s_allocator_p->allocate(k_MAX_SIZE)); + char* buffer = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(k_MAX_SIZE)); bsl::generate_n(buffer, k_MAX_SIZE, bsl::rand); // Measure calculation time and report @@ -2456,7 +2497,7 @@ testN5_bdldPerformanceSoftware_GoogleBenchmark(benchmark::State& state) } // - s_allocator_p->deallocate(buffer); + bmqtst::TestHelperUtil::allocator()->deallocate(buffer); } BSLA_MAYBE_UNUSED @@ -2487,7 +2528,8 @@ testN6_bmqpPerformanceDefault_GoogleBenchmark(benchmark::State& state) const int k_MAX_SIZE = 67108864; // 64 Mi // Read in random input - char* buffer = static_cast(s_allocator_p->allocate(k_MAX_SIZE)); + char* buffer = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(k_MAX_SIZE)); bsl::generate_n(buffer, k_MAX_SIZE, bsl::rand); // Measure calculation time and report @@ -2501,7 +2543,7 @@ testN6_bmqpPerformanceDefault_GoogleBenchmark(benchmark::State& state) bmqp::Crc32c::calculate(buffer, length); } // - s_allocator_p->deallocate(buffer); + bmqtst::TestHelperUtil::allocator()->deallocate(buffer); } BSLA_MAYBE_UNUSED @@ -2516,7 +2558,8 @@ testN6_bdldPerformanceDefault_GoogleBenchmark(benchmark::State& state) const int k_MAX_SIZE = 67108864; // 64 Mi // Read in random input - char* buffer = static_cast(s_allocator_p->allocate(k_MAX_SIZE)); + char* buffer = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(k_MAX_SIZE)); bsl::generate_n(buffer, k_MAX_SIZE, bsl::rand); // Measure calculation time and report @@ -2529,7 +2572,7 @@ testN6_bdldPerformanceDefault_GoogleBenchmark(benchmark::State& state) crcBde.update(buffer, length); crcBde.checksumAndReset(); } - s_allocator_p->deallocate(buffer); + bmqtst::TestHelperUtil::allocator()->deallocate(buffer); } #endif // BSLS_PLATFORM_OS_LINUX @@ -2603,7 +2646,7 @@ int main(int argc, char* argv[]) break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } #ifdef BSLS_PLATFORM_OS_LINUX diff --git a/src/groups/bmq/bmqp/bmqp_event.t.cpp b/src/groups/bmq/bmqp/bmqp_event.t.cpp index 3b16be0b9..6a5502a15 100644 --- a/src/groups/bmq/bmqp/bmqp_event.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_event.t.cpp @@ -46,34 +46,36 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); // "Un-cloned" event - bmqp::Event event1(&blob, s_allocator_p); + bmqp::Event event1(&blob, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(event1.isValid(), false); ASSERT_EQ(event1.isCloned(), false); ASSERT_EQ(event1.blob(), &blob); // Cloned event - bmqp::Event event2(&blob, s_allocator_p, true /* clone == true */); + bmqp::Event event2(&blob, + bmqtst::TestHelperUtil::allocator(), + true /* clone == true */); ASSERT_EQ(event2.isValid(), false); ASSERT_EQ(event2.isCloned(), true); ASSERT_EQ(&blob == event2.blob(), false); // Initialize from "un-cloned" event - bmqp::Event event3(event1, s_allocator_p); + bmqp::Event event3(event1, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(event3.isValid(), false); ASSERT_EQ(event3.isCloned(), false); ASSERT_EQ(event3.blob(), &blob); // Initialize from cloned event - bmqp::Event event4(event2, s_allocator_p); + bmqp::Event event4(event2, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(event4.isValid(), false); ASSERT_EQ(event4.isCloned(), true); ASSERT_EQ(&blob == event4.blob(), false); // Create an "un-cloned" event and assign an "un-cloned" event - bmqp::Event event5(event1, s_allocator_p); + bmqp::Event event5(event1, bmqtst::TestHelperUtil::allocator()); event5 = event3; ASSERT_EQ(event5.isValid(), false); ASSERT_EQ(event5.isCloned(), false); @@ -86,13 +88,13 @@ static void test1_breathingTest() ASSERT_EQ(&blob == event5.blob(), false); // Default ctor - bmqp::Event event6(s_allocator_p); + bmqp::Event event6(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(event6.isValid(), false); ASSERT_EQ(event6.isCloned(), false); ASSERT_EQ(event6.blob(), static_cast(0)); // Clone - bmqp::Event event7 = event3.clone(s_allocator_p); + bmqp::Event event7 = event3.clone(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(event7.isValid(), false); ASSERT_EQ(event7.isCloned(), true); ASSERT_EQ(event7.blob() == &blob, false); @@ -134,15 +136,17 @@ static void test2_isValid() { bmqtst::TestHelper::printTestName("IS VALID"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { // Create blob of length 1 (something shorter than // EventHeader::k_MIN_HEADER_SIZE), isValid() should fail. - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, "a", 0, 1); - bmqp::Event event(&blob, s_allocator_p, false); + bmqp::Event event(&blob, bmqtst::TestHelperUtil::allocator(), false); ASSERT_EQ(event.isValid(), false); } @@ -155,7 +159,7 @@ static void test2_isValid() eh.setHeaderWords(100); // specify big number fo header words eh.setLength(sizeof(eh)); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, reinterpret_cast(&eh), sizeof(eh)); @@ -165,7 +169,7 @@ static void test2_isValid() eh.headerWords() * bmqp::Protocol::k_WORD_SIZE); // isValid() should fail - bmqp::Event event(&blob, s_allocator_p, false); + bmqp::Event event(&blob, bmqtst::TestHelperUtil::allocator(), false); ASSERT_EQ(false, event.isValid()); } } @@ -203,7 +207,9 @@ static void test3_eventTypes() { bmqtst::TestHelper::printTestName("EVENT TYPES"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -440,12 +446,12 @@ static void test3_eventTypes() PVVV(test.d_line << ": Testing: bmqp::Event [" << test.d_type << "]"); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, reinterpret_cast(&eh), sizeof(eh)); - bmqp::Event event(&blob, s_allocator_p, false); + bmqp::Event event(&blob, bmqtst::TestHelperUtil::allocator(), false); ASSERT_EQ(event.isValid(), test.d_isValid); @@ -508,14 +514,16 @@ static void test4_eventLoading() { bmqtst::TestHelper::printTestName("EVENT LOADING"); // Disable check that no memory was allocated from the default allocator - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // baljsn::Encoder constructor does not pass the allocator to the // formatter. - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); int rc; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -533,14 +541,15 @@ static void test4_eventLoading() PVV(test.d_line << ": Testing " << test.d_encodingType << "encoding"); bmqp::SchemaEventBuilder obj(&bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), test.d_encodingType); BSLS_ASSERT_OPT(obj.blob().length() == 0); { PVV(test.d_line << ": Create a control message"); - bmqp_ctrlmsg::ControlMessage ctrlMessage(s_allocator_p); + bmqp_ctrlmsg::ControlMessage ctrlMessage( + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::Status& status = ctrlMessage.choice().makeStatus(); status.code() = 123; status.message() = "Test"; @@ -553,12 +562,14 @@ static void test4_eventLoading() PVV(test.d_line << ": Decode and compare message"); - bmqp::Event ctrlEvent(&obj.blob(), s_allocator_p); + bmqp::Event ctrlEvent(&obj.blob(), + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ctrlEvent.isValid(), true); ASSERT_EQ(ctrlEvent.isControlEvent(), true); - bmqp_ctrlmsg::ControlMessage decodedCtrlMsg(s_allocator_p); + bmqp_ctrlmsg::ControlMessage decodedCtrlMsg( + bmqtst::TestHelperUtil::allocator()); rc = ctrlEvent.loadControlEvent(&decodedCtrlMsg); ASSERT_EQ(rc, 0); @@ -575,7 +586,8 @@ static void test4_eventLoading() } { - bmqp::SchemaEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::SchemaEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(obj.blob().length() == 0); PVV(L_ << ": Create an elector message"); @@ -592,7 +604,8 @@ static void test4_eventLoading() PVV(L_ << ": Decode and compare message"); - bmqp::Event electorEvent(&obj.blob(), s_allocator_p); + bmqp::Event electorEvent(&obj.blob(), + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(electorEvent.isValid()); BSLS_ASSERT_OPT(electorEvent.isElectorEvent()); @@ -644,7 +657,9 @@ static void test5_iteratorLoading() { bmqtst::TestHelper::printTestName("ITERATOR LOADING"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -671,20 +686,23 @@ static void test5_iteratorLoading() PVVV(test.d_line << ": Testing: bmqp::Event [" << test.d_type << "]"); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, reinterpret_cast(&eh), sizeof(eh)); - bmqp::Event event(&blob, s_allocator_p, false); + bmqp::Event event(&blob, bmqtst::TestHelperUtil::allocator(), false); ASSERT_EQ(event.isValid(), (test.d_type != bmqp::EventType::e_UNDEFINED)); bmqp::AckMessageIterator ackIter; bmqp::ConfirmMessageIterator confirmIter; - bmqp::PushMessageIterator pushIter(&bufferFactory, s_allocator_p); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator pushIter( + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqp::StorageMessageIterator storageIter; bmqp::RecoveryMessageIterator recoveryIter; @@ -769,7 +787,9 @@ static void test6_printing() BSLMF_ASSERT(bmqp::EventType::e_REPLICATION_RECEIPT == bmqp::EventType::k_HIGHEST_SUPPORTED_EVENT_TYPE); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); struct Test { bmqp::EventType::Enum d_type; @@ -796,16 +816,16 @@ static void test6_printing() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eh(static_cast(test.d_type)); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, reinterpret_cast(&eh), sizeof(eh)); - bmqp::Event obj(&blob, s_allocator_p, false); + bmqp::Event obj(&blob, bmqtst::TestHelperUtil::allocator(), false); if (test.d_type == bmqp::EventType::e_UNDEFINED) { ASSERT_SAFE_FAIL(obj.print(out, 0, -1)); @@ -849,7 +869,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_eventutil.t.cpp b/src/groups/bmq/bmqp/bmqp_eventutil.t.cpp index cdaa48d0c..66e1ea4f3 100644 --- a/src/groups/bmq/bmqp/bmqp_eventutil.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_eventutil.t.cpp @@ -248,9 +248,13 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PushEventBuilder pushEventBuilder(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PushEventBuilder pushEventBuilder( + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); int payloadLength = 0; int numSubQueueInfos = 0; int rc = 0; @@ -263,7 +267,7 @@ static void test1_breathingTest() numSubQueueInfos, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Msg2 payloadLength = generateRandomInteger(1, 120); @@ -272,7 +276,7 @@ static void test1_breathingTest() numSubQueueInfos, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Msg3 payloadLength = generateRandomInteger(1, 120); @@ -281,7 +285,7 @@ static void test1_breathingTest() numSubQueueInfos, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Msg4 payloadLength = generateRandomInteger(1, 120); @@ -290,7 +294,7 @@ static void test1_breathingTest() numSubQueueInfos, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Msg5 payloadLength = generateRandomInteger(1, 120); @@ -299,24 +303,29 @@ static void test1_breathingTest() numSubQueueInfos, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Create event appendMessages(&pushEventBuilder, data); - bmqp::Event event(&(pushEventBuilder.blob()), s_allocator_p); + bmqp::Event event(&(pushEventBuilder.blob()), + bmqtst::TestHelperUtil::allocator()); // 2) Flatten the event - bsl::vector eventInfos(s_allocator_p); - rc = bmqp::EventUtil::flattenPushEvent(&eventInfos, - event, - &bufferFactory, - s_allocator_p); + bsl::vector eventInfos( + bmqtst::TestHelperUtil::allocator()); + rc = bmqp::EventUtil::flattenPushEvent( + &eventInfos, + event, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); ASSERT_EQ(eventInfos.size(), 1u); // 3) Verify that the flattened event has the expected messages. - bmqp::Event flattenedEvent(&(eventInfos[0].d_blob), s_allocator_p); - bmqp::PushMessageIterator msgIterator(&bufferFactory, s_allocator_p); + bmqp::Event flattenedEvent(&(eventInfos[0].d_blob), + bmqtst::TestHelperUtil::allocator()); + bmqp::PushMessageIterator msgIterator(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); flattenedEvent.loadPushMessageIterator(&msgIterator, true); for (bsl::vector::size_type i = 0; i < data.size(); ++i) { @@ -333,7 +342,8 @@ static void test1_breathingTest() rc = msgIterator.next(); BSLS_ASSERT_OPT(rc == 1); - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadMessagePayload(&payload); BSLS_ASSERT_OPT(rc == 0); @@ -362,20 +372,22 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(rc == 1); BSLS_ASSERT_OPT(msgIterator.hasOptions()); - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadMessagePayload(&payload); BSLS_ASSERT_OPT(rc == 0); ASSERT_EQ(bdlbb::BlobUtil::compare(D.d_payload, payload), 0); - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadOptionsView(&optionsView); BSLS_ASSERT_OPT(rc == 0); BSLS_ASSERT_OPT(optionsView.isValid()); BSLS_ASSERT_OPT( optionsView.find(bmqp::OptionType::e_SUB_QUEUE_INFOS) != optionsView.end()); - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); rc = optionsView.loadSubQueueInfosOption(&subQueueInfos); BSLS_ASSERT_OPT(rc == 0); BSLS_ASSERT_OPT(subQueueInfos.size() == 1); @@ -397,7 +409,7 @@ static void test1_breathingTest() // // TBD: figure out the right way to "fix" this. - Data dummy(&bufferFactory, s_allocator_p); + Data dummy(&bufferFactory, bmqtst::TestHelperUtil::allocator()); static_cast( static_cast< bslmf::NestedTraitDeclaration data(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PushEventBuilder pushEventBuilder( + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); int payloadLength = 0; int numSubQueueIds = 0; int rc = 0; @@ -455,31 +471,36 @@ static void test2_flattenExplodesEvent() numSubQueueIds, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); total += data[count].d_payload.length(); ++count; } // Create event appendMessages(&pushEventBuilder, data); - bmqp::Event event(&(pushEventBuilder.blob()), s_allocator_p); + bmqp::Event event(&(pushEventBuilder.blob()), + bmqtst::TestHelperUtil::allocator()); // 2) Flatten the event - bsl::vector eventInfos(s_allocator_p); - rc = bmqp::EventUtil::flattenPushEvent(&eventInfos, - event, - &bufferFactory, - s_allocator_p); + bsl::vector eventInfos( + bmqtst::TestHelperUtil::allocator()); + rc = bmqp::EventUtil::flattenPushEvent( + &eventInfos, + event, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); ASSERT_EQ(eventInfos.size(), 2u); // 3) Verify that the flattening results in two event blobs, each having // two messages with one SubQueueId each. - bmqp::PushMessageIterator msgIterator(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator msgIterator(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int idx = 0; // 1st flattened event - bmqp::Event flattenedEvent1(&(eventInfos[0].d_blob), s_allocator_p); + bmqp::Event flattenedEvent1(&(eventInfos[0].d_blob), + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(eventInfos[0].d_ids.size(), static_cast(count * numSubQueueIds - 1)); @@ -493,7 +514,8 @@ static void test2_flattenExplodesEvent() // Verify payload { - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadMessagePayload(&payload); BSLS_ASSERT_OPT(rc == 0); @@ -502,14 +524,15 @@ static void test2_flattenExplodesEvent() // Verify SubQueueInfos { - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadOptionsView(&optionsView); BSLS_ASSERT_OPT(rc == 0); BSLS_ASSERT_OPT(optionsView.isValid()); BSLS_ASSERT_OPT( optionsView.find(bmqp::OptionType::e_SUB_QUEUE_INFOS) != optionsView.end()); - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); rc = optionsView.loadSubQueueInfosOption(&subQueueInfos); BSLS_ASSERT_OPT(rc == 0); BSLS_ASSERT_OPT(subQueueInfos.size() == 1); @@ -535,7 +558,8 @@ static void test2_flattenExplodesEvent() // Verify payload { - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadMessagePayload(&payload); BSLS_ASSERT_OPT(rc == 0); @@ -544,14 +568,15 @@ static void test2_flattenExplodesEvent() // Verify SubQueueInfos { - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadOptionsView(&optionsView); BSLS_ASSERT_OPT(rc == 0); BSLS_ASSERT_OPT(optionsView.isValid()); BSLS_ASSERT_OPT( optionsView.find(bmqp::OptionType::e_SUB_QUEUE_INFOS) != optionsView.end()); - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); rc = optionsView.loadSubQueueInfosOption(&subQueueInfos); BSLS_ASSERT_OPT(rc == 0); BSLS_ASSERT_OPT(subQueueInfos.size() == 1); @@ -562,7 +587,8 @@ static void test2_flattenExplodesEvent() idx = count - 1; // the last one did not fit the first event // 2nd flattened event - bmqp::Event flattenedEvent2(&(eventInfos[1].d_blob), s_allocator_p); + bmqp::Event flattenedEvent2(&(eventInfos[1].d_blob), + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(eventInfos[1].d_ids.size(), 1u); flattenedEvent2.loadPushMessageIterator(&msgIterator, true); @@ -575,7 +601,8 @@ static void test2_flattenExplodesEvent() // Verify payload { - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadMessagePayload(&payload); BSLS_ASSERT_OPT(rc == 0); @@ -584,14 +611,15 @@ static void test2_flattenExplodesEvent() // Verify SubQueueInfos { - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadOptionsView(&optionsView); BSLS_ASSERT_OPT(rc == 0); BSLS_ASSERT_OPT(optionsView.isValid()); BSLS_ASSERT_OPT( optionsView.find(bmqp::OptionType::e_SUB_QUEUE_INFOS) != optionsView.end()); - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); rc = optionsView.loadSubQueueInfosOption(&subQueueInfos); BSLS_ASSERT_OPT(rc == 0); BSLS_ASSERT_OPT(subQueueInfos.size() == 1); @@ -641,10 +669,14 @@ static void test3_flattenWithMessageProperties() { bmqtst::TestHelper::printTestName("FLATTEN WITH MESSAGE PROPERTIES"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::MessageProperties msgProperties(s_allocator_p); - bdlbb::Blob appData(s_allocator_p); - bmqp::PushEventBuilder pushEventBuilder(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::MessageProperties msgProperties(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob appData(bmqtst::TestHelperUtil::allocator()); + bmqp::PushEventBuilder pushEventBuilder( + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqt::EventBuilderResult::Enum result; int payloadLength = 0; int numSubQueueInfos = 0; @@ -654,7 +686,7 @@ static void test3_flattenWithMessageProperties() // 1) Create an event composed of one message having message properties // and two SubQueueIds. - Data datum(&bufferFactory, s_allocator_p); + Data datum(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::PushHeaderFlagUtil::setFlag( &flags, @@ -714,24 +746,29 @@ static void test3_flattenWithMessageProperties() logic); BSLS_ASSERT_OPT(result == bmqt::EventBuilderResult::e_SUCCESS); - bmqp::Event event(&(pushEventBuilder.blob()), s_allocator_p); + bmqp::Event event(&(pushEventBuilder.blob()), + bmqtst::TestHelperUtil::allocator()); // 2) Flatten the event. - bsl::vector eventInfos(s_allocator_p); - rc = bmqp::EventUtil::flattenPushEvent(&eventInfos, - event, - &bufferFactory, - s_allocator_p); + bsl::vector eventInfos( + bmqtst::TestHelperUtil::allocator()); + rc = bmqp::EventUtil::flattenPushEvent( + &eventInfos, + event, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); ASSERT_EQ(eventInfos.size(), 1U); // 3) Verify that the flattening results in one event blob containing // two messages with the original message properties and message // payload and corresponding to the respective SubQueueIds. - bmqp::Event flattenedEvent(&(eventInfos[0].d_blob), s_allocator_p); + bmqp::Event flattenedEvent(&(eventInfos[0].d_blob), + bmqtst::TestHelperUtil::allocator()); ASSERT(flattenedEvent.isPushEvent()); - bmqp::PushMessageIterator msgIterator(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator msgIterator(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); flattenedEvent.loadPushMessageIterator(&msgIterator, true); for (bmqp::Protocol::SubQueueInfosArray::size_type i = 0; @@ -742,35 +779,39 @@ static void test3_flattenWithMessageProperties() BSLS_ASSERT_OPT(msgIterator.hasOptions()); // Verify msgProperties - bdlbb::Blob properties(&bufferFactory, s_allocator_p); + bdlbb::Blob properties(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadMessageProperties(&properties); P(msgIterator.messagePropertiesSize()); ASSERT_EQ(rc, 0); ASSERT_EQ(bdlbb::BlobUtil::compare(datum.d_properties, properties), 0); // Verify msgPayload - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadMessagePayload(&payload); P(msgIterator.messagePayloadSize()); ASSERT_EQ(rc, 0); ASSERT_EQ(bdlbb::BlobUtil::compare(datum.d_payload, payload), 0); // Verify applicationData (msgProperties + msgPayload) - bdlbb::Blob applicationData(&bufferFactory, s_allocator_p); + bdlbb::Blob applicationData(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rc = msgIterator.loadApplicationData(&applicationData); P(msgIterator.applicationDataSize()); ASSERT_EQ(rc, 0); ASSERT_EQ(bdlbb::BlobUtil::compare(appData, applicationData), 0); // Verify subQueueInfo - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); msgIterator.loadOptionsView(&optionsView); BSLS_ASSERT_OPT(rc == 0); BSLS_ASSERT_OPT(optionsView.isValid()); BSLS_ASSERT_OPT( optionsView.find(bmqp::OptionType::e_SUB_QUEUE_INFOS) != optionsView.end()); - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); rc = optionsView.loadSubQueueInfosOption(&subQueueInfos); BSLS_ASSERT_OPT(rc == 0); BSLS_ASSERT_OPT(subQueueInfos.size() == 1); @@ -787,7 +828,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); unsigned int seed = bsl::time(0); bsl::srand(seed); @@ -800,7 +841,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_messageguidgenerator.t.cpp b/src/groups/bmq/bmqp/bmqp_messageguidgenerator.t.cpp index 232a0411b..9abdf95aa 100644 --- a/src/groups/bmq/bmqp/bmqp_messageguidgenerator.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_messageguidgenerator.t.cpp @@ -463,7 +463,7 @@ static void test1_breathingTest() // Basic functionality // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -517,7 +517,7 @@ static void test1_breathingTest() bsl::unordered_map > - myMap(s_allocator_p); + myMap(bmqtst::TestHelperUtil::allocator()); bmqt::MessageGUID guid; generator.generateGUID(&guid); myMap.insert(bsl::make_pair(guid, 1)); @@ -531,7 +531,8 @@ static void test2_extract() // TBD: // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; // Implicit string conversion in ASSERT_EQ + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = + true; // Implicit string conversion in ASSERT_EQ bmqtst::TestHelper::printTestName("EXTRACT"); @@ -550,7 +551,7 @@ static void test2_extract() int version; unsigned int counter; bsls::Types::Int64 timerTick; - bsl::string clientId(s_allocator_p); + bsl::string clientId(bmqtst::TestHelperUtil::allocator()); int rc = bmqp::MessageGUIDGenerator::extractFields(&version, &counter, @@ -579,7 +580,7 @@ static void test2_extract() int version; unsigned int counter; bsls::Types::Int64 timerTick; - bsl::string clientId(s_allocator_p); + bsl::string clientId(bmqtst::TestHelperUtil::allocator()); int rc = bmqp::MessageGUIDGenerator::extractFields(&version, &counter, @@ -608,7 +609,7 @@ static void test2_extract() int version; unsigned int counter; bsls::Types::Int64 timerTick; - bsl::string clientId(s_allocator_p); + bsl::string clientId(bmqtst::TestHelperUtil::allocator()); int rc = bmqp::MessageGUIDGenerator::extractFields(&version, &counter, @@ -647,12 +648,12 @@ static void test3_multithreadUseIP() // using IP to calculate 'ClientId' part of the GUIDs. // ------------------------------------------------------------------------ { - s_ignoreCheckGblAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckGblAlloc() = true; // Can't ensure no global memory is allocated because // 'bslmt::ThreadUtil::create()' uses the global allocator to allocate // memory. - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -675,13 +676,14 @@ static void test3_multithreadUseIP() const int k_NUM_GUIDS = 1000000; // 1M #endif - bslmt::ThreadGroup threadGroup(s_allocator_p); + bslmt::ThreadGroup threadGroup(bmqtst::TestHelperUtil::allocator()); // Barrier to get each thread to start at the same time; `+1` for this // (main) thread. bslmt::Barrier barrier(k_NUM_THREADS + 1); - bsl::vector > threadsData(s_allocator_p); + bsl::vector > threadsData( + bmqtst::TestHelperUtil::allocator()); threadsData.resize(k_NUM_THREADS); bmqp::MessageGUIDGenerator generator(0); @@ -699,7 +701,7 @@ static void test3_multithreadUseIP() threadGroup.joinAll(); // Check uniqueness across all threads - bsl::set allGUIDs(s_allocator_p); + bsl::set allGUIDs(bmqtst::TestHelperUtil::allocator()); for (int tIt = 0; tIt < k_NUM_THREADS; ++tIt) { const bsl::vector& guids = threadsData[tIt]; for (int gIt = 0; gIt < k_NUM_GUIDS; ++gIt) { @@ -729,12 +731,12 @@ static void test4_multithreadUseHostname() // using hostname to calculate 'ClientId' part of the GUIDs. // ------------------------------------------------------------------------ { - s_ignoreCheckGblAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckGblAlloc() = true; // Can't ensure no global memory is allocated because // 'bslmt::ThreadUtil::create()' uses the global allocator to allocate // memory. - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -753,13 +755,14 @@ static void test4_multithreadUseHostname() const int k_NUM_GUIDS = 1000000; // 1M #endif - bslmt::ThreadGroup threadGroup(s_allocator_p); + bslmt::ThreadGroup threadGroup(bmqtst::TestHelperUtil::allocator()); // Barrier to get each thread to start at the same time; `+1` for this // (main) thread. bslmt::Barrier barrier(k_NUM_THREADS + 1); - bsl::vector > threadsData(s_allocator_p); + bsl::vector > threadsData( + bmqtst::TestHelperUtil::allocator()); threadsData.resize(k_NUM_THREADS); // Create generator with 'doIpResolving' flag set to false @@ -778,7 +781,7 @@ static void test4_multithreadUseHostname() threadGroup.joinAll(); // Check uniqueness across all threads - bsl::set allGUIDs(s_allocator_p); + bsl::set allGUIDs(bmqtst::TestHelperUtil::allocator()); for (int tIt = 0; tIt < k_NUM_THREADS; ++tIt) { const bsl::vector& guids = threadsData[tIt]; for (int gIt = 0; gIt < k_NUM_GUIDS; ++gIt) { @@ -804,7 +807,7 @@ static void test5_print() // Printing of the various parts of a GUID. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -817,7 +820,7 @@ static void test5_print() bmqt::MessageGUID guid; ASSERT_EQ(guid.isUnset(), true); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); bmqp::MessageGUIDGenerator::print(out, guid); ASSERT_EQ(out.str(), "** UNSET **"); } @@ -837,7 +840,7 @@ static void test5_print() // Print and compare const char k_EXPECTED[] = "1-2964169-297593876864458-0DCE04742D2E"; - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); bmqp::MessageGUIDGenerator::print(out, guid); ASSERT_EQ(out.str(), k_EXPECTED); } @@ -857,7 +860,7 @@ static void test5_print() // Print and compare const char k_EXPECTED[] = "[Unsupported GUID version 0]"; - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); bmqp::MessageGUIDGenerator::print(out, guid); ASSERT_EQ(out.str(), k_EXPECTED); } @@ -867,7 +870,7 @@ static void test5_print() bmqt::MessageGUID guid; generator.generateGUID(&guid); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); bmqp::MessageGUIDGenerator::print(out, guid); PVV("Output: '" << out.str() << "', GUID " << guid); @@ -889,8 +892,8 @@ static void test5_print() // Print and compare const char k_EXPECTED_1[] = "1-0-0-000000000001"; const char k_EXPECTED_2[] = "1-0-0-000000000002"; - bmqu::MemOutStream out1(s_allocator_p); - bmqu::MemOutStream out2(s_allocator_p); + bmqu::MemOutStream out1(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream out2(bmqtst::TestHelperUtil::allocator()); bmqp::MessageGUIDGenerator::print(out1, guid1); bmqp::MessageGUIDGenerator::print(out2, guid2); @@ -914,7 +917,7 @@ static void test6_defaultHashUniqueness() // Hash uniqueness of the generated GUIDs. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Because there is no emplace on unordered_map, the temporary list // created upon insertion of objects in the map uses the default // allocator. @@ -936,7 +939,8 @@ static void test6_defaultHashUniqueness() typedef bsl::vector Guids; // hash -> vector of corresponding GUIDs - bsl::unordered_map hashes(s_allocator_p); + bsl::unordered_map hashes( + bmqtst::TestHelperUtil::allocator()); hashes.reserve(k_NUM_GUIDS); bsl::hash hasher; @@ -1003,7 +1007,7 @@ static void test7_customHashUniqueness() // Hash uniqueness of the generated GUIDs. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Because there is no emplace on unordered_map, the temporary list // created upon insertion of objects in the map uses the default // allocator. @@ -1025,7 +1029,8 @@ static void test7_customHashUniqueness() typedef bsl::vector Guids; // hash -> vector of corresponding GUIDs - bsl::unordered_map hashes(s_allocator_p); + bsl::unordered_map hashes( + bmqtst::TestHelperUtil::allocator()); hashes.reserve(k_NUM_GUIDS); @@ -1101,7 +1106,8 @@ static void testN1_decode() // - // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; // istringstream allocates + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = + true; // istringstream allocates bmqtst::TestHelper::printTestName("DECODE"); @@ -1117,7 +1123,7 @@ static void testN1_decode() bsl::istringstream is(buffer); - bsl::string hexGuid(s_allocator_p); + bsl::string hexGuid(bmqtst::TestHelperUtil::allocator()); bsls::Types::Int64 nanoSecondsFromEpoch = 0; is >> hexGuid; @@ -1193,7 +1199,7 @@ static void testN2_bmqtPerformance() // Performance of the bmqt::MessageGUID generation. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -1251,7 +1257,7 @@ static void testN2_bdlbPerformance() // Performance of the bdlb::Guid generation. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -1304,7 +1310,7 @@ BSLA_MAYBE_UNUSED static void testN3_defaultHashBenchmark() // NA // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -1327,7 +1333,7 @@ BSLA_MAYBE_UNUSED static void testN4_customHashBenchmark() // NA // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -1345,7 +1351,7 @@ BSLA_MAYBE_UNUSED static void testN5_hashTableWithDefaultHashBenchmark() // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -1353,7 +1359,8 @@ BSLA_MAYBE_UNUSED static void testN5_hashTableWithDefaultHashBenchmark() const size_t k_NUM_ELEMS = 10000000; // 10M bmqt::MessageGUID guid; - bsl::unordered_map ht(s_allocator_p); + bsl::unordered_map ht( + bmqtst::TestHelperUtil::allocator()); ht.reserve(k_NUM_ELEMS); bmqp::MessageGUIDGenerator generator(0); @@ -1394,7 +1401,7 @@ BSLA_MAYBE_UNUSED static void testN6_hashTableWithCustomHashBenchmark() // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -1406,7 +1413,7 @@ BSLA_MAYBE_UNUSED static void testN6_hashTableWithCustomHashBenchmark() bsl::unordered_map > - ht(s_allocator_p); + ht(bmqtst::TestHelperUtil::allocator()); ht.reserve(k_NUM_ELEMS); bmqp::MessageGUIDGenerator generator(0); @@ -1447,7 +1454,7 @@ BSLA_MAYBE_UNUSED static void testN7_orderedMapWithDefaultHashBenchmark() // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -1456,8 +1463,9 @@ BSLA_MAYBE_UNUSED static void testN7_orderedMapWithDefaultHashBenchmark() const size_t k_NUM_ELEMS = 10000000; // 10M bmqt::MessageGUID guid; - bmqc::OrderedHashMap ht(k_NUM_ELEMS, - s_allocator_p); + bmqc::OrderedHashMap ht( + k_NUM_ELEMS, + bmqtst::TestHelperUtil::allocator()); bmqp::MessageGUIDGenerator generator(0); @@ -1497,7 +1505,7 @@ BSLA_MAYBE_UNUSED static void testN8_orderedMapWithCustomHashBenchmark() // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -1509,7 +1517,7 @@ BSLA_MAYBE_UNUSED static void testN8_orderedMapWithCustomHashBenchmark() bmqc::OrderedHashMap > - ht(k_NUM_ELEMS, s_allocator_p); + ht(k_NUM_ELEMS, bmqtst::TestHelperUtil::allocator()); bmqp::MessageGUIDGenerator generator(0); @@ -1549,7 +1557,7 @@ static void testN9_hashBenchmarkComparison() // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -1585,7 +1593,7 @@ static void testN10_hashCollisionsComparison() // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Because there is no emplace on unordered_map, the temporary list // created upon insertion of objects in the map uses the default // allocator. @@ -1636,9 +1644,9 @@ static void testN10_hashCollisionsComparison() generators; generators.resize(10); for (int i = 0; i < k_NUM_GENERATORS; i++) { - generators[i].load(new (*s_allocator_p) + generators[i].load(new (*bmqtst::TestHelperUtil::allocator()) bmqp::MessageGUIDGenerator(i), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); } bmqp::MessageGUIDGenerator generator(0); @@ -1818,13 +1826,13 @@ static void testN10_hashCollisionsComparison() table.column("Name").insertValue(checker.d_name); } - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); guids.reserve(k_NUM_GUIDS); for (size_t genId = 0; genId < k_NUM_GENERATORS; genId++) { const GeneratorContext& gen = k_GENERATORS[genId]; gen.d_func(&guids, k_NUM_GUIDS); - bsl::string sample(s_allocator_p); + bsl::string sample(bmqtst::TestHelperUtil::allocator()); sample.resize(bmqt::MessageGUID::e_SIZE_HEX); guids.at(k_NUM_GUIDS / 2).toHex(sample.data()); @@ -1867,7 +1875,8 @@ static void testN1_decode_GoogleBenchmark(benchmark::State& state) { for (auto _ : state) { state.PauseTiming(); - s_ignoreCheckDefAlloc = true; // istringstream allocates + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = + true; // istringstream allocates bmqtst::TestHelper::printTestName("GOOGLE BENCHMARK DECODE"); @@ -1884,7 +1893,7 @@ static void testN1_decode_GoogleBenchmark(benchmark::State& state) bsl::istringstream is(buffer); - bsl::string hexGuid(s_allocator_p); + bsl::string hexGuid(bmqtst::TestHelperUtil::allocator()); bsls::Types::Int64 nanoSecondsFromEpoch = 0; is >> hexGuid; @@ -1965,7 +1974,7 @@ static void testN2_bmqtPerformance_GoogleBenchmark(benchmark::State& state) // bdlb::Guid generation. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("GOOGLE BENCHMARK PERFORMANCE"); // ---------------------------- // bmqt::MessageGUID generation @@ -1996,7 +2005,7 @@ static void testN2_bdlbPerformance_GoogleBenchmark(benchmark::State& state) // --------------------- // Warm the cache - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("GOOGLE BENCHMARK PERFORMANCE"); for (int i = 0; i < 1000; ++i) { @@ -2029,7 +2038,7 @@ testN3_defaultHashBenchmark_GoogleBenchmark(benchmark::State& state) // NA // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -2063,7 +2072,7 @@ static void testN4_customHashBenchmark_GoogleBenchmark(benchmark::State& state) // NA // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -2094,7 +2103,7 @@ static void testN5_hashTableWithDefaultHashBenchmark_GoogleBenchmark( // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -2102,7 +2111,8 @@ static void testN5_hashTableWithDefaultHashBenchmark_GoogleBenchmark( "w/ DEFAULT HASH BENCHMARK"); bmqt::MessageGUID guid; - bsl::unordered_map ht(s_allocator_p); + bsl::unordered_map ht( + bmqtst::TestHelperUtil::allocator()); ht.reserve(state.range(0)); bmqp::MessageGUIDGenerator generator(0); @@ -2134,7 +2144,7 @@ static void testN6_hashTableWithCustomHashBenchmark_GoogleBenchmark( // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -2146,7 +2156,7 @@ static void testN6_hashTableWithCustomHashBenchmark_GoogleBenchmark( bsl::unordered_map > - ht(s_allocator_p); + ht(bmqtst::TestHelperUtil::allocator()); ht.reserve(state.range(0)); bmqp::MessageGUIDGenerator generator(0); @@ -2178,7 +2188,7 @@ static void testN7_orderedMapWithDefaultHashBenchmark_GoogleBenchmark( // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -2187,8 +2197,9 @@ static void testN7_orderedMapWithDefaultHashBenchmark_GoogleBenchmark( bmqt::MessageGUID guid; - bmqc::OrderedHashMap ht(state.range(0), - s_allocator_p); + bmqc::OrderedHashMap ht( + state.range(0), + bmqtst::TestHelperUtil::allocator()); bmqp::MessageGUIDGenerator generator(0); @@ -2218,7 +2229,7 @@ static void testN8_orderedMapWithCustomHashBenchmark_GoogleBenchmark( // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'bmqp::MessageGUIDGenerator::ctor' prints a BALL_LOG_INFO which // allocates using the default allocator. @@ -2230,7 +2241,7 @@ static void testN8_orderedMapWithCustomHashBenchmark_GoogleBenchmark( bmqc::OrderedHashMap > - ht(state.range(0), s_allocator_p); + ht(state.range(0), bmqtst::TestHelperUtil::allocator()); bmqp::MessageGUIDGenerator generator(0); @@ -2323,7 +2334,7 @@ int main(int argc, char* argv[]) case -10: testN10_hashCollisionsComparison(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } #ifdef BSLS_PLATFORM_OS_LINUX diff --git a/src/groups/bmq/bmqp/bmqp_messageproperties.t.cpp b/src/groups/bmq/bmqp/bmqp_messageproperties.t.cpp index 6b25bd56a..8e9161c2a 100644 --- a/src/groups/bmq/bmqp/bmqp_messageproperties.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_messageproperties.t.cpp @@ -164,7 +164,7 @@ void populateProperties(bmqp::MessageProperties* properties, for (size_t i = 1; i < (numProps + 1); ++i) { size_t remainder = i % numPropTypes; - bmqu::MemOutStream osstr(s_allocator_p); + bmqu::MemOutStream osstr(bmqtst::TestHelperUtil::allocator()); switch (remainder) { case 0: { @@ -250,7 +250,9 @@ void populateProperties(bmqp::MessageProperties* properties, case 5: { osstr << "stringPropName" << i << bsl::ends; - const bsl::string value(i, 'x', s_allocator_p); + const bsl::string value(i, + 'x', + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(i, 0, p.setPropertyAsString(osstr.str(), value)); @@ -265,7 +267,9 @@ void populateProperties(bmqp::MessageProperties* properties, case 6: { osstr << "binaryPropName" << i << bsl::ends; - const bsl::vector value(i, 'x', s_allocator_p); + const bsl::vector value(i, + 'x', + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(i, 0, p.setPropertyAsBinary(osstr.str(), value)); @@ -463,8 +467,10 @@ static void test1_breathingTest() bmqtst::TestHelper::printTestName("BREATHING TEST"); PV("Testing MessageProperties"); - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bmqp::MessageProperties p(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bmqp::MessageProperties p(bmqtst::TestHelperUtil::allocator()); int totalLen = 0; bmqp::MessagePropertiesInfo logic = bmqp::MessagePropertiesInfo::makeInvalidSchema(); @@ -540,9 +546,13 @@ static void test1_breathingTest() ASSERT_GT(p.streamOut(&bufferFactory, logic).length(), totalLen); // Test 'Or' flavor. - const bsl::string dummyName("blahblah", s_allocator_p); - const bsl::string defaultVal("defval", s_allocator_p); - const bsl::vector defaultBin(1024, 'F', s_allocator_p); + const bsl::string dummyName("blahblah", + bmqtst::TestHelperUtil::allocator()); + const bsl::string defaultVal("defval", + bmqtst::TestHelperUtil::allocator()); + const bsl::vector defaultBin(1024, + 'F', + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(p.getPropertyAsStringOr(dummyName, defaultVal), defaultVal); ASSERT_EQ(p.getPropertyAsInt32Or(dummyName, 42), 42); @@ -574,15 +584,22 @@ static void test2_setPropertyTest() { // Test all flavors of 'setPropertyAs*'. - bmqp::MessageProperties obj(s_allocator_p); - - const bsl::string boolN("boolPropName", s_allocator_p); - const bsl::string charN("charPropName", s_allocator_p); - const bsl::string shortN("shortPropName", s_allocator_p); - const bsl::string intN("intPropName", s_allocator_p); - const bsl::string int64N("int64PropName", s_allocator_p); - const bsl::string stringN("stringPropName", s_allocator_p); - const bsl::string binaryN("binaryPropName", s_allocator_p); + bmqp::MessageProperties obj(bmqtst::TestHelperUtil::allocator()); + + const bsl::string boolN("boolPropName", + bmqtst::TestHelperUtil::allocator()); + const bsl::string charN("charPropName", + bmqtst::TestHelperUtil::allocator()); + const bsl::string shortN("shortPropName", + bmqtst::TestHelperUtil::allocator()); + const bsl::string intN("intPropName", + bmqtst::TestHelperUtil::allocator()); + const bsl::string int64N("int64PropName", + bmqtst::TestHelperUtil::allocator()); + const bsl::string stringN("stringPropName", + bmqtst::TestHelperUtil::allocator()); + const bsl::string binaryN("binaryPropName", + bmqtst::TestHelperUtil::allocator()); bool boolV = true; char charV = bsl::numeric_limits::max(); @@ -591,8 +608,10 @@ static void test2_setPropertyTest() bsls::Types::Int64 int64V = bsl::numeric_limits::max(); - bsl::string stringV(42, 'x', s_allocator_p); - bsl::vector binaryV(84, 250, s_allocator_p); + bsl::string stringV(42, 'x', bmqtst::TestHelperUtil::allocator()); + bsl::vector binaryV(84, + 250, + bmqtst::TestHelperUtil::allocator()); ASSERT_NE(0, obj.setPropertyAsBool("", boolV)); ASSERT_NE(0, obj.setPropertyAsChar("", charV)); @@ -666,8 +685,10 @@ static void test2_setPropertyTest() shortV = 17; intV = 987; int64V = 123456LL; - stringV = bsl::string(42, 'z', s_allocator_p); - binaryV = bsl::vector(29, 170, s_allocator_p); + stringV = bsl::string(42, 'z', bmqtst::TestHelperUtil::allocator()); + binaryV = bsl::vector(29, + 170, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, obj.setPropertyAsBool(boolN, boolV)); ASSERT_EQ(0, obj.setPropertyAsChar(charN, charV)); @@ -688,15 +709,17 @@ static void test2_setPropertyTest() { // Test 'setPropertyAs*' to return error. - bmqp::MessageProperties p(s_allocator_p); + bmqp::MessageProperties p(bmqtst::TestHelperUtil::allocator()); // Invalid property name. // --------------------- - const bsl::string invalidPropName1("#MyPropName", s_allocator_p); + const bsl::string invalidPropName1( + "#MyPropName", + bmqtst::TestHelperUtil::allocator()); const bsl::string invalidPropName2( bmqp::MessageProperties::k_MAX_PROPERTY_NAME_LENGTH + 1, 'x', - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bmqt::GenericResult::e_INVALID_ARGUMENT, p.setPropertyAsChar(invalidPropName1, 'A')); @@ -708,7 +731,7 @@ static void test2_setPropertyTest() const bsl::string invalidValue( bmqp::MessageProperties::k_MAX_PROPERTY_VALUE_LENGTH + 1, 'x', - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bmqt::GenericResult::e_INVALID_ARGUMENT, p.setPropertyAsString("dummy", invalidValue)); @@ -725,14 +748,14 @@ static void test2_setPropertyTest() const bsl::string bigValue( bmqp::MessageProperties::k_MAX_PROPERTY_VALUE_LENGTH, 'x', - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); const int numProp = bmqp::MessageProperties::k_MAX_PROPERTIES_AREA_LENGTH / bmqp::MessageProperties::k_MAX_PROPERTY_VALUE_LENGTH; for (int i = 0; i < numProp; ++i) { - bmqu::MemOutStream osstr(s_allocator_p); + bmqu::MemOutStream osstr(bmqtst::TestHelperUtil::allocator()); osstr << "propName" << i << bsl::ends; ASSERT_EQ(0, p.setPropertyAsString(osstr.str(), bigValue)); } @@ -746,7 +769,7 @@ static void test2_setPropertyTest() for (int i = 0; i < bmqp::MessageProperties::k_MAX_NUM_PROPERTIES; ++i) { - bmqu::MemOutStream osstr(s_allocator_p); + bmqu::MemOutStream osstr(bmqtst::TestHelperUtil::allocator()); osstr << "propName" << i << bsl::ends; ASSERT_EQ(0, p.setPropertyAsInt32(osstr.str(), i)); } @@ -761,14 +784,19 @@ static void test3_binaryPropertyTest() // Ensure that a binary property is set and retrieved correctly. bmqtst::TestHelper::printTestName("'setPropertyAsBinary' TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); const size_t length = 2080; const char binValue = bsl::numeric_limits::max(); - bsl::vector binaryV(length, binValue, s_allocator_p); - const bsl::string binaryN("binPropName", s_allocator_p); + bsl::vector binaryV(length, + binValue, + bmqtst::TestHelperUtil::allocator()); + const bsl::string binaryN("binPropName", + bmqtst::TestHelperUtil::allocator()); - bmqp::MessageProperties p(s_allocator_p); + bmqp::MessageProperties p(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, p.setPropertyAsBinary(binaryN, binaryV)); bmqt::PropertyType::Enum ptype = bmqt::PropertyType::e_UNDEFINED; @@ -783,10 +811,12 @@ static void test4_iteratorTest() // Ensure iterator's functionality is correct. bmqtst::TestHelper::printTestName("'setPropertyAsBinary' TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bmqp::MessageProperties p(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bmqp::MessageProperties p(bmqtst::TestHelperUtil::allocator()); const size_t numProps = 157; - PropertyMap pmap(s_allocator_p); + PropertyMap pmap(bmqtst::TestHelperUtil::allocator()); // Populate 'p' instance with various properties. populateProperties(&p, &pmap, numProps); @@ -806,9 +836,11 @@ static void test5_streamInTest() // Ensure 'streamIn' functionality is correct. bmqtst::TestHelper::printTestName("'streamIn' TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bmqp::MessageProperties p(s_allocator_p); - bdlbb::Blob wireRep(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bmqp::MessageProperties p(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob wireRep(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::MessagePropertiesInfo logic = bmqp::MessagePropertiesInfo::makeNoSchema(); // Empty rep. @@ -818,13 +850,13 @@ static void test5_streamInTest() // Real stuff. const size_t numProps = 207; - PropertyMap pmap(s_allocator_p); + PropertyMap pmap(bmqtst::TestHelperUtil::allocator()); // Populate with various properties. // Note that `dummyP` is used only because `populateProperties` // requires one. - bmqp::MessageProperties dummyP(s_allocator_p); + bmqp::MessageProperties dummyP(bmqtst::TestHelperUtil::allocator()); populateProperties(&dummyP, &pmap, numProps); @@ -855,9 +887,11 @@ static void test6_streamOutTest() // Ensure 'streamOut' functionality is correct. bmqtst::TestHelper::printTestName("'streamOut' TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bdlbb::Blob wireRep(&bufferFactory, s_allocator_p); - bmqp::MessageProperties p(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob wireRep(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bmqp::MessageProperties p(bmqtst::TestHelperUtil::allocator()); bmqp::MessagePropertiesInfo logic = bmqp::MessagePropertiesInfo::makeInvalidSchema(); @@ -867,7 +901,7 @@ static void test6_streamOutTest() // Non empty. const size_t numProps = 187; - PropertyMap pmap(s_allocator_p); + PropertyMap pmap(bmqtst::TestHelperUtil::allocator()); populateProperties(&p, &pmap, numProps); @@ -879,8 +913,10 @@ static void test6_streamOutTest() const bdlbb::Blob& out2 = p.streamOut(&bufferFactory, logic); - bdlbb::PooledBlobBufferFactory bigBufferFactory(1024, s_allocator_p); - bdlbb::Blob buffer(&bigBufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bigBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob buffer(&bigBufferFactory, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, bmqp::ProtocolUtil::convertToOld( @@ -888,7 +924,7 @@ static void test6_streamOutTest() &out2, bmqt::CompressionAlgorithmType::e_NONE, &bufferFactory, - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); // 'streamOut' encodes in the new style, 'encode' - in the old ASSERT_EQ(0, bdlbb::BlobUtil::compare(wireRep, buffer)); @@ -898,7 +934,7 @@ static void test6_streamOutTest() &out2, bmqt::CompressionAlgorithmType::e_NONE, &bufferFactory, - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); // 'streamOut' encodes in the new style, 'encode' - in the old ASSERT_EQ(0, bdlbb::BlobUtil::compare(wireRep, out2)); } @@ -910,21 +946,23 @@ static void test7_streamInOutMixTest() bmqtst::TestHelper::printTestName("'streamIn/Out Mix' TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bdlbb::Blob wireRep(&bufferFactory, s_allocator_p); - bmqp::MessageProperties p(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob wireRep(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bmqp::MessageProperties p(bmqtst::TestHelperUtil::allocator()); bmqp::MessagePropertiesInfo logic = bmqp::MessagePropertiesInfo::makeNoSchema(); // First stream in a valid wire-representation in an instance. const size_t numProps = 37; - PropertyMap pmap(s_allocator_p); + PropertyMap pmap(bmqtst::TestHelperUtil::allocator()); // Populate with various properties. // Note that `dummyP` is used only because `populateProperties` // requires one. - bmqp::MessageProperties dummyP(s_allocator_p); + bmqp::MessageProperties dummyP(bmqtst::TestHelperUtil::allocator()); populateProperties(&dummyP, &pmap, numProps); @@ -952,7 +990,7 @@ static void test7_streamInOutMixTest() // 'wireRep' has now been correctly streamed into 'p'. // Add another property in 'p' so that internal wire rep becomes dirty. - bsl::string newPropName("1111111111", s_allocator_p); + bsl::string newPropName("1111111111", bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, p.setPropertyAsBool(newPropName, false)); ASSERT_EQ(static_cast(numProps + 1), p.numProperties()); @@ -997,21 +1035,27 @@ static void test8_printTest() BSLMF_ASSERT(bmqt::PropertyType::e_BINARY == bmqt::PropertyType::k_HIGHEST_SUPPORTED_PROPERTY_TYPE); - const bsl::string boolN("boolPropName", s_allocator_p); - const bsl::string charN("charPropName", s_allocator_p); - const bsl::string shortN("shortPropName", s_allocator_p); - const bsl::string intN("intPropName", s_allocator_p); - const bsl::string int64N("int64PropName", s_allocator_p); - const bsl::string stringN("stringPropName", s_allocator_p); - const bsl::string binaryN("binaryPropName", s_allocator_p); + const bsl::string boolN("boolPropName", + bmqtst::TestHelperUtil::allocator()); + const bsl::string charN("charPropName", + bmqtst::TestHelperUtil::allocator()); + const bsl::string shortN("shortPropName", + bmqtst::TestHelperUtil::allocator()); + const bsl::string intN("intPropName", bmqtst::TestHelperUtil::allocator()); + const bsl::string int64N("int64PropName", + bmqtst::TestHelperUtil::allocator()); + const bsl::string stringN("stringPropName", + bmqtst::TestHelperUtil::allocator()); + const bsl::string binaryN("binaryPropName", + bmqtst::TestHelperUtil::allocator()); bool boolV = true; char charV = 63; short shortV = 500; int intV = 333; bsls::Types::Int64 int64V = 123LL; - bsl::string stringV(3, 'A', s_allocator_p); - bsl::vector binaryV(15, 255, s_allocator_p); + bsl::string stringV(3, 'A', bmqtst::TestHelperUtil::allocator()); + bsl::vector binaryV(15, 255, bmqtst::TestHelperUtil::allocator()); struct Test { bmqt::PropertyType::Enum d_type; @@ -1033,9 +1077,9 @@ static void test8_printTest() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqp::MessageProperties obj(s_allocator_p); - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqp::MessageProperties obj(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); switch (test.d_type) { case bmqt::PropertyType::e_BOOL: { @@ -1104,10 +1148,12 @@ static void test9_copyAssignTest() { bmqtst::TestHelper::printTestName("COPY AND ASSIGN"); - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bmqp::MessageProperties obj(s_allocator_p); - bdlbb::Blob wireRep(&bufferFactory, s_allocator_p); - PropertyMap pmap(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bmqp::MessageProperties obj(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob wireRep(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + PropertyMap pmap(bmqtst::TestHelperUtil::allocator()); bmqp::MessagePropertiesInfo logic = bmqp::MessagePropertiesInfo::makeNoSchema(); @@ -1118,7 +1164,7 @@ static void test9_copyAssignTest() // Note that `dummyP` is used only because `populateProperties` // requires one. - bmqp::MessageProperties dummyP(s_allocator_p); + bmqp::MessageProperties dummyP(bmqtst::TestHelperUtil::allocator()); populateProperties(&dummyP, &pmap, numProps); @@ -1159,9 +1205,11 @@ static void test10_empty() bmqtst::TestHelper::printTestName("'empty MPs' TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bmqp::MessageProperties p(s_allocator_p); - bdlbb::Blob wireRep(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bmqp::MessageProperties p(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob wireRep(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::MessagePropertiesInfo logic(true, 1, true); // Empty rep. @@ -1183,7 +1231,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -1199,7 +1247,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_optionsview.t.cpp b/src/groups/bmq/bmqp/bmqp_optionsview.t.cpp index b14f2b975..45790d377 100644 --- a/src/groups/bmq/bmqp/bmqp_optionsview.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_optionsview.t.cpp @@ -54,7 +54,8 @@ void verifySubQueueInfos(const bmqp::OptionsView& view, ASSERT(view.isValid()); ASSERT(view.find(bmqp::OptionType::e_SUB_QUEUE_INFOS) != view.end()); - bmqp::Protocol::SubQueueInfosArray retrievedSubQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray retrievedSubQueueInfos( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, view.loadSubQueueInfosOption(&retrievedSubQueueInfos)); ASSERT_EQ(retrievedSubQueueInfos.size(), subQueueInfos.size()); for (size_t i = 0; i < subQueueInfos.size(); ++i) { @@ -75,7 +76,8 @@ void verifySubQueueIdsOld( const size_t numSubQueueIds = subQueueIdsOld.size(); - bmqp::Protocol::SubQueueInfosArray retrievedSubQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray retrievedSubQueueInfos( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, view.loadSubQueueInfosOption(&retrievedSubQueueInfos)); ASSERT_EQ(numSubQueueIds, retrievedSubQueueInfos.size()); for (size_t i = 0; i < numSubQueueIds; ++i) { @@ -85,7 +87,8 @@ void verifySubQueueIdsOld( retrievedSubQueueInfos[i].rdaInfo().isUnlimited()); } - bmqp::Protocol::SubQueueIdsArrayOld retrievedSubQueueIdsOld(s_allocator_p); + bmqp::Protocol::SubQueueIdsArrayOld retrievedSubQueueIdsOld( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, view.loadSubQueueIdsOption(&retrievedSubQueueIdsOld)); ASSERT_EQ(numSubQueueIds, retrievedSubQueueIdsOld.size()); for (size_t i = 0; i < numSubQueueIds; ++i) { @@ -161,7 +164,7 @@ static void generateMsgGroupId(bmqp::Protocol::MsgGroupId* msgGroupId) int seed = bsl::numeric_limits::max(); - bmqu::MemOutStream oss(s_allocator_p); + bmqu::MemOutStream oss(bmqtst::TestHelperUtil::allocator()); oss << "gid:" << bdlb::Random::generate15(&seed); *msgGroupId = oss.str(); } @@ -400,7 +403,9 @@ void test1_breathingTest() // Basic functionality // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); PV(endl << "BREATHING TEST" << endl << "==============" << endl); @@ -409,7 +414,7 @@ void test1_breathingTest() PV("DEFAULT CONSTRUCTOR: INVALID INSTANCE"); // Create invalid instance - bmqp::OptionsView view(s_allocator_p); + bmqp::OptionsView view(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view.isValid()); } @@ -418,8 +423,8 @@ void test1_breathingTest() PV("COPY CONSTRUCTOR: INVALID INSTANCE"); // Create invalid instance from another invalid instance - bmqp::OptionsView view1(s_allocator_p); - bmqp::OptionsView view2(view1, s_allocator_p); + bmqp::OptionsView view1(bmqtst::TestHelperUtil::allocator()); + bmqp::OptionsView view2(view1, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view2.isValid()); } @@ -428,14 +433,15 @@ void test1_breathingTest() PV("BASIC FUNCTIONALITY: ZERO OPTIONS"); // Create valid view, PUSH event with 1 message, zero options - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition optionsAreaPosition; int optionsAreaSize = 0; // Populate blob, 0 options - bsl::vector subQueueInfos(s_allocator_p); + bsl::vector subQueueInfos( + bmqtst::TestHelperUtil::allocator()); size_t numSubQueueIds = 0; - NullableMsgGroupId msgGroupId(s_allocator_p); + NullableMsgGroupId msgGroupId(bmqtst::TestHelperUtil::allocator()); bool hasMsgGroupId = false; populateBlob(&blob, @@ -452,7 +458,7 @@ void test1_breathingTest() bmqp::OptionsView view(&blob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, view.isValid()); ASSERT_EQ(true, @@ -460,7 +466,7 @@ void test1_breathingTest() view.end()); // Copy valid instance - bmqp::OptionsView view2(view, s_allocator_p); + bmqp::OptionsView view2(view, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, view2.isValid()); ASSERT_EQ(true, view2.find(bmqp::OptionType::e_SUB_QUEUE_INFOS) == @@ -477,7 +483,7 @@ void test1_breathingTest() view2.end()); // Copy invalid instance (original) - bmqp::OptionsView view3(view, s_allocator_p); + bmqp::OptionsView view3(view, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view3.isValid()); // Reset original, iterate and verify again @@ -495,14 +501,15 @@ void test1_breathingTest() // Create valid view, PUSH event with 1 message, 1 option header and // 1 sub-queue id - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition optionsAreaPosition; int optionsAreaSize = 0; // Populate blob, 1 option header and 1 sub-queue id - bsl::vector subQueueInfos(s_allocator_p); + bsl::vector subQueueInfos( + bmqtst::TestHelperUtil::allocator()); size_t numSubQueueIds = 1; - NullableMsgGroupId msgGroupId(s_allocator_p); + NullableMsgGroupId msgGroupId(bmqtst::TestHelperUtil::allocator()); bool hasMsgGroupId = false; populateBlob(&blob, @@ -531,11 +538,11 @@ void test1_breathingTest() bmqp::OptionsView view(&blob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); verifySubQueueInfos(view, subQueueInfos); // Copy valid instance - bmqp::OptionsView view2(view, s_allocator_p); + bmqp::OptionsView view2(view, bmqtst::TestHelperUtil::allocator()); verifySubQueueInfos(view2, subQueueInfos); // Clear original @@ -546,7 +553,7 @@ void test1_breathingTest() verifySubQueueInfos(view2, subQueueInfos); // Copy invalid instance (original) - bmqp::OptionsView view3(view, s_allocator_p); + bmqp::OptionsView view3(view, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view3.isValid()); // Reset original, iterate and verify again @@ -559,14 +566,15 @@ void test1_breathingTest() PV("BASIC FUNCTIONALITY: ONE OPTION HEADER, MULTIPLE OPTION VALUES"); // Create valid view, PUSH event with 3 sub-queue ids - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition optionsAreaPosition; int optionsAreaSize = 0; // Populate blob, 1 option header, multiple sub-queue ids) - bsl::vector subQueueInfos(s_allocator_p); + bsl::vector subQueueInfos( + bmqtst::TestHelperUtil::allocator()); size_t numSubQueueIds = 3; - NullableMsgGroupId msgGroupId(s_allocator_p); + NullableMsgGroupId msgGroupId(bmqtst::TestHelperUtil::allocator()); bool hasMsgGroupId = false; populateBlob(&blob, @@ -583,11 +591,11 @@ void test1_breathingTest() bmqp::OptionsView view(&blob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); verifySubQueueInfos(view, subQueueInfos); // Copy valid instance, iterate and verify - bmqp::OptionsView view2(view, s_allocator_p); + bmqp::OptionsView view2(view, bmqtst::TestHelperUtil::allocator()); verifySubQueueInfos(view2, subQueueInfos); // Clear original @@ -599,7 +607,7 @@ void test1_breathingTest() verifySubQueueInfos(view2, subQueueInfos); // Copy invalid instance (original) - bmqp::OptionsView view3(view, s_allocator_p); + bmqp::OptionsView view3(view, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view3.isValid()); // Reset original, iterate and verify again @@ -613,14 +621,15 @@ void test1_breathingTest() "VALUES INCLUDING GROUP ID"); // Create valid view, PUSH event with 3 sub-queue ids - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition optionsAreaPosition; int optionsAreaSize = 0; // Populate blob, 1 option header, multiple sub-queue ids) - bsl::vector subQueueInfos(s_allocator_p); + bsl::vector subQueueInfos( + bmqtst::TestHelperUtil::allocator()); size_t numSubQueueIds = 3; - NullableMsgGroupId msgGroupId(s_allocator_p); + NullableMsgGroupId msgGroupId(bmqtst::TestHelperUtil::allocator()); bool hasMsgGroupId = true; populateBlob(&blob, @@ -637,17 +646,18 @@ void test1_breathingTest() bmqp::OptionsView view(&blob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); verifySubQueueInfos(view, subQueueInfos); ASSERT_EQ(true, !msgGroupId.isNull()); ASSERT_EQ(true, view.find(bmqp::OptionType::e_MSG_GROUP_ID) != view.end()); - bmqp::Protocol::MsgGroupId readGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId readGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, view.loadMsgGroupIdOption(&readGroupId)); ASSERT_EQ(readGroupId, msgGroupId.value()); // Copy valid instance, iterate and verify - bmqp::OptionsView view2(view, s_allocator_p); + bmqp::OptionsView view2(view, bmqtst::TestHelperUtil::allocator()); verifySubQueueInfos(view2, subQueueInfos); ASSERT_EQ(true, view2.find(bmqp::OptionType::e_MSG_GROUP_ID) != view2.end()); @@ -668,7 +678,7 @@ void test1_breathingTest() ASSERT_EQ(readGroupId, msgGroupId.value()); // Copy invalid instance (original) - bmqp::OptionsView view3(view, s_allocator_p); + bmqp::OptionsView view3(view, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view3.isValid()); // Reset original, iterate and verify again @@ -704,17 +714,20 @@ void test2_subQueueIdsOld() { PV(endl << "SUB QUEUE IDS OLD" << endl << "=================" << endl); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); // Create valid view, PUSH event with 3 old sub-queue ids - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition optionsAreaPosition; int optionsAreaSize = 0; // Populate blob, 1 option header, multiple old sub-queue ids) - bsl::vector subQueueIdsOld(s_allocator_p); + bsl::vector subQueueIdsOld( + bmqtst::TestHelperUtil::allocator()); size_t numSubQueueIds = 3; - NullableMsgGroupId msgGroupId(s_allocator_p); + NullableMsgGroupId msgGroupId(bmqtst::TestHelperUtil::allocator()); bool hasMsgGroupId = false; populateBlob(&blob, @@ -731,11 +744,11 @@ void test2_subQueueIdsOld() bmqp::OptionsView view(&blob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); verifySubQueueIdsOld(view, subQueueIdsOld); // Copy valid instance, iterate and verify - bmqp::OptionsView view2(view, s_allocator_p); + bmqp::OptionsView view2(view, bmqtst::TestHelperUtil::allocator()); verifySubQueueIdsOld(view2, subQueueIdsOld); // Clear original @@ -746,7 +759,7 @@ void test2_subQueueIdsOld() verifySubQueueIdsOld(view2, subQueueIdsOld); // Copy invalid instance (original) - bmqp::OptionsView view3(view, s_allocator_p); + bmqp::OptionsView view3(view, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view3.isValid()); // Reset original, iterate and verify again @@ -773,14 +786,17 @@ void test3_packedOptions() // loadSubQueueIdsOption(...) // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); // Create valid view, PUSH event with a *packed* sub-queue id option - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition optionsAreaPosition; int optionsAreaSize = 0; - bsl::vector subQueueInfos(s_allocator_p); + bsl::vector subQueueInfos( + bmqtst::TestHelperUtil::allocator()); populatePackedBlob(&blob, &optionsAreaPosition, &optionsAreaSize, @@ -790,11 +806,11 @@ void test3_packedOptions() bmqp::OptionsView view(&blob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); verifySubQueueInfos(view, subQueueInfos); // Copy valid instance, iterate and verify - bmqp::OptionsView view2(view, s_allocator_p); + bmqp::OptionsView view2(view, bmqtst::TestHelperUtil::allocator()); verifySubQueueInfos(view2, subQueueInfos); // Clear original @@ -805,7 +821,7 @@ void test3_packedOptions() verifySubQueueInfos(view2, subQueueInfos); // Copy invalid instance (original) - bmqp::OptionsView view3(view, s_allocator_p); + bmqp::OptionsView view3(view, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view3.isValid()); // Reset original, iterate and verify again @@ -839,7 +855,9 @@ void test4_invalidOptionsArea() << "INVALID OPTIONS AREA" << endl << "====================" << endl); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { // [1] @@ -851,7 +869,8 @@ void test4_invalidOptionsArea() // the responsibility of the user. This means that an option header // could lie to us that it has bigger payload than it actually has in // the blob and the view will still be valid. - bdlbb::Blob optionsBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob optionsBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition optionsAreaPosition; // start of blob int numSubQueueInfos = 6; @@ -870,7 +889,8 @@ void test4_invalidOptionsArea() sizeof(bmqp::OptionHeader)); // Write option payload minus one subQueueInfo - bsl::vector subQueueInfos(s_allocator_p); + bsl::vector subQueueInfos( + bmqtst::TestHelperUtil::allocator()); generateSubQueueInfos(&subQueueInfos, numSubQueueInfos - 1); // one less than expected by OptionHeader's 'words()' @@ -883,7 +903,7 @@ void test4_invalidOptionsArea() bmqp::OptionsView view(&optionsBlob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, view.isValid()); // The view is valid despite the inconsistency. @@ -894,7 +914,8 @@ void test4_invalidOptionsArea() PV("OPTION HEADER INDICATES ZERO OPTION VALUES"); // An OptionsHeader but no option payload (sub-queue info) - bdlbb::Blob optionsBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob optionsBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); const bmqu::BlobPosition optionsAreaPosition; // start of blob const int optionsAreaSize = sizeof(bmqp::OptionHeader); @@ -911,7 +932,7 @@ void test4_invalidOptionsArea() bmqp::OptionsView view(&optionsBlob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view.isValid()); } @@ -921,7 +942,8 @@ void test4_invalidOptionsArea() PV("OPTION HEADER WITH TYPE UNDEFINED"); // An OptionHeader with type 'OptionType::e_UNDEFINED' - bdlbb::Blob optionsBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob optionsBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); const bmqu::BlobPosition optionsAreaPosition; // start of blob const int numSubQueueInfos = 1; @@ -941,7 +963,8 @@ void test4_invalidOptionsArea() // Write option payload (not really necessary but just to differentiate // it from the test case where there's only an OptionHeader). - bsl::vector subQueueInfos(s_allocator_p); + bsl::vector subQueueInfos( + bmqtst::TestHelperUtil::allocator()); generateSubQueueInfos(&subQueueInfos, numSubQueueInfos); bdlbb::BlobUtil::append( @@ -953,7 +976,7 @@ void test4_invalidOptionsArea() bmqp::OptionsView view(&optionsBlob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view.isValid()); } @@ -963,7 +986,8 @@ void test4_invalidOptionsArea() PV("OPTION HEADER WITH UNSUPPORTED TYPES"); // #1: An OptionHeader with an unsupported type - bdlbb::Blob optionsBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob optionsBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); const bmqu::BlobPosition optionsAreaPosition; // start of blob const int numSubQueueInfos = 2; @@ -985,7 +1009,8 @@ void test4_invalidOptionsArea() sizeof(bmqp::OptionHeader)); // Write option payload - bsl::vector subQueueInfos(s_allocator_p); + bsl::vector subQueueInfos( + bmqtst::TestHelperUtil::allocator()); generateSubQueueInfos(&subQueueInfos, numSubQueueInfos); bdlbb::BlobUtil::append( @@ -997,7 +1022,7 @@ void test4_invalidOptionsArea() bmqp::OptionsView view1(&optionsBlob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view1.isValid()); @@ -1016,7 +1041,7 @@ void test4_invalidOptionsArea() bmqp::OptionsView view2(&optionsBlob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view2.isValid()); } @@ -1026,7 +1051,8 @@ void test4_invalidOptionsArea() PV("MULTIPLE OPTION HEADERS OF THE SAME TYPE (DUPLICATE)"); // Multiple OptionHeader of the same type (duplicate) - bdlbb::Blob optionsBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob optionsBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); const bmqu::BlobPosition optionsAreaPosition; // start of blob const int numSubQueueInfos = 2; @@ -1045,7 +1071,8 @@ void test4_invalidOptionsArea() sizeof(bmqp::OptionHeader)); // Write option payload - bsl::vector subQueueInfos(s_allocator_p); + bsl::vector subQueueInfos( + bmqtst::TestHelperUtil::allocator()); generateSubQueueInfos(&subQueueInfos, numSubQueueInfos); bdlbb::BlobUtil::append( @@ -1082,7 +1109,7 @@ void test4_invalidOptionsArea() bmqp::OptionsView view(&optionsBlob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view.isValid()); } @@ -1090,7 +1117,8 @@ void test4_invalidOptionsArea() // [6] PV("EMPTY BLOB"); - bdlbb::Blob optionsBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob optionsBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); const bmqu::BlobPosition optionsAreaPosition; // start of blob const int optionsAreaSize = sizeof(bmqp::OptionHeader); @@ -1101,7 +1129,7 @@ void test4_invalidOptionsArea() bmqp::OptionsView view(&optionsBlob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view.isValid()); } @@ -1109,7 +1137,8 @@ void test4_invalidOptionsArea() // [7] PV("WRONG AREA SIZE FOR OPTION VIEW"); - bdlbb::Blob optionsBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob optionsBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); const bmqu::BlobPosition optionsAreaPosition; // start of blob const int numSubQueueInfos = 6; @@ -1128,7 +1157,8 @@ void test4_invalidOptionsArea() sizeof(bmqp::OptionHeader)); // Write option payload - bsl::vector subQueueInfos(s_allocator_p); + bsl::vector subQueueInfos( + bmqtst::TestHelperUtil::allocator()); generateSubQueueInfos(&subQueueInfos, numSubQueueInfos); bdlbb::BlobUtil::append( @@ -1140,7 +1170,7 @@ void test4_invalidOptionsArea() bmqp::OptionsView view(&optionsBlob, optionsAreaPosition, optionsAreaSize - 1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, view.isValid()); } @@ -1166,19 +1196,22 @@ void test5_iteratorTest() // // ------------------------------------------------------------------------ - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); PV("OPTIONS VIEW ITERATOR FUNCTIONALITY TEST"); // Create valid view, PUSH event with 3 sub-queue ids - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition optionsAreaPosition; int optionsAreaSize = 0; // Populate blob, 1 option header, multiple sub-queue ids - bsl::vector subQueueIds(s_allocator_p); + bsl::vector subQueueIds( + bmqtst::TestHelperUtil::allocator()); size_t numSubQueueIds = 3; - NullableMsgGroupId msgGroupId(s_allocator_p); + NullableMsgGroupId msgGroupId(bmqtst::TestHelperUtil::allocator()); bool hasMsgGroupId = true; populateBlob(&blob, @@ -1195,7 +1228,7 @@ void test5_iteratorTest() bmqp::OptionsView view(&blob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT(view.isValid()); bmqp::OptionsView::const_iterator iter = view.begin(); @@ -1243,19 +1276,22 @@ void test6_iteratorTestSubQueueIdsOld() // // ------------------------------------------------------------------------ - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); PV("OPTIONS VIEW ITERATOR FUNCTIONALITY TEST (SUB QUEUE IDS OLD)"); // Create valid view, PUSH event with 3 old version sub-queue ids - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition optionsAreaPosition; int optionsAreaSize = 0; // Populate blob, 1 option header, multiple sub-queue ids - bsl::vector subQueueIdsOld(s_allocator_p); + bsl::vector subQueueIdsOld( + bmqtst::TestHelperUtil::allocator()); size_t numSubQueueIds = 3; - NullableMsgGroupId msgGroupId(s_allocator_p); + NullableMsgGroupId msgGroupId(bmqtst::TestHelperUtil::allocator()); bool hasMsgGroupId = true; populateBlob(&blob, @@ -1272,7 +1308,7 @@ void test6_iteratorTestSubQueueIdsOld() bmqp::OptionsView view(&blob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT(view.isValid()); bmqp::OptionsView::const_iterator iter = view.begin(); @@ -1319,20 +1355,23 @@ void test7_dumpBlob() // Testing: // void dumpBlob(bsl::ostream& stream); // -------------------------------------------------------------------- - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); PV("DUMP BLOB: ONE OPTION HEADER, MULTIPLE OPTION VALUES"); // Create valid view, PUSH event with 3 sub-queue ids - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition optionsAreaPosition; int optionsAreaSize = 0; - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); // Populate blob, 1 option header, multiple sub-queue ids) - bsl::vector subQueueIds(s_allocator_p); + bsl::vector subQueueIds( + bmqtst::TestHelperUtil::allocator()); size_t numSubQueueIds = 3; - NullableMsgGroupId msgGroupId(s_allocator_p); + NullableMsgGroupId msgGroupId(bmqtst::TestHelperUtil::allocator()); bool hasMsgGroupId = true; populateBlob(&blob, @@ -1350,11 +1389,11 @@ void test7_dumpBlob() bmqp::OptionsView view(&blob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(view.isValid()); // Dump blob view.dumpBlob(stream); - bsl::string str1(stream.str(), s_allocator_p); + bsl::string str1(stream.str(), bmqtst::TestHelperUtil::allocator()); bsl::string str2(" 0: 00000054 44020000 40000013 00000B08 " "|...TD...@.......|\n" " 16: 0000007B 00000000 00000000 00000000 " @@ -1367,7 +1406,7 @@ void test7_dumpBlob() "|........gid:1592|\n" " 80: 39030303 " "|9... |\n", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Verify that dump contains expected value ASSERT_EQ(str1, str2); stream.reset(); @@ -1375,12 +1414,12 @@ void test7_dumpBlob() // Create view without blob { - bmqp::OptionsView view(s_allocator_p); + bmqp::OptionsView view(bmqtst::TestHelperUtil::allocator()); // Dump blob view.dumpBlob(stream); - bsl::string str1(stream.str(), s_allocator_p); - bsl::string str2("/no blob/", s_allocator_p); + bsl::string str1(stream.str(), bmqtst::TestHelperUtil::allocator()); + bsl::string str2("/no blob/", bmqtst::TestHelperUtil::allocator()); // Verify that dump contains expected value ASSERT_EQ(str1, str2); @@ -1405,21 +1444,24 @@ void test8_dumpBlobSubQueueIdsOld() // Testing: // void dumpBlob(bsl::ostream& stream); // -------------------------------------------------------------------- - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); PV("DUMP BLOB: ONE OPTION HEADER, MULTIPLE OPTION VALUES " "(SUB QUEUE IDS OLD)"); // Create valid view, PUSH event with 3 old version sub-queue ids - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition optionsAreaPosition; int optionsAreaSize = 0; - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); // Populate blob, 1 option header, multiple sub-queue ids) - bsl::vector subQueueIdsOld(s_allocator_p); + bsl::vector subQueueIdsOld( + bmqtst::TestHelperUtil::allocator()); size_t numSubQueueIds = 3; - NullableMsgGroupId msgGroupId(s_allocator_p); + NullableMsgGroupId msgGroupId(bmqtst::TestHelperUtil::allocator()); bool hasMsgGroupId = true; populateBlob(&blob, @@ -1437,11 +1479,11 @@ void test8_dumpBlobSubQueueIdsOld() bmqp::OptionsView view(&blob, optionsAreaPosition, optionsAreaSize, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Dump blob view.dumpBlob(stream); - bsl::string str1(stream.str(), s_allocator_p); + bsl::string str1(stream.str(), bmqtst::TestHelperUtil::allocator()); bsl::string str2(" 0: 00000048 44020000 40000010 00000808 " "|...HD...@.......|\n" " 16: 0000007B 00000000 00000000 00000000 " @@ -1452,7 +1494,7 @@ void test8_dumpBlobSubQueueIdsOld() "|...9..&.....gid:|\n" " 64: 31353932 39030303 " "|15929... |\n", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Verify that dump contains expected value ASSERT_EQ(str1, str2); @@ -1470,7 +1512,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -1484,7 +1526,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_optionutil.t.cpp b/src/groups/bmq/bmqp/bmqp_optionutil.t.cpp index e3c93ebd7..d030eafb0 100644 --- a/src/groups/bmq/bmqp/bmqp_optionutil.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_optionutil.t.cpp @@ -50,9 +50,9 @@ LimitT maxCanBeAdded(const int contentSize, const int payloadSize) bdlbb::PooledBlobBufferFactory bufferFactory( bmqp::EventHeader::k_MAX_SIZE_SOFT, - s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); - bsl::string payload(payloadSize, 'a', s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bsl::string payload(payloadSize, 'a', bmqtst::TestHelperUtil::allocator()); const OptionMeta meta = OptionMeta::forOption(type, payloadSize); OptionsBox box; LimitT limit(0, Result::e_SUCCESS); @@ -334,8 +334,8 @@ static void test3_checkOptionsBlobSegment() // Initialize the blob and add header bdlbb::PooledBlobBufferFactory bufferFactory( bmqp::EventHeader::k_MAX_SIZE_SOFT, - s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bsl::string header = "...."; // Fake headers int headerSize = header.size(); bdlbb::BlobUtil::append(&blob, header.c_str(), headerSize); @@ -411,10 +411,10 @@ static void test4_isValidMsgGroupId() const bmqp::Protocol::MsgGroupId maxLength( "1234567890123456789012345678901", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); const bmqp::Protocol::MsgGroupId overMaxLength( "12345678901234567890123456789012", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); #ifdef BMQ_ENABLE_MSG_GROUPID ASSERT_EQ(Result::e_INVALID_MSG_GROUP_ID, @@ -437,7 +437,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -449,7 +449,7 @@ int main(int argc, char* argv[]) case 1: test1_basicOptionMetaProperties(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_protocol.t.cpp b/src/groups/bmq/bmqp/bmqp_protocol.t.cpp index 48e107590..6511c4a82 100644 --- a/src/groups/bmq/bmqp/bmqp_protocol.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_protocol.t.cpp @@ -1115,7 +1115,7 @@ static void test3_flagUtils() bmqp::PutHeaderFlagUtil::setFlag(&flags, test.d_value); ASSERT(bmqp::PutHeaderFlagUtil::isSet(flags, test.d_value)); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); bmqp::PutHeaderFlagUtil::prettyPrint(out, flags); const bslstl::StringRef& flagsString = out.str(); for (int currFlagVal = 1; @@ -1138,7 +1138,7 @@ static void test3_flagUtils() // 3. Verify that, with this flag set, the flags are correctly // identified as 'isValid' or not 'isValid'. - bmqu::MemOutStream errDesc(s_allocator_p); + bmqu::MemOutStream errDesc(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bmqp::PutHeaderFlagUtil::isValid(errDesc, flags), test.d_isValid); @@ -1180,7 +1180,7 @@ static void test3_flagUtils() bmqp::PushHeaderFlagUtil::setFlag(&flags, test.d_value); ASSERT(bmqp::PushHeaderFlagUtil::isSet(flags, test.d_value)); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); bmqp::PushHeaderFlagUtil::prettyPrint(out, flags); const bslstl::StringRef& flagsString = out.str(); for (int currFlagVal = 1; @@ -1203,7 +1203,7 @@ static void test3_flagUtils() // 3. Verify that, with this flag set, the flags are correctly // identified as 'isValid' or not 'isValid'. - bmqu::MemOutStream errDesc(s_allocator_p); + bmqu::MemOutStream errDesc(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bmqp::PushHeaderFlagUtil::isValid(errDesc, flags), test.d_isValid); @@ -1250,7 +1250,7 @@ static void test3_flagUtils() static_cast(flags), test.d_value)); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); bmqp::StorageHeaderFlagUtil::prettyPrint( out, static_cast(flags)); @@ -1277,7 +1277,7 @@ static void test3_flagUtils() // 3. Verify that, with this flag set, the flags are correctly // identified as 'isValid' or not 'isValid'. - bmqu::MemOutStream errDesc(s_allocator_p); + bmqu::MemOutStream errDesc(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(bmqp::StorageHeaderFlagUtil::isValid( errDesc, static_cast(flags)), @@ -1300,8 +1300,8 @@ static void printEnumHelper(ARRAY (&data)[SIZE]) PVVV("Line [" << test.d_line << "]"); - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); typedef typename ENUM_TYPE::Enum T; @@ -1574,7 +1574,7 @@ static void test5_enumIsomorphism() PV("Check isomorphism for " #ENUM_VAL " value of " #ENUM_TYPE \ " enum"); \ typedef bmqp::ENUM_TYPE T; \ - bmqu::MemOutStream stream(s_allocator_p); \ + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); \ \ T::Enum obj; \ const char* str; \ @@ -1617,7 +1617,7 @@ static void enumFromStringHelper(FLAG_TYPE expectedFlags, const bsl::string& incorrStr, const bsl::string& errOutput) { - bmqu::MemOutStream errStream(s_allocator_p); + bmqu::MemOutStream errStream(bmqtst::TestHelperUtil::allocator()); FLAG_TYPE outFlags; int rc; rc = ENUM_UTIL_TYPE::fromString(errStream, &outFlags, corrStr); @@ -1661,11 +1661,12 @@ static void test6_enumFromString() bmqp::PushHeaderFlags::e_UNUSED4; bsl::string corrStr( "IMPLICIT_PAYLOAD,MESSAGE_PROPERTIES,OUT_OF_ORDER,UNUSED4", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bsl::string incorrStr( "IMPLICIT_PAYLOAD,MESSAGE_PROPERTIES,OUT_OF_ORDER,INVLD1,INVLD2", - s_allocator_p); - bsl::string errOutput("Invalid flag(s) 'INVLD1','INVLD2'", s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::string errOutput("Invalid flag(s) 'INVLD1','INVLD2'", + bmqtst::TestHelperUtil::allocator()); enumFromStringHelper(expectedFlags, corrStr, incorrStr, @@ -1772,7 +1773,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_protocolutil.t.cpp b/src/groups/bmq/bmqp/bmqp_protocolutil.t.cpp index e87730d53..1aace00a0 100644 --- a/src/groups/bmq/bmqp/bmqp_protocolutil.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_protocolutil.t.cpp @@ -83,10 +83,12 @@ static void test1_initializeShutdown() // 2. Should be able to call 'initialize()' after the instance has already // started and have no effect. // Initialize the 'ProtocolUtil' - ASSERT_SAFE_PASS(bmqp::ProtocolUtil::initialize(s_allocator_p)); + ASSERT_SAFE_PASS( + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator())); // 'initialize' should be a no-op - ASSERT_SAFE_PASS(bmqp::ProtocolUtil::initialize(s_allocator_p)); + ASSERT_SAFE_PASS( + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator())); // 3. Should be able to call 'shutdown' after already calling 'shutdown' // and have no effect, provided that the number of calls to 'shutdown' @@ -102,7 +104,8 @@ static void test1_initializeShutdown() ASSERT_SAFE_FAIL(bmqp::ProtocolUtil::shutdown()); // 4. It is safe to call 'initialize' after calling 'shutdown'. - ASSERT_SAFE_PASS(bmqp::ProtocolUtil::initialize(s_allocator_p)); + ASSERT_SAFE_PASS( + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator())); // Finally, shutdown the 'ProtocolUtil' ASSERT_SAFE_PASS(bmqp::ProtocolUtil::shutdown()); @@ -233,7 +236,7 @@ static void test3_calcNumWordsAndPadding() { bmqtst::TestHelper::printTestName("CALC NUM WORDS AND PADDING"); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -299,7 +302,7 @@ static void test4_paddingChar() { bmqtst::TestHelper::printTestName("APPEND PADDING (char)"); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); PV("WORD"); { @@ -386,13 +389,15 @@ static void test5_paddingBlob() { bmqtst::TestHelper::printTestName("APPEND PADDING (blob)"); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); PV("blob with enough capacity in last buffer"); { - bdlbb::PooledBlobBufferFactory bufferFactory(5, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 5, + bmqtst::TestHelperUtil::allocator()); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Initialize the blob: it will have one buffer of capacity 5, and a // total size of 3. @@ -413,9 +418,11 @@ static void test5_paddingBlob() PV("blob without enough capacity in last buffer"); { - bdlbb::PooledBlobBufferFactory bufferFactory(5, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 5, + bmqtst::TestHelperUtil::allocator()); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Initialize the blob: it will have one buffer of capacity 5, and a // total size of 3. @@ -446,9 +453,11 @@ static void test5_paddingBlob() PV("append padding"); { - bdlbb::PooledBlobBufferFactory bufferFactory(5, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 5, + bmqtst::TestHelperUtil::allocator()); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Initialize the blob: it will have one buffer of capacity 5, and a // total size of 3. @@ -487,7 +496,7 @@ static void test6_heartbeatAndEmptyBlobs() { bmqtst::TestHelper::printTestName("HEARTBEAT BLOBS"); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); PV("Verifying the HeartbeatReq blob") { @@ -639,28 +648,30 @@ static void test9_loadFieldValues() { bmqtst::TestHelper::printTestName("LOAD FIELD VALUES"); // Disable check that no memory was allocated from the default allocator - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; - const bsl::string field1("f1", s_allocator_p); - const bsl::string val1("v1", s_allocator_p); - const bsl::string val2("v2", s_allocator_p); - const bsl::string val3("v3", s_allocator_p); + const bsl::string field1("f1", bmqtst::TestHelperUtil::allocator()); + const bsl::string val1("v1", bmqtst::TestHelperUtil::allocator()); + const bsl::string val2("v2", bmqtst::TestHelperUtil::allocator()); + const bsl::string val3("v3", bmqtst::TestHelperUtil::allocator()); const unsigned int field1NumVal = 3; - const bsl::string field2("f2", s_allocator_p); - const bsl::string val4("v4", s_allocator_p); + const bsl::string field2("f2", bmqtst::TestHelperUtil::allocator()); + const bsl::string val4("v4", bmqtst::TestHelperUtil::allocator()); const unsigned int field2NumVal = 1; - const bsl::string emptyField("fEmpty", s_allocator_p); + const bsl::string emptyField("fEmpty", + bmqtst::TestHelperUtil::allocator()); const bsl::string featureSet(field1 + ":" + val1 + "," + val2 + "," + val3 + ";" + field2 + ":" + val4 + ";" + emptyField, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); PV("Load valid fields"); { - bsl::vector field1Values(s_allocator_p); + bsl::vector field1Values( + bmqtst::TestHelperUtil::allocator()); ASSERT(bmqp::ProtocolUtil::loadFieldValues(&field1Values, field1, @@ -670,7 +681,8 @@ static void test9_loadFieldValues() ASSERT_EQ(val2, field1Values[1]); ASSERT_EQ(val3, field1Values[2]); - bsl::vector field2Values(s_allocator_p); + bsl::vector field2Values( + bmqtst::TestHelperUtil::allocator()); ASSERT(bmqp::ProtocolUtil::loadFieldValues(&field2Values, field2, @@ -679,7 +691,8 @@ static void test9_loadFieldValues() ASSERT_EQ(val4, field2Values[0]); PVV("Load field with no specified value"); - bsl::vector emptyFieldValues(s_allocator_p); + bsl::vector emptyFieldValues( + bmqtst::TestHelperUtil::allocator()); ASSERT(bmqp::ProtocolUtil::loadFieldValues(&emptyFieldValues, emptyField, @@ -689,8 +702,10 @@ static void test9_loadFieldValues() PV("Load invalid field"); { - bsl::vector invalidFieldValues(s_allocator_p); - const bsl::string invalidField("invalidField", s_allocator_p); + bsl::vector invalidFieldValues( + bmqtst::TestHelperUtil::allocator()); + const bsl::string invalidField("invalidField", + bmqtst::TestHelperUtil::allocator()); ASSERT(!bmqp::ProtocolUtil::loadFieldValues(&invalidFieldValues, invalidField, @@ -700,8 +715,11 @@ static void test9_loadFieldValues() PV("Load from malformed feature set"); { - bsl::vector field1Values(s_allocator_p); - const bsl::string malformedFeatureSet(field1 + ":", s_allocator_p); + bsl::vector field1Values( + bmqtst::TestHelperUtil::allocator()); + const bsl::string malformedFeatureSet( + field1 + ":", + bmqtst::TestHelperUtil::allocator()); ASSERT(!bmqp::ProtocolUtil::loadFieldValues(&field1Values, field1, @@ -714,8 +732,10 @@ template static void encodeDecodeHelper(E encodingType) { bmqu::MemOutStream ms; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::ClusterMessage clusterMessage; bmqp_ctrlmsg::LeaderAdvisoryCommit commit; @@ -774,7 +794,7 @@ static void test10_encodeDecodeMessage() // decodeMessage // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // The default allocator check fails in this test case because the // 'loggedMessages' methods of Encoder returns a memory-aware object // without utilizing the parameter allocator. @@ -834,16 +854,19 @@ static void test11_parseMessageProperties() // // ------------------------------------------------------------------------ { - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); bmqtst::TestHelper::printTestName("TEST PARSING"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::MessageProperties in(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::MessageProperties in(bmqtst::TestHelperUtil::allocator()); encode(&in); const int queueId = 4; - bmqp::PutEventBuilder peb(&bufferFactory, s_allocator_p); - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(&bufferFactory, bmqtst::TestHelperUtil::allocator()); populateBlob(&payload, 2 * bmqp::Protocol::k_COMPRESSION_MIN_APPDATA_SIZE); @@ -857,21 +880,25 @@ static void test11_parseMessageProperties() ASSERT_EQ(bmqt::EventBuilderResult::e_SUCCESS, builderResult); - bmqp::PutMessageIterator putIt(&bufferFactory, s_allocator_p, true); - bmqp::Event rawEvent(&peb.blob(), s_allocator_p); + bmqp::PutMessageIterator putIt(&bufferFactory, + bmqtst::TestHelperUtil::allocator(), + true); + bmqp::Event rawEvent(&peb.blob(), bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_SAFE(rawEvent.isPutEvent()); rawEvent.loadPutMessageIterator(&putIt); ASSERT_EQ(1, putIt.next()); - bdlbb::Blob payloadIn(&bufferFactory, s_allocator_p); + bdlbb::Blob payloadIn(&bufferFactory, bmqtst::TestHelperUtil::allocator()); putIt.loadApplicationData(&payloadIn); - bdlbb::Blob msgPropertiesBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob msgPropertiesBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int messagePropertiesSize = 0; - bdlbb::Blob payloadOut(&bufferFactory, s_allocator_p); + bdlbb::Blob payloadOut(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int rc = bmqp::ProtocolUtil::parse(&msgPropertiesBlob, &messagePropertiesSize, &payloadOut, @@ -883,9 +910,9 @@ static void test11_parseMessageProperties() true, // new style peb.compressionAlgorithmType(), &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, rc); - bmqp::MessageProperties out(s_allocator_p); + bmqp::MessageProperties out(bmqtst::TestHelperUtil::allocator()); out.streamIn(msgPropertiesBlob, true); verify(out); @@ -920,7 +947,7 @@ int main(int argc, char* argv[]) case 1: test1_initializeShutdown(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_pusheventbuilder.t.cpp b/src/groups/bmq/bmqp/bmqp_pusheventbuilder.t.cpp index 75959ac81..89279dedf 100644 --- a/src/groups/bmq/bmqp/bmqp_pusheventbuilder.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_pusheventbuilder.t.cpp @@ -156,7 +156,7 @@ static void generateMsgGroupId(bmqp::Protocol::MsgGroupId* msgGroupId) // PRECONDITIONS BSLS_ASSERT_OPT(msgGroupId); - bmqu::MemOutStream oss(s_allocator_p); + bmqu::MemOutStream oss(bmqtst::TestHelperUtil::allocator()); oss << "gid:" << generateRandomInteger(0, 120); *msgGroupId = oss.str(); } @@ -270,8 +270,11 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); const int queueId = 4321; const bmqt::MessageGUID guid; @@ -282,14 +285,15 @@ static void test1_breathingTest() // Use a value for 'numSubQueueInfos' which extends beyond 'static' part of // the 'SubQueueInfosArray'. - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&payload, buffer, bsl::strlen(buffer)); ASSERT_EQ(static_cast(payload.length()), bsl::strlen(buffer)); // Create PushEventBuilder - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(sizeof(bmqp::EventHeader), static_cast(peb.eventSize())); ASSERT_EQ(sizeof(bmqp::EventHeader), static_cast(peb.blob().length())); @@ -320,12 +324,13 @@ static void test1_breathingTest() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = peb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_SAFE(true == rawEvent.isValid()); BSLS_ASSERT_SAFE(true == rawEvent.isPushEvent()); - bmqp::PushMessageIterator pushIter(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator pushIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPushMessageIterator(&pushIter, true); ASSERT_EQ(true, pushIter.isValid()); @@ -337,7 +342,7 @@ static void test1_breathingTest() ASSERT_EQ(guid, pushIter.header().messageGUID()); ASSERT_EQ(bmqt::CompressionAlgorithmType::e_NONE, pushIter.header().compressionAlgorithmType()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadMessagePayload(&payloadBlob)); ASSERT_EQ(payload.length(), pushIter.messagePayloadSize()); @@ -347,14 +352,15 @@ static void test1_breathingTest() ASSERT_EQ(0, bdlbb::BlobUtil::compare(payload, payloadBlob)); ASSERT_EQ(true, pushIter.hasOptions()); - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadOptionsView(&optionsView)); ASSERT_EQ(true, optionsView.isValid()); ASSERT_EQ(true, optionsView.find(bmqp::OptionType::e_SUB_QUEUE_INFOS) != optionsView.end()); - bmqp::Protocol::SubQueueInfosArray retrievedSubQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray retrievedSubQueueInfos( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, optionsView.loadSubQueueInfosOption(&retrievedSubQueueInfos)); ASSERT_EQ(subQueueInfos.size(), retrievedSubQueueInfos.size()); @@ -384,8 +390,11 @@ static void test2_buildEventBackwardsCompatibility() { bmqtst::TestHelper::printTestName("BACKWARDS COMPATIBILITY"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); const int queueId = 4321; const bmqt::MessageGUID guid; @@ -396,14 +405,15 @@ static void test2_buildEventBackwardsCompatibility() // Use a value for 'numSubQueueInfos' which extends beyond 'static' part of // the 'SubQueueInfosArray'. - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&payload, buffer, bsl::strlen(buffer)); ASSERT_EQ(static_cast(payload.length()), bsl::strlen(buffer)); // Create PushEventBuilder - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(sizeof(bmqp::EventHeader), static_cast(peb.eventSize())); ASSERT_EQ(sizeof(bmqp::EventHeader), static_cast(peb.blob().length())); @@ -434,12 +444,13 @@ static void test2_buildEventBackwardsCompatibility() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = peb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_SAFE(true == rawEvent.isValid()); BSLS_ASSERT_SAFE(true == rawEvent.isPushEvent()); - bmqp::PushMessageIterator pushIter(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator pushIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPushMessageIterator(&pushIter, true); ASSERT_EQ(true, pushIter.isValid()); @@ -451,7 +462,7 @@ static void test2_buildEventBackwardsCompatibility() ASSERT_EQ(guid, pushIter.header().messageGUID()); ASSERT_EQ(bmqt::CompressionAlgorithmType::e_NONE, pushIter.header().compressionAlgorithmType()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadMessagePayload(&payloadBlob)); ASSERT_EQ(payload.length(), pushIter.messagePayloadSize()); @@ -461,14 +472,15 @@ static void test2_buildEventBackwardsCompatibility() ASSERT_EQ(0, bdlbb::BlobUtil::compare(payload, payloadBlob)); ASSERT_EQ(true, pushIter.hasOptions()); - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadOptionsView(&optionsView)); ASSERT_EQ(true, optionsView.isValid()); ASSERT_EQ(true, optionsView.find(bmqp::OptionType::e_SUB_QUEUE_IDS_OLD) != optionsView.end()); - bmqp::Protocol::SubQueueInfosArray retrievedSubQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray retrievedSubQueueInfos( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, optionsView.loadSubQueueInfosOption(&retrievedSubQueueInfos)); ASSERT_EQ(subQueueInfos.size(), retrievedSubQueueInfos.size()); @@ -499,22 +511,26 @@ static void test3_buildEventWithPackedOption() { bmqtst::TestHelper::printTestName("PACKED OPTION"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); const int queueId = 4321; const bmqt::MessageGUID guid; const char* buffer = "abcdefghijklmnopqrstuvwxyz"; const int flags = 0; - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&payload, buffer, bsl::strlen(buffer)); ASSERT_EQ(static_cast(payload.length()), bsl::strlen(buffer)); // Create PushEventBuilder - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(sizeof(bmqp::EventHeader), static_cast(peb.eventSize())); ASSERT_EQ(sizeof(bmqp::EventHeader), static_cast(peb.blob().length())); @@ -548,12 +564,13 @@ static void test3_buildEventWithPackedOption() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = peb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_SAFE(true == rawEvent.isValid()); BSLS_ASSERT_SAFE(true == rawEvent.isPushEvent()); - bmqp::PushMessageIterator pushIter(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator pushIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPushMessageIterator(&pushIter, true); ASSERT_EQ(true, pushIter.isValid()); @@ -565,7 +582,7 @@ static void test3_buildEventWithPackedOption() ASSERT_EQ(guid, pushIter.header().messageGUID()); ASSERT_EQ(bmqt::CompressionAlgorithmType::e_NONE, pushIter.header().compressionAlgorithmType()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadMessagePayload(&payloadBlob)); ASSERT_EQ(payload.length(), pushIter.messagePayloadSize()); @@ -575,14 +592,15 @@ static void test3_buildEventWithPackedOption() ASSERT_EQ(0, bdlbb::BlobUtil::compare(payload, payloadBlob)); ASSERT_EQ(true, pushIter.hasOptions()); - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadOptionsView(&optionsView)); ASSERT_EQ(true, optionsView.isValid()); ASSERT_EQ(true, optionsView.find(bmqp::OptionType::e_SUB_QUEUE_INFOS) != optionsView.end()); - bmqp::Protocol::SubQueueInfosArray retrievedSubQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray retrievedSubQueueInfos( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, optionsView.loadSubQueueInfosOption(&retrievedSubQueueInfos)); ASSERT_EQ(subQueueInfos.size(), retrievedSubQueueInfos.size()); @@ -601,28 +619,36 @@ static void test4_buildEventWithMultipleMessages() bmqtst::TestHelper::printTestName("BUILD EVENT WITH MULTIPLE MESSAGES"); // Create PushEventBuilder - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); const size_t k_NUM_MSGS = 1000; for (size_t dataIdx = 0; dataIdx < k_NUM_MSGS; ++dataIdx) { - bmqt::EventBuilderResult::Enum rc = - appendMessage(dataIdx, &peb, &data, &bufferFactory, s_allocator_p); + bmqt::EventBuilderResult::Enum rc = appendMessage( + dataIdx, + &peb, + &data, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(dataIdx, rc, bmqt::EventBuilderResult::e_SUCCESS); } // Iterate and check const bdlbb::Blob& eventBlob = peb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_SAFE(true == rawEvent.isValid()); BSLS_ASSERT_SAFE(true == rawEvent.isPushEvent()); - bmqp::PushMessageIterator pushIter(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator pushIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPushMessageIterator(&pushIter, true); ASSERT_EQ(true, pushIter.isValid()); @@ -636,7 +662,7 @@ static void test4_buildEventWithMultipleMessages() ASSERT_EQ_D(dataIndex, D.d_guid, pushIter.header().messageGUID()); ASSERT_EQ_D(dataIndex, D.d_qid, pushIter.header().queueId()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(dataIndex, 0, pushIter.loadMessagePayload(&payloadBlob)); ASSERT_EQ_D(dataIndex, @@ -647,7 +673,7 @@ static void test4_buildEventWithMultipleMessages() 0, bdlbb::BlobUtil::compare(payloadBlob, D.d_payload)); - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadOptionsView(&optionsView)); ASSERT_EQ(true, optionsView.isValid()); @@ -656,7 +682,8 @@ static void test4_buildEventWithMultipleMessages() optionsView.find(bmqp::OptionType::e_SUB_QUEUE_INFOS) != optionsView.end()); if (hasSubQueueInfos) { - bmqp::Protocol::SubQueueInfosArray retrievedSQInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray retrievedSQInfos( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, optionsView.loadSubQueueInfosOption(&retrievedSQInfos)); ASSERT_EQ(D.d_subQueueInfos.size(), retrievedSQInfos.size()); @@ -670,7 +697,8 @@ static void test4_buildEventWithMultipleMessages() optionsView.find(bmqp::OptionType::e_MSG_GROUP_ID) != optionsView.end()); if (hasMsgGroupId) { - bmqp::Protocol::MsgGroupId retrievedMsgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId retrievedMsgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, optionsView.loadMsgGroupIdOption(&retrievedMsgGroupId)); ASSERT_EQ(D.d_msgGroupId.value(), retrievedMsgGroupId); @@ -701,10 +729,14 @@ static void test5_buildEventWithPayloadTooBig() { bmqtst::TestHelper::printTestName("PAYLOAD TOO BIG"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); const bmqt::MessageGUID guid; - bdlbb::Blob bigMsgPayload(&bufferFactory, s_allocator_p); - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); + bdlbb::Blob bigMsgPayload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); const int queueId = 4321; int numSubQueueInfos = bmqp::Protocol::SubQueueInfosArray::static_size + 4; // Use a value for 'numSubQueueInfos' which extends beyond 'static' part of @@ -720,7 +752,8 @@ static void test5_buildEventWithPayloadTooBig() bigMsgPayload.length()); // Create PutEventBuilder - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(sizeof(bmqp::EventHeader), static_cast(peb.eventSize())); ASSERT_EQ(sizeof(bmqp::EventHeader), static_cast(peb.blob().length())); @@ -755,7 +788,8 @@ static void test5_buildEventWithPayloadTooBig() // Now append a "regular"-sized message and make sure event builder // behaves as expected - bdlbb::Blob regularPayload(&bufferFactory, s_allocator_p); + bdlbb::Blob regularPayload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); const char* regularBuffer = "abcedefghijklmnopqrstuv"; bdlbb::BlobUtil::append(®ularPayload, @@ -776,12 +810,13 @@ static void test5_buildEventWithPayloadTooBig() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = peb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_SAFE(true == rawEvent.isValid()); BSLS_ASSERT_SAFE(true == rawEvent.isPushEvent()); - bmqp::PushMessageIterator pushIter(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator pushIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPushMessageIterator(&pushIter, true); ASSERT_EQ(true, pushIter.isValid()); ASSERT_EQ(1, pushIter.next()); @@ -789,7 +824,7 @@ static void test5_buildEventWithPayloadTooBig() ASSERT_EQ(queueId, pushIter.header().queueId()); ASSERT_EQ(guid, pushIter.header().messageGUID()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadMessagePayload(&payloadBlob)); ASSERT_EQ(regularPayload.length(), pushIter.messagePayloadSize()); ASSERT_EQ(payloadBlob.length(), pushIter.messagePayloadSize()); @@ -797,7 +832,7 @@ static void test5_buildEventWithPayloadTooBig() ASSERT_EQ(0, bdlbb::BlobUtil::compare(payloadBlob, regularPayload)); ASSERT_EQ(false, pushIter.hasOptions()); - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadOptionsView(&optionsView)); ASSERT_EQ(true, optionsView.isValid()); ASSERT_EQ(true, @@ -811,13 +846,16 @@ static void test6_buildEventWithImplicitPayload() // Implicit payload test // -------------------------------------------------------------------- { - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); const bmqt::MessageGUID guid; const int queueId = 4321; const int flags = bmqp::PushHeaderFlags::e_IMPLICIT_PAYLOAD; // Create PutEventBuilder - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqt::EventBuilderResult::Enum rc = peb.packMessage( queueId, guid, @@ -835,11 +873,12 @@ static void test6_buildEventWithImplicitPayload() // iterators are lower than bmqp builders, and thus, can be used to test // them. const bdlbb::Blob& eventBlob = peb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_SAFE(true == rawEvent.isValid()); BSLS_ASSERT_SAFE(true == rawEvent.isPushEvent()); - bmqp::PushMessageIterator pushIter(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator pushIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPushMessageIterator(&pushIter, true); ASSERT_EQ(true, pushIter.isValid()); ASSERT_EQ(1, pushIter.next()); @@ -848,7 +887,7 @@ static void test6_buildEventWithImplicitPayload() ASSERT_EQ(queueId, pushIter.header().queueId()); ASSERT_EQ(guid, pushIter.header().messageGUID()); - bdlbb::Blob dummy(s_allocator_p); + bdlbb::Blob dummy(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, 0 == pushIter.loadMessagePayload(&dummy)); ASSERT_EQ(0, pushIter.messagePayloadSize()); ASSERT_EQ(false, 0 == pushIter.loadApplicationData(&dummy)); @@ -858,7 +897,7 @@ static void test6_buildEventWithImplicitPayload() ASSERT_EQ(false, 0 == pushIter.loadMessageProperties(&dummy)); ASSERT_EQ(false, pushIter.hasOptions()); - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadOptionsView(&optionsView)); ASSERT_EQ(true, optionsView.isValid()); ASSERT_EQ(true, @@ -887,10 +926,13 @@ static void test7_buildEventOptionTooBig() { bmqtst::TestHelper::printTestName("OPTION TOO BIG TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); int numSubQueueInfos; int optionSize; - bmqp::Protocol::SubQueueInfosArray subQueueInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray subQueueInfos( + bmqtst::TestHelperUtil::allocator()); // No. of SubQueueInfos is exactly one more than would exceed the option // size limit. @@ -907,7 +949,8 @@ static void test7_buildEventOptionTooBig() generateSubQueueInfos(&subQueueInfos, numSubQueueInfos); // Create PutEventBuilder - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Add option larger than maximum allowed bmqt::EventBuilderResult::Enum rc = peb.addSubQueueInfosOption( @@ -917,9 +960,10 @@ static void test7_buildEventOptionTooBig() #ifdef BMQ_ENABLE_MSG_GROUPID // Add another option larger than maximum allowed - bmqp::Protocol::MsgGroupId msgGrIdBig1(bmqp::OptionHeader::k_MAX_SIZE + 1, - 'x', - s_allocator_p); + bmqp::Protocol::MsgGroupId msgGrIdBig1( + bmqp::OptionHeader::k_MAX_SIZE + 1, + 'x', + bmqtst::TestHelperUtil::allocator()); rc = peb.addMsgGroupIdOption(msgGrIdBig1); @@ -928,7 +972,7 @@ static void test7_buildEventOptionTooBig() bmqp::Protocol::MsgGroupId msgGrIdBig2( bmqp::Protocol::k_MSG_GROUP_ID_MAX_LENGTH + 1, 'x', - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); rc = peb.addMsgGroupIdOption(msgGrIdBig2); @@ -966,7 +1010,8 @@ static void test7_buildEventOptionTooBig() // Now append a valid-sized message and make sure event builder behaves as // expected - bdlbb::Blob regularPayload(&bufferFactory, s_allocator_p); + bdlbb::Blob regularPayload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); const char* regularBuffer = "abcedefghijklmnopqrstuv"; const int queueId = 1399; const bmqt::MessageGUID guid; @@ -996,12 +1041,13 @@ static void test7_buildEventOptionTooBig() // iterators are lower than bmqp builders, and thus, can be used to test // them. const bdlbb::Blob& eventBlob = peb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_SAFE(true == rawEvent.isValid()); BSLS_ASSERT_SAFE(true == rawEvent.isPushEvent()); - bmqp::PushMessageIterator pushIter(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator pushIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPushMessageIterator(&pushIter, true); ASSERT_EQ(true, pushIter.isValid()); ASSERT_EQ(1, pushIter.next()); @@ -1009,7 +1055,7 @@ static void test7_buildEventOptionTooBig() ASSERT_EQ(queueId, pushIter.header().queueId()); ASSERT_EQ(guid, pushIter.header().messageGUID()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadMessagePayload(&payloadBlob)); ASSERT_EQ(regularPayload.length(), pushIter.messagePayloadSize()); ASSERT_EQ(payloadBlob.length(), pushIter.messagePayloadSize()); @@ -1017,14 +1063,15 @@ static void test7_buildEventOptionTooBig() ASSERT_EQ(0, bdlbb::BlobUtil::compare(payloadBlob, regularPayload)); ASSERT_EQ(true, pushIter.hasOptions()); - bmqp::OptionsView optionsView(s_allocator_p); + bmqp::OptionsView optionsView(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, pushIter.loadOptionsView(&optionsView)); ASSERT_EQ(true, optionsView.isValid()); ASSERT_EQ(true, optionsView.find(bmqp::OptionType::e_SUB_QUEUE_INFOS) != optionsView.end()); - bmqp::Protocol::SubQueueInfosArray retrievedSQInfos(s_allocator_p); + bmqp::Protocol::SubQueueInfosArray retrievedSQInfos( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, optionsView.loadSubQueueInfosOption(&retrievedSQInfos)); ASSERT_EQ(subQueueInfos.size(), retrievedSQInfos.size()); for (size_t i = 0; i < subQueueInfos.size(); ++i) { @@ -1056,9 +1103,12 @@ static void test8_buildEventTooBig() { bmqtst::TestHelper::printTestName("EVENT TOO BIG"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); const bmqt::MessageGUID guid; - bdlbb::Blob validPayload1(&bufferFactory, s_allocator_p); + bdlbb::Blob validPayload1(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); const int queueId = 4321; int validLen = 0; const int flags = 0; @@ -1067,12 +1117,13 @@ static void test8_buildEventTooBig() sizeof(bmqp::EventHeader) - sizeof(bmqp::PushHeader) - bmqp::Protocol::k_WORD_SIZE; // max padding - bsl::string s(validLen, 'x', s_allocator_p); + bsl::string s(validLen, 'x', bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&validPayload1, s.c_str(), validLen); // Create PutEventBuilder - bmqp::PushEventBuilder peb(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder peb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Add message with valid payload size bmqt::EventBuilderResult::Enum rc = peb.packMessage( @@ -1089,7 +1140,8 @@ static void test8_buildEventTooBig() // Add message with valid payload size such that it would make the event // have a size that is larger than the enforced maximum. - bdlbb::Blob validPayload2(&bufferFactory, s_allocator_p); + bdlbb::Blob validPayload2(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&validPayload2, s.c_str(), validLen); int count = 1; @@ -1139,11 +1191,15 @@ static void testN1_decodeFromFile() const int k_QID = 9876; const int k_SIZE = 128; char buf[k_SIZE] = {0}; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob outBlob(&bufferFactory, s_allocator_p); - bdlbb::Blob payloadBlob(&bufferFactory, s_allocator_p); - bmqu::MemOutStream os(s_allocator_p); - bmqp::PushMessageIterator pushIter(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob outBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payloadBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); + bmqp::PushMessageIterator pushIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqt::MessageGUID messageGUID; bdlb::Guid guid; @@ -1151,7 +1207,8 @@ static void testN1_decodeFromFile() bdlbb::BlobUtil::append(&payloadBlob, k_PAYLOAD, k_PAYLOAD_LEN); // Create PutEventBuilder - bmqp::PushEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::PushEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Pack one msg obj.packMessage(payloadBlob, @@ -1194,7 +1251,7 @@ static void testN1_decodeFromFile() bsl::shared_ptr dataBufferSp(buf, bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer dataBlobBuffer(dataBufferSp, k_SIZE); outBlob.appendDataBuffer(dataBlobBuffer); @@ -1203,7 +1260,7 @@ static void testN1_decodeFromFile() ASSERT_EQ(bdlbb::BlobUtil::compare(obj.blob(), outBlob), 0); // Decode event - bmqp::Event rawEvent(&outBlob, s_allocator_p); + bmqp::Event rawEvent(&outBlob, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rawEvent.isPushEvent(), true); @@ -1217,7 +1274,7 @@ static void testN1_decodeFromFile() ASSERT_EQ(pushIter.loadMessagePayload(&payloadBlob), 0); ASSERT_EQ(pushIter.messagePayloadSize(), k_PAYLOAD_LEN); - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); int res, compareResult; res = bmqu::BlobUtil::compareSection(&compareResult, payloadBlob, @@ -1244,13 +1301,14 @@ int main(int argc, char* argv[]) // Temporary workaround to suppress the 'unused operator // NestedTraitDeclaration' warning/error generated by clang. TBD: // figure out the right way to "fix" this. - Data dummy(static_cast(0), s_allocator_p); + Data dummy(static_cast(0), + bmqtst::TestHelperUtil::allocator()); static_cast( static_cast< bslmf::NestedTraitDeclaration >( dummy)); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); unsigned int seed = bsl::time(NULL); bsl::srand(seed); @@ -1271,7 +1329,7 @@ int main(int argc, char* argv[]) case -1: testN1_decodeFromFile(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_pushmessageiterator.t.cpp b/src/groups/bmq/bmqp/bmqp_pushmessageiterator.t.cpp index fd3f757c0..cce752419 100644 --- a/src/groups/bmq/bmqp/bmqp_pushmessageiterator.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_pushmessageiterator.t.cpp @@ -191,7 +191,8 @@ generateSubQueueInfos(bsl::vector* subQueueInfos, subQueueInfos->clear(); - bsl::unordered_set generatedIds(s_allocator_p); + bsl::unordered_set generatedIds( + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < numSubQueueInfos; ++i) { unsigned int currId = static_cast( generateRandomInteger(0, 200)); @@ -217,7 +218,7 @@ static void generateMsgGroupId(bmqp::Protocol::MsgGroupId* msgGroupId) // PRECONDITIONS BSLS_ASSERT_OPT(msgGroupId); - bmqu::MemOutStream oss(s_allocator_p); + bmqu::MemOutStream oss(bmqtst::TestHelperUtil::allocator()); oss << "gid:" << generateRandomInteger(0, 200); *msgGroupId = oss.str(); } @@ -711,14 +712,16 @@ void breathingTestHelper( bdlbb::BlobBufferFactory* bufferFactory_p) { // Create valid iter - bdlbb::Blob blob(bufferFactory_p, s_allocator_p); - bdlbb::Blob expectedBlob(bufferFactory_p, s_allocator_p); - bdlbb::Blob expectedCompressedBlob(bufferFactory_p, s_allocator_p); + bdlbb::Blob blob(bufferFactory_p, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob expectedBlob(bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob expectedCompressedBlob(bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); int expectedBlobLength = 0; bmqu::BlobPosition expectedHeaderPos; bmqu::BlobPosition expectedPayloadPos; bmqu::BlobPosition retrievedPayloadPos; - bdlbb::Blob retrievedPayloadBlob(s_allocator_p); + bdlbb::Blob retrievedPayloadBlob(bmqtst::TestHelperUtil::allocator()); // Populate blob const int queueId = 123; @@ -736,14 +739,14 @@ void breathingTestHelper( compressionAlgorithmType, &expectedCompressedBlob, bufferFactory_p, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Iterate and verify bmqp::PushMessageIterator iter(&blob, eventHeader, decompressFlag, bufferFactory_p, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); ASSERT_EQ(true, iter.next()); @@ -759,11 +762,12 @@ void breathingTestHelper( ASSERT_EQ(expectedBlobLength, iter.applicationDataSize()); ASSERT_EQ(0, iter.messagePropertiesSize()); - bdlbb::Blob emptyBlob(s_allocator_p); + bdlbb::Blob emptyBlob(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, iter.loadMessageProperties(&emptyBlob)); ASSERT_EQ(0, emptyBlob.length()); - bmqp::MessageProperties emptyProps(s_allocator_p); + bmqp::MessageProperties emptyProps( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, iter.loadMessageProperties(&emptyProps)); ASSERT_EQ(0, emptyProps.numProperties()); @@ -773,7 +777,7 @@ void breathingTestHelper( expectedBlob)); } - bmqp::OptionsView emptyOptionsView(s_allocator_p); + bmqp::OptionsView emptyOptionsView(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, iter.loadOptionsView(&emptyOptionsView)); ASSERT_EQ(true, emptyOptionsView.isValid()); @@ -805,7 +809,7 @@ void breathingTestHelper( ASSERT_EQ(false, iter.isValid()); // Copy - bmqp::PushMessageIterator iter2(iter, s_allocator_p); + bmqp::PushMessageIterator iter2(iter, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, iter2.isValid()); // Clear @@ -835,15 +839,16 @@ void breathingTestHelper( ASSERT_EQ(expectedBlobLength, iter.applicationDataSize()); ASSERT_EQ(0, iter.messagePropertiesSize()); - bdlbb::Blob emptyBlob(s_allocator_p); + bdlbb::Blob emptyBlob(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, iter.loadMessageProperties(&emptyBlob)); ASSERT_EQ(0, emptyBlob.length()); - bmqp::MessageProperties emptyProps(s_allocator_p); + bmqp::MessageProperties emptyProps( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, iter.loadMessageProperties(&emptyProps)); ASSERT_EQ(0, emptyProps.numProperties()); - bdlbb::Blob retrievedPayloadBlob2(s_allocator_p); + bdlbb::Blob retrievedPayloadBlob2(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, iter.loadMessagePayload(&retrievedPayloadBlob2)); ASSERT_EQ(0, @@ -856,7 +861,7 @@ void breathingTestHelper( ASSERT_EQ(0, iter.loadApplicationDataPosition(&retrievedPayloadPos2)); ASSERT_EQ(retrievedPayloadPos2, expectedPayloadPos); - bdlbb::Blob retrievedApplicationData(s_allocator_p); + bdlbb::Blob retrievedApplicationData(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, iter.loadApplicationData(&retrievedApplicationData)); // expect decompressed payload if decompressFlag is true and vice-versa. @@ -916,18 +921,23 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { // Create invalid iter - bmqp::PushMessageIterator iter(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator iter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, iter.isValid()); } { // Create invalid iter from another invalid iter - bmqp::PushMessageIterator iter1(&bufferFactory, s_allocator_p); - bmqp::PushMessageIterator iter2(iter1, s_allocator_p); + bmqp::PushMessageIterator iter1(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqp::PushMessageIterator iter2(iter1, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, iter1.isValid()); ASSERT_EQ(false, iter2.isValid()); @@ -935,8 +945,9 @@ static void test1_breathingTest() { // Assigning invalid iter - bmqp::PushMessageIterator iter1(&bufferFactory, s_allocator_p), - iter2(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator iter1(&bufferFactory, + bmqtst::TestHelperUtil::allocator()), + iter2(&bufferFactory, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, iter1.isValid()); ASSERT_EQ(false, iter2.isValid()); @@ -978,22 +989,27 @@ static void test2_iteratorReset() { bmqtst::TestHelper::printTestName("ITERATOR RESET"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PushMessageIterator pmt(&bufferFactory, s_allocator_p); - bdlbb::Blob copiedBlob(s_allocator_p); - bdlbb::Blob expectedBlob(&bufferFactory, s_allocator_p); - bdlbb::Blob expectedCompressedBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PushMessageIterator pmt(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob copiedBlob(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob expectedBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob expectedCompressedBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int expectedBlobLength = 0; bmqu::BlobPosition headerPosition; bmqu::BlobPosition payloadPosition; const int queueId = 123; bmqt::MessageGUID guid; bmqp::EventHeader eventHeader; - bdlbb::Blob payloadBlob(s_allocator_p); - bdlbb::Blob appDataBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob appDataBlob(bmqtst::TestHelperUtil::allocator()); { - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, @@ -1007,13 +1023,13 @@ static void test2_iteratorReset() bmqt::CompressionAlgorithmType::e_ZLIB, &expectedCompressedBlob, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqp::PushMessageIterator iter(&blob, eventHeader, true, // decompress flag &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); @@ -1049,10 +1065,12 @@ static void test3_iteratePushEventHavingNoMessages() bmqtst::TestHelper::printTestName( "ITERATE PUSH EVENT HAVING NO PUSH MESSAGES"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; populateBlob(&eventBlob, @@ -1062,10 +1080,11 @@ static void test3_iteratePushEventHavingNoMessages() &bufferFactory, false, // No zero-length msgs false, // No implicit app data - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Verify non-validity - bmqp::PushMessageIterator iter(&bufferFactory, s_allocator_p); + bmqp::PushMessageIterator iter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_LT(iter.reset(&eventBlob, eventHeader, true), 0); ASSERT_EQ(false, iter.isValid()); } @@ -1076,10 +1095,12 @@ static void test4_iterateInvalidPushEvent() { bmqtst::TestHelper::printTestName("ITERATE INVALID PUSH EVENT"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; populateBlob(&eventBlob, @@ -1089,7 +1110,7 @@ static void test4_iterateInvalidPushEvent() &bufferFactory, false, // No zero-length msgs false, // No implicit app data - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Render the blob invalid by removing it's last byte bdlbb::BlobUtil::erase(&eventBlob, eventBlob.length() - 1, 1); @@ -1099,7 +1120,7 @@ static void test4_iterateInvalidPushEvent() eventHeader, true, // decompress flag &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); // First message is valid.. @@ -1116,9 +1137,11 @@ static void test5_iteratePushEventHavingMultipleMessages() bmqtst::TestHelper::printTestName("PUSH EVENT HAVING MULTIPLE MESSAGES"); // Test iterating over PUSH event having multiple PUSH messages - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; const size_t k_NUM_MSGS = 1000; @@ -1129,14 +1152,14 @@ static void test5_iteratePushEventHavingMultipleMessages() &bufferFactory, false, // No zero-length PUSH msgs. true, // make some PUSH msgs w/ implicit app data - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Iterate and verify bmqp::PushMessageIterator iter(&eventBlob, eventHeader, true, // decompress flag &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); size_t index = 0; @@ -1168,9 +1191,9 @@ static void test5_iteratePushEventHavingMultipleMessages() (D.d_msgLen + D.d_propLen), iter.applicationDataSize()); - bdlbb::Blob props(s_allocator_p); - bdlbb::Blob payload(s_allocator_p); - bdlbb::Blob appData(s_allocator_p); + bdlbb::Blob props(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob appData(bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition propsPos; bmqu::BlobPosition payloadPos; bmqu::BlobPosition appDataPos; @@ -1220,9 +1243,11 @@ static void test6_iteratePushEventHavingZeroLengthMessages() bmqtst::TestHelper::printTestName( "PUSH EVENT HAVING ZERO-LENGTH MESSAGES"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; const size_t k_NUM_MSGS = 1000; @@ -1233,14 +1258,14 @@ static void test6_iteratePushEventHavingZeroLengthMessages() &bufferFactory, true, // make some PUSH msgs zero-length true, // make some PUSH msgs w/ implicit app data - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Iterate and verify bmqp::PushMessageIterator iter(&eventBlob, eventHeader, true, // decompress flag &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); size_t index = 0; @@ -1274,9 +1299,9 @@ static void test6_iteratePushEventHavingZeroLengthMessages() (D.d_msgLen + D.d_propLen), iter.applicationDataSize()); - bdlbb::Blob props(s_allocator_p); - bdlbb::Blob payload(s_allocator_p); - bdlbb::Blob appData(s_allocator_p); + bdlbb::Blob props(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob appData(bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition propsPos; bmqu::BlobPosition payloadPos; bmqu::BlobPosition appDataPos; @@ -1352,9 +1377,11 @@ static void test7_extractOptions() { bmqtst::TestHelper::printTestName("EXTRACT OPTIONS"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; int qid; bool hasSubQueueInfo = false; @@ -1375,7 +1402,7 @@ static void test7_extractOptions() hasMsgGroupId, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Msg2: One SubQueueId qid = 1; @@ -1390,7 +1417,7 @@ static void test7_extractOptions() hasMsgGroupId, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Msg3: No SubQueueId and no GroupId qid = 1; @@ -1405,7 +1432,7 @@ static void test7_extractOptions() hasMsgGroupId, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Msg4: One SubQueueId and one GroupId qid = 2; @@ -1420,7 +1447,7 @@ static void test7_extractOptions() hasMsgGroupId, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Msg5: No SubQueueId and one GroupId qid = 1; @@ -1435,7 +1462,7 @@ static void test7_extractOptions() hasMsgGroupId, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Msg 6: One subQueueId encoded using old SubQueueId options qid = 1; @@ -1450,21 +1477,21 @@ static void test7_extractOptions() hasMsgGroupId, payloadLength, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Build the event blob appendMessages1(&eventHeader, &eventBlob, data, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Iterate and verify bmqp::PushMessageIterator iter(&eventBlob, eventHeader, true, // decompress flag &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(iter.isValid(), true); size_t index = 0; @@ -1515,7 +1542,8 @@ static void test7_extractOptions() actualHavingMsgGroupId); } else if (actualHavingMsgGroupId) { - bmqp::Protocol::MsgGroupId actual(s_allocator_p); + bmqp::Protocol::MsgGroupId actual( + bmqtst::TestHelperUtil::allocator()); const bmqp::Protocol::MsgGroupId& expected = D.d_msgGroupId.value(); iter.extractMsgGroupId(&actual); @@ -1540,18 +1568,20 @@ int main(int argc, char* argv[]) // Temporary workaround to suppress the 'unused operator // NestedTraitDeclaration' warning/error generated by clang. TBD: // figure out the right way to "fix" this. - Data dummy(static_cast(0), s_allocator_p); + Data dummy(static_cast(0), + bmqtst::TestHelperUtil::allocator()); static_cast( static_cast< bslmf::NestedTraitDeclaration >( dummy)); - Data1 dummy1(static_cast(0), s_allocator_p); + Data1 dummy1(static_cast(0), + bmqtst::TestHelperUtil::allocator()); static_cast( static_cast< bslmf::NestedTraitDeclaration >( dummy1)); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); unsigned int seed = bsl::time(0); bsl::srand(seed); @@ -1568,7 +1598,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_puteventbuilder.t.cpp b/src/groups/bmq/bmqp/bmqp_puteventbuilder.t.cpp index c120b609b..5360f805c 100644 --- a/src/groups/bmq/bmqp/bmqp_puteventbuilder.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_puteventbuilder.t.cpp @@ -98,7 +98,7 @@ Data::Data(const Data& other, bslma::Allocator* allocator) #ifdef BMQ_ENABLE_MSG_GROUPID void setMsgGroupId(bmqp::PutEventBuilder* peb, const size_t iteration) { - bmqu::MemOutStream oss(s_allocator_p); + bmqu::MemOutStream oss(bmqtst::TestHelperUtil::allocator()); oss << "gid:" << iteration; peb->setMsgGroupId(oss.str()); } @@ -109,7 +109,7 @@ void validateGroupId(const size_t iteration, ASSERT(putIter.hasMsgGroupId()); bmqp::Protocol::MsgGroupId msgGroupId; ASSERT(putIter.extractMsgGroupId(&msgGroupId)); - bmqu::MemOutStream oss(s_allocator_p); + bmqu::MemOutStream oss(bmqtst::TestHelperUtil::allocator()); oss << "gid:" << iteration; ASSERT_EQ(oss.str(), msgGroupId); } @@ -124,7 +124,7 @@ appendMessage(size_t iteration, const bmqt::MessageGUID& guid, bslma::Allocator* allocator) { - Data data(bufferFactory, s_allocator_p); + Data data(bufferFactory, bmqtst::TestHelperUtil::allocator()); data.d_guid = guid; data.d_qid = iteration; @@ -156,7 +156,8 @@ unsigned int findExpectedCrc32( bslma::Allocator* allocator, bmqt::CompressionAlgorithmType::Enum compressionAlgorithmType) { - bdlbb::Blob applicationData(bufferFactory, s_allocator_p); + bdlbb::Blob applicationData(bufferFactory, + bmqtst::TestHelperUtil::allocator()); if (hasProperties) { bdlbb::BlobUtil::append( &applicationData, @@ -213,9 +214,13 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); #ifdef BMQ_ENABLE_MSG_GROUPID - const bmqp::Protocol::MsgGroupId k_MSG_GROUP_ID("gid:0", s_allocator_p); + const bmqp::Protocol::MsgGroupId k_MSG_GROUP_ID( + "gid:0", + bmqtst::TestHelperUtil::allocator()); #endif const int k_PROPERTY_VAL_ENCODING = 3; const bsl::string k_PROPERTY_VAL_ID = "myCoolId"; @@ -239,7 +244,7 @@ static void test1_breathingTest() { PVV("DO NOT USE COMPRESSION FOR MESSAGE PROPERTIES AND PAYLOAD"); - bmqp::MessageProperties msgProps(s_allocator_p); + bmqp::MessageProperties msgProps(bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT( 0 == @@ -252,7 +257,8 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(k_NUM_PROPERTIES == msgProps.numProperties()); // Create PutEventBuilder - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.crc32c(), 0U); @@ -307,7 +313,7 @@ static void test1_breathingTest() &msgProps, test.d_hasProperties, &bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), obj.compressionAlgorithmType()); #ifdef BMQ_ENABLE_MSG_GROUPID @@ -334,16 +340,17 @@ static void test1_breathingTest() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = obj.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(rawEvent.isValid()); BSLS_ASSERT_OPT(rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); BSLS_ASSERT_OPT(putIter.isValid()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; @@ -374,7 +381,7 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(compareResult == 0); bmqt::PropertyType::Enum ptype; - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); if (!test.d_hasProperties) { ASSERT_EQ(false, putIter.hasMessageProperties()); @@ -401,7 +408,8 @@ static void test1_breathingTest() } #ifdef BMQ_ENABLE_MSG_GROUPID - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(putIter.hasMsgGroupId(), true); ASSERT_EQ(putIter.extractMsgGroupId(&msgGroupId), true); ASSERT_EQ(msgGroupId, k_MSG_GROUP_ID); @@ -445,7 +453,7 @@ static void test1_breathingTest() ASSERT_EQ(putIter.loadMessagePayload(&payloadBlob), 0); ASSERT_EQ(putIter.messagePayloadSize(), k_PAYLOAD_BIGGER_LEN); - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); int res, compareResult; res = bmqu::BlobUtil::compareSection(&compareResult, payloadBlob, @@ -463,7 +471,7 @@ static void test1_breathingTest() } { PVV("USE ZLIB COMPRESSION FOR MESSAGE PROPERTIES AND PAYLOAD"); - bmqp::MessageProperties msgProps(s_allocator_p); + bmqp::MessageProperties msgProps(bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT( 0 == @@ -476,7 +484,8 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(k_NUM_PROPERTIES == msgProps.numProperties()); // Create PutEventBuilder - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.crc32c(), 0U); @@ -530,7 +539,7 @@ static void test1_breathingTest() &msgProps, test.d_hasProperties, &bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), obj.compressionAlgorithmType()); #ifdef BMQ_ENABLE_MSG_GROUPID @@ -558,16 +567,17 @@ static void test1_breathingTest() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = obj.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(rawEvent.isValid()); BSLS_ASSERT_OPT(rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); BSLS_ASSERT_OPT(putIter.isValid()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; @@ -598,7 +608,7 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(compareResult == 0); bmqt::PropertyType::Enum ptype; - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); if (!test.d_hasProperties) { ASSERT_EQ(false, putIter.hasMessageProperties()); @@ -625,7 +635,8 @@ static void test1_breathingTest() } #ifdef BMQ_ENABLE_MSG_GROUPID - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(putIter.hasMsgGroupId(), true); ASSERT_EQ(putIter.extractMsgGroupId(&msgGroupId), true); ASSERT_EQ(msgGroupId, k_MSG_GROUP_ID); @@ -675,7 +686,7 @@ static void test1_breathingTest() ASSERT_EQ(putIter.loadMessagePayload(&payloadBlob), 0); ASSERT_EQ(putIter.messagePayloadSize(), k_PAYLOAD_BIGGER_LEN); - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); int res, compareResult; res = bmqu::BlobUtil::compareSection(&compareResult, payloadBlob, @@ -693,7 +704,7 @@ static void test1_breathingTest() } { PVV("USE MIX OF ZLIB COMPRESSION AND NO COMPRESSION FOR MESSAGES"); - bmqp::MessageProperties msgProps(s_allocator_p); + bmqp::MessageProperties msgProps(bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT( 0 == @@ -706,7 +717,8 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(k_NUM_PROPERTIES == msgProps.numProperties()); // Create PutEventBuilder - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.crc32c(), 0U); @@ -767,7 +779,7 @@ static void test1_breathingTest() &msgProps, test.d_hasProperties, &bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), obj.compressionAlgorithmType()); #ifdef BMQ_ENABLE_MSG_GROUPID @@ -796,16 +808,17 @@ static void test1_breathingTest() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = obj.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(rawEvent.isValid()); BSLS_ASSERT_OPT(rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); BSLS_ASSERT_OPT(putIter.isValid()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; @@ -842,7 +855,7 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(compareResult == 0); bmqt::PropertyType::Enum ptype; - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); if (!test.d_hasProperties) { ASSERT_EQ(false, putIter.hasMessageProperties()); @@ -869,7 +882,8 @@ static void test1_breathingTest() } #ifdef BMQ_ENABLE_MSG_GROUPID - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(putIter.hasMsgGroupId(), true); ASSERT_EQ(putIter.extractMsgGroupId(&msgGroupId), true); ASSERT_EQ(msgGroupId, k_MSG_GROUP_ID); @@ -919,7 +933,7 @@ static void test1_breathingTest() ASSERT_EQ(putIter.loadMessagePayload(&payloadBlob), 0); ASSERT_EQ(putIter.messagePayloadSize(), k_PAYLOAD_BIGGER_LEN); - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); int res, compareResult; res = bmqu::BlobUtil::compareSection(&compareResult, payloadBlob, @@ -938,7 +952,7 @@ static void test1_breathingTest() { PVV("USE COMPRESSION MIX BUT VERY SMALL MESSAGE: EXPECT NO COMPRESS"); - bmqp::MessageProperties msgProps(s_allocator_p); + bmqp::MessageProperties msgProps(bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT( 0 == @@ -951,7 +965,8 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(k_NUM_PROPERTIES == msgProps.numProperties()); // Create PutEventBuilder - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.crc32c(), 0U); @@ -1012,7 +1027,7 @@ static void test1_breathingTest() &msgProps, test.d_hasProperties, &bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), bmqt::CompressionAlgorithmType::e_NONE); #ifdef BMQ_ENABLE_MSG_GROUPID @@ -1039,16 +1054,17 @@ static void test1_breathingTest() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = obj.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(rawEvent.isValid()); BSLS_ASSERT_OPT(rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); BSLS_ASSERT_OPT(putIter.isValid()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; @@ -1080,7 +1096,7 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(compareResult == 0); bmqt::PropertyType::Enum ptype; - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); if (!test.d_hasProperties) { ASSERT_EQ(false, putIter.hasMessageProperties()); @@ -1107,7 +1123,8 @@ static void test1_breathingTest() } #ifdef BMQ_ENABLE_MSG_GROUPID - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(putIter.hasMsgGroupId(), true); ASSERT_EQ(putIter.extractMsgGroupId(&msgGroupId), true); ASSERT_EQ(msgGroupId, k_MSG_GROUP_ID); @@ -1152,7 +1169,7 @@ static void test1_breathingTest() ASSERT_EQ(putIter.loadMessagePayload(&payloadBlob), 0); ASSERT_EQ(putIter.messagePayloadSize(), k_PAYLOAD_LEN); - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); int res, compareResult; res = bmqu::BlobUtil::compareSection(&compareResult, payloadBlob, @@ -1171,7 +1188,7 @@ static void test1_breathingTest() { PVV("COMPRESSION USING UNKNOWN ALGORITHM TYPE"); - bmqp::MessageProperties msgProps(s_allocator_p); + bmqp::MessageProperties msgProps(bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT( 0 == @@ -1184,7 +1201,8 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(k_NUM_PROPERTIES == msgProps.numProperties()); // Create PutEventBuilder - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.crc32c(), 0U); @@ -1239,7 +1257,7 @@ static void test1_breathingTest() &msgProps, test.d_hasProperties, &bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), bmqt::CompressionAlgorithmType::e_NONE); #ifdef BMQ_ENABLE_MSG_GROUPID @@ -1266,16 +1284,17 @@ static void test1_breathingTest() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = obj.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(rawEvent.isValid()); BSLS_ASSERT_OPT(rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); BSLS_ASSERT_OPT(putIter.isValid()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; @@ -1306,7 +1325,7 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(compareResult == 0); bmqt::PropertyType::Enum ptype; - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); if (!test.d_hasProperties) { ASSERT_EQ(false, putIter.hasMessageProperties()); @@ -1333,7 +1352,8 @@ static void test1_breathingTest() } #ifdef BMQ_ENABLE_MSG_GROUPID - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(putIter.hasMsgGroupId(), true); ASSERT_EQ(putIter.extractMsgGroupId(&msgGroupId), true); ASSERT_EQ(msgGroupId, k_MSG_GROUP_ID); @@ -1378,7 +1398,7 @@ static void test1_breathingTest() ASSERT_EQ(putIter.loadMessagePayload(&payloadBlob), 0); ASSERT_EQ(putIter.messagePayloadSize(), k_PAYLOAD_BIGGER_LEN); - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); int res, compareResult; res = bmqu::BlobUtil::compareSection(&compareResult, payloadBlob, @@ -1399,22 +1419,24 @@ static void test1_breathingTest() PVV("DO NOT USE COMPRESSION FOR RELAYED PUT MESSAGES"); // Create PutEventBuilder - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.crc32c(), 0U); - bmqu::MemOutStream error(s_allocator_p); + bmqu::MemOutStream error(bmqtst::TestHelperUtil::allocator()); obj.startMessage(); // create payload which has compressed data. - bdlbb::Blob payload(&bufferFactory, s_allocator_p); + bdlbb::Blob payload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqp::Compression::compress(&payload, &bufferFactory, bmqt::CompressionAlgorithmType::e_ZLIB, k_PAYLOAD_BIGGER, k_PAYLOAD_BIGGER_LEN, &error, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); obj.setMessagePayload(&payload); #ifdef BMQ_ENABLE_MSG_GROUPID @@ -1470,16 +1492,17 @@ static void test1_breathingTest() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = obj.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(rawEvent.isValid()); BSLS_ASSERT_OPT(rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); BSLS_ASSERT_OPT(putIter.isValid()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; @@ -1509,14 +1532,15 @@ static void test1_breathingTest() BSLS_ASSERT_OPT(res == 0); BSLS_ASSERT_OPT(compareResult == 0); - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, putIter.hasMessageProperties()); ASSERT_EQ(0, putIter.loadMessageProperties(&prop)); ASSERT_EQ(0, prop.numProperties()); #ifdef BMQ_ENABLE_MSG_GROUPID - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(putIter.hasMsgGroupId(), true); ASSERT_EQ(putIter.extractMsgGroupId(&msgGroupId), true); ASSERT_EQ(msgGroupId, k_MSG_GROUP_ID); @@ -1563,7 +1587,7 @@ static void test1_breathingTest() ASSERT_EQ(putIter.loadMessagePayload(&payloadBlob), 0); ASSERT_EQ(putIter.messagePayloadSize(), k_PAYLOAD_BIGGER_LEN); - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); int res, compareResult; res = bmqu::BlobUtil::compareSection(&compareResult, payloadBlob, @@ -1646,11 +1670,14 @@ static void test2_manipulators_one() const int k_NUM_DATA = sizeof(k_DATA) / sizeof(*k_DATA); // Create PutEventBuilder - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Properties. - bmqp::MessageProperties msgProps(s_allocator_p); + bmqp::MessageProperties msgProps(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, msgProps.setPropertyAsInt32("encoding", 3)); ASSERT_EQ(0, msgProps.setPropertyAsString("id", "myCoolId")); ASSERT_EQ(0, msgProps.setPropertyAsInt64("timestamp", 0LL)); @@ -1694,7 +1721,7 @@ static void test2_manipulators_one() &msgProps, true, // hasProperties &bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), bmqt::CompressionAlgorithmType::e_NONE); bmqt::EventBuilderResult::Enum rc = obj.packMessage(data.d_qid); @@ -1708,12 +1735,13 @@ static void test2_manipulators_one() // Iterate and check const bdlbb::Blob& eventBlob = obj.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(true == rawEvent.isValid()); BSLS_ASSERT_OPT(true == rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); ASSERT_EQ(true, putIter.isValid()); @@ -1731,7 +1759,7 @@ static void test2_manipulators_one() ASSERT_EQ_D(dataIndex, data.d_crc32c, putIter.header().crc32c()); ASSERT_EQ_D(dataIndex, phFlags, putIter.header().flags()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(dataIndex, 0, putIter.loadMessagePayload(&payloadBlob)); ASSERT_EQ_D(dataIndex, @@ -1748,7 +1776,7 @@ static void test2_manipulators_one() ASSERT_EQ_D(dataIndex, 0, res); ASSERT_EQ_D(dataIndex, 0, compareResult); - bmqp::MessageProperties p(s_allocator_p); + bmqp::MessageProperties p(bmqtst::TestHelperUtil::allocator()); bmqt::PropertyType::Enum ptype; ASSERT_EQ(true, putIter.hasMessageProperties()); ASSERT_EQ(0, putIter.loadMessageProperties(&p)); @@ -1790,10 +1818,15 @@ static void test3_eventTooBig() { bmqtst::TestHelper::printTestName("EVENT TOO BIG"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob bigMsgPayload(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob bigMsgPayload(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); #ifdef BMQ_ENABLE_MSG_GROUPID - bmqp::Protocol::MsgGroupId k_MSG_GROUP_ID("gid:0", s_allocator_p); + bmqp::Protocol::MsgGroupId k_MSG_GROUP_ID( + "gid:0", + bmqtst::TestHelperUtil::allocator()); #endif const int k_QID = 4321; bmqt::MessageGUID guid = bmqp::MessageGUIDGenerator::testGUID(); @@ -1806,7 +1839,8 @@ static void test3_eventTooBig() bigMsgPayload.length()); // Create PutEventBuilder - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); obj.startMessage(); #ifdef BMQ_ENABLE_MSG_GROUPID @@ -1837,12 +1871,13 @@ static void test3_eventTooBig() // iterators are lower than bmqp builders, and thus, can be used to test // them. const bdlbb::Blob& eventBlob = obj.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(true == rawEvent.isValid()); BSLS_ASSERT(true == rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); ASSERT_EQ(true, putIter.isValid()); @@ -1851,7 +1886,8 @@ static void test3_eventTooBig() ASSERT_EQ(putIter.header().queueId(), k_QID); ASSERT_EQ(putIter.header().messageGUID(), guid); - bdlbb::Blob payloadBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob payloadBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(putIter.loadMessagePayload(&payloadBlob), 0); ASSERT_EQ(putIter.messagePayloadSize(), k_PAYLOAD_LEN); @@ -1868,7 +1904,7 @@ static void test3_eventTooBig() #ifdef BMQ_ENABLE_MSG_GROUPID ASSERT(putIter.hasMsgGroupId()); - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(putIter.extractMsgGroupId(&msgGroupId), true); ASSERT_EQ(msgGroupId, k_MSG_GROUP_ID); #endif @@ -1894,9 +1930,12 @@ static void test4_manipulators_two() bmqtst::TestHelper::printTestName("MANIPULATORS - TWO"); // Create PutEventBuilder - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); const size_t k_NUM_MSGS = 1000; for (size_t dataIdx = 0; dataIdx < k_NUM_MSGS; ++dataIdx) { @@ -1907,19 +1946,20 @@ static void test4_manipulators_two() &bufferFactory, false, bmqp::MessageGUIDGenerator::testGUID(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(dataIdx, rc, bmqt::EventBuilderResult::e_SUCCESS); } // Iterate and check const bdlbb::Blob& eventBlob = obj.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(true == rawEvent.isValid()); BSLS_ASSERT(true == rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); ASSERT_EQ(true, putIter.isValid()); @@ -1932,7 +1972,8 @@ static void test4_manipulators_two() ASSERT_EQ_D(dataIndex, D.d_qid, putIter.header().queueId()); ASSERT_EQ_D(dataIndex, D.d_guid, putIter.header().messageGUID()); - bdlbb::Blob payloadBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob payloadBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(dataIndex, 0, putIter.loadMessagePayload(&payloadBlob)); ASSERT_EQ_D(dataIndex, @@ -1970,9 +2011,12 @@ static void test5_putEventWithZeroLengthMessage() bmqtst::TestHelper::printTestName("PUT EVENT WITH ZERO LEGNTH MESSAGE"); // Create PutEventBuilder - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqt::EventBuilderResult::Enum rc = appendMessage( 0, @@ -1981,17 +2025,18 @@ static void test5_putEventWithZeroLengthMessage() &bufferFactory, true, bmqp::MessageGUIDGenerator::testGUID(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(0, rc, bmqt::EventBuilderResult::e_SUCCESS); // Iterate and check const bdlbb::Blob& eventBlob = obj.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(true == rawEvent.isValid()); BSLS_ASSERT(true == rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); ASSERT_EQ(true, putIter.isValid()); @@ -2017,9 +2062,13 @@ static void test6_emptyBuilder() { bmqtst::TestHelper::printTestName("EMPTY BUILDER"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); #ifdef BMQ_ENABLE_MSG_GROUPID - bmqp::Protocol::MsgGroupId k_MSG_GROUP_ID("gid:0", s_allocator_p); + bmqp::Protocol::MsgGroupId k_MSG_GROUP_ID( + "gid:0", + bmqtst::TestHelperUtil::allocator()); #endif unsigned char zeroGuidBuf[bmqt::MessageGUID::e_SIZE_BINARY]; @@ -2034,7 +2083,8 @@ static void test6_emptyBuilder() const char* k_PAYLOAD = "abcdefghijklmnopqrstuvwxyz"; - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.unpackedMessageSize(), 0); ASSERT_SAFE_FAIL(obj.setFlags(0)); @@ -2102,9 +2152,13 @@ static void test7_multiplePackMessage() { bmqtst::TestHelper::printTestName("TEST MULTIPLE CALLS TO PACK MESSAGE"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); #ifdef BMQ_ENABLE_MSG_GROUPID - const bmqp::Protocol::MsgGroupId k_MSG_GROUP_ID("gid:0", s_allocator_p); + const bmqp::Protocol::MsgGroupId k_MSG_GROUP_ID( + "gid:0", + bmqtst::TestHelperUtil::allocator()); #endif const int k_PROPERTY_VAL_ENCODING = 3; const bsl::string k_PROPERTY_VAL_ID = "myCoolId"; @@ -2126,7 +2180,7 @@ static void test7_multiplePackMessage() k_PAYLOAD_BIGGER[i] = k_PAYLOAD[i % 26]; } - bmqp::MessageProperties msgProps(s_allocator_p); + bmqp::MessageProperties msgProps(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, msgProps.setPropertyAsInt32("encoding", @@ -2137,7 +2191,8 @@ static void test7_multiplePackMessage() ASSERT_EQ(k_NUM_PROPERTIES, msgProps.numProperties()); // Create PutEventBuilder - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.crc32c(), 0U); @@ -2166,7 +2221,7 @@ static void test7_multiplePackMessage() &msgProps, true, // has properties &bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), obj.compressionAlgorithmType()); #ifdef BMQ_ENABLE_MSG_GROUPID @@ -2197,16 +2252,17 @@ static void test7_multiplePackMessage() // bmqp iterators are lower than bmqp builders, and thus, can be used // to test them. const bdlbb::Blob& eventBlob = obj.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); ASSERT(rawEvent.isValid()); ASSERT(rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIter, true); ASSERT(putIter.isValid()); - bdlbb::Blob payloadBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); // check for the 2 packed messages for (size_t idx = 0; idx < 2; ++idx) { @@ -2236,7 +2292,7 @@ static void test7_multiplePackMessage() ASSERT_EQ(compareResult, 0); bmqt::PropertyType::Enum ptype; - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(putIter.hasMessageProperties(), true); ASSERT_EQ(putIter.loadMessageProperties(&prop), 0); @@ -2255,7 +2311,8 @@ static void test7_multiplePackMessage() ASSERT_EQ(prop.getPropertyAsInt64("timestamp"), k_TIME_STAMP); #ifdef BMQ_ENABLE_MSG_GROUPID - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(putIter.hasMsgGroupId(), true); ASSERT_EQ(putIter.extractMsgGroupId(&msgGroupId), true); ASSERT_EQ(msgGroupId, k_MSG_GROUP_ID); @@ -2302,7 +2359,7 @@ static void test7_multiplePackMessage() ASSERT_EQ(putIter.loadMessagePayload(&payloadBlob), 0); ASSERT_EQ(putIter.messagePayloadSize(), k_PAYLOAD_BIGGER_LEN); - bmqp::MessageProperties prop(s_allocator_p); + bmqp::MessageProperties prop(bmqtst::TestHelperUtil::allocator()); int res, compareResult; res = bmqu::BlobUtil::compareSection(&compareResult, payloadBlob, @@ -2339,11 +2396,14 @@ static void testN1_decodeFromFile() { bmqtst::TestHelper::printTestName("DECODE FROM FILE"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob outBlob(&bufferFactory, s_allocator_p); - bdlbb::Blob payloadBlob(s_allocator_p); - bmqu::MemOutStream os(s_allocator_p); - bmqp::PutMessageIterator putIter(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob outBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); + bmqp::PutMessageIterator putIter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlb::Guid guid = bdlb::GuidUtil::generate(); const char* k_PAYLOAD = "abcdefghijklmnopqrstuvwxyz"; @@ -2357,7 +2417,7 @@ static void testN1_decodeFromFile() const bsls::Types::Int64 k_TIME_STAMP = 1234567890LL; const int k_PROPERTY_NUM = 3; - bmqp::MessageProperties msgProps(s_allocator_p); + bmqp::MessageProperties msgProps(bmqtst::TestHelperUtil::allocator()); bmqt::MessageGUID msgGuid = bmqp::MessageGUIDGenerator::testGUID(); msgProps.setPropertyAsInt32("encoding", k_PROPERTY_VAL_ENCODING); @@ -2379,7 +2439,8 @@ static void testN1_decodeFromFile() bmqp::PutHeaderFlags::e_MESSAGE_PROPERTIES); // Create PutEventBuilder - bmqp::PutEventBuilder obj(&bufferFactory, s_allocator_p); + bmqp::PutEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); obj.startMessage(); @@ -2395,7 +2456,7 @@ static void testN1_decodeFromFile() &msgProps, true, &bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), obj.compressionAlgorithmType()); obj.packMessage(k_QID); @@ -2434,7 +2495,7 @@ static void testN1_decodeFromFile() bsl::shared_ptr dataBufferSp(buf, bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer dataBlobBuffer(dataBufferSp, k_SIZE); outBlob.appendDataBuffer(dataBlobBuffer); @@ -2443,7 +2504,7 @@ static void testN1_decodeFromFile() ASSERT_EQ(bdlbb::BlobUtil::compare(obj.blob(), outBlob), 0); // Decode event - bmqp::Event rawEvent(&outBlob, s_allocator_p); + bmqp::Event rawEvent(&outBlob, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rawEvent.isPutEvent(), true); @@ -2502,13 +2563,14 @@ int main(int argc, char* argv[]) // Temporary workaround to suppress the 'unused operator // NestedTraitDeclaration' warning/error generated by clang. TBD: figure // out the right way to "fix" this. - Data dummy(static_cast(0), s_allocator_p); + Data dummy(static_cast(0), + bmqtst::TestHelperUtil::allocator()); static_cast( static_cast< bslmf::NestedTraitDeclaration >( dummy)); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); // Initialize Crc32c bmqp::Crc32c::initialize(); @@ -2527,7 +2589,7 @@ int main(int argc, char* argv[]) case -1: testN1_decodeFromFile(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_putmessageiterator.t.cpp b/src/groups/bmq/bmqp/bmqp_putmessageiterator.t.cpp index eb526eb34..0958c4632 100644 --- a/src/groups/bmq/bmqp/bmqp_putmessageiterator.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_putmessageiterator.t.cpp @@ -75,18 +75,23 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { PVV("CREATE INVALID ITER"); - bmqp::PutMessageIterator iter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator iter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, iter.isValid()); } { PVV("CREATE INVALID ITER FROM ANOTHER INVALID ITER"); - bmqp::PutMessageIterator iter1(&bufferFactory, s_allocator_p); - bmqp::PutMessageIterator iter2(iter1, s_allocator_p); + bmqp::PutMessageIterator iter1(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqp::PutMessageIterator iter2(iter1, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, iter1.isValid()); ASSERT_EQ(false, iter2.isValid()); @@ -94,8 +99,9 @@ static void test1_breathingTest() { PVV("ASSIGNING INVALID ITER"); - bmqp::PutMessageIterator iter1(&bufferFactory, s_allocator_p), - iter2(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator iter1(&bufferFactory, + bmqtst::TestHelperUtil::allocator()), + iter2(&bufferFactory, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, iter1.isValid()); ASSERT_EQ(false, iter2.isValid()); @@ -106,13 +112,14 @@ static void test1_breathingTest() { PVV("CREATE VALID ITER DECOMPRESSFLAG FALSE, E_NONE COMPRESSION"); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); - bdlbb::Blob expectedBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob expectedBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int expectedBlobLength = 0; bmqu::BlobPosition expectedHeaderPos; bmqu::BlobPosition expectedPayloadPos; bmqu::BlobPosition retrievedPayloadPos; - bdlbb::Blob retrievedPayloadBlob(s_allocator_p); + bdlbb::Blob retrievedPayloadBlob(bmqtst::TestHelperUtil::allocator()); // Populate blob const int queueId = 123; @@ -133,7 +140,7 @@ static void test1_breathingTest() eventHeader, false, // decompress flag &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); ASSERT_EQ(true, iter.next()); @@ -161,7 +168,8 @@ static void test1_breathingTest() ASSERT_EQ(false, iter.isValid()); // Copy - bmqp::PutMessageIterator iter2(iter, s_allocator_p); + bmqp::PutMessageIterator iter2(iter, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, iter2.isValid()); // Clear @@ -186,7 +194,7 @@ static void test1_breathingTest() ASSERT_EQ(false, 0 == iter.loadMessagePropertiesPosition(&emptyPos)); ASSERT_EQ(bmqu::BlobPosition(), emptyPos); - bdlbb::Blob retrievedPayloadBlob2(s_allocator_p); + bdlbb::Blob retrievedPayloadBlob2(bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition retrievedPayloadPos2; ASSERT_EQ(0, iter.loadApplicationDataPosition(&retrievedPayloadPos2)); @@ -206,13 +214,14 @@ static void test1_breathingTest() { PVV("CREATE VALID ITER DECOMPRESSFLAG FALSE, E_ZLIB COMPRESSION"); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); - bdlbb::Blob expectedBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob expectedBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int expectedBlobLength = 0; bmqu::BlobPosition expectedHeaderPos; bmqu::BlobPosition expectedPayloadPos; bmqu::BlobPosition retrievedPayloadPos; - bdlbb::Blob retrievedPayloadBlob(s_allocator_p); + bdlbb::Blob retrievedPayloadBlob(bmqtst::TestHelperUtil::allocator()); // Populate blob const int queueId = 123; @@ -229,14 +238,14 @@ static void test1_breathingTest() guid, bmqt::CompressionAlgorithmType::e_ZLIB, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Iterate and verify bmqp::PutMessageIterator iter(&blob, eventHeader, false, // decompress flag &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); ASSERT_EQ(true, iter.next()); @@ -261,7 +270,8 @@ static void test1_breathingTest() ASSERT_EQ(false, iter.isValid()); // Copy - bmqp::PutMessageIterator iter2(iter, s_allocator_p); + bmqp::PutMessageIterator iter2(iter, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, iter2.isValid()); // Clear @@ -286,7 +296,7 @@ static void test1_breathingTest() ASSERT_EQ(false, 0 == iter.loadMessagePropertiesPosition(&emptyPos)); ASSERT_EQ(bmqu::BlobPosition(), emptyPos); - bdlbb::Blob retrievedPayloadBlob2(s_allocator_p); + bdlbb::Blob retrievedPayloadBlob2(bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition retrievedPayloadPos2; ASSERT_EQ(0, iter.loadApplicationDataPosition(&retrievedPayloadPos2)); @@ -306,13 +316,15 @@ static void test1_breathingTest() { PVV("CREATE VALID ITER DECOMPRESSFLAG TRUE, E_NONE COMPRESSION"); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); - bdlbb::Blob expectedBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob expectedBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int expectedBlobLength = 0; bmqu::BlobPosition expectedHeaderPos; bmqu::BlobPosition expectedPayloadPos; bmqu::BlobPosition retrievedPayloadPos; - bdlbb::Blob retrievedPayloadBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob retrievedPayloadBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Populate blob const int queueId = 123; @@ -333,7 +345,7 @@ static void test1_breathingTest() eventHeader, true, // decompress flag &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); ASSERT_EQ(true, iter.next()); @@ -344,7 +356,7 @@ static void test1_breathingTest() ASSERT_EQ(false, iter.hasMessageProperties()); ASSERT_EQ(0, iter.messagePropertiesSize()); - bdlbb::Blob emptyBlob(s_allocator_p); + bdlbb::Blob emptyBlob(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, iter.loadMessageProperties(&emptyBlob)); ASSERT_EQ(0, emptyBlob.length()); @@ -352,7 +364,8 @@ static void test1_breathingTest() ASSERT_EQ(false, 0 == iter.loadMessagePropertiesPosition(&emptyPos)); ASSERT_EQ(bmqu::BlobPosition(), emptyPos); - bmqp::MessageProperties emptyProps(s_allocator_p); + bmqp::MessageProperties emptyProps( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, iter.loadMessageProperties(&emptyProps)); ASSERT_EQ(0, emptyProps.numProperties()); @@ -376,7 +389,8 @@ static void test1_breathingTest() ASSERT_EQ(false, iter.isValid()); // Copy - bmqp::PutMessageIterator iter2(iter, s_allocator_p); + bmqp::PutMessageIterator iter2(iter, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, iter2.isValid()); // Clear @@ -406,7 +420,8 @@ static void test1_breathingTest() ASSERT_EQ(0, iter.loadMessageProperties(&emptyProps)); ASSERT_EQ(0, emptyProps.numProperties()); - bdlbb::Blob retrievedPayloadBlob2(&bufferFactory, s_allocator_p); + bdlbb::Blob retrievedPayloadBlob2(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition retrievedPayloadPos2; ASSERT_EQ(0, iter.loadMessagePayload(&retrievedPayloadBlob2)); @@ -431,13 +446,15 @@ static void test1_breathingTest() { PVV("CREATE VALID ITER DECOMPRESSFLAG TRUE, E_ZLIB COMPRESSION"); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); - bdlbb::Blob expectedBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob expectedBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int expectedBlobLength = 0; bmqu::BlobPosition expectedHeaderPos; bmqu::BlobPosition expectedPayloadPos; bmqu::BlobPosition retrievedPayloadPos; - bdlbb::Blob retrievedPayloadBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob retrievedPayloadBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Populate blob const int queueId = 123; @@ -454,14 +471,14 @@ static void test1_breathingTest() guid, bmqt::CompressionAlgorithmType::e_ZLIB, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Iterate and verify bmqp::PutMessageIterator iter(&blob, eventHeader, true, // decompress flag &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); ASSERT_EQ(true, iter.next()); @@ -472,7 +489,7 @@ static void test1_breathingTest() ASSERT_EQ(false, iter.hasMessageProperties()); ASSERT_EQ(0, iter.messagePropertiesSize()); - bdlbb::Blob emptyBlob(s_allocator_p); + bdlbb::Blob emptyBlob(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, iter.loadMessageProperties(&emptyBlob)); ASSERT_EQ(0, emptyBlob.length()); @@ -480,7 +497,8 @@ static void test1_breathingTest() ASSERT_EQ(false, 0 == iter.loadMessagePropertiesPosition(&emptyPos)); ASSERT_EQ(bmqu::BlobPosition(), emptyPos); - bmqp::MessageProperties emptyProps(s_allocator_p); + bmqp::MessageProperties emptyProps( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, iter.loadMessageProperties(&emptyProps)); ASSERT_EQ(0, emptyProps.numProperties()); @@ -504,7 +522,8 @@ static void test1_breathingTest() ASSERT_EQ(false, iter.isValid()); // Copy - bmqp::PutMessageIterator iter2(iter, s_allocator_p); + bmqp::PutMessageIterator iter2(iter, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, iter2.isValid()); // Clear @@ -534,7 +553,8 @@ static void test1_breathingTest() ASSERT_EQ(0, iter.loadMessageProperties(&emptyProps)); ASSERT_EQ(0, emptyProps.numProperties()); - bdlbb::Blob retrievedPayloadBlob2(&bufferFactory, s_allocator_p); + bdlbb::Blob retrievedPayloadBlob2(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition retrievedPayloadPos2; ASSERT_EQ(0, iter.loadMessagePayload(&retrievedPayloadBlob2)); @@ -571,24 +591,29 @@ static void test2_reset() { bmqtst::TestHelper::printTestName("RESET"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { PVV("NO COMPRESSION, DECOMPRESS FLAG FALSE"); - bmqp::PutMessageIterator pmt(&bufferFactory, s_allocator_p); - bdlbb::Blob copiedBlob(s_allocator_p); - bdlbb::Blob expectedBlob(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator pmt(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob copiedBlob(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob expectedBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int expectedBlobLength = 0; bmqu::BlobPosition headerPosition; bmqu::BlobPosition payloadPosition; const int queueId = 123; bmqp::EventHeader eventHeader; - bdlbb::Blob payloadBlob(s_allocator_p); - bdlbb::Blob appDataBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob appDataBlob(bmqtst::TestHelperUtil::allocator()); bmqt::MessageGUID guid = bmqp::MessageGUIDGenerator::testGUID(); { - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Populate blob bmqp::PutTester::populateBlob(&blob, @@ -604,7 +629,7 @@ static void test2_reset() eventHeader, false, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); @@ -633,20 +658,23 @@ static void test2_reset() { PVV("ZLIB COMPRESSION, DECOMPRESS FLAG TRUE"); - bmqp::PutMessageIterator pmt(&bufferFactory, s_allocator_p); - bdlbb::Blob copiedBlob(s_allocator_p); - bdlbb::Blob expectedBlob(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator pmt(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob copiedBlob(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob expectedBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); int expectedBlobLength = 0; bmqu::BlobPosition headerPosition; bmqu::BlobPosition payloadPosition; const int queueId = 123; bmqp::EventHeader eventHeader; - bdlbb::Blob payloadBlob(s_allocator_p); - bdlbb::Blob appDataBlob(s_allocator_p); + bdlbb::Blob payloadBlob(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob appDataBlob(bmqtst::TestHelperUtil::allocator()); bmqt::MessageGUID guid = bmqp::MessageGUIDGenerator::testGUID(); { - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); // Populate blob bmqp::PutTester::populateBlob( @@ -660,13 +688,13 @@ static void test2_reset() guid, bmqt::CompressionAlgorithmType::e_ZLIB, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqp::PutMessageIterator iter(&blob, eventHeader, true, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); @@ -710,10 +738,13 @@ static void test3_putEventWithNoMessages() bmqtst::TestHelper::printTestName("PUT EVENT WITH NO MESSAGES"); // Test - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); - bsl::vector data(s_allocator_p); + bsl::vector data( + bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; bmqp::PutTester::populateBlob(&eventBlob, @@ -722,10 +753,11 @@ static void test3_putEventWithNoMessages() 0, &bufferFactory, false, // No zero-length msgs - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Verify non-validity - bmqp::PutMessageIterator iter(&bufferFactory, s_allocator_p); + bmqp::PutMessageIterator iter(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_LT(iter.reset(&eventBlob, eventHeader, true), 0); ASSERT_EQ(iter.isValid(), false); } @@ -743,11 +775,15 @@ static void test4_invalidPutEvent() { bmqtst::TestHelper::printTestName("INVALID PUT EVENT"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { PVV("NEXT METHOD OVER INVALID BLOB"); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::Blob eventBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector data( + bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; bmqp::PutTester::populateBlob(&eventBlob, @@ -756,7 +792,7 @@ static void test4_invalidPutEvent() 2, &bufferFactory, false, // No zero-length msgs - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Render the blob invalid by removing it's last byte bdlbb::BlobUtil::erase(&eventBlob, eventBlob.length() - 1, 1); @@ -766,7 +802,7 @@ static void test4_invalidPutEvent() eventHeader, false, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); // First message is valid.. ASSERT_EQ(1, iter.next()); // Second message is error. @@ -780,8 +816,10 @@ static void test4_invalidPutEvent() { PVV("LOAD OPTIONS METHOD OVER INVALID BLOB"); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::Blob eventBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector data( + bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; bmqp::PutTester::populateBlob(&eventBlob, @@ -790,14 +828,14 @@ static void test4_invalidPutEvent() 3, &bufferFactory, true, // Include zero-length msgs - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Verify bmqp::PutMessageIterator iter(&eventBlob, eventHeader, false, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // First 3 messages are valid.. ASSERT_EQ(true, iter.isValid()); @@ -825,12 +863,16 @@ static void test5_putEventWithMultipleMessages() { bmqtst::TestHelper::printTestName("PUT EVENT WITH MULTIPLE MESSAGES"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { PVV("WITH ZLIB COMPRESSION, DECOMPRESS FLAG TRUE"); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::Blob eventBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector data( + bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; const size_t k_NUM_MSGS = 1000; @@ -840,7 +882,7 @@ static void test5_putEventWithMultipleMessages() k_NUM_MSGS, &bufferFactory, false, // No zero-length PUT msgs. - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), bmqt::CompressionAlgorithmType::e_ZLIB); // Iterate and verify @@ -848,7 +890,7 @@ static void test5_putEventWithMultipleMessages() eventHeader, true, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); size_t index = 0; @@ -869,10 +911,10 @@ static void test5_putEventWithMultipleMessages() (D.d_msgLen + D.d_propLen), iter.applicationDataSize()); - bdlbb::Blob options(s_allocator_p); - bdlbb::Blob props(s_allocator_p); - bdlbb::Blob payload(s_allocator_p); - bdlbb::Blob appData(s_allocator_p); + bdlbb::Blob options(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob props(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob appData(bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition propsPos; bmqu::BlobPosition payloadPos; bmqu::BlobPosition appDataPos; @@ -903,7 +945,8 @@ static void test5_putEventWithMultipleMessages() const bool hasMsgGroupId = iter.hasMsgGroupId(); ASSERT_EQ_D(index, hasMsgGroupId, !D.d_msgGroupId.isNull()); if (hasMsgGroupId) { - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(index, true, iter.extractMsgGroupId(&msgGroupId)); ASSERT_EQ_D(index, msgGroupId, D.d_msgGroupId.valueOr("")); @@ -931,8 +974,10 @@ static void test5_putEventWithMultipleMessages() { PVV("WITH NO COMPRESSION, DECOMPRESS FLAG TRUE"); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::Blob eventBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector data( + bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; const size_t k_NUM_MSGS = 1000; @@ -942,14 +987,14 @@ static void test5_putEventWithMultipleMessages() k_NUM_MSGS, &bufferFactory, false, // No zero-length PUT msgs. - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Iterate and verify bmqp::PutMessageIterator iter(&eventBlob, eventHeader, true, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); size_t index = 0; @@ -970,10 +1015,10 @@ static void test5_putEventWithMultipleMessages() (D.d_msgLen + D.d_propLen), iter.applicationDataSize()); - bdlbb::Blob options(s_allocator_p); - bdlbb::Blob props(s_allocator_p); - bdlbb::Blob payload(s_allocator_p); - bdlbb::Blob appData(s_allocator_p); + bdlbb::Blob options(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob props(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob appData(bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition propsPos; bmqu::BlobPosition payloadPos; bmqu::BlobPosition appDataPos; @@ -1004,7 +1049,8 @@ static void test5_putEventWithMultipleMessages() const bool hasMsgGroupId = iter.hasMsgGroupId(); ASSERT_EQ_D(index, hasMsgGroupId, !D.d_msgGroupId.isNull()); if (hasMsgGroupId) { - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(index, true, iter.extractMsgGroupId(&msgGroupId)); ASSERT_EQ_D(index, msgGroupId, D.d_msgGroupId.valueOr("")); @@ -1043,12 +1089,16 @@ static void test6_putEventWithZeroLengthPutMessages() { bmqtst::TestHelper::printTestName("PUT EVENT WITH ZERO-LENGTH MESSAGES"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { PVV("WITH NO COMPRESSION, DECOMPRESS FLAG TRUE"); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::Blob eventBlob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector data( + bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; const size_t k_NUM_MSGS = 1000; @@ -1058,14 +1108,14 @@ static void test6_putEventWithZeroLengthPutMessages() k_NUM_MSGS, &bufferFactory, true, // make some PUT msgs zero-length - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Iterate and verify bmqp::PutMessageIterator iter(&eventBlob, eventHeader, true, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(true, iter.isValid()); size_t index = 0; @@ -1085,9 +1135,9 @@ static void test6_putEventWithZeroLengthPutMessages() (D.d_msgLen + D.d_propLen), iter.applicationDataSize()); - bdlbb::Blob props(s_allocator_p); - bdlbb::Blob payload(s_allocator_p); - bdlbb::Blob appData(s_allocator_p); + bdlbb::Blob props(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob appData(bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition propsPos; bmqu::BlobPosition payloadPos; bmqu::BlobPosition appDataPos; @@ -1118,7 +1168,8 @@ static void test6_putEventWithZeroLengthPutMessages() const bool hasMsgGroupId = iter.hasMsgGroupId(); ASSERT_EQ_D(index, hasMsgGroupId, !D.d_msgGroupId.isNull()); if (hasMsgGroupId) { - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(index, true, iter.extractMsgGroupId(&msgGroupId)); ASSERT_EQ_D(index, msgGroupId, D.d_msgGroupId.valueOr("")); } @@ -1139,7 +1190,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -1151,7 +1202,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_queueid.t.cpp b/src/groups/bmq/bmqp/bmqp_queueid.t.cpp index c8fcb10a8..966c7ffda 100644 --- a/src/groups/bmq/bmqp/bmqp_queueid.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_queueid.t.cpp @@ -132,7 +132,7 @@ static void test2_print() bmqp::QueueId obj(id, subId); // Print - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); out.setstate(bsl::ios_base::badbit); obj.print(out, 0, -1); @@ -214,7 +214,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_queueutil.t.cpp b/src/groups/bmq/bmqp/bmqp_queueutil.t.cpp index dde06ae64..bb6f833eb 100644 --- a/src/groups/bmq/bmqp/bmqp_queueutil.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_queueutil.t.cpp @@ -65,7 +65,8 @@ static void test1_createQueueIdFromHandleParameters() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqp_ctrlmsg::QueueHandleParameters handleParams(s_allocator_p); + bmqp_ctrlmsg::QueueHandleParameters handleParams( + bmqtst::TestHelperUtil::allocator()); handleParams.qId() = test.d_id; if (test.d_hasSubId) { @@ -120,8 +121,10 @@ static void test2_extractSubQueueId() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqp_ctrlmsg::QueueStreamParameters streamParams(s_allocator_p); - bmqp_ctrlmsg::QueueHandleParameters handleParams(s_allocator_p); + bmqp_ctrlmsg::QueueStreamParameters streamParams( + bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::QueueHandleParameters handleParams( + bmqtst::TestHelperUtil::allocator()); if (test.d_hasSubId) { streamParams.subIdInfo().makeValue().subId() = test.d_subId; @@ -235,13 +238,16 @@ static void test3_extractCanonicalHandleParameters() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqp_ctrlmsg::QueueHandleParameters handleParams(s_allocator_p); + bmqp_ctrlmsg::QueueHandleParameters handleParams( + bmqtst::TestHelperUtil::allocator()); handleParams.flags() = test.d_flags; - handleParams.uri() = bsl::string(test.d_uri, s_allocator_p); + handleParams.uri() = bsl::string(test.d_uri, + bmqtst::TestHelperUtil::allocator()); if (test.d_hasSubStreamInfo) { bmqp_ctrlmsg::SubQueueIdInfo& subStreamInfo = handleParams.subIdInfo().makeValue(); - subStreamInfo.appId() = bsl::string(test.d_appId, s_allocator_p); + subStreamInfo.appId() = + bsl::string(test.d_appId, bmqtst::TestHelperUtil::allocator()); subStreamInfo.subId() = test.d_subId; } handleParams.readCount() = test.d_readCount; @@ -251,12 +257,13 @@ static void test3_extractCanonicalHandleParameters() PVV(test.d_line << ": extracting canonical handle parameters from " << "'handleParameters': " << handleParams); - bmqp_ctrlmsg::QueueHandleParameters result(s_allocator_p); + bmqp_ctrlmsg::QueueHandleParameters result( + bmqtst::TestHelperUtil::allocator()); result = bmqp::QueueUtil::extractCanonicalHandleParameters( &result, handleParams); - bmqt::Uri expectedUri(s_allocator_p); - bsl::string errorDescription(s_allocator_p); + bmqt::Uri expectedUri(bmqtst::TestHelperUtil::allocator()); + bsl::string errorDescription(bmqtst::TestHelperUtil::allocator()); int rc = bmqt::UriParser::parse(&expectedUri, &errorDescription, test.d_uri); @@ -341,7 +348,8 @@ static void test4_isEmpty() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqp_ctrlmsg::QueueHandleParameters handleParams(s_allocator_p); + bmqp_ctrlmsg::QueueHandleParameters handleParams( + bmqtst::TestHelperUtil::allocator()); handleParams.readCount() = test.d_readCount; handleParams.writeCount() = test.d_writeCount; handleParams.adminCount() = test.d_adminCount; @@ -380,7 +388,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -391,7 +399,7 @@ int main(int argc, char* argv[]) case 1: test1_createQueueIdFromHandleParameters(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_recoveryeventbuilder.t.cpp b/src/groups/bmq/bmqp/bmqp_recoveryeventbuilder.t.cpp index a4c4e92d0..20a6bdb9a 100644 --- a/src/groups/bmq/bmqp/bmqp_recoveryeventbuilder.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_recoveryeventbuilder.t.cpp @@ -112,7 +112,9 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); const char* CHUNK = "abcdefghijklmnopqrstuvwx"; // Note that chunk must be word aligned per RecoveryEventBuilder's @@ -124,7 +126,8 @@ static void test1_breathingTest() // Create RecoveryEventBuilder. - bmqp::RecoveryEventBuilder reb(&bufferFactory, s_allocator_p); + bmqp::RecoveryEventBuilder reb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(sizeof(bmqp::EventHeader), static_cast(reb.eventSize())); ASSERT_EQ(reb.messageCount(), 0); @@ -148,7 +151,7 @@ static void test1_breathingTest() // them. const bdlbb::Blob& eventBlob = reb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(true == rawEvent.isValid()); BSLS_ASSERT(true == rawEvent.isRecoveryEvent()); @@ -200,9 +203,12 @@ static void test2_multipleMessagesTest() { bmqtst::TestHelper::printTestName("MULTIPLE MESSAGES TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::RecoveryEventBuilder reb(&bufferFactory, s_allocator_p); - bsl::vector data(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::RecoveryEventBuilder reb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); const size_t NUM_MSGS = 1000; data.reserve(NUM_MSGS); @@ -216,7 +222,7 @@ static void test2_multipleMessagesTest() // Iterate and check const bdlbb::Blob& eventBlob = reb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(true == rawEvent.isValid()); BSLS_ASSERT(true == rawEvent.isRecoveryEvent()); @@ -277,9 +283,12 @@ static void test3_eventTooBigTest() { bmqtst::TestHelper::printTestName("EVENT TOO BIG TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::RecoveryEventBuilder reb(&bufferFactory, s_allocator_p); - bsl::string bigChunk(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::RecoveryEventBuilder reb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::string bigChunk(bmqtst::TestHelperUtil::allocator()); bigChunk.resize(bmqp::RecoveryHeader::k_MAX_PAYLOAD_SIZE_SOFT + 4, 'a'); // Note that chunk's size must be word aligned. @@ -322,7 +331,7 @@ static void test3_eventTooBigTest() ASSERT_EQ(reb.messageCount(), 1); const bdlbb::Blob& eventBlob = reb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(true == rawEvent.isValid()); BSLS_ASSERT(true == rawEvent.isRecoveryEvent()); @@ -366,8 +375,11 @@ static void test4_emptyPayloadTest() { bmqtst::TestHelper::printTestName("EMPTY PAYLOAD TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::RecoveryEventBuilder reb(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::RecoveryEventBuilder reb(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr chunkBufferSp( reinterpret_cast(&reb), // dummy @@ -388,7 +400,7 @@ static void test4_emptyPayloadTest() ASSERT_EQ(reb.messageCount(), 1); const bdlbb::Blob& eventBlob = reb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(true == rawEvent.isValid()); BSLS_ASSERT(true == rawEvent.isRecoveryEvent()); @@ -427,7 +439,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_recoverymessageiterator.t.cpp b/src/groups/bmq/bmqp/bmqp_recoverymessageiterator.t.cpp index 982ee10b6..7bfae84fd 100644 --- a/src/groups/bmq/bmqp/bmqp_recoverymessageiterator.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_recoverymessageiterator.t.cpp @@ -179,7 +179,9 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { // Create invalid iter @@ -209,7 +211,7 @@ static void test1_breathingTest() { // Create valid iter - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob const bool isFinal = true; @@ -301,10 +303,12 @@ static void test2_multipleMessages() // Basic functionality // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; const size_t NUM_MSGS = 5000; @@ -359,8 +363,10 @@ static void test3_corruptHeader() // Basic functionality // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); const char* p = "abcdefgh"; unsigned int pLen = bsl::strlen(p); @@ -433,8 +439,10 @@ static void test4_corruptPayload() // Basic functionality // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); const int chunkLen = 1024 * 1024; // valid, under max limit. @@ -460,7 +468,7 @@ static void test4_corruptPayload() reinterpret_cast(&rhd1), sizeof(bmqp::RecoveryHeader)); - bsl::string chunkA(s_allocator_p); + bsl::string chunkA(bmqtst::TestHelperUtil::allocator()); chunkA.resize(chunkLen, 'a'); // length under max limit bdlbb::BlobUtil::append(&eventBlob, chunkA.c_str(), chunkLen); @@ -516,8 +524,10 @@ static void test5_emptyPayload() // Basic functionality // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eh; @@ -602,7 +612,7 @@ static void test6_nextMethod() bmqtst::TestHelper::printTestName("NEXT METHOD"); // Populate blob - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; // Next method. Iterator is in invalid state case. @@ -610,8 +620,10 @@ static void test6_nextMethod() PVV("ITERATOR INVALID STATE"); // Create buffer factory and blob - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, &eventHeader, &data, 1); @@ -635,8 +647,10 @@ static void test6_nextMethod() sizeof(bmqp::EventHeader); // Create buffer factory and blob - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, &eventHeader, &data, 1); @@ -658,8 +672,10 @@ static void test6_nextMethod() sizeof(bmqp::EventHeader); // Create buffer factory and blob - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, &eventHeader, &data, 1); @@ -684,8 +700,10 @@ static void test6_nextMethod() 4; // 4 is payload size due to populateBlob // Create buffer factory and blob - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, &eventHeader, &data, k_NUM_MSGS); @@ -720,7 +738,7 @@ static void test7_resetMethod() bmqtst::TestHelper::printTestName("RESET METHOD"); // Populate blob - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; ASSERT_EQ(eventHeader.headerWords(), sizeof(bmqp::EventHeader) / bmqp::Protocol::k_WORD_SIZE); @@ -730,10 +748,12 @@ static void test7_resetMethod() PVV("INVALID EVENT HEADER"); // Min buf size not to reproduce given rc const size_t enoughSize = sizeof(bmqp::EventHeader) + 1; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); // Create buffer factory and blob - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob and manually set length populateBlob(&blob, &eventHeader, &data, 1); @@ -774,10 +794,12 @@ static void test8_dumpBlob() // Test iterator dump contains expected value bmqp::EventHeader eventHeader; - bsl::vector data(s_allocator_p); - bmqu::MemOutStream stream(s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, &eventHeader, &data, 1); @@ -789,14 +811,14 @@ static void test8_dumpBlob() // Dump blob iter.dumpBlob(stream); - bsl::string str1(stream.str(), s_allocator_p); + bsl::string str1(stream.str(), bmqtst::TestHelperUtil::allocator()); bsl::string str2(" 0: 00000024 49020000 80000007 00720000 " "|...$I........r..|\n" " 16: 00000000 00000000 00000000 00000000 " "|................|\n" " 32: 00000000 " "|.... |\n", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Verify that dump contains expected value ASSERT_EQ(str1, str2); @@ -809,8 +831,8 @@ static void test8_dumpBlob() // Dump blob iter.dumpBlob(stream); - bsl::string str1(stream.str(), s_allocator_p); - bsl::string str2("/no blob/", s_allocator_p); + bsl::string str1(stream.str(), bmqtst::TestHelperUtil::allocator()); + bsl::string str2("/no blob/", bmqtst::TestHelperUtil::allocator()); // Verify that dump contains expected value ASSERT_EQ(str1, str2); @@ -836,7 +858,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_rejecteventbuilder.t.cpp b/src/groups/bmq/bmqp/bmqp_rejecteventbuilder.t.cpp index 38bdabe4e..1863401fa 100644 --- a/src/groups/bmq/bmqp/bmqp_rejecteventbuilder.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_rejecteventbuilder.t.cpp @@ -98,7 +98,7 @@ static void verifyContent(const bmqp::RejectEventBuilder& builder, ASSERT_EQ(static_cast(builder.blob().length()), expectedSize); PVV("Iterating over messages"); - bmqp::Event event(&builder.blob(), s_allocator_p); + bmqp::Event event(&builder.blob(), bmqtst::TestHelperUtil::allocator()); ASSERT(event.isValid()); ASSERT(event.isRejectEvent()); @@ -134,9 +134,12 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::RejectEventBuilder obj(&bufferFactory, s_allocator_p); - bsl::vector messages(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::RejectEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector messages(bmqtst::TestHelperUtil::allocator()); PVV("Verifying accessors"); ASSERT_EQ(obj.messageCount(), 0); @@ -158,9 +161,12 @@ static void test2_multiMessage() const int k_NUM_MSGS = 1000; - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::RejectEventBuilder obj(&bufferFactory, s_allocator_p); - bsl::vector messages(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::RejectEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector messages(bmqtst::TestHelperUtil::allocator()); PVV("Appending messages"); appendMessages(&obj, &messages, k_NUM_MSGS); @@ -174,9 +180,12 @@ static void test3_reset() bmqtst::TestHelper::printTestName("RESET"); // Verifying reset: add three messages, reset, and add another message. - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::RejectEventBuilder obj(&bufferFactory, s_allocator_p); - bsl::vector messages(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::RejectEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector messages(bmqtst::TestHelperUtil::allocator()); PV("Appending 3 messages"); appendMessages(&obj, &messages, 3); @@ -203,8 +212,11 @@ static void test4_capacity() // Verify that once the event is full, AppendMessage returns error. int rc; - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::RejectEventBuilder obj(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::RejectEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); PVV("Computing max message"); // Compute max message using a different logic than how it is done in @@ -256,11 +268,14 @@ static void testN1_decodeFromFile() { bmqtst::TestHelper::printTestName("DECODE FROM FILE"); - bdlbb::PooledBlobBufferFactory bufferFactory(256, s_allocator_p); - bmqp::RejectEventBuilder obj(&bufferFactory, s_allocator_p); - bsl::vector messages(s_allocator_p); - bdlbb::Blob outBlob(&bufferFactory, s_allocator_p); - bmqu::MemOutStream os(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 256, + bmqtst::TestHelperUtil::allocator()); + bmqp::RejectEventBuilder obj(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::vector messages(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob outBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); bdlb::Guid guid = bdlb::GuidUtil::generate(); const int k_NUM_MSGS = 10; @@ -305,7 +320,7 @@ static void testN1_decodeFromFile() bsl::shared_ptr dataBufferSp(buf, bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer dataBlobBuffer(dataBufferSp, blobLen); outBlob.appendDataBuffer(dataBlobBuffer); @@ -314,7 +329,7 @@ static void testN1_decodeFromFile() ASSERT_EQ(bdlbb::BlobUtil::compare(obj.blob(), outBlob), 0); // Decode event - bmqp::Event event(&outBlob, s_allocator_p); + bmqp::Event event(&outBlob, bmqtst::TestHelperUtil::allocator()); ASSERT(event.isValid()); ASSERT(event.isRejectEvent()); @@ -359,7 +374,7 @@ int main(int argc, char* argv[]) case -1: testN1_decodeFromFile(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_rejectmessageiterator.t.cpp b/src/groups/bmq/bmqp/bmqp_rejectmessageiterator.t.cpp index 611c10c05..74f111aea 100644 --- a/src/groups/bmq/bmqp/bmqp_rejectmessageiterator.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_rejectmessageiterator.t.cpp @@ -189,7 +189,9 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { // Create invalid iter @@ -219,7 +221,7 @@ static void test1_breathingTest() { // Create valid iter - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob bmqp::EventHeader eventHeader; @@ -297,10 +299,12 @@ static void test2_multiReject() // Test iterating over REJECT event having multiple REJECT messages - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; const size_t k_NUM_MSGS = 1000; @@ -359,8 +363,10 @@ static void test3_nextMethod() // Next method. Iterator is in invalid state case. { // Create buffer factory and blob - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, &eventHeader, qId, guid, sQId); @@ -383,8 +389,10 @@ static void test3_nextMethod() sizeof(bmqp::RejectMessage); // Create buffer factory and blob - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, &eventHeader, qId, guid, sQId); @@ -433,11 +441,12 @@ static void test4_resetMethod() { // Min buf size not to reproduce given rc const size_t enoughSize = sizeof(bmqp::EventHeader) + 1; - bdlbb::PooledBlobBufferFactory bufferFactory(enoughSize, - s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + enoughSize, + bmqtst::TestHelperUtil::allocator()); // Create buffer factory and blob - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob and manually set length populateBlob(&blob, &eventHeader, qId, guid, sQId); @@ -464,9 +473,10 @@ static void test4_resetMethod() sizeof(bmqp::RejectHeader); // Create buffer factory and blob - bdlbb::PooledBlobBufferFactory bufferFactory(enoughSize, - s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + enoughSize, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob and manually set length populateBlob(&blob, &eventHeader, qId, guid, sQId); @@ -507,12 +517,14 @@ static void test5_dumpBlob() // Test iterator dump contains expected value bmqp::EventHeader eventHeader; - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); const int qId = 54321; const bmqt::MessageGUID guid; const int sQId = 123; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, &eventHeader, qId, guid, sQId); @@ -524,14 +536,14 @@ static void test5_dumpBlob() // Dump blob iter.dumpBlob(stream); - bsl::string str1(stream.str(), s_allocator_p); + bsl::string str1(stream.str(), bmqtst::TestHelperUtil::allocator()); bsl::string str2(" 0: 00000024 4D020000 16000000 0000D431 " "|...$M..........1|\n" " 16: 00000000 00000000 00000000 00000000 " "|................|\n" " 32: 0000007B " "|...{ |\n", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Verify that dump contains expected value ASSERT_EQ(str1, str2); @@ -544,8 +556,8 @@ static void test5_dumpBlob() // Dump blob iter.dumpBlob(stream); - bsl::string str1(stream.str(), s_allocator_p); - bsl::string str2("/no blob/", s_allocator_p); + bsl::string str1(stream.str(), bmqtst::TestHelperUtil::allocator()); + bsl::string str2("/no blob/", bmqtst::TestHelperUtil::allocator()); // Verify that dump contains expected value ASSERT_EQ(str1, str2); @@ -560,7 +572,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -571,7 +583,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_requestmanager.t.cpp b/src/groups/bmq/bmqp/bmqp_requestmanager.t.cpp index df5ba6a8b..814b041dc 100644 --- a/src/groups/bmq/bmqp/bmqp_requestmanager.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_requestmanager.t.cpp @@ -316,7 +316,8 @@ void TestContext::populateRequest(const ReqSp& request, { bmqp_ctrlmsg::OpenQueue& req = request->request().choice().makeOpenQueue(); - bmqp_ctrlmsg::QueueHandleParameters params(s_allocator_p); + bmqp_ctrlmsg::QueueHandleParameters params( + bmqtst::TestHelperUtil::allocator()); bmqt::QueueFlagsUtil::setWriter(&flags); bmqt::QueueFlagsUtil::setAck(&flags); @@ -377,37 +378,39 @@ static void test1_creatorsTest() { bmqtst::TestHelper::printTestName("CREATORS TEST"); - bdlbb::PooledBlobBufferFactory blobBufferFactory(4096, s_allocator_p); + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 4096, + bmqtst::TestHelperUtil::allocator()); { // Wrong clock type bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_REALTIME, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_SAFE_FAIL(ReqManagerType(bmqp::EventType::e_CONTROL, &blobBufferFactory, &scheduler, false, // late response mode is off - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); } { // Success creation bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_PASS(ReqManagerType(bmqp::EventType::e_CONTROL, &blobBufferFactory, &scheduler, false, // late response mode is off - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); ASSERT_PASS(ReqManagerType(bmqp::EventType::e_CONTROL, &blobBufferFactory, &scheduler, false, // late response mode is off bmqex::SystemExecutor(), - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); ASSERT_PASS(ReqManagerType(bmqp::EventType::e_CONTROL, &blobBufferFactory, @@ -415,7 +418,7 @@ static void test1_creatorsTest() false, // late response mode is off bmqex::SystemExecutor(), ReqManagerType::DTContextSp(), - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); } } @@ -429,7 +432,7 @@ static void test2_setExecutorTest() { // set SystemExecutor - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); ASSERT_PASS(context.manager().setExecutor(bmqex::SystemExecutor())); } } @@ -444,7 +447,7 @@ static void test3_createRequestTest() { // Check that RequestManager really creates request - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); ReqSp request = context.createRequest(); ASSERT(request); } @@ -465,9 +468,9 @@ static void test4_sendRequestTest() sendFn(bool* called, const bdlbb::Blob& blob, const ReqSp& request) { *called = true; - bmqp::Event ev(&blob, s_allocator_p); + bmqp::Event ev(&blob, bmqtst::TestHelperUtil::allocator()); ASSERT(ev.isControlEvent()); - Mes controlMessage(s_allocator_p); + Mes controlMessage(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, ev.loadControlEvent(&controlMessage)); ASSERT_EQ(request->request(), controlMessage); return bmqt::GenericResult::e_SUCCESS; @@ -476,7 +479,7 @@ static void test4_sendRequestTest() { // Check one request sent to channel - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); ReqSp request = context.createRequest(); context.populateRequest(request); context.sendChannelRequest(request); @@ -489,14 +492,14 @@ static void test4_sendRequestTest() { // Check several requests sent to channel in correct order - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); const bsl::size_t num_requests = 5; - ReqVec requests(s_allocator_p); + ReqVec requests(bmqtst::TestHelperUtil::allocator()); requests.reserve(num_requests); for (bsl::size_t i = 0; i < num_requests; ++i) { ReqSp request = context.createRequest(); - bsl::ostringstream os(s_allocator_p); + bsl::ostringstream os(bmqtst::TestHelperUtil::allocator()); os << "bmq://foo.bar" << i; context.populateRequest(request, os.str(), @@ -520,7 +523,7 @@ static void test4_sendRequestTest() { // Check one request sent with provided SendFunction - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); ReqSp request = context.createRequest(); context.populateRequest(request); bool called = false; @@ -536,13 +539,13 @@ static void test4_sendRequestTest() { // Concurrency - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); ReqChoiceSet requestsWithoutId; // We store only 'choices' because request obtains id only after it has // been sent const bsl::size_t numThreads = 10; const bsl::size_t numRequests = 100; - bslmt::ThreadGroup threadGroup(s_allocator_p); + bslmt::ThreadGroup threadGroup(bmqtst::TestHelperUtil::allocator()); bslmt::Barrier barrier(numThreads + 1); struct Caller { @@ -564,11 +567,11 @@ static void test4_sendRequestTest() }; for (bsl::size_t i = 0; i < numThreads; ++i) { - ReqVec requestsGroup(s_allocator_p); + ReqVec requestsGroup(bmqtst::TestHelperUtil::allocator()); requestsGroup.reserve(numRequests); for (bsl::size_t j = 0; j < numRequests; ++j) { ReqSp req = context.createRequest(); - bsl::ostringstream os(s_allocator_p); + bsl::ostringstream os(bmqtst::TestHelperUtil::allocator()); os << "bmq://foo.bar_" << i << "_" << j; context.populateRequest(req, os.str(), @@ -620,7 +623,7 @@ static void test5_processResponseTest() { // Correct response - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); ReqSp request = context.createRequest(); context.populateRequest(request); context.sendChannelRequest(request); @@ -638,7 +641,7 @@ static void test5_processResponseTest() { // Response with invalid ID - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); ReqSp request = context.createRequest(); context.populateRequest(request); request->request().rId() = 111; @@ -655,7 +658,7 @@ static void test5_processResponseTest() { // Callback - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); ReqSp request = context.createRequest(); context.populateRequest(request); @@ -676,7 +679,7 @@ static void test5_processResponseTest() { // Timeout - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); ReqSp request = context.createRequest(); context.populateRequest(request); @@ -699,7 +702,7 @@ static void test5_processResponseTest() { // Late Mes mode - TestContext context(true, s_allocator_p); + TestContext context(true, bmqtst::TestHelperUtil::allocator()); ReqSp request = context.createRequest(); context.populateRequest(request); @@ -722,13 +725,13 @@ static void test5_processResponseTest() { // Concurrency - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); bslmt::Mutex responsesLock; - MesQue responses(s_allocator_p); + MesQue responses(bmqtst::TestHelperUtil::allocator()); bsls::AtomicUint callsCounter = 0; const bsl::size_t numThreads = 10; const bsl::size_t numRequests = 500; - bslmt::ThreadGroup threadGroup(s_allocator_p); + bslmt::ThreadGroup threadGroup(bmqtst::TestHelperUtil::allocator()); bslmt::Barrier barrier(numThreads + 1); /// Check that the specified `request` is the same request as @@ -782,7 +785,7 @@ static void test5_processResponseTest() for (bsl::size_t i = 0; i < numRequests; ++i) { ReqSp& request = requests.emplace_back(context.createRequest()); - bsl::ostringstream os(s_allocator_p); + bsl::ostringstream os(bmqtst::TestHelperUtil::allocator()); os << "bmq://foo.bar" << i; context.populateRequest(request, os.str(), @@ -792,7 +795,7 @@ static void test5_processResponseTest() i + 4); request->setResponseCb( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &ConcurrentCaller::callback, &callsCounter, bdlf::PlaceHolders::_1, @@ -831,7 +834,7 @@ static void test6_cancelAllRequestsTest() { // Cancel one event - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); ReqSp request = context.createRequest(); context.populateRequest(request); context.sendChannelRequest(request); @@ -845,13 +848,13 @@ static void test6_cancelAllRequestsTest() { // Cancel all events - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); const bsl::size_t numRequests = 10; - ReqVec requests(s_allocator_p); + ReqVec requests(bmqtst::TestHelperUtil::allocator()); requests.reserve(numRequests); for (bsl::size_t i = 0; i < numRequests; ++i) { ReqSp request = context.createRequest(); - bsl::ostringstream os(s_allocator_p); + bsl::ostringstream os(bmqtst::TestHelperUtil::allocator()); os << "bmq://foo.bar" << i; context.populateRequest(request, os.str(), @@ -876,11 +879,11 @@ static void test6_cancelAllRequestsTest() { // Cancel group of events - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); const bsl::size_t numRequests = 10; - ReqVec requests(s_allocator_p); + ReqVec requests(bmqtst::TestHelperUtil::allocator()); requests.reserve(numRequests); - bsl::vector groupIds(2, s_allocator_p); + bsl::vector groupIds(2, bmqtst::TestHelperUtil::allocator()); groupIds[0] = 1; groupIds[1] = 2; for (bsl::size_t i = 0; i < numRequests; ++i) { @@ -919,7 +922,9 @@ static void test7_requestBreathingTest() { // Create request and check its initial state ReqSp request; - ASSERT_PASS(request.createInplace(s_allocator_p, s_allocator_p)); + ASSERT_PASS( + request.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator())); ASSERT(request); ASSERT(!request->isLateResponse()); ASSERT(!request->isLocalTimeout()); @@ -940,13 +945,15 @@ static void test7_requestBreathingTest() { // set responseCb and call it ReqSp request; - request.createInplace(s_allocator_p, s_allocator_p); + request.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); bool called = false; - request->setResponseCb(bdlf::BindUtil::bindS(s_allocator_p, - &Caller::callback, - &called, - bdlf::PlaceHolders::_1, - &request)); + request->setResponseCb( + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), + &Caller::callback, + &called, + bdlf::PlaceHolders::_1, + &request)); request->responseCb()(request); ASSERT(called); @@ -954,11 +961,11 @@ static void test7_requestBreathingTest() { // set asyncNotifierCb and check if it is called - TestContext context(false, s_allocator_p); + TestContext context(false, bmqtst::TestHelperUtil::allocator()); ReqSp request = context.createRequest(); bool called = false; request->setAsyncNotifierCb( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &Caller::callback, &called, bdlf::PlaceHolders::_1, @@ -970,7 +977,8 @@ static void test7_requestBreathingTest() { // set groupId and check it ReqSp request; - request.createInplace(s_allocator_p, s_allocator_p); + request.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); int expected = 666; request->setGroupId(expected); ASSERT_EQ(request->groupId(), expected); @@ -978,11 +986,13 @@ static void test7_requestBreathingTest() { // set user data and check it - bsl::string test("test string", s_allocator_p); - bdld::Datum datum = bdld::Datum::createStringRef(test.c_str(), - s_allocator_p); + bsl::string test("test string", bmqtst::TestHelperUtil::allocator()); + bdld::Datum datum = bdld::Datum::createStringRef( + test.c_str(), + bmqtst::TestHelperUtil::allocator()); ReqSp request; - request.createInplace(s_allocator_p, s_allocator_p); + request.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); request->adoptUserData(datum); const bdld::Datum& new_datum = request->userData(); ASSERT(new_datum.isString()); @@ -1013,17 +1023,19 @@ static void test8_requestSignalWaitTest() // Wait for signal in separate thread bool worked = false; ReqSp request; - ASSERT_PASS(request.createInplace(s_allocator_p, s_allocator_p)); + ASSERT_PASS( + request.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator())); bslmt::ThreadUtil::Handle handle; int rc = bslmt::ThreadUtil::createWithAllocator( &handle, - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &RequestKeeper::waiter, &worked, &request), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(rc, 0); bslmt::ThreadUtil::yield(); ASSERT(!worked); @@ -1044,8 +1056,8 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqsys::Time::initialize(s_allocator_p); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqsys::Time::initialize(bmqtst::TestHelperUtil::allocator()); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -1059,7 +1071,7 @@ int main(int argc, char* argv[]) case 1: test1_creatorsTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_routingconfigurationutils.t.cpp b/src/groups/bmq/bmqp/bmqp_routingconfigurationutils.t.cpp index 785c8b2fd..29273e3ff 100644 --- a/src/groups/bmq/bmqp/bmqp_routingconfigurationutils.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_routingconfigurationutils.t.cpp @@ -182,7 +182,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_schemaeventbuilder.t.cpp b/src/groups/bmq/bmqp/bmqp_schemaeventbuilder.t.cpp index f4e349f77..0dfe0f7b4 100644 --- a/src/groups/bmq/bmqp/bmqp_schemaeventbuilder.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_schemaeventbuilder.t.cpp @@ -55,7 +55,9 @@ static void test1_breathingTest() bmqtst::TestHelper::printTestName("BREATHING TEST"); int rc; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -73,14 +75,15 @@ static void test1_breathingTest() PVV(test.d_line << ": Testing " << test.d_encodingType << "encoding"); bmqp::SchemaEventBuilder obj(&bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), test.d_encodingType); PVV(test.d_line << ": Verifying accessors"); ASSERT_EQ(obj.blob().length(), 0); PVV(test.d_line << ": Create a message"); - bmqp_ctrlmsg::ControlMessage message(s_allocator_p); + bmqp_ctrlmsg::ControlMessage message( + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::Status& status = message.choice().makeStatus(); status.code() = 123; status.message() = "Test"; @@ -92,12 +95,13 @@ static void test1_breathingTest() ASSERT_EQ(obj.blob().length() % 4, 0); PVV(test.d_line << ": Decode and compare message"); - bmqp::Event event(&obj.blob(), s_allocator_p); + bmqp::Event event(&obj.blob(), bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(event.isValid(), true); ASSERT_EQ(event.isControlEvent(), true); - bmqp_ctrlmsg::ControlMessage decoded(s_allocator_p); + bmqp_ctrlmsg::ControlMessage decoded( + bmqtst::TestHelperUtil::allocator()); rc = event.loadControlEvent(&decoded); ASSERT_EQ(rc, 0); @@ -131,7 +135,7 @@ void testDecodeFromFileHelper(bmqp::SchemaEventBuilder* obj, ASSERT_EQ(rc, 0); ASSERT_NE(obj->blob().length(), 0); - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); bdlb::Guid guid = bdlb::GuidUtil::generate(); os << "msg_control_" << typeString << "_" << guid << ".bin" << bsl::ends; @@ -172,15 +176,15 @@ void testDecodeFromFileHelper(bmqp::SchemaEventBuilder* obj, bsl::shared_ptr dataBufferSp(buf, bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer dataBlobBuffer(dataBufferSp, blobLen); - bdlbb::Blob blb(bufferFactory, s_allocator_p); + bdlbb::Blob blb(bufferFactory, bmqtst::TestHelperUtil::allocator()); blb.appendDataBuffer(dataBlobBuffer); blb.setLength(blobLen); PVVV("Decode event"); - bmqp::Event event(&blb, s_allocator_p); + bmqp::Event event(&blb, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(event.isValid(), true); ASSERT_EQ(event.isControlEvent(), true); @@ -215,7 +219,7 @@ static void test2_bestEncodingSupported() PV("Remote feature set only supports one encoding"); { - bsl::string features1(s_allocator_p); + bsl::string features1(bmqtst::TestHelperUtil::allocator()); features1.append(bmqp::EncodingFeature::k_FIELD_NAME) .append(":") .append(bmqp::EncodingFeature::k_ENCODING_BER); @@ -224,7 +228,7 @@ static void test2_bestEncodingSupported() bmqp::EncodingType::e_BER, bmqp::SchemaEventBuilderUtil::bestEncodingSupported(features1)); - bsl::string features2(s_allocator_p); + bsl::string features2(bmqtst::TestHelperUtil::allocator()); features2.append(bmqp::EncodingFeature::k_FIELD_NAME) .append(":") .append(bmqp::EncodingFeature::k_ENCODING_JSON); @@ -236,7 +240,7 @@ static void test2_bestEncodingSupported() PV("Remote feature set supports all encodings"); { - bsl::string features(s_allocator_p); + bsl::string features(bmqtst::TestHelperUtil::allocator()); features.append(bmqp::EncodingFeature::k_FIELD_NAME) .append(":") .append(bmqp::EncodingFeature::k_ENCODING_BER) @@ -274,7 +278,9 @@ static void testN1_decodeFromFile() bmqtst::TestHelper::printTestName("DECODE FROM FILE"); const int k_SIZE = 512; - bdlbb::PooledBlobBufferFactory bufferFactory(k_SIZE, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + k_SIZE, + bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -292,13 +298,15 @@ static void testN1_decodeFromFile() PVV(test.d_line << ": Testing " << test.d_encodingType << " encoding"); bmqp::SchemaEventBuilder obj(&bufferFactory, - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), test.d_encodingType); PVV(test.d_line << ": Status message"); { - bmqp_ctrlmsg::ControlMessage message(s_allocator_p); - bmqp_ctrlmsg::ControlMessage decoded(s_allocator_p); + bmqp_ctrlmsg::ControlMessage message( + bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::ControlMessage decoded( + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::Status& status = message.choice().makeStatus(); status.code() = 123; status.message() = "Test"; @@ -316,8 +324,10 @@ static void testN1_decodeFromFile() PVV(test.d_line << ": Negotiation message - ClientIdentity"); { - bmqp_ctrlmsg::NegotiationMessage message(s_allocator_p); - bmqp_ctrlmsg::NegotiationMessage decoded(s_allocator_p); + bmqp_ctrlmsg::NegotiationMessage message( + bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::NegotiationMessage decoded( + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::ClientIdentity& ci = message.makeClientIdentity(); ci.protocolVersion() = bmqp::Protocol::k_VERSION; @@ -364,8 +374,10 @@ static void testN1_decodeFromFile() PVV(test.d_line << ": Negotiation message - ClientIdentity (GUIDS)"); { - bmqp_ctrlmsg::NegotiationMessage message(s_allocator_p); - bmqp_ctrlmsg::NegotiationMessage decoded(s_allocator_p); + bmqp_ctrlmsg::NegotiationMessage message( + bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::NegotiationMessage decoded( + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::ClientIdentity& ci = message.makeClientIdentity(); ci.protocolVersion() = bmqp::Protocol::k_VERSION; @@ -412,8 +424,10 @@ static void testN1_decodeFromFile() PVV(test.d_line << ": Negotiation message - BrokerResponse"); { const int k_BROKER_VERSION = 3; - bmqp_ctrlmsg::NegotiationMessage message(s_allocator_p); - bmqp_ctrlmsg::NegotiationMessage decoded(s_allocator_p); + bmqp_ctrlmsg::NegotiationMessage message( + bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::NegotiationMessage decoded( + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::BrokerResponse& br = message.makeBrokerResponse(); br.protocolVersion() = bmqp::Protocol::k_VERSION; br.brokerVersion() = k_BROKER_VERSION; @@ -465,12 +479,15 @@ static void testN1_decodeFromFile() PVV(test.d_line << ": OpenQueue message"); { - bmqp_ctrlmsg::ControlMessage message(s_allocator_p); - bmqp_ctrlmsg::ControlMessage decoded(s_allocator_p); + bmqp_ctrlmsg::ControlMessage message( + bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::ControlMessage decoded( + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::OpenQueue& openQueue = message.choice().makeOpenQueue(); - bmqp_ctrlmsg::QueueHandleParameters params(s_allocator_p); + bmqp_ctrlmsg::QueueHandleParameters params( + bmqtst::TestHelperUtil::allocator()); bsls::Types::Uint64 flags = 0; bmqt::QueueFlagsUtil::setWriter(&flags); @@ -501,14 +518,17 @@ static void testN1_decodeFromFile() PVV(test.d_line << ": OpenQueueResponse message"); { - bmqp_ctrlmsg::ControlMessage message(s_allocator_p); - bmqp_ctrlmsg::ControlMessage decoded(s_allocator_p); + bmqp_ctrlmsg::ControlMessage message( + bmqtst::TestHelperUtil::allocator()); + bmqp_ctrlmsg::ControlMessage decoded( + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::OpenQueueResponse& openQueueResponse = message.choice().makeOpenQueueResponse(); bmqp_ctrlmsg::OpenQueue& openQueue = openQueueResponse.originalRequest(); - bmqp_ctrlmsg::QueueHandleParameters params(s_allocator_p); + bmqp_ctrlmsg::QueueHandleParameters params( + bmqtst::TestHelperUtil::allocator()); bsls::Types::Uint64 flags = 0; bmqt::QueueFlagsUtil::setWriter(&flags); @@ -549,7 +569,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -558,7 +578,7 @@ int main(int argc, char* argv[]) case -1: testN1_decodeFromFile(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_schemagenerator.t.cpp b/src/groups/bmq/bmqp/bmqp_schemagenerator.t.cpp index fd7f924d1..e9ff73461 100644 --- a/src/groups/bmq/bmqp/bmqp_schemagenerator.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_schemagenerator.t.cpp @@ -68,7 +68,7 @@ static void generateMessageProperties(bmqp::MessageProperties* mps, int property = bsl::rand() % length[combination]; for (int l = 0; l < length[combination]; ++l) { - bsl::string name("property_", s_allocator_p); + bsl::string name("property_", bmqtst::TestHelperUtil::allocator()); name += bsl::to_string(lap); name += "_"; name += bsl::to_string(sequence[combination] + property); @@ -84,8 +84,8 @@ static void generateMessageProperties(bmqp::MessageProperties* mps, static void test1_breathingTest() { int count = 0; - bsl::map ids(s_allocator_p); - bmqp::SchemaGenerator theGenerator(s_allocator_p); + bsl::map ids(bmqtst::TestHelperUtil::allocator()); + bmqp::SchemaGenerator theGenerator(bmqtst::TestHelperUtil::allocator()); theGenerator._setCapacity(MAX_SCHEMA); @@ -128,7 +128,7 @@ static void test1_breathingTest() for (int i = 0; i < NUM_COMBINATIONS; ++i, ++count) { BSLS_ASSERT_SAFE(length[i]); - bmqp::MessageProperties mps(s_allocator_p); + bmqp::MessageProperties mps(bmqtst::TestHelperUtil::allocator()); // For example, given {a, b, c} properties: // [a] // [a, b] @@ -157,7 +157,7 @@ static void test1_breathingTest() // Some number of first test combinations (65) got recycled. // Repeat them again and verify, they got new IDs. for (int i = 0; i < 33; ++i) { - bmqp::MessageProperties mps(s_allocator_p); + bmqp::MessageProperties mps(bmqtst::TestHelperUtil::allocator()); generateMessageProperties(&mps, 0, i); // Sequence numbering starts from '0', schema's - from '1' @@ -194,7 +194,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_schemalearner.t.cpp b/src/groups/bmq/bmqp/bmqp_schemalearner.t.cpp index 31c4e8e15..f094e9bdf 100644 --- a/src/groups/bmq/bmqp/bmqp_schemalearner.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_schemalearner.t.cpp @@ -43,7 +43,7 @@ static void test1_multiplexingTest() // Two distinct sources translate the same id ('1'). The result must be // unique id in each case. // - bmqp::SchemaLearner theLearner(s_allocator_p); + bmqp::SchemaLearner theLearner(bmqtst::TestHelperUtil::allocator()); bmqp::SchemaLearner::Context clientSession1 = theLearner.createContext(); bmqp::SchemaLearner::Context clientSession2 = theLearner.createContext(); @@ -83,11 +83,13 @@ static void test2_readingTest() // The resulting schema must be the same until recycling is indicated. // - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bmqp::SchemaLearner theLearner(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bmqp::SchemaLearner theLearner(bmqtst::TestHelperUtil::allocator()); bmqp::SchemaLearner::Context queueEngine(theLearner.createContext()); bmqp::SchemaLearner::Context clientSession(theLearner.createContext()); - bmqp::MessageProperties in(s_allocator_p); + bmqp::MessageProperties in(bmqtst::TestHelperUtil::allocator()); bmqp::MessagePropertiesInfo input(true, 1, false); bmqp::MessagePropertiesInfo recycledInput(true, 1, true); @@ -99,7 +101,7 @@ static void test2_readingTest() } const bdlbb::Blob blob = in.streamOut(&bufferFactory, input); - bmqp::MessageProperties out(s_allocator_p); + bmqp::MessageProperties out(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, theLearner.read(queueEngine, @@ -107,7 +109,8 @@ static void test2_readingTest() theLearner.multiplex(clientSession, input), blob)); - bmqp::MessageProperties::SchemaPtr schema1 = out.makeSchema(s_allocator_p); + bmqp::MessageProperties::SchemaPtr schema1 = out.makeSchema( + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, theLearner.read(queueEngine, @@ -115,7 +118,7 @@ static void test2_readingTest() theLearner.multiplex(clientSession, input), blob)); - ASSERT_EQ(schema1, out.makeSchema(s_allocator_p)); + ASSERT_EQ(schema1, out.makeSchema(bmqtst::TestHelperUtil::allocator())); // subsequent call returns the same Schema int start = bsl::rand() % num; @@ -138,7 +141,7 @@ static void test2_readingTest() blob)); bmqp::MessageProperties::SchemaPtr schema2; - schema2 = out.makeSchema(s_allocator_p); + schema2 = out.makeSchema(bmqtst::TestHelperUtil::allocator()); ASSERT_NE(schema1, schema2); // ...unless the input is recycled @@ -168,11 +171,13 @@ static void test3_observingTest() // While reading the same MPs in the same context, the result must be the // same until observing recycling indication. // - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bmqp::SchemaLearner theLearner(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bmqp::SchemaLearner theLearner(bmqtst::TestHelperUtil::allocator()); bmqp::SchemaLearner::Context server(theLearner.createContext()); - bmqp::MessageProperties in(s_allocator_p); + bmqp::MessageProperties in(bmqtst::TestHelperUtil::allocator()); bmqp::MessagePropertiesInfo input(true, 1, false); in.setPropertyAsString("z", "z"); @@ -180,21 +185,21 @@ static void test3_observingTest() in.setPropertyAsString("x", "x"); const bdlbb::Blob blob = in.streamOut(&bufferFactory, input); - bmqp::MessageProperties out1(s_allocator_p); - bmqp::MessageProperties out2(s_allocator_p); + bmqp::MessageProperties out1(bmqtst::TestHelperUtil::allocator()); + bmqp::MessageProperties out2(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, theLearner.read(server, &out1, input, blob)); ASSERT_EQ(0, theLearner.read(server, &out2, input, blob)); bmqp::MessageProperties::SchemaPtr schema1 = out1.makeSchema( - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - ASSERT_EQ(schema1, out2.makeSchema(s_allocator_p)); + ASSERT_EQ(schema1, out2.makeSchema(bmqtst::TestHelperUtil::allocator())); // subsequent call returns the same Schema ASSERT_EQ(0, theLearner.read(server, &out2, input, blob)); - ASSERT_EQ(schema1, out2.makeSchema(s_allocator_p)); + ASSERT_EQ(schema1, out2.makeSchema(bmqtst::TestHelperUtil::allocator())); // subsequent call returns the same Schema bmqp::MessagePropertiesInfo recycledInput(true, 1, true); @@ -203,7 +208,7 @@ static void test3_observingTest() ASSERT_EQ(0, theLearner.read(server, &out2, input, blob)); - ASSERT_NE(schema1, out2.makeSchema(s_allocator_p)); + ASSERT_NE(schema1, out2.makeSchema(bmqtst::TestHelperUtil::allocator())); // ...unless the input is recycled } @@ -212,8 +217,10 @@ static void test4_demultiplexingTest() // Demultiplexing (PUSH) indicates recycling first, then no recycling until // multiplexing (PUT) indicates recycling. - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bmqp::SchemaLearner theLearner(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bmqp::SchemaLearner theLearner(bmqtst::TestHelperUtil::allocator()); bmqp::SchemaLearner::Context queueHandle(theLearner.createContext()); bmqp::MessagePropertiesInfo muxIn(true, 1, false); @@ -242,12 +249,14 @@ static void test5_emptyMPs() bmqtst::TestHelper::printTestName("'empty MPs' TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bmqp::SchemaLearner theLearner(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bmqp::SchemaLearner theLearner(bmqtst::TestHelperUtil::allocator()); bmqp::SchemaLearner::Context context(theLearner.createContext()); - bmqp::MessageProperties p(s_allocator_p); - bdlbb::Blob wireRep(&bufferFactory, s_allocator_p); + bmqp::MessageProperties p(bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob wireRep(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqp::MessagePropertiesInfo logic(true, 1, true); // Empty rep. @@ -266,11 +275,13 @@ static void test6_partialRead() { // Read known schema partially. Change one property and then continue // reading. - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bmqp::SchemaLearner theLearner(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bmqp::SchemaLearner theLearner(bmqtst::TestHelperUtil::allocator()); bmqp::SchemaLearner::Context context(theLearner.createContext()); - bmqp::MessageProperties in(s_allocator_p); + bmqp::MessageProperties in(bmqtst::TestHelperUtil::allocator()); bmqp::MessagePropertiesInfo input(true, 1, false); const char x[] = "x"; const char y[] = "y"; @@ -282,13 +293,13 @@ static void test6_partialRead() in.setPropertyAsString("x", x); const bdlbb::Blob blob = in.streamOut(&bufferFactory, input); - bmqp::MessageProperties out1(s_allocator_p); + bmqp::MessageProperties out1(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, theLearner.read(context, &out1, input, blob)); // 1st setProperty w/o getProperty and then getProperty { - bmqp::MessageProperties out2(s_allocator_p); + bmqp::MessageProperties out2(bmqtst::TestHelperUtil::allocator()); // The second read is optimized (only one MPS header) ASSERT_EQ(0, theLearner.read(context, &out2, input, blob)); @@ -302,7 +313,7 @@ static void test6_partialRead() // 2nd getProperty, setProperty and then load all { - bmqp::MessageProperties out3(s_allocator_p); + bmqp::MessageProperties out3(bmqtst::TestHelperUtil::allocator()); // The third read is optimized (only one MPS header) ASSERT_EQ(0, theLearner.read(context, &out3, input, blob)); @@ -310,7 +321,7 @@ static void test6_partialRead() ASSERT_EQ(y, out3.getPropertyAsString("y")); ASSERT_EQ(0, out3.setPropertyAsString("y", mod)); - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); out3.print(os, 0, -1); PV(os.str()); @@ -327,7 +338,7 @@ static void test6_partialRead() // 3rd getProperty, setProperty and then getProperty { - bmqp::MessageProperties out4(s_allocator_p); + bmqp::MessageProperties out4(bmqtst::TestHelperUtil::allocator()); // The fourth read is optimized (only one MPS header) ASSERT_EQ(0, theLearner.read(context, &out4, input, blob)); @@ -345,11 +356,13 @@ static void test7_removeBeforeRead() { // Read known schema partially. Remove one property and then continue // reading. - bdlbb::PooledBlobBufferFactory bufferFactory(128, s_allocator_p); - bmqp::SchemaLearner theLearner(s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 128, + bmqtst::TestHelperUtil::allocator()); + bmqp::SchemaLearner theLearner(bmqtst::TestHelperUtil::allocator()); bmqp::SchemaLearner::Context context(theLearner.createContext()); - bmqp::MessageProperties in(s_allocator_p); + bmqp::MessageProperties in(bmqtst::TestHelperUtil::allocator()); bmqp::MessagePropertiesInfo input(true, 1, false); const int numProps = 3; @@ -361,14 +374,14 @@ static void test7_removeBeforeRead() } const bdlbb::Blob blob = in.streamOut(&bufferFactory, input); - bmqp::MessageProperties out1(s_allocator_p); + bmqp::MessageProperties out1(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(0, theLearner.read(context, &out1, input, blob)); for (int iProperty = 0; iProperty < numProps; ++iProperty) { const char* current = name[iProperty]; for (int iScenario = 0; iScenario < 3; ++iScenario) { - bmqp::MessageProperties out2(s_allocator_p); + bmqp::MessageProperties out2(bmqtst::TestHelperUtil::allocator()); // All subsequent reads are optimized (only one MPS header) ASSERT_EQ(0, theLearner.read(context, &out2, input, blob)); @@ -400,7 +413,7 @@ static void test7_removeBeforeRead() } } - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); out2.print(os, 0, -1); PV(os.str()); @@ -448,7 +461,7 @@ static void test7_removeBeforeRead() int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -461,7 +474,7 @@ int main(int argc, char* argv[]) case 1: test1_multiplexingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_storageeventbuilder.t.cpp b/src/groups/bmq/bmqp/bmqp_storageeventbuilder.t.cpp index 89c01e472..dc2675908 100644 --- a/src/groups/bmq/bmqp/bmqp_storageeventbuilder.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_storageeventbuilder.t.cpp @@ -184,7 +184,9 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); const char* PAYLOAD = "abcdefghijklmnopqrstuvwx"; const unsigned int PAYLOAD_LEN = bsl::strlen(PAYLOAD); // 24 const char* JOURNAL_REC = "12345678"; @@ -197,19 +199,20 @@ static void test1_breathingTest() bmqp::StorageEventBuilder seb(1, // storage protocol version bmqp::EventType::e_STORAGE, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(seb.eventSize(), static_cast(sizeof(bmqp::EventHeader))); ASSERT_EQ(seb.messageCount(), 0); - bsl::shared_ptr journalRecordBufferSp(const_cast(JOURNAL_REC), - bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bsl::shared_ptr journalRecordBufferSp( + const_cast(JOURNAL_REC), + bslstl::SharedPtrNilDeleter(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer journalRecordBlobBuffer(journalRecordBufferSp, JOURNAL_REC_LEN); bsl::shared_ptr dataBufferSp(const_cast(PAYLOAD), bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer dataBlobBuffer(dataBufferSp, PAYLOAD_LEN); bmqt::EventBuilderResult::Enum rc = seb.packMessage( @@ -228,7 +231,7 @@ static void test1_breathingTest() // Note that bmqp event and bmqp iterators are lower than bmqp builders, // and thus, can be used to test them. const bdlbb::Blob& eventBlob = seb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(true == rawEvent.isValid()); BSLS_ASSERT(true == rawEvent.isStorageEvent()); @@ -284,24 +287,29 @@ static void test2_storageEventHavingMultipleMessages() " MESSAGES"); const int k_SPV = 2; // Storage protocol version - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bmqp::StorageEventBuilder seb(k_SPV, bmqp::EventType::e_STORAGE, &bufferFactory, - s_allocator_p); - bsl::vector data(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); const size_t NUM_MSGS = 1000; data.reserve(NUM_MSGS); for (size_t dataIdx = 0; dataIdx < NUM_MSGS; ++dataIdx) { - bmqt::EventBuilderResult::Enum rc = - appendMessage(dataIdx, &seb, &data, s_allocator_p); + bmqt::EventBuilderResult::Enum rc = appendMessage( + dataIdx, + &seb, + &data, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(dataIdx, rc, bmqt::EventBuilderResult::e_SUCCESS); } // Iterate and check const bdlbb::Blob& eventBlob = seb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(true == rawEvent.isValid()); BSLS_ASSERT(true == rawEvent.isStorageEvent()); @@ -369,7 +377,9 @@ static void test3_packMessage_payloadTooBig() { bmqtst::TestHelper::printTestName("PACK MESSAGE - PAYLOAD TOO BIG"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); const int k_SPV = 1; // Storage proto version const char* PAYLOAD = "abcdefghijklmnopqrstuvwx"; @@ -381,22 +391,22 @@ static void test3_packMessage_payloadTooBig() bmqp::StorageEventBuilder seb(k_SPV, bmqp::EventType::e_STORAGE, &bufferFactory, - s_allocator_p); - bsl::string bigPayload(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::string bigPayload(bmqtst::TestHelperUtil::allocator()); bigPayload.resize(bmqp::StorageHeader::k_MAX_PAYLOAD_SIZE_SOFT + 4, 'a'); // Note that payload's size must be word aligned. bsl::shared_ptr journalRecordBufferSp( const_cast(IGNORED_JOURNAL_REC), bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer journalRecordBlobBuffer( journalRecordBufferSp, bsl::strlen(IGNORED_JOURNAL_REC)); bsl::shared_ptr dataBufferSp(const_cast(bigPayload.c_str()), bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer dataBlobBuffer(dataBufferSp, bigPayload.length()); bmqt::EventBuilderResult::Enum rc = seb.packMessage( @@ -413,12 +423,12 @@ static void test3_packMessage_payloadTooBig() journalRecordBufferSp.reset(const_cast(JOURNAL_REC), bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); journalRecordBlobBuffer.reset(journalRecordBufferSp, JOURNAL_REC_LEN); dataBufferSp.reset(const_cast(PAYLOAD), bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); dataBlobBuffer.reset(dataBufferSp, PAYLOAD_LEN); // Now append a "regular"-sized message and make sure event builder @@ -437,7 +447,7 @@ static void test3_packMessage_payloadTooBig() ASSERT_EQ(seb.messageCount(), 1); const bdlbb::Blob& eventBlob = seb.blob(); - bmqp::Event rawEvent(&eventBlob, s_allocator_p); + bmqp::Event rawEvent(&eventBlob, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(true == rawEvent.isValid()); BSLS_ASSERT(true == rawEvent.isStorageEvent()); @@ -502,23 +512,28 @@ static void test4_packMessageRaw() // messages packed in event 'A'. const int k_SPV = 2; // Storage protocol version - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bmqp::StorageEventBuilder sebA(k_SPV, bmqp::EventType::e_STORAGE, &bufferFactory, - s_allocator_p); - bsl::vector data(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); const size_t NUM_MSGS = 1000; data.reserve(NUM_MSGS); for (size_t dataIdx = 0; dataIdx < NUM_MSGS; ++dataIdx) { - bmqt::EventBuilderResult::Enum rc = - appendMessage(dataIdx, &sebA, &data, s_allocator_p); + bmqt::EventBuilderResult::Enum rc = appendMessage( + dataIdx, + &sebA, + &data, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(dataIdx, rc, bmqt::EventBuilderResult::e_SUCCESS); } const bdlbb::Blob& eventA = sebA.blob(); - bmqp::Event rawEventA(&eventA, s_allocator_p); + bmqp::Event rawEventA(&eventA, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(rawEventA.isValid() == true); BSLS_ASSERT(rawEventA.isStorageEvent() == true); @@ -532,7 +547,7 @@ static void test4_packMessageRaw() bmqp::StorageEventBuilder sebB(k_SPV, bmqp::EventType::e_STORAGE, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); while (1 == iterA.next() && dataIndex < NUM_MSGS) { ASSERT_EQ_D(dataIndex, true, iterA.isValid()); @@ -554,7 +569,7 @@ static void test4_packMessageRaw() // Finally, iterate over event 'B' and verify. const bdlbb::Blob& eventB = sebB.blob(); - bmqp::Event rawEventB(&eventB, s_allocator_p); + bmqp::Event rawEventB(&eventB, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(true == rawEventB.isValid()); BSLS_ASSERT(true == rawEventB.isStorageEvent()); @@ -630,13 +645,15 @@ static void test5_packMessageRaw_emptyMessage() bmqtst::TestHelper::printTestName("PACK MESSAGE RAW - EMPTY MESSAGE"); const int k_SPV = 2; // Storage protocol version - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bmqp::StorageEventBuilder seb(k_SPV, + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqp::StorageEventBuilder seb(k_SPV, bmqp::EventType::e_STORAGE, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - bdlbb::Blob emptyBlob(&bufferFactory, s_allocator_p); + bdlbb::Blob emptyBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(emptyBlob.length() == 0); ASSERT_SAFE_FAIL( seb.packMessageRaw(emptyBlob, bmqu::BlobPosition(0, 0), 0)); @@ -669,21 +686,24 @@ static void test6_packMessageRaw_invalidPosition() bmqtst::TestHelper::printTestName("PACK MESSAGE RAW - INVALID POSITION"); const int k_SPV = 2; // Storage protocol version - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob k_EMPTY_BLOB(&bufferFactory, s_allocator_p); - bmqp::StorageEventBuilder seb(k_SPV, + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob k_EMPTY_BLOB(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqp::StorageEventBuilder seb(k_SPV, bmqp::EventType::e_STORAGE, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // 1. - bsl::string payloadStr(1024U, 'x', s_allocator_p); + bsl::string payloadStr(1024U, 'x', bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr dataBufferSp(const_cast(payloadStr.c_str()), bslstl::SharedPtrNilDeleter(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer dataBlobBuffer(dataBufferSp, payloadStr.length()); - bdlbb::Blob message(&bufferFactory, s_allocator_p); + bdlbb::Blob message(&bufferFactory, bmqtst::TestHelperUtil::allocator()); message.appendDataBuffer(dataBlobBuffer); bmqu::BlobPosition invalidPosition(-1, -1); @@ -705,7 +725,7 @@ int main(int argc, char* argv[]) // Temporary workaround to suppress the 'unused operator // NestedTraitDeclaration' warning/error generated by clang. TBD: figure // out the right way to "fix" this. - Data dummy(s_allocator_p); + Data dummy(bmqtst::TestHelperUtil::allocator()); static_cast( static_cast< bslmf::NestedTraitDeclaration >( @@ -721,7 +741,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqp/bmqp_storagemessageiterator.t.cpp b/src/groups/bmq/bmqp/bmqp_storagemessageiterator.t.cpp index 3823fff79..085eca44d 100644 --- a/src/groups/bmq/bmqp/bmqp_storagemessageiterator.t.cpp +++ b/src/groups/bmq/bmqp/bmqp_storagemessageiterator.t.cpp @@ -107,7 +107,7 @@ void populateBlob(bdlbb::Blob* blob, for (size_t i = 0; i < numMsgs; ++i) { int msgSize = 0; - Data data(s_allocator_p); + Data data(bmqtst::TestHelperUtil::allocator()); data.d_flags = 1; data.d_spv = 1; data.d_pid = i % 100; @@ -250,7 +250,9 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); { // Create invalid iter @@ -280,7 +282,7 @@ static void test1_breathingTest() { // Create valid iter - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob const int flags = 2; @@ -365,10 +367,12 @@ static void test2_storageEventHavingMultipleMessages() bmqtst::TestHelper::printTestName("STORAGE EVENT HAVING MULTIPLE" " MESSAGES"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; const size_t NUM_MSGS = 5000; @@ -449,8 +453,10 @@ static void test3_corruptedStorageEvent_part1() { bmqtst::TestHelper::printTestName("CORRUPTED STORAGE EVENT - PART 1"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); const char* p = "abcdefgh"; unsigned int pLen = bsl::strlen(p); @@ -526,8 +532,10 @@ static void test4_corruptedStorageEvent_part2() { bmqtst::TestHelper::printTestName("CORRUPTED STORAGE EVENT - PART 2"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob eventBlob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob eventBlob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // BUILD the event blob ... // EventHeader @@ -551,7 +559,7 @@ static void test4_corruptedStorageEvent_part2() reinterpret_cast(&shd1), sizeof(bmqp::StorageHeader)); - bsl::string confirmRecord(s_allocator_p); + bsl::string confirmRecord(bmqtst::TestHelperUtil::allocator()); confirmRecord.resize(k_RECORD_SIZE, 'a'); bdlbb::BlobUtil::append(&eventBlob, confirmRecord.c_str(), k_RECORD_SIZE); @@ -609,7 +617,7 @@ static void test5_corruptedStorageEvent_part3() bmqtst::TestHelper::printTestName("CORRUPTED STORAGE EVENT - PART 3"); // Populate blob - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; // Next method. No recovery header. Less then min header size. { @@ -618,8 +626,10 @@ static void test5_corruptedStorageEvent_part3() sizeof(bmqp::EventHeader); // Create buffer factory and blob - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, &eventHeader, &data, 1); @@ -651,17 +661,19 @@ static void test6_resetMethod() bmqtst::TestHelper::printTestName("RESET METHOD"); // Populate blob - bsl::vector data(s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); bmqp::EventHeader eventHeader; // Reset method. Invalid event header case. { // Min buf size not to reproduce given rc const size_t enoughSize = sizeof(bmqp::EventHeader) + 1; - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); // Create buffer factory and blob - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob and manually set length populateBlob(&blob, &eventHeader, &data, 1); @@ -704,10 +716,12 @@ static void test7_dumpBlob() // Test iterator dump contains expected value bmqp::EventHeader eventHeader; - bsl::vector data(s_allocator_p); - bmqu::MemOutStream stream(s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bsl::vector data(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); // Populate blob populateBlob(&blob, &eventHeader, &data, 1); @@ -719,7 +733,7 @@ static void test7_dumpBlob() // Dump blob iter.dumpBlob(stream); - bsl::string str1(stream.str(), s_allocator_p); + bsl::string str1(stream.str(), bmqtst::TestHelperUtil::allocator()); bsl::string str2(" 0: 00000044 48020000 0800000F 13010000 " "|...DH...........|\n" " 16: 00000005 00000000 00000000 00000000 " @@ -730,7 +744,7 @@ static void test7_dumpBlob() "|................|\n" " 64: 00000000 " "|.... |\n", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Verify that dump contains expected value ASSERT_EQ(str1, str2); @@ -742,8 +756,8 @@ static void test7_dumpBlob() bmqp::StorageMessageIterator iter; // Dump blob iter.dumpBlob(stream); - bsl::string str1(stream.str(), s_allocator_p); - bsl::string str2("/no blob/", s_allocator_p); + bsl::string str1(stream.str(), bmqtst::TestHelperUtil::allocator()); + bsl::string str2("/no blob/", bmqtst::TestHelperUtil::allocator()); // Verify that dump contains expected value ASSERT_EQ(str1, str2); @@ -761,7 +775,7 @@ int main(int argc, char* argv[]) // Temporary workaround to suppress the 'unused operator // NestedTraitDeclaration' warning/error generated by clang. TBD: figure // out the right way to "fix" this. - Data dummy(s_allocator_p); + Data dummy(bmqtst::TestHelperUtil::allocator()); static_cast( static_cast< bslmf::NestedTraitDeclaration >( @@ -778,7 +792,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqpi/bmqpi_dtcontext.t.cpp b/src/groups/bmq/bmqpi/bmqpi_dtcontext.t.cpp index 17a565f72..9e087be73 100644 --- a/src/groups/bmq/bmqpi/bmqpi_dtcontext.t.cpp +++ b/src/groups/bmq/bmqpi/bmqpi_dtcontext.t.cpp @@ -83,7 +83,7 @@ static void test1_breathingTest() // PROTOCOL TEST // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // The default allocator check fails in this test case because the // 'markDone' methods of AbstractSession may sometimes return a // memory-aware object without utilizing the parameter allocator. @@ -122,7 +122,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqpi/bmqpi_dtspan.t.cpp b/src/groups/bmq/bmqpi/bmqpi_dtspan.t.cpp index 601975e59..2539557c4 100644 --- a/src/groups/bmq/bmqpi/bmqpi_dtspan.t.cpp +++ b/src/groups/bmq/bmqpi/bmqpi_dtspan.t.cpp @@ -71,7 +71,7 @@ static void test1_breathingTest() // PROTOCOL TEST // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // The default allocator check fails in this test case because the // 'markDone' methods of AbstractSession may sometimes return a // memory-aware object without utilizing the parameter allocator. @@ -109,7 +109,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqpi/bmqpi_dttracer.t.cpp b/src/groups/bmq/bmqpi/bmqpi_dttracer.t.cpp index 997137a15..f67e2e008 100644 --- a/src/groups/bmq/bmqpi/bmqpi_dttracer.t.cpp +++ b/src/groups/bmq/bmqpi/bmqpi_dttracer.t.cpp @@ -80,7 +80,7 @@ static void test1_breathingTest() // PROTOCOL TEST // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // The default allocator check fails in this test case because the // 'markDone' methods of AbstractSession may sometimes return a // memory-aware object without utilizing the parameter allocator. @@ -118,7 +118,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqpi/bmqpi_hosthealthmonitor.t.cpp b/src/groups/bmq/bmqpi/bmqpi_hosthealthmonitor.t.cpp index 0b7ecb52f..3202ce493 100644 --- a/src/groups/bmq/bmqpi/bmqpi_hosthealthmonitor.t.cpp +++ b/src/groups/bmq/bmqpi/bmqpi_hosthealthmonitor.t.cpp @@ -86,7 +86,7 @@ static void test1_breathingTest() // PROTOCOL TEST // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // The default allocator check fails in this test case because the // 'markDone' methods of AbstractSession may sometimes return a // memory-aware object without utilizing the parameter allocator. @@ -126,7 +126,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqsys/bmqsys_mocktime.t.cpp b/src/groups/bmq/bmqsys/bmqsys_mocktime.t.cpp index f488eb9e3..41eddf140 100644 --- a/src/groups/bmq/bmqsys/bmqsys_mocktime.t.cpp +++ b/src/groups/bmq/bmqsys/bmqsys_mocktime.t.cpp @@ -74,7 +74,7 @@ int main(int argc, char* argv[]) case 1: test1_basicFunctionality(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqsys/bmqsys_statmonitor.t.cpp b/src/groups/bmq/bmqsys/bmqsys_statmonitor.t.cpp index d16734e23..b692d4f7d 100644 --- a/src/groups/bmq/bmqsys/bmqsys_statmonitor.t.cpp +++ b/src/groups/bmq/bmqsys/bmqsys_statmonitor.t.cpp @@ -201,12 +201,12 @@ void doWorkAndPostWhenDone(bslmt::Semaphore* workDoneSemaphore) const int k_NUM_THREADS = 3; // Multithreaded calculation - bslmt::ThreadGroup threadGroup(s_allocator_p); + bslmt::ThreadGroup threadGroup(bmqtst::TestHelperUtil::allocator()); bslmt::Barrier workDoneBarrier(k_NUM_THREADS + 1); for (int i = 0; i < k_NUM_THREADS; ++i) { int rc = threadGroup.addThread( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &doWork_threadFunction, &workDoneBarrier, 10000, // rate @@ -245,15 +245,16 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'snapshot' passes a string using default alloc PVV("Constructor"); { const int k_HISTORY_SIZE = 5; - bmqu::MemOutStream errorDesc(s_allocator_p); - bmqsys::StatMonitor obj(k_HISTORY_SIZE, s_allocator_p); + bmqu::MemOutStream errorDesc(bmqtst::TestHelperUtil::allocator()); + bmqsys::StatMonitor obj(k_HISTORY_SIZE, + bmqtst::TestHelperUtil::allocator()); ASSERT(obj.isStarted() == false); ASSERT(obj.statContext() != 0); @@ -296,15 +297,16 @@ static void test2_start() // - Constructor // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'start' passes a string using default alloc bmqtst::TestHelper::printTestName("START"); const int k_HISTORY_SIZE = 5; - bmqu::MemOutStream errorDesc(s_allocator_p); - bmqsys::StatMonitor obj(k_HISTORY_SIZE, s_allocator_p); + bmqu::MemOutStream errorDesc(bmqtst::TestHelperUtil::allocator()); + bmqsys::StatMonitor obj(k_HISTORY_SIZE, + bmqtst::TestHelperUtil::allocator()); // Given BSLS_ASSERT_OPT(obj.isStarted() == false); @@ -349,15 +351,16 @@ static void test3_stop() // - stop // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'start' passes a string using default alloc bmqtst::TestHelper::printTestName("STOP"); const int k_HISTORY_SIZE = 5; - bmqu::MemOutStream errorDesc(s_allocator_p); - bmqsys::StatMonitor obj(k_HISTORY_SIZE, s_allocator_p); + bmqu::MemOutStream errorDesc(bmqtst::TestHelperUtil::allocator()); + bmqsys::StatMonitor obj(k_HISTORY_SIZE, + bmqtst::TestHelperUtil::allocator()); // Given BSLS_ASSERT_OPT(obj.start(errorDesc) == 0); @@ -439,15 +442,16 @@ static void test4_snapshot() PVV_INV_CONTEXT_SWITCHES_N(0); \ BSLS_MACROREPEAT(3, PVV_INV_CONTEXT_SWITCHES_N); - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'start' passes a string using default alloc bmqtst::TestHelper::printTestName("SNAPSHOT"); const int k_HISTORY_SIZE = 5; - bmqu::MemOutStream errorDesc(s_allocator_p); - bmqsys::StatMonitor obj(k_HISTORY_SIZE, s_allocator_p); + bmqu::MemOutStream errorDesc(bmqtst::TestHelperUtil::allocator()); + bmqsys::StatMonitor obj(k_HISTORY_SIZE, + bmqtst::TestHelperUtil::allocator()); // Given int rc = obj.start(errorDesc); @@ -466,10 +470,10 @@ static void test4_snapshot() bslmt::ThreadUtil::createWithAllocator( &handle, attributes, - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &doWorkAndPostWhenDone, &workDoneSemaphore), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bslmt::ThreadUtil::sleep( bsls::TimeInterval(0, 1 * bdlt::TimeUnitRatio::k_NS_PER_MS)); @@ -510,10 +514,10 @@ static void test4_snapshot() bslmt::ThreadUtil::createWithAllocator( &handle, attributes, - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &doWorkAndPostWhenDone, &workDoneSemaphore), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); workDoneSemaphore.wait(); BSLS_ASSERTTEST_ASSERT_OPT_PASS(obj.snapshot()); @@ -532,10 +536,10 @@ static void test4_snapshot() bslmt::ThreadUtil::createWithAllocator( &handle, attributes, - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &doWorkAndPostWhenDone, &workDoneSemaphore), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); workDoneSemaphore.wait(); BSLS_ASSERTTEST_ASSERT_OPT_PASS(obj.snapshot()); @@ -574,7 +578,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqsys/bmqsys_statmonitorsnapshotrecorder.t.cpp b/src/groups/bmq/bmqsys/bmqsys_statmonitorsnapshotrecorder.t.cpp index 986edf213..8c192bffb 100644 --- a/src/groups/bmq/bmqsys/bmqsys_statmonitorsnapshotrecorder.t.cpp +++ b/src/groups/bmq/bmqsys/bmqsys_statmonitorsnapshotrecorder.t.cpp @@ -129,9 +129,10 @@ static void test1_usageExample() { bmqtst::TestHelper::printTestName("USAGE EXAMPLE"); - bmqsys::Time::initialize(s_allocator_p); + bmqsys::Time::initialize(bmqtst::TestHelperUtil::allocator()); - const bsl::string k_HEADER("Cluster (testCluster): ", s_allocator_p); + const bsl::string k_HEADER("Cluster (testCluster): ", + bmqtst::TestHelperUtil::allocator()); // Begin testing PV("Valued constructor"); @@ -145,7 +146,7 @@ static void test1_usageExample() ASSERT_GT(statRecorder.totalElapsed(), 0); // Log stats for step 1 (resets the stat recorder) - bmqu::MemOutStream os1(s_allocator_p); + bmqu::MemOutStream os1(bmqtst::TestHelperUtil::allocator()); statRecorder.print(os1, "EXPENSIVE OPERATION - STEP 1"); PVV(os1.str()); @@ -158,7 +159,7 @@ static void test1_usageExample() "CPU SYSTEM AVG.*: (0|\\d+\\.?\\d*.*) %.*" "CPU ALL AVG.*: (0|\\d+\\.?\\d*.*) %.*" "VOLUNTARY CONTEXT SWITCHES.*: \\d+.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); // Perform some intensive work - step 2 @@ -166,7 +167,7 @@ static void test1_usageExample() 3); // duration // Log stats for step 2 (resets the stat recorder) - bmqu::MemOutStream os2(s_allocator_p); + bmqu::MemOutStream os2(bmqtst::TestHelperUtil::allocator()); statRecorder.print(os2, "EXPENSIVE OPERATION - STEP 2"); PVV(os2.str()); @@ -178,7 +179,7 @@ static void test1_usageExample() "CPU SYSTEM AVG.*: (0|\\d+\\.?\\d*.*) %.*" "CPU ALL AVG.*: (0|\\d+\\.?\\d*.*) %.*" "VOLUNTARY CONTEXT SWITCHES.*: \\d+.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); // Finally, assert stats have changed @@ -188,15 +189,16 @@ static void test1_usageExample() PV("Copy constructor"); { bmqsys::StatMonitorSnapshotRecorder statRecorderTemp(k_HEADER); - bmqsys::StatMonitorSnapshotRecorder statRecorder(statRecorderTemp, - s_allocator_p); + bmqsys::StatMonitorSnapshotRecorder statRecorder( + statRecorderTemp, + bmqtst::TestHelperUtil::allocator()); // Perform some intensive work - step 1 doWork(7500, // rate 3); // duration // Log stats for step 1 (resets the stat recorder) - bmqu::MemOutStream os1(s_allocator_p); + bmqu::MemOutStream os1(bmqtst::TestHelperUtil::allocator()); statRecorder.print(os1, "EXPENSIVE OPERATION - STEP 1"); PVV(os1.str()); @@ -209,7 +211,7 @@ static void test1_usageExample() "CPU SYSTEM AVG.*: (0|\\d+\\.?\\d*.*) %.*" "CPU ALL AVG.*: (0|\\d+\\.?\\d*.*) %.*" "VOLUNTARY CONTEXT SWITCHES.*: \\d+.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); // Perform some intensive work - step 2 @@ -217,7 +219,7 @@ static void test1_usageExample() 3); // duration // Log stats for step 2 (resets the stat recorder) - bmqu::MemOutStream os2(s_allocator_p); + bmqu::MemOutStream os2(bmqtst::TestHelperUtil::allocator()); statRecorder.print(os2, "EXPENSIVE OPERATION - STEP 2"); PVV(os2.str()); @@ -230,7 +232,7 @@ static void test1_usageExample() "CPU SYSTEM AVG.*: (0|\\d+\\.?\\d*.*) %.*" "CPU ALL AVG.*: (0|\\d+\\.?\\d*.*) %.*" "VOLUNTARY CONTEXT SWITCHES.*: \\d+.*", - s_allocator_p), + bmqtst::TestHelperUtil::allocator()), true); // Finally, assert stats have changed @@ -276,7 +278,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // 'snapshot' in 'bmqsys::StatMonitor' passes a string using default // alloc. @@ -286,7 +288,7 @@ int main(int argc, char* argv[]) case 1: test1_usageExample(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqsys/bmqsys_time.t.cpp b/src/groups/bmq/bmqsys/bmqsys_time.t.cpp index a63c39749..c1c5f844b 100644 --- a/src/groups/bmq/bmqsys/bmqsys_time.t.cpp +++ b/src/groups/bmq/bmqsys/bmqsys_time.t.cpp @@ -414,7 +414,7 @@ int main(int argc, char* argv[]) break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_compressionalgorithmtype.t.cpp b/src/groups/bmq/bmqt/bmqt_compressionalgorithmtype.t.cpp index 6a32a209d..28a3a74cb 100644 --- a/src/groups/bmq/bmqt/bmqt_compressionalgorithmtype.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_compressionalgorithmtype.t.cpp @@ -53,8 +53,8 @@ static void printEnumHelper(ARRAY (&data)[SIZE]) PVVV("Line [" << test.d_line << "]"); - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); typedef typename ENUM_TYPE::Enum T; @@ -135,7 +135,7 @@ int main(int argc, char* argv[]) case 1: test1_enumPrint(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_correlationid.t.cpp b/src/groups/bmq/bmqt/bmqt_correlationid.t.cpp index 2f21d077f..df8198687 100644 --- a/src/groups/bmq/bmqt/bmqt_correlationid.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_correlationid.t.cpp @@ -53,7 +53,7 @@ static void test1_breathingTest() bmqtst::TestHelper::printTestName("BREATHING TEST"); // An object for testing pointers - bsl::string foo("foo", s_allocator_p); + bsl::string foo("foo", bmqtst::TestHelperUtil::allocator()); bsl::string* fooPtr = &foo; PV("Test unset correlationId"); @@ -140,7 +140,7 @@ static void test2_copyAndAssign() bmqtst::TestHelper::printTestName("COPY AND ASSIGN"); // An object for testing pointers - bsl::string foo("foo", s_allocator_p); + bsl::string foo("foo", bmqtst::TestHelperUtil::allocator()); bsl::string* fooPtr = &foo; // conversions to bmqt::CorrelationId and back @@ -205,8 +205,8 @@ static void test3_compare() bsl::shared_ptr intPtr1; bsl::shared_ptr intPtr4; - intPtr1.createInplace(s_allocator_p, val1); - intPtr4.createInplace(s_allocator_p, val4); + intPtr1.createInplace(bmqtst::TestHelperUtil::allocator(), val1); + intPtr4.createInplace(bmqtst::TestHelperUtil::allocator(), val4); bmqt::CorrelationId sptrId1(intPtr1); bmqt::CorrelationId sptrId4(intPtr4); @@ -266,7 +266,7 @@ static void test4_smartPointers() bmqt::CorrelationId smartIntCorrelation; { bsl::shared_ptr intPtr; - intPtr.createInplace(s_allocator_p, value); + intPtr.createInplace(bmqtst::TestHelperUtil::allocator(), value); bmqt::CorrelationId id(intPtr); smartIntCorrelation = id; ASSERT_EQ(smartIntCorrelation.isNumeric(), false); @@ -324,14 +324,14 @@ static void test6_hashAppend() PV("HASH FUNCTION DETERMINISTIC"); - bsl::string foo("foo", s_allocator_p); + bsl::string foo("foo", bmqtst::TestHelperUtil::allocator()); bsl::string* fooPtr = &foo; bsls::Types::Int64 numeric = 0xA5A5A5A5A5A5A5A5; const size_t k_NUM_ITERATIONS = 1000; size_t t = bmqt::CorrelationId::e_NUMERIC; bsl::shared_ptr intPtr; - intPtr.createInplace(s_allocator_p, numeric); + intPtr.createInplace(bmqtst::TestHelperUtil::allocator(), numeric); for (; t < bmqt::CorrelationId::e_UNSET + 1; ++t) { bmqt::CorrelationId obj; @@ -377,18 +377,18 @@ static void test7_printTest() PV("Testing print"); - bsl::string foo("foo", s_allocator_p); + bsl::string foo("foo", bmqtst::TestHelperUtil::allocator()); bsl::string* fooPtr = &foo; bsls::Types::Int64 numeric = 0x5a5a5a5a5a5a5a5a; size_t t = bmqt::CorrelationId::e_NUMERIC; bsl::shared_ptr intPtr; - intPtr.createInplace(s_allocator_p, numeric); + intPtr.createInplace(bmqtst::TestHelperUtil::allocator(), numeric); for (; t < bmqt::CorrelationId::e_UNSET + 1; ++t) { bmqt::CorrelationId obj; - bmqu::MemOutStream patStream(s_allocator_p); - bmqu::MemOutStream objStream(s_allocator_p); + bmqu::MemOutStream patStream(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream objStream(bmqtst::TestHelperUtil::allocator()); switch (t) { case bmqt::CorrelationId::e_NUMERIC: { obj = bmqt::CorrelationId(numeric); @@ -432,7 +432,7 @@ static void test7_printTest() PV("Bad stream test"); bmqt::CorrelationId obj; - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); stream << "BAD STREAM"; stream.clear(bsl::ios_base::badbit); @@ -460,7 +460,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_encodingtype.t.cpp b/src/groups/bmq/bmqt/bmqt_encodingtype.t.cpp index 1d797b55e..fe2769132 100644 --- a/src/groups/bmq/bmqt/bmqt_encodingtype.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_encodingtype.t.cpp @@ -56,7 +56,7 @@ static void test1_toAscii() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bsl::string ascii(s_allocator_p); + bsl::string ascii(bmqtst::TestHelperUtil::allocator()); ascii = bmqt::EncodingType::toAscii( bmqt::EncodingType::Enum(test.d_value)); ASSERT_EQ_D(test.d_line, ascii, test.d_expected); @@ -88,9 +88,10 @@ static void test2_fromAscii() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqu::MemOutStream errorDescription(s_allocator_p); + bmqu::MemOutStream errorDescription( + bmqtst::TestHelperUtil::allocator()); - bsl::string str(test.d_input, s_allocator_p); + bsl::string str(test.d_input, bmqtst::TestHelperUtil::allocator()); bool isValid = bmqt::EncodingType::isValid(&str, errorDescription); ASSERT_EQ_D(test.d_line, isValid, test.d_isValid); @@ -108,7 +109,7 @@ static void test3_isomorphism() bmqtst::TestHelper::printTestName("ISOMORPHISM"); bmqt::EncodingType::Enum obj; - bsl::string str(s_allocator_p); + bsl::string str(bmqtst::TestHelperUtil::allocator()); bool res; PV("Testing: fromAscii(toAscii(value)) = value"); @@ -155,8 +156,8 @@ static void test4_printTest() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); expected << test.d_expected; @@ -193,7 +194,7 @@ int main(int argc, char* argv[]) case 1: test1_toAscii(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_hosthealthstate.t.cpp b/src/groups/bmq/bmqt/bmqt_hosthealthstate.t.cpp index b1ad4b022..87d683bcc 100644 --- a/src/groups/bmq/bmqt/bmqt_hosthealthstate.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_hosthealthstate.t.cpp @@ -85,8 +85,8 @@ static void test2_printTest() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); expected << test.d_expected; @@ -121,7 +121,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_messageeventtype.t.cpp b/src/groups/bmq/bmqt/bmqt_messageeventtype.t.cpp index 216803967..5b64875b7 100644 --- a/src/groups/bmq/bmqt/bmqt_messageeventtype.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_messageeventtype.t.cpp @@ -91,8 +91,8 @@ static void test2_printTest() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); expected << test.d_expected; @@ -127,7 +127,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_messageguid.t.cpp b/src/groups/bmq/bmqt/bmqt_messageguid.t.cpp index 4cd2e88f1..f31bc4beb 100644 --- a/src/groups/bmq/bmqt/bmqt_messageguid.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_messageguid.t.cpp @@ -127,7 +127,7 @@ static void test2_streamout() PV("Unset GUID"); bmqt::MessageGUID obj; - bmqu::MemOutStream osstr(s_allocator_p); + bmqu::MemOutStream osstr(bmqtst::TestHelperUtil::allocator()); osstr << obj; ASSERT_EQ("** UNSET **", osstr.str()); @@ -142,12 +142,12 @@ static void test2_streamout() bmqt::MessageGUID obj; obj.fromHex(k_HEX_G); - bmqu::MemOutStream osstr(s_allocator_p); + bmqu::MemOutStream osstr(bmqtst::TestHelperUtil::allocator()); osstr << obj; bsl::string guidStr(k_HEX_G, bmqt::MessageGUID::e_SIZE_HEX, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(guidStr, osstr.str()); @@ -164,7 +164,7 @@ static void test2_streamout() bmqt::MessageGUID obj; obj.fromHex(k_HEX_G); - bmqu::MemOutStream osstr(s_allocator_p); + bmqu::MemOutStream osstr(bmqtst::TestHelperUtil::allocator()); obj.print(osstr, 2, 4); ASSERT_EQ(k_EXPECTED, osstr.str()); @@ -177,7 +177,7 @@ static void test2_streamout() bmqt::MessageGUID obj; - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); out.setstate(bsl::ios_base::badbit); obj.print(out, 0, -1); @@ -322,7 +322,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_propertytype.t.cpp b/src/groups/bmq/bmqt/bmqt_propertytype.t.cpp index 8b2bb2860..c410e929f 100644 --- a/src/groups/bmq/bmqt/bmqt_propertytype.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_propertytype.t.cpp @@ -71,7 +71,7 @@ static void test2_printTest() { bmqtst::TestHelper::printTestName("PRINT"); PV("Testing print"); - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); stream << bmqt::PropertyType::e_INT64; ASSERT_EQ(stream.str(), "INT64"); stream.reset(); @@ -93,7 +93,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_queueflags.t.cpp b/src/groups/bmq/bmqt/bmqt_queueflags.t.cpp index 1b5b97bf2..766cc49c9 100644 --- a/src/groups/bmq/bmqt/bmqt_queueflags.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_queueflags.t.cpp @@ -60,7 +60,7 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bmqu::MemOutStream errorOs(s_allocator_p); + bmqu::MemOutStream errorOs(bmqtst::TestHelperUtil::allocator()); int rc; bsls::Types::Uint64 flags1 = 0; bsls::Types::Uint64 flags2 = 0; @@ -84,7 +84,7 @@ static void test1_breathingTest() errorOs.reset(); PV("Testing prettyPrint"); - bmqu::MemOutStream osPrint(s_allocator_p); + bmqu::MemOutStream osPrint(bmqtst::TestHelperUtil::allocator()); bmqt::QueueFlagsUtil::prettyPrint(osPrint, flags2); ASSERT_EQ(osPrint.str(), ""); @@ -103,7 +103,8 @@ static void test1_breathingTest() ASSERT(bmqt::QueueFlagsUtil::isReader(flags2)); ASSERT(!bmqt::QueueFlagsUtil::isWriter(flags2)); - bsl::string flagsStr("WRITE,INVALID,READ,INVALID2", s_allocator_p); + bsl::string flagsStr("WRITE,INVALID,READ,INVALID2", + bmqtst::TestHelperUtil::allocator()); rc = bmqt::QueueFlagsUtil::fromString(errorOs, &flags2, flagsStr); ASSERT_NE(rc, 0); ASSERT_EQ(errorOs.str(), "Invalid flag(s) 'INVALID','INVALID2'"); @@ -188,8 +189,8 @@ static void test3_printTest() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); expected << test.d_expected; @@ -344,7 +345,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_queueoptions.t.cpp b/src/groups/bmq/bmqt/bmqt_queueoptions.t.cpp index 27229a680..415103106 100644 --- a/src/groups/bmq/bmqt/bmqt_queueoptions.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_queueoptions.t.cpp @@ -33,7 +33,7 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bmqt::QueueOptions obj(s_allocator_p); + bmqt::QueueOptions obj(bmqtst::TestHelperUtil::allocator()); const int msgs = 8; const int bytes = 1024; @@ -62,7 +62,7 @@ static void test1_breathingTest() ASSERT_EQ(suspendsOnBadHostHealth, obj.suspendsOnBadHostHealth()); PV("Copy constructor"); - bmqt::QueueOptions obj1(obj, s_allocator_p); + bmqt::QueueOptions obj1(obj, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj1.maxUnconfirmedMessages(), obj.maxUnconfirmedMessages()); ASSERT_EQ(obj1.maxUnconfirmedBytes(), obj.maxUnconfirmedBytes()); @@ -87,21 +87,21 @@ static void test1_breathingTest() " suspendsOnBadHostHealth = false ]"; { PVV("Print (print function)"); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); obj.print(out, 0, -1); ASSERT_EQ(out.str(), expected); } { PVV("Print (stream operator)"); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); out << obj; ASSERT_EQ(out.str(), expected); } { PVV("Print (bad stream)"); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); out.setstate(bsl::ios_base::badbit); obj.print(out, 0, -1); ASSERT_EQ(out.str(), ""); @@ -129,7 +129,7 @@ static void test2_defaultsTest() bmqtst::TestHelper::printTestName("DEFAULTS TEST"); PVV("Step 1. Construct default instance and test its values"); - bmqt::QueueOptions options(s_allocator_p); + bmqt::QueueOptions options(bmqtst::TestHelperUtil::allocator()); ASSERT(!options.hasMaxUnconfirmedBytes()); ASSERT(!options.hasMaxUnconfirmedMessages()); ASSERT(!options.hasConsumerPriority()); @@ -174,13 +174,13 @@ static void test3_mergeTest() bmqtst::TestHelper::printTestName("MERGE TEST"); PVV("Step 1. Construct two objects"); - bmqt::QueueOptions options(s_allocator_p); + bmqt::QueueOptions options(bmqtst::TestHelperUtil::allocator()); options.setMaxUnconfirmedMessages(54321).setMaxUnconfirmedBytes(0); ASSERT(options.hasMaxUnconfirmedMessages()); ASSERT(options.hasMaxUnconfirmedBytes()); ASSERT(!options.hasConsumerPriority()); - bmqt::QueueOptions diff(s_allocator_p); + bmqt::QueueOptions diff(bmqtst::TestHelperUtil::allocator()); diff.setMaxUnconfirmedBytes(7890).setConsumerPriority(42); ASSERT(!diff.hasMaxUnconfirmedMessages()); ASSERT(diff.hasMaxUnconfirmedBytes()); @@ -203,7 +203,7 @@ static void test4_subscriptionsTest() { bmqtst::TestHelper::printTestName("SUBSCRIPTIONS TEST"); - bmqt::QueueOptions obj(s_allocator_p); + bmqt::QueueOptions obj(bmqtst::TestHelperUtil::allocator()); const int msgs = 8; const int bytes = 1024; @@ -211,7 +211,8 @@ static void test4_subscriptionsTest() int in = 1; - bsl::set handles(s_allocator_p); + bsl::set handles( + bmqtst::TestHelperUtil::allocator()); for (; in <= 3; ++in) { const bmqt::CorrelationId cid(in); @@ -249,7 +250,8 @@ static void test4_subscriptionsTest() ASSERT(!error.empty()); } - bmqt::QueueOptions::SubscriptionsSnapshot snapshot(s_allocator_p); + bmqt::QueueOptions::SubscriptionsSnapshot snapshot( + bmqtst::TestHelperUtil::allocator()); obj.loadSubscriptions(&snapshot); for (bmqt::QueueOptions::SubscriptionsSnapshot::const_iterator citOut = @@ -286,7 +288,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_resultcode.t.cpp b/src/groups/bmq/bmqt/bmqt_resultcode.t.cpp index adff143b0..a584d81ba 100644 --- a/src/groups/bmq/bmqt/bmqt_resultcode.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_resultcode.t.cpp @@ -126,8 +126,8 @@ static void printEnumHelper(ARRAY (&data)[SIZE]) PVVV("Line [" << test.d_line << "]"); - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); typedef typename ENUM_TYPE::Enum T; @@ -448,7 +448,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_sessioneventtype.t.cpp b/src/groups/bmq/bmqt/bmqt_sessioneventtype.t.cpp index e2b12a352..19d4a34c9 100644 --- a/src/groups/bmq/bmqt/bmqt_sessioneventtype.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_sessioneventtype.t.cpp @@ -106,8 +106,8 @@ static void test2_printTest() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); expected << test.d_expected; @@ -142,7 +142,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_sessionoptions.t.cpp b/src/groups/bmq/bmqt/bmqt_sessionoptions.t.cpp index 42e5d1d1a..ce3fd742f 100644 --- a/src/groups/bmq/bmqt/bmqt_sessionoptions.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_sessionoptions.t.cpp @@ -37,15 +37,17 @@ static void test1_breathingTest() bmqtst::TestHelper::printTestName("BREATHING TEST"); // Create default sessionOptions - bmqt::SessionOptions sessionOptions(s_allocator_p); + bmqt::SessionOptions sessionOptions(bmqtst::TestHelperUtil::allocator()); // Make sure 'k_BROKER_DEFAULT_PORT' and the default brokerUri are in sync { PV("CHECKING k_BROKER_DEFAULT_PORT and brokerUri()"); - bmqu::MemOutStream ss(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); ss << "tcp://localhost:" << bmqt::SessionOptions::k_BROKER_DEFAULT_PORT; - bsl::string str(ss.str().data(), ss.str().length(), s_allocator_p); + bsl::string str(ss.str().data(), + ss.str().length(), + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(str, sessionOptions.brokerUri()); } } @@ -63,9 +65,9 @@ static void test2_printTest() "hasDistributedTracing = false ]"; bmqtst::TestHelper::printTestName("PRINT"); PV("Testing print"); - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); // Create default sessionOptions - bmqt::SessionOptions sessionOptions(s_allocator_p); + bmqt::SessionOptions sessionOptions(bmqtst::TestHelperUtil::allocator()); stream << sessionOptions; ASSERT_EQ(stream.str(), sampleSessionOptionsLayout); stream.reset(); @@ -81,7 +83,7 @@ static void test3_setterGetterAndCopyTest() bmqtst::TestHelper::printTestName("SETTER GETTER"); PVV("Setter getter test"); // Create default sessionOptions - bmqt::SessionOptions obj(s_allocator_p); + bmqt::SessionOptions obj(bmqtst::TestHelperUtil::allocator()); PVV("Checking setter and getter for brokerUri"); const char* const brokerUri = "tcp://localhost:30115"; @@ -178,7 +180,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_uri.t.cpp b/src/groups/bmq/bmqt/bmqt_uri.t.cpp index 3d1dcf0a8..b1326599f 100644 --- a/src/groups/bmq/bmqt/bmqt_uri.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_uri.t.cpp @@ -54,13 +54,13 @@ static void threadFunction(int threadId, barrier->wait(); for (int i = 0; i < numIterations; ++i) { - bmqu::MemOutStream osstrDomain(s_allocator_p); - bmqu::MemOutStream osstrQueue(s_allocator_p); + bmqu::MemOutStream osstrDomain(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream osstrQueue(bmqtst::TestHelperUtil::allocator()); osstrDomain << "my.domain." << threadId << "." << i; osstrQueue << "queue-foo-bar-" << threadId << "-" << i; - bmqt::Uri qualifiedUri(s_allocator_p); - bmqt::UriBuilder builder(s_allocator_p); + bmqt::Uri qualifiedUri(bmqtst::TestHelperUtil::allocator()); + bmqt::UriBuilder builder(bmqtst::TestHelperUtil::allocator()); builder.setDomain(osstrDomain.str()); builder.setQueue(osstrQueue.str()); @@ -96,31 +96,32 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); int rc = 0; - bsl::string error(s_allocator_p); + bsl::string error(bmqtst::TestHelperUtil::allocator()); PV("Test constructors"); { - bsl::string uriStr("bmq://my.domain/queue-foo-bar", s_allocator_p); - bmqt::Uri obj1(uriStr, s_allocator_p); + bsl::string uriStr("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); + bmqt::Uri obj1(uriStr, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj1.isValid(), true); const bslstl::StringRef& uriStrRef = uriStr; - bmqt::Uri obj2(uriStrRef, s_allocator_p); + bmqt::Uri obj2(uriStrRef, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj2.isValid(), true); ASSERT_EQ(obj1, obj2); const char* uriRaw = uriStr.data(); - bmqt::Uri obj3(uriRaw, s_allocator_p); + bmqt::Uri obj3(uriRaw, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj3.isValid(), true); ASSERT_EQ(obj2, obj3); - bmqt::Uri obj4(obj3, s_allocator_p); + bmqt::Uri obj4(obj3, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj4.isValid(), true); ASSERT_EQ(obj3, obj4); @@ -128,12 +129,13 @@ static void test1_breathingTest() PV("Test basic parsing"); { - bmqt::Uri obj(s_allocator_p); + bmqt::Uri obj(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.isValid(), false); { // Scope input to ensure it gets deleted after (and so validate the // string ref are correctly pointing to the right values). - bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); rc = bmqt::UriParser::parse(&obj, &error, uri); ASSERT_EQ(rc, 0); ASSERT_EQ(error, ""); @@ -154,12 +156,12 @@ static void test1_breathingTest() PV("Test assignment operator") { const char k_URI[] = "bmq://my.domain.~tst/queue"; - bmqt::Uri objCopy(s_allocator_p); + bmqt::Uri objCopy(bmqtst::TestHelperUtil::allocator()); { // Scope the original URI, so that it will be destroyed before we // check the copy. - bmqt::Uri objOriginal(s_allocator_p); + bmqt::Uri objOriginal(bmqtst::TestHelperUtil::allocator()); rc = bmqt::UriParser::parse(&objOriginal, &error, k_URI); ASSERT_EQ(rc, 0); ASSERT_EQ(error, ""); @@ -181,14 +183,14 @@ static void test1_breathingTest() PV("Testing comparison operators") { const char k_URI[] = "bmq://my.domain/queue"; - bmqt::Uri obj1(s_allocator_p); + bmqt::Uri obj1(bmqtst::TestHelperUtil::allocator()); bmqt::UriParser::parse(&obj1, &error, k_URI); - bmqt::Uri obj2(obj1, s_allocator_p); + bmqt::Uri obj2(obj1, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj1, obj2); - bmqt::Uri obj3(s_allocator_p); + bmqt::Uri obj3(bmqtst::TestHelperUtil::allocator()); ASSERT_NE(obj1, obj3); obj3 = obj2; @@ -199,7 +201,7 @@ static void test1_breathingTest() { { const char k_URI[] = "bmq://ts.trades.myapp/my.queue"; - bmqt::Uri obj(s_allocator_p); + bmqt::Uri obj(bmqtst::TestHelperUtil::allocator()); rc = bmqt::UriParser::parse(&obj, &error, k_URI); ASSERT_EQ(rc, 0); ASSERT_EQ(error, ""); @@ -214,7 +216,7 @@ static void test1_breathingTest() } { const char k_URI[] = "bmq://ts.trades.myapp/my.queue?id=my.app"; - bmqt::Uri obj(s_allocator_p); + bmqt::Uri obj(bmqtst::TestHelperUtil::allocator()); rc = bmqt::UriParser::parse(&obj, &error, k_URI); ASSERT_EQ(rc, 0); ASSERT_EQ(error, ""); @@ -228,7 +230,7 @@ static void test1_breathingTest() } { const char k_URI[] = "bmq://ts.trades.myapp.~tst/my.queue"; - bmqt::Uri obj(s_allocator_p); + bmqt::Uri obj(bmqtst::TestHelperUtil::allocator()); rc = bmqt::UriParser::parse(&obj, &error, k_URI); ASSERT_EQ(rc, 0); ASSERT_EQ(error, ""); @@ -245,7 +247,7 @@ static void test1_breathingTest() } { const char k_URI[] = "bmq://ts.trades.myapp.~lcl-fooBar/my.queue"; - bmqt::Uri obj(s_allocator_p); + bmqt::Uri obj(bmqtst::TestHelperUtil::allocator()); rc = bmqt::UriParser::parse(&obj, &error, k_URI); ASSERT_EQ(rc, 0); ASSERT_EQ(error, ""); @@ -297,7 +299,7 @@ static void test1_breathingTest() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqt::Uri obj(s_allocator_p); + bmqt::Uri obj(bmqtst::TestHelperUtil::allocator()); rc = bmqt::UriParser::parse(&obj, &error, test.d_input); ASSERT_EQ_D(test.d_line, rc, test.d_rc); ASSERT_EQ_D(test.d_line, obj.isValid(), false); @@ -316,12 +318,12 @@ static void test2_URIBuilder() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); - bmqt::UriBuilder builder(s_allocator_p); + bmqt::UriBuilder builder(bmqtst::TestHelperUtil::allocator()); { - bmqt::Uri uri(s_allocator_p); + bmqt::Uri uri(bmqtst::TestHelperUtil::allocator()); builder.reset(); builder.setDomain("si.uics.tester").setQueue("siqueue"); @@ -331,7 +333,7 @@ static void test2_URIBuilder() } { - bmqt::Uri uri(s_allocator_p); + bmqt::Uri uri(bmqtst::TestHelperUtil::allocator()); builder.reset(); builder.setDomain("bmq.tutorial").setQueue("worker").setId("myApp"); @@ -346,7 +348,7 @@ static void test2_URIBuilder() } { - bmqt::Uri uri(s_allocator_p); + bmqt::Uri uri(bmqtst::TestHelperUtil::allocator()); builder.reset(); builder.setDomain("bmq.tutorial").setTier("tst").setQueue("myQueue"); @@ -361,7 +363,7 @@ static void test2_URIBuilder() PV("domain/tier/qualifiedDomain correlation") { - bmqt::Uri uri(s_allocator_p); + bmqt::Uri uri(bmqtst::TestHelperUtil::allocator()); builder.reset(); builder.setQualifiedDomain("bmq.tutorial.~lcl").setQueue("myQueue"); @@ -399,8 +401,8 @@ static void test2_URIBuilder() PV("Test error case"); { - bmqt::Uri uri(s_allocator_p); - bsl::string errorMessage(s_allocator_p); + bmqt::Uri uri(bmqtst::TestHelperUtil::allocator()); + bsl::string errorMessage(bmqtst::TestHelperUtil::allocator()); builder.reset(); ASSERT_EQ(builder.uri(&uri, &errorMessage), -3); // -3: MISSING DOMAIN @@ -418,9 +420,10 @@ static void test2_URIBuilder() PV("Test creating a builder by copy of a Uri"); { - bmqt::Uri uri("bmq://my.domain/myQueue", s_allocator_p); - bmqt::Uri tmpUri(s_allocator_p); - bmqt::UriBuilder uriBuilder(uri, s_allocator_p); + bmqt::Uri uri("bmq://my.domain/myQueue", + bmqtst::TestHelperUtil::allocator()); + bmqt::Uri tmpUri(bmqtst::TestHelperUtil::allocator()); + bmqt::UriBuilder uriBuilder(uri, bmqtst::TestHelperUtil::allocator()); // Validate the uri in builder is the same ASSERT_EQ(uriBuilder.uri(&tmpUri, 0), 0); @@ -444,19 +447,19 @@ static void test2_URIBuilder() /// from multiple threads. static void test3_URIBuilderMultiThreaded() { - s_ignoreCheckGblAlloc = true; - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckGblAlloc() = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't ensure no global memory is allocated because // 'bslmt::ThreadUtil::create()' uses the global allocator to allocate // memory. bmqtst::TestHelper::printTestName("MULTI-THREADED URI BUILDER TEST"); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); const int k_NUM_THREADS = 6; const int k_NUM_ITERATIONS = 10000; - bslmt::ThreadGroup threadGroup(s_allocator_p); + bslmt::ThreadGroup threadGroup(bmqtst::TestHelperUtil::allocator()); // Barrier to get each thread to start at the same time; `+1` for this // (main) thread. @@ -464,7 +467,8 @@ static void test3_URIBuilderMultiThreaded() typedef bsl::pair Result; - bsl::vector > threadsData(s_allocator_p); + bsl::vector > threadsData( + bmqtst::TestHelperUtil::allocator()); threadsData.resize(k_NUM_THREADS); for (int i = 0; i < k_NUM_THREADS; ++i) { @@ -492,10 +496,12 @@ static void test3_URIBuilderMultiThreaded() threadResults[j].second, 0); // builder rc - bmqu::MemOutStream expectedUriStr(s_allocator_p); + bmqu::MemOutStream expectedUriStr( + bmqtst::TestHelperUtil::allocator()); expectedUriStr << "bmq://my.domain." << i << "." << j << "/queue-foo-bar-" << i << "-" << j; - bmqt::Uri expectedUri(expectedUriStr.str(), s_allocator_p); + bmqt::Uri expectedUri(expectedUriStr.str(), + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D(i << ", " << j, threadResults[j].first, expectedUri); } @@ -522,10 +528,10 @@ static void test4_initializeShutdown() bmqtst::TestHelper::printTestName("INITIALIZE / SHUTDOWN"); // Initialize the 'UriParser'. - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); // Initialize should be a no-op. - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); // Shutdown the parser is a no-op. bmqt::UriParser::shutdown(); @@ -542,12 +548,13 @@ static void test5_testPrint() { bmqtst::TestHelper::printTestName("PRINT"); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); PV("Testing print"); - bmqu::MemOutStream stream(s_allocator_p); - bmqt::Uri obj("bmq://my.domain/myQueue", s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); + bmqt::Uri obj("bmq://my.domain/myQueue", + bmqtst::TestHelperUtil::allocator()); // Test stream output without line feed stream << obj; @@ -588,14 +595,15 @@ static void test6_hashAppend() { bmqtst::TestHelper::printTestName("HASH APPEND"); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); PV("HASH FUNCTION DETERMINISTIC"); int rc = 0; - bsl::string error(s_allocator_p); - bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); - bmqt::Uri obj(s_allocator_p); + bsl::string error(bmqtst::TestHelperUtil::allocator()); + bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); + bmqt::Uri obj(bmqtst::TestHelperUtil::allocator()); rc = bmqt::UriParser::parse(&obj, &error, uri); @@ -619,7 +627,7 @@ static void test6_hashAppend() static void test7_testLongUri() { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Disable the default allocator check. When 'bmqt::Uri' // is created from a long uri string error message is // logged via 'BALL_LOG_ERROR' which allocates using @@ -627,19 +635,21 @@ static void test7_testLongUri() bmqtst::TestHelper::printTestName("LONG URI TEST"); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); - bmqtst::ScopedLogObserver observer(ball::Severity::WARN, s_allocator_p); + bmqtst::ScopedLogObserver observer(ball::Severity::WARN, + bmqtst::TestHelperUtil::allocator()); - bsl::string domainStr("bmq://my.domain/", s_allocator_p); + bsl::string domainStr("bmq://my.domain/", + bmqtst::TestHelperUtil::allocator()); bsl::string pathStr(bmqt::Uri::k_QUEUENAME_MAX_LENGTH + 1, 'q', - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); stream << domainStr << pathStr; - bmqt::Uri obj(stream.str(), s_allocator_p); + bmqt::Uri obj(stream.str(), bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(observer.records().size(), 1U); @@ -649,7 +659,7 @@ static void test7_testLongUri() ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( observer.records()[0], pathStr.data(), - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.isValid(), true); @@ -675,7 +685,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqt/bmqt_version.t.cpp b/src/groups/bmq/bmqt/bmqt_version.t.cpp index 1f01dc93b..9b85ab90f 100644 --- a/src/groups/bmq/bmqt/bmqt_version.t.cpp +++ b/src/groups/bmq/bmqt/bmqt_version.t.cpp @@ -114,28 +114,28 @@ static void test1_breathingTest() // Printing { - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os << a; - bsl::string str(s_allocator_p); + bsl::string str(bmqtst::TestHelperUtil::allocator()); str.assign(os.str().data(), os.str().length()); ASSERT_EQ(str, "[ major = 0 minor = 0 ]"); } { - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os << b; - bsl::string str(s_allocator_p); + bsl::string str(bmqtst::TestHelperUtil::allocator()); str.assign(os.str().data(), os.str().length()); ASSERT_EQ(str, "[ major = 1 minor = 2 ]"); } { - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os << c; - bsl::string str(s_allocator_p); + bsl::string str(bmqtst::TestHelperUtil::allocator()); str.assign(os.str().data(), os.str().length()); ASSERT_EQ(str, "[ major = 4 minor = 3 ]"); } { - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); out.setstate(bsl::ios_base::badbit); a.print(out, 0, -1); ASSERT_EQ(out.str(), ""); @@ -155,7 +155,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqtsk/bmqtsk_logcontroller.t.cpp b/src/groups/bmq/bmqtsk/bmqtsk_logcontroller.t.cpp index 20824e1e1..84142125f 100644 --- a/src/groups/bmq/bmqtsk/bmqtsk_logcontroller.t.cpp +++ b/src/groups/bmq/bmqtsk/bmqtsk_logcontroller.t.cpp @@ -54,54 +54,62 @@ static void test1_logControllerConfigFromDatum() { bmqtst::TestHelper::printTestName("LogControllerConfig::fromDatum Test"); - bdld::DatumMapBuilder syslogBuilder(s_allocator_p); + bdld::DatumMapBuilder syslogBuilder(bmqtst::TestHelperUtil::allocator()); syslogBuilder.pushBack("enabled", bdld::Datum::createBoolean(true)); - syslogBuilder.pushBack("appName", - bdld::Datum::createStringRef("testapp", - s_allocator_p)); + syslogBuilder.pushBack( + "appName", + bdld::Datum::createStringRef("testapp", + bmqtst::TestHelperUtil::allocator())); syslogBuilder.pushBack( "logFormat", bdld::Datum::createStringRef("test %d (%t) %s %F:%l %m\n\n", - s_allocator_p)); - syslogBuilder.pushBack("verbosity", - bdld::Datum::createStringRef("info", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); + syslogBuilder.pushBack( + "verbosity", + bdld::Datum::createStringRef("info", + bmqtst::TestHelperUtil::allocator())); - bdld::DatumArrayBuilder categoriesBuilder(s_allocator_p); + bdld::DatumArrayBuilder categoriesBuilder( + bmqtst::TestHelperUtil::allocator()); categoriesBuilder.pushBack( - bdld::Datum::copyString("category:info:red", s_allocator_p)); + bdld::Datum::copyString("category:info:red", + bmqtst::TestHelperUtil::allocator())); - bdld::DatumMapBuilder logControllerBuilder(s_allocator_p); - logControllerBuilder.pushBack("fileName", - bdld::Datum::copyString("fileName", - s_allocator_p)); + bdld::DatumMapBuilder logControllerBuilder( + bmqtst::TestHelperUtil::allocator()); + logControllerBuilder.pushBack( + "fileName", + bdld::Datum::copyString("fileName", + bmqtst::TestHelperUtil::allocator())); logControllerBuilder.pushBack("fileMaxAgeDays", bdld::Datum::createDouble(8.2)); logControllerBuilder.pushBack("rotationBytes", bdld::Datum::createDouble(2048)); logControllerBuilder.pushBack( "logfileFormat", - bdld::Datum::copyString("%d (%t) %s %F:%l %m\n\n", s_allocator_p)); + bdld::Datum::copyString("%d (%t) %s %F:%l %m\n\n", + bmqtst::TestHelperUtil::allocator())); logControllerBuilder.pushBack( "consoleFormat", - bdld::Datum::copyString("%d (%t) %s %F:%l %m\n\n", s_allocator_p)); - logControllerBuilder.pushBack("loggingVerbosity", - bdld::Datum::copyString("debug", - s_allocator_p)); - logControllerBuilder.pushBack("bslsLogSeverityThreshold", - bdld::Datum::copyString("info", - s_allocator_p)); - logControllerBuilder.pushBack("consoleSeverityThreshold", - bdld::Datum::copyString("info", - s_allocator_p)); + bdld::Datum::copyString("%d (%t) %s %F:%l %m\n\n", + bmqtst::TestHelperUtil::allocator())); + logControllerBuilder.pushBack( + "loggingVerbosity", + bdld::Datum::copyString("debug", bmqtst::TestHelperUtil::allocator())); + logControllerBuilder.pushBack( + "bslsLogSeverityThreshold", + bdld::Datum::copyString("info", bmqtst::TestHelperUtil::allocator())); + logControllerBuilder.pushBack( + "consoleSeverityThreshold", + bdld::Datum::copyString("info", bmqtst::TestHelperUtil::allocator())); logControllerBuilder.pushBack("categories", categoriesBuilder.commit()); logControllerBuilder.pushBack("syslog", syslogBuilder.commit()); bdld::Datum datum = logControllerBuilder.commit(); - bmqtsk::LogControllerConfig config(s_allocator_p); - bmqu::MemOutStream errorDesc(s_allocator_p); + bmqtsk::LogControllerConfig config(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream errorDesc(bmqtst::TestHelperUtil::allocator()); config.fromDatum(errorDesc, datum); - bdld::Datum::destroy(datum, s_allocator_p); + bdld::Datum::destroy(datum, bmqtst::TestHelperUtil::allocator()); ASSERT_D(errorDesc.str(), errorDesc.str().empty()); @@ -128,7 +136,7 @@ int main(int argc, char* argv[]) case 1: test1_logControllerConfigFromDatum(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqtst/bmqtst_blobtestutil.h b/src/groups/bmq/bmqtst/bmqtst_blobtestutil.h index 5bf5b252e..fd1f109f7 100644 --- a/src/groups/bmq/bmqtst/bmqtst_blobtestutil.h +++ b/src/groups/bmq/bmqtst/bmqtst_blobtestutil.h @@ -35,8 +35,9 @@ // specifying the internal breakdown of the blob buffers in the string. // //.. -// bdlbb::Blob blob(s_allocator_p); -// bmqtst::BlobTestUtil::fromString(&blob, "a|b", s_allocator_p); +// bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); +// bmqtst::BlobTestUtil::fromString(&blob, "a|b", +// bmqtst::TestHelperUtil::allocator()); // // ASSERT_EQ(blob.length(), 2); // ASSERT_EQ(blob.numDataBuffers(), 2); @@ -58,14 +59,14 @@ // // First, let's put the string 'abcdefg' into the blob. //.. -// bdlbb::Blob blob(s_allocator_p); -// bmqtst::BlobTestUtil::fromString(&blob, "abcdefg", s_allocator_p); -// BSLS_ASSERT_OPT(blob.length() == 7); +// bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); +// bmqtst::BlobTestUtil::fromString(&blob, "abcdefg", +// bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(blob.length() == 7); // BSLS_ASSERT_OPT(blob.numDataBuffers() == 1); //.. // Finally, we can convert the blob to a string using the 'toString' method. //.. -// bsl::string str(s_allocator_p); +// bsl::string str(bmqtst::TestHelperUtil::allocator()); // ASSERT_EQ("abcdefg", bmqtst::BlobTestUtil::toString(&str, blob)); //.. diff --git a/src/groups/bmq/bmqtst/bmqtst_blobtestutil.t.cpp b/src/groups/bmq/bmqtst/bmqtst_blobtestutil.t.cpp index 6dcfc2465..e0f9411ae 100644 --- a/src/groups/bmq/bmqtst/bmqtst_blobtestutil.t.cpp +++ b/src/groups/bmq/bmqtst/bmqtst_blobtestutil.t.cpp @@ -51,8 +51,10 @@ static void test1_fromString() { PVV("FROM STRING - ''"); - bdlbb::Blob blob(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, "", s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&blob, + "", + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(blob.length(), 0); ASSERT_EQ(blob.numDataBuffers(), 0); @@ -61,8 +63,10 @@ static void test1_fromString() { PVV("FROM STRING - 'a|b'"); - bdlbb::Blob blob(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, "a|b", s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&blob, + "a|b", + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(blob.length(), 2); ASSERT_EQ(blob.numDataBuffers(), 2); @@ -81,8 +85,10 @@ static void test1_fromString() { PVV("FROM STRING - 'ab'"); - bdlbb::Blob blob(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, "ab", s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&blob, + "ab", + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(blob.length(), 2); ASSERT_EQ(blob.numDataBuffers(), 1); @@ -94,8 +100,10 @@ static void test1_fromString() { PVV("FROM STRING - 'aXX'"); - bdlbb::Blob blob(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, "aXX", s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&blob, + "aXX", + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(blob.length(), 1); ASSERT_EQ(blob.numDataBuffers(), 1); @@ -122,49 +130,57 @@ static void test2_toString() { PVV("TO STRING - 'abcdefg'"); - bdlbb::Blob blob(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, "abcdefg", s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&blob, + "abcdefg", + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(blob.length() == 7); BSLS_ASSERT_OPT(blob.numDataBuffers() == 1); - bsl::string out(s_allocator_p); + bsl::string out(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ("abcdefg", bmqtst::BlobTestUtil::toString(&out, blob)); } { PVV("TO STRING - 'a|b'"); - bdlbb::Blob blob(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, "a|b", s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&blob, + "a|b", + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(blob.length() == 2); BSLS_ASSERT_OPT(blob.numDataBuffers() == 2); - bsl::string out(s_allocator_p); + bsl::string out(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ("a|b", bmqtst::BlobTestUtil::toString(&out, blob, true)); } { PVV("TO STRING - 'a|bXXX'"); - bdlbb::Blob blob(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, "a|bXXX", s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&blob, + "a|bXXX", + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(blob.length() == 2); BSLS_ASSERT_OPT(blob.numDataBuffers() == 2); BSLS_ASSERT_OPT(blob.totalSize() == 5); - bsl::string out(s_allocator_p); + bsl::string out(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ("a|bXXX", bmqtst::BlobTestUtil::toString(&out, blob, true)); } { PVV("TO STRING - 'abc|def|g'"); - bdlbb::Blob blob(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, "abc|def|g", s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&blob, + "abc|def|g", + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(blob.length() == 7); BSLS_ASSERT_OPT(blob.numDataBuffers() == 3); - bsl::string out(s_allocator_p); + bsl::string out(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ("abcdefg", bmqtst::BlobTestUtil::toString(&out, blob)); } } @@ -183,7 +199,7 @@ int main(int argc, char* argv[]) case 1: test1_fromString(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqtst/bmqtst_scopedlogobserver.h b/src/groups/bmq/bmqtst/bmqtst_scopedlogobserver.h index 39b81c23f..bb298ae86 100644 --- a/src/groups/bmq/bmqtst/bmqtst_scopedlogobserver.h +++ b/src/groups/bmq/bmqtst/bmqtst_scopedlogobserver.h @@ -48,7 +48,8 @@ // threshold for capturing log records (in this case, 'ball::Severity::ERROR'). //.. // BALL_LOG_SET_CATEGORY("TEST"); -// bmqtst::ScopedLogObserver observer(ball::Severity::ERROR, s_allocator_p); +// bmqtst::ScopedLogObserver observer(ball::Severity::ERROR, +// bmqtst::TestHelperUtil::allocator()); //.. // Next, publish a log using the BALL logging infrastructure. Note that the // severity threshold should be at or above that of the observer for the log @@ -63,7 +64,7 @@ // BSLS_ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( // observer.records()[0], // ".*Sample.*", -// s_allocator_p)); +// bmqtst::TestHelperUtil::allocator())); //.. // BDE diff --git a/src/groups/bmq/bmqtst/bmqtst_scopedlogobserver.t.cpp b/src/groups/bmq/bmqtst/bmqtst_scopedlogobserver.t.cpp index 8b2b2608f..2842923ed 100644 --- a/src/groups/bmq/bmqtst/bmqtst_scopedlogobserver.t.cpp +++ b/src/groups/bmq/bmqtst/bmqtst_scopedlogobserver.t.cpp @@ -52,7 +52,8 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bmqtst::ScopedLogObserver observer(ball::Severity::OFF, s_allocator_p); + bmqtst::ScopedLogObserver observer(ball::Severity::OFF, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(observer.severityThreshold(), ball::Severity::OFF); ASSERT(!observer.isEnabled()); @@ -85,12 +86,13 @@ static void test2_publish() { bmqtst::TestHelper::printTestName("PUBLISH"); - ball::Record record1(s_allocator_p); - ball::Record record2(s_allocator_p); - ball::Context context1(s_allocator_p); - ball::Context context2(s_allocator_p); + ball::Record record1(bmqtst::TestHelperUtil::allocator()); + ball::Record record2(bmqtst::TestHelperUtil::allocator()); + ball::Context context1(bmqtst::TestHelperUtil::allocator()); + ball::Context context2(bmqtst::TestHelperUtil::allocator()); - bmqtst::ScopedLogObserver observer(ball::Severity::ERROR, s_allocator_p); + bmqtst::ScopedLogObserver observer(ball::Severity::ERROR, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(observer.severityThreshold(), ball::Severity::ERROR); ASSERT(observer.isEnabled()); @@ -155,16 +157,16 @@ static void test3_recordMessageMatch() << test.d_msg << "\", \"" << test.d_pattern << "\")'" << " == " << bsl::boolalpha << test.d_isMatch); - ball::Record record(s_allocator_p); - ball::Context context(s_allocator_p); + ball::Record record(bmqtst::TestHelperUtil::allocator()); + ball::Context context(bmqtst::TestHelperUtil::allocator()); record.fixedFields().setMessage(test.d_msg); - ASSERT_EQ( - bmqtst::ScopedLogObserverUtil::recordMessageMatch(record, - test.d_pattern, - s_allocator_p), - test.d_isMatch); + ASSERT_EQ(bmqtst::ScopedLogObserverUtil::recordMessageMatch( + record, + test.d_pattern, + bmqtst::TestHelperUtil::allocator()), + test.d_isMatch); } } @@ -182,7 +184,7 @@ static void test4_usageExample() // Testing: // TODO: { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -190,7 +192,8 @@ static void test4_usageExample() BALL_LOG_SET_CATEGORY("TEST"); - bmqtst::ScopedLogObserver observer(ball::Severity::ERROR, s_allocator_p); + bmqtst::ScopedLogObserver observer(ball::Severity::ERROR, + bmqtst::TestHelperUtil::allocator()); BALL_LOG_ERROR << "MySampleError"; @@ -198,7 +201,7 @@ static void test4_usageExample() ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( observer.records()[0], ".*Sample.*", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); } // ============================================================================ @@ -217,7 +220,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqtst/bmqtst_testhelper.cpp b/src/groups/bmq/bmqtst/bmqtst_testhelper.cpp index c968739d6..f77201e7a 100644 --- a/src/groups/bmq/bmqtst/bmqtst_testhelper.cpp +++ b/src/groups/bmq/bmqtst/bmqtst_testhelper.cpp @@ -22,6 +22,9 @@ #include namespace BloombergLP { +namespace bmqtst { + +namespace { // ============================================================================ // GLOBAL VARIABLES @@ -33,7 +36,32 @@ bool s_ignoreCheckGblAlloc = false; bslmt::QLock s_serializePrintLock = BSLMT_QLOCK_INITIALIZER; bslma::Allocator* s_allocator_p = 0; -namespace bmqtst { +} + +int& bmqtst::TestHelperUtil::testStatus() +{ + return s_testStatus; +} +int& bmqtst::TestHelperUtil::verbosityLevel() +{ + return s_verbosityLevel; +} +bool& bmqtst::TestHelperUtil::ignoreCheckDefAlloc() +{ + return s_ignoreCheckDefAlloc; +} +bool& bmqtst::TestHelperUtil::ignoreCheckGblAlloc() +{ + return s_ignoreCheckGblAlloc; +} +bslmt::QLock& bmqtst::TestHelperUtil::serializePrintLock() +{ + return s_serializePrintLock; +} +bslma::Allocator*& bmqtst::TestHelperUtil::allocator() +{ + return s_allocator_p; +} // ----------------- // struct TestHelper @@ -42,7 +70,7 @@ namespace bmqtst { // CLASS METHODS void TestHelper::printTestName(bslstl::StringRef value) { - if (s_verbosityLevel < 1) { + if (bmqtst::TestHelperUtil::verbosityLevel() < 1) { return; // RETURN } @@ -109,7 +137,7 @@ void runTest(int index) if (testCase < 0 || testCase >= TestHelper_Test::s_numTests) { bsl::cerr << "WARNING: CASE '" << testCase << "' NOT FOUND.\n"; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; return; // RETURN } diff --git a/src/groups/bmq/bmqtst/bmqtst_testhelper.h b/src/groups/bmq/bmqtst/bmqtst_testhelper.h index 6447edda1..9a6dd569d 100644 --- a/src/groups/bmq/bmqtst/bmqtst_testhelper.h +++ b/src/groups/bmq/bmqtst/bmqtst_testhelper.h @@ -56,9 +56,11 @@ // NOTE: Because the Epilog flags are global and apply to all the tests in // the test driver, it is not always possible to enable them if one of // the test cases may make usage of default or global allocator. For -// that matter, the global variables 's_ignoreCheckDefAlloc' and -// 's_ignoreCheckGblAlloc' can be set to 'true' in the test of a given -// case to selectively disable those checks for that test case only. +// that matter, the global variables +// 'TestHelperUtil::ignoreCheckDefAlloc()' and +// 'TestHelperUtil::ignoreCheckGblAlloc()' can be set to 'true' in the +// test of a given case to selectively disable those checks for that test +// case only. // /// ASSERTIONS ///---------- @@ -120,9 +122,9 @@ // either the default or the global allocators. 'TEST_PROLOG' also creates a // 'bslma::TestAllocator' (by default, or a 'balst::StackTraceTestAllocator' if // the 'e_USE_STACKTRACE_ALLOCATOR' flag is set) and makes it available as the -// global 's_allocator_p' pointer. This allocator is the one that should be -// used and passed to all objects under test. 'TEST_EPILOG' does verify that -// no memory was leaked from that allocator as well. +// global 'TestHelperUtil::allocator()' pointer. This allocator is the one +// that should be used and passed to all objects under test. 'TEST_EPILOG' +// does verify that no memory was leaked from that allocator as well. // /// BALL LOGGING ///------------ @@ -197,7 +199,7 @@ // static void test1_breathingTest() { // bmqtst::TestHelper::printTestName("BREATHING TEST"); // -// grppkg::MyComponent myComponent("name", s_allocator_p); +// grppkg::MyComponent myComponent("name", TestHelperUtil::allocator()); // ASSERT(myComponent.isValid()); // ASSERT_EQ(myComponent.name(), "name"); // } @@ -215,7 +217,7 @@ // default: { // bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." // << bsl::endl; -// s_testStatus = -1; +// TestHelperUtil::testStatus() = -1; // } break; // } // @@ -256,8 +258,8 @@ // // TEST_F(FunctionalTest, breathingTest) // { -// grppkg::MyComponent myComponent("name", config, mock, s_allocator_p); -// ASSERT(myComponent.isValid()); +// grppkg::MyComponent myComponent("name", config, mock, +// TestHelperUtil::allocator()); ASSERT(myComponent.isValid()); // ASSERT_EQ(myComponent.name(), "name"); // } // @@ -344,8 +346,9 @@ int line) \ { \ if (!(xResult OP yResult)) { \ - bdlsb::MemOutStreamBuf buffer(s_allocator_p); \ - bsl::ostream os(&buffer); \ + bdlsb::MemOutStreamBuf buffer( \ + bmqtst::TestHelperUtil::allocator()); \ + bsl::ostream os(&buffer); \ os << prefix << "'" << xStr << "' " << "(" \ << bmqtst::printer(xResult) << ")" << " " #OP " " << "'" \ << yStr << "' " << "(" << bmqtst::printer(yResult) << ")" \ @@ -384,7 +387,7 @@ // case of failure. #define ASSERT_D(D, X) \ { \ - bdlsb::MemOutStreamBuf _buf(s_allocator_p); \ + bdlsb::MemOutStreamBuf _buf(bmqtst::TestHelperUtil::allocator()); \ bsl::ostream _os(&_buf); \ _os << D << '\0'; \ bslstl::StringRef _osStr(_buf.data(), _buf.length()); \ @@ -394,7 +397,7 @@ } #define ASSERT_EQ_D(D, X, Y) \ { \ - bdlsb::MemOutStreamBuf _buf(s_allocator_p); \ + bdlsb::MemOutStreamBuf _buf(bmqtst::TestHelperUtil::allocator()); \ bsl::ostream _os(&_buf); \ _os << D << ": "; \ bslstl::StringRef _osStr(_buf.data(), _buf.length()); \ @@ -402,7 +405,7 @@ } #define ASSERT_NE_D(D, X, Y) \ { \ - bdlsb::MemOutStreamBuf _buf(s_allocator_p); \ + bdlsb::MemOutStreamBuf _buf(bmqtst::TestHelperUtil::allocator()); \ bsl::ostream _os(&_buf); \ _os << D << ": "; \ bslstl::StringRef _osStr(_buf.data(), _buf.length()); \ @@ -410,7 +413,7 @@ } #define ASSERT_LT_D(D, X, Y) \ { \ - bdlsb::MemOutStreamBuf _buf(s_allocator_p); \ + bdlsb::MemOutStreamBuf _buf(bmqtst::TestHelperUtil::allocator()); \ bsl::ostream _os(&_buf); \ _os << D << ": "; \ bslstl::StringRef _osStr(_buf.data(), _buf.length()); \ @@ -418,7 +421,7 @@ } #define ASSERT_LE_D(D, X, Y) \ { \ - bdlsb::MemOutStreamBuf _buf(s_allocator_p); \ + bdlsb::MemOutStreamBuf _buf(bmqtst::TestHelperUtil::allocator()); \ bsl::ostream _os(&_buf); \ _os << D << ": "; \ bslstl::StringRef _osStr(_buf.data(), _buf.length()); \ @@ -426,7 +429,7 @@ } #define ASSERT_GT_D(D, X, Y) \ { \ - bdlsb::MemOutStreamBuf _buf(s_allocator_p); \ + bdlsb::MemOutStreamBuf _buf(bmqtst::TestHelperUtil::allocator()); \ bsl::ostream _os(&_buf); \ _os << D << ": "; \ bslstl::StringRef _osStr(_buf.data(), _buf.length()); \ @@ -434,7 +437,7 @@ } #define ASSERT_GE_D(D, X, Y) \ { \ - bdlsb::MemOutStreamBuf _buf(s_allocator_p); \ + bdlsb::MemOutStreamBuf _buf(bmqtst::TestHelperUtil::allocator()); \ bsl::ostream _os(&_buf); \ _os << D << ": "; \ bslstl::StringRef _osStr(_buf.data(), _buf.length()); \ @@ -455,8 +458,9 @@ << "): " << #X << " (" << bmqtst::printer(X) \ << ") ~= " << #Y << " (" << bmqtst::printer(Y) << ")" \ << " (failed)" << bsl::endl; \ - if (s_testStatus >= 0 && s_testStatus <= 100) \ - ++s_testStatus; \ + if (bmqtst::TestHelperUtil::testStatus() >= 0 && \ + bmqtst::TestHelperUtil::testStatus() <= 100) \ + ++bmqtst::TestHelperUtil::testStatus(); \ } \ } @@ -467,8 +471,9 @@ << "): " << #X << " (" << bmqtst::printer(X) \ << ") !~= " << #Y << " (" << bmqtst::printer(Y) << ")" \ << " (failed)" << bsl::endl; \ - if (s_testStatus >= 0 && s_testStatus <= 100) \ - ++s_testStatus; \ + if (bmqtst::TestHelperUtil::testStatus() >= 0 && \ + bmqtst::TestHelperUtil::testStatus() <= 100) \ + ++bmqtst::TestHelperUtil::testStatus(); \ } \ } @@ -502,36 +507,38 @@ #define PRINT_SAFE(X) \ { \ - bslmt::QLockGuard qGuard(&s_serializePrintLock); \ + bslmt::QLockGuard qGuard( \ + &bmqtst::TestHelperUtil::serializePrintLock()); \ PRINT(X); \ } #define PRINT_SAFE_(X) \ { \ - bslmt::QLockGuard qGuard(&s_serializePrintLock); \ + bslmt::QLockGuard qGuard( \ + &bmqtst::TestHelperUtil::serializePrintLock()); \ PRINT_(X); \ } #define PV(X) \ - if (s_verbosityLevel >= 1) \ + if (bmqtst::TestHelperUtil::verbosityLevel() >= 1) \ PRINT(X); #define PVV(X) \ - if (s_verbosityLevel >= 2) \ + if (bmqtst::TestHelperUtil::verbosityLevel() >= 2) \ PRINT(X); #define PVVV(X) \ - if (s_verbosityLevel >= 3) \ + if (bmqtst::TestHelperUtil::verbosityLevel() >= 3) \ PRINT(X); #define PV_SAFE(X) \ - if (s_verbosityLevel >= 1) { \ + if (bmqtst::TestHelperUtil::verbosityLevel() >= 1) { \ PRINT_SAFE(X); \ }; #define PVV_SAFE(X) \ - if (s_verbosityLevel >= 2) { \ + if (bmqtst::TestHelperUtil::verbosityLevel() >= 2) { \ PRINT_SAFE(X); \ }; #define PVVV_SAFE(X) \ - if (s_verbosityLevel >= 3) { \ + if (bmqtst::TestHelperUtil::verbosityLevel() >= 3) { \ PRINT_SAFE(X); \ }; @@ -539,8 +546,8 @@ // TEST SHELL // ---------------------------------------------------------------------------- #define TEST_PROLOG(F) \ - const int _testCase = argc > 1 ? atoi(argv[1]) : 0; \ - s_verbosityLevel = argc - 2; \ + const int _testCase = argc > 1 ? atoi(argv[1]) : 0; \ + bmqtst::TestHelperUtil::verbosityLevel() = argc - 2; \ \ /* Install an assert handler to gracefully mark the test as failure */ \ /* in case of assert. */ \ @@ -563,13 +570,13 @@ ball::LoggerManagerConfiguration _logConfig; \ ball::Severity::Level _logSeverity = ball::Severity::WARN; \ { \ - if (s_verbosityLevel == 1) { \ + if (bmqtst::TestHelperUtil::verbosityLevel() == 1) { \ _logSeverity = ball::Severity::INFO; \ } \ - else if (s_verbosityLevel == 2) { \ + else if (bmqtst::TestHelperUtil::verbosityLevel() == 2) { \ _logSeverity = ball::Severity::DEBUG; \ } \ - else if (s_verbosityLevel >= 3) { \ + else if (bmqtst::TestHelperUtil::verbosityLevel() >= 3) { \ _logSeverity = ball::Severity::TRACE; \ } \ _logConfig.setDefaultThresholdLevelsIfValid(ball::Severity::OFF, \ @@ -604,7 +611,9 @@ /* Global Allocator */ \ /* NOTE: The global allocator has a static storage duration to outlive */ \ /* all static objects using that allocator. */ \ - static bslma::TestAllocator _gblAlloc("global", (s_verbosityLevel >= 4)); \ + static bslma::TestAllocator _gblAlloc( \ + "global", \ + (bmqtst::TestHelperUtil::verbosityLevel() >= 4)); \ INIT_METRICS_REGISTRY() \ bslma::Default::setGlobalAllocator(&_gblAlloc); @@ -617,25 +626,29 @@ #define INIT_GLOBAL_ALLOCATOR() INIT_GLOBAL_ALLOCATOR_INTERNAL() #endif -#define INIT_ALLOCATORS(F) \ - INIT_GLOBAL_ALLOCATOR(); \ - \ - /* Default allocator */ \ - bslma::TestAllocator _defAlloc("default", (s_verbosityLevel >= 4)); \ - bslma::DefaultAllocatorGuard _defAllocGuard(&_defAlloc); \ - \ - /* Test driver allocator */ \ - bslma::TestAllocator _testAlloc("test", (s_verbosityLevel >= 4)); \ - _testAlloc.setNoAbort(true); \ - \ - balst::StackTraceTestAllocator _stTestAlloc; \ - _stTestAlloc.setName("test"); \ - \ - if ((F) & bmqtst::TestHelper::e_USE_STACKTRACE_ALLOCATOR) { \ - s_allocator_p = &_stTestAlloc; \ - } \ - else { \ - s_allocator_p = &_testAlloc; \ +#define INIT_ALLOCATORS(F) \ + INIT_GLOBAL_ALLOCATOR(); \ + \ + /* Default allocator */ \ + bslma::TestAllocator _defAlloc( \ + "default", \ + (bmqtst::TestHelperUtil::verbosityLevel() >= 4)); \ + bslma::DefaultAllocatorGuard _defAllocGuard(&_defAlloc); \ + \ + /* Test driver allocator */ \ + bslma::TestAllocator _testAlloc( \ + "test", \ + (bmqtst::TestHelperUtil::verbosityLevel() >= 4)); \ + _testAlloc.setNoAbort(true); \ + \ + balst::StackTraceTestAllocator _stTestAlloc; \ + _stTestAlloc.setName("test"); \ + \ + if ((F) & bmqtst::TestHelper::e_USE_STACKTRACE_ALLOCATOR) { \ + bmqtst::TestHelperUtil::allocator() = &_stTestAlloc; \ + } \ + else { \ + bmqtst::TestHelperUtil::allocator() = &_testAlloc; \ } #define TEST_EPILOG(F) \ @@ -647,13 +660,13 @@ \ /* Verify no default allocator usage */ \ if (F & bmqtst::TestHelper::e_CHECK_DEF_ALLOC && \ - !s_ignoreCheckDefAlloc) { \ + !bmqtst::TestHelperUtil::ignoreCheckDefAlloc()) { \ ASSERT_EQ(_defAlloc.numBlocksTotal(), 0); \ } \ \ /* Verify no global allocator usage */ \ if (F & bmqtst::TestHelper::e_CHECK_GBL_ALLOC && \ - !s_ignoreCheckGblAlloc) { \ + !bmqtst::TestHelperUtil::ignoreCheckGblAlloc()) { \ ASSERT_EQ(_gblAlloc.numBlocksTotal(), 0); \ } \ \ @@ -661,13 +674,15 @@ _logMultiplexObserver.deregisterObserver(&_logStdoutObserver); \ \ /* Check test result */ \ - if (s_testStatus > 0) { \ - bsl::cerr << "Error, non-zero test status: " << s_testStatus << "." \ + if (bmqtst::TestHelperUtil::testStatus() > 0) { \ + bsl::cerr << "Error, non-zero test status: " \ + << bmqtst::TestHelperUtil::testStatus() << "." \ << bsl::endl; \ } \ \ - s_allocator_p = 0; /* clang-tidy warning silencing */ \ - return s_testStatus; + bmqtst::TestHelperUtil::allocator() = \ + 0; /* clang-tidy warning silencing */ \ + return bmqtst::TestHelperUtil::testStatus(); #define TEST_F(FIXTURE, NAME) \ struct FIXTURE##NAME : FIXTURE { \ @@ -730,33 +745,37 @@ class TestHelper_Printer; template TestHelper_Printer printer(const TYPE& obj); -} +// ====================== +// struct TestHelperUtil +// ====================== -// ============================================================================ -// GLOBAL VARIABLES -// ---------------------------------------------------------------------------- +/// A helper struct for accessing and setting global options in the test +/// drivers. +struct TestHelperUtil { + /// Result of the test: 0: success + /// >0: number of errors + /// -1: no such test + static int& testStatus(); -/// Result of the test: 0: success -/// >0: number of errors -/// -1: no such test -extern int s_testStatus; + /// Verbosity to use ([0..4], the higher the more verbose). + static int& verbosityLevel(); -/// Verbosity to use ([0..4], the higher the more verbose). -extern int s_verbosityLevel; + /// Global flag which can be set to ignore checking the default allocator + /// usage for a specific test case. + static bool& ignoreCheckDefAlloc(); -/// Global flag which can be set to ignore checking the default allocator -/// usage for a specific test case. -extern bool s_ignoreCheckDefAlloc; + /// Global flag which can be set to ignore checking the global allocator + /// usage for a specific test case. + static bool& ignoreCheckGblAlloc(); -/// Global flag which can be set to ignore checking the global allocator -/// usage for a specific test case. -extern bool s_ignoreCheckGblAlloc; + /// Lock mechanism to serialize output in. + static bslmt::QLock& serializePrintLock(); -/// Lock mechanism to serialize output in. -extern bslmt::QLock s_serializePrintLock; + /// Allocator to use by the components under test. + static bslma::Allocator*& allocator(); +}; -/// Allocator to use by the components under test. -extern bslma::Allocator* s_allocator_p; +} // ============================================================================ // GLOBAL FUNCTIONS @@ -769,8 +788,9 @@ _assert(bool result, const char* expression, const char* file, int line) { if (!result) { printf("Error %s(%d): %s (failed)\n", file, line, expression); - if (s_testStatus >= 0 && s_testStatus <= 100) { - ++s_testStatus; + if (bmqtst::TestHelperUtil::testStatus() >= 0 && + bmqtst::TestHelperUtil::testStatus() <= 100) { + ++bmqtst::TestHelperUtil::testStatus(); } } } diff --git a/src/groups/bmq/bmqu/bmqu_atomicstate.t.cpp b/src/groups/bmq/bmqu/bmqu_atomicstate.t.cpp index f8db517e6..399150448 100644 --- a/src/groups/bmq/bmqu/bmqu_atomicstate.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_atomicstate.t.cpp @@ -101,7 +101,7 @@ static void test3_lockThenProcess() bslmt::ThreadUtil::createWithAllocator( &threadHandle, bdlf::BindUtil::bind(&threadFn, &result2, &state, &semaphore), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // wait for the thread to arrive at the start semaphore.wait(); @@ -155,7 +155,7 @@ int main(int argc, char* argv[]) case 4: test4_lockThenCancelThenProcess(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_atomicvalidator.t.cpp b/src/groups/bmq/bmqu/bmqu_atomicvalidator.t.cpp index f610f49b6..11d245393 100644 --- a/src/groups/bmq/bmqu/bmqu_atomicvalidator.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_atomicvalidator.t.cpp @@ -216,11 +216,11 @@ static void test2_atomicValidatorMultiThreaded() int ret = bslmt::ThreadUtil::createWithAllocator( &handles[i], bmqsys::ThreadUtil::defaultAttributes(), - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &acquireReleaseThread, &validator, &numRunningThreads), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ret, 0); } @@ -267,7 +267,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_blob.t.cpp b/src/groups/bmq/bmqu/bmqu_blob.t.cpp index 16149d822..5700b0d67 100644 --- a/src/groups/bmq/bmqu/bmqu_blob.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_blob.t.cpp @@ -99,14 +99,14 @@ static void test1_positionBreathingTest() // Verifying printing bmqu::BlobPosition position(1, 2); { - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os << position; PV("position = " << os.str()); ASSERT_EQ(os.str(), "[ buffer = 1 byte = 2 ]"); } { - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); bslim::Printer printer(&os, 0, -1); printer.start(); printer.printAttribute("position", position); @@ -217,7 +217,7 @@ static void test3_sectionBreathingTest() // Verifying printing bmqu::BlobSection obj(bmqu::BlobPosition(1, 2), bmqu::BlobPosition(9, 8)); { - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os << obj; PV("section = " << os.str()); ASSERT_EQ(os.str(), @@ -226,7 +226,7 @@ static void test3_sectionBreathingTest() } { - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); bslim::Printer printer(&os, 0, -1); printer.start(); printer.printAttribute("section", obj); @@ -276,10 +276,10 @@ static void test4_bufferSize() PVV(test.d_line << ": checking blob '" << test.d_blobFormat << "'"); - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::fromString(&blob, test.d_blobFormat, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); for (int bufIdx = 0; test.d_bufSizes[bufIdx] != -1; ++bufIdx) { ASSERT_EQ_D("line " << test.d_line << ", bufIdx " << bufIdx, @@ -306,8 +306,10 @@ static void test5_isValidPos() { bmqtst::TestHelper::printTestName("Is Valid Pos Test"); - bdlbb::Blob blob(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, "ab|cde|f|ghiXX", s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&blob, + "ab|cde|f|ghiXX", + bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -366,8 +368,10 @@ static void test6_positionToOffset() { bmqtst::TestHelper::printTestName("Position To Offset Test"); - bdlbb::Blob blob(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, "ab|cde|f|ghiXX", s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&blob, + "ab|cde|f|ghiXX", + bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -441,8 +445,10 @@ static void test7_findOffset() { bmqtst::TestHelper::printTestName("Find Offset Test"); - bdlbb::Blob blob(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, "ab|cde|f|ghiXX", s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&blob, + "ab|cde|f|ghiXX", + bmqtst::TestHelperUtil::allocator()); PV("Without a start offset"); { @@ -594,7 +600,9 @@ static void test8_reserve() { bmqtst::TestHelper::printTestName("Reserve Test"); - bdlbb::PooledBlobBufferFactory bufferFactory(4, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 4, + bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -620,10 +628,12 @@ static void test8_reserve() PVVV("reserve"); { - bdlbb::Blob blob(&bufferFactory, s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, - test.d_blobPattern, - s_allocator_p); + bdlbb::Blob blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString( + &blob, + test.d_blobPattern, + bmqtst::TestHelperUtil::allocator()); int length = blob.length(); bmqu::BlobUtil::reserve(&blob, test.d_reserveLength); @@ -633,10 +643,12 @@ static void test8_reserve() } PVVV("reserve and load the position"); { - bdlbb::Blob blob(&bufferFactory, s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, - test.d_blobPattern, - s_allocator_p); + bdlbb::Blob blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString( + &blob, + test.d_blobPattern, + bmqtst::TestHelperUtil::allocator()); int length = blob.length(); bmqu::BlobPosition pos; @@ -712,10 +724,10 @@ static void test9_writeBytes() << test.d_data << "' bytes starting from " << test.d_position); - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::fromString(&blob, test.d_blobPattern, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); int rc = bmqu::BlobUtil::writeBytes(&blob, test.d_position, @@ -723,11 +735,12 @@ static void test9_writeBytes() bsl::strlen(test.d_data)); ASSERT_EQ_D("line " << test.d_line, rc, test.d_expectedRc); - bsl::string resultBlob(s_allocator_p); + bsl::string resultBlob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::toString(&resultBlob, blob); ASSERT_EQ_D("line " << test.d_line, resultBlob, - bsl::string(test.d_resultBlob, s_allocator_p)); + bsl::string(test.d_resultBlob, + bmqtst::TestHelperUtil::allocator())); } } @@ -750,7 +763,9 @@ static void test10_appendBlobFromIndex() using namespace bmqu; - bdlbb::PooledBlobBufferFactory bufferFactory(4, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 4, + bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -784,13 +799,15 @@ static void test10_appendBlobFromIndex() << "' blob starting from (" << test.d_index << ", " << test.d_byte << ") position"); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); + bdlbb::Blob blob(&bufferFactory, bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::fromString(&blob, test.d_blobPattern, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - bdlbb::Blob src(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&src, test.d_data, s_allocator_p); + bdlbb::Blob src(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString(&src, + test.d_data, + bmqtst::TestHelperUtil::allocator()); bmqu::BlobUtil::appendBlobFromIndex(&blob, src, @@ -798,11 +815,12 @@ static void test10_appendBlobFromIndex() test.d_byte, test.d_length); - bsl::string resultBlob(s_allocator_p); + bsl::string resultBlob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::toString(&resultBlob, blob, true); ASSERT_EQ_D("line " << test.d_line, resultBlob, - bsl::string(test.d_resultBlob, s_allocator_p)); + bsl::string(test.d_resultBlob, + bmqtst::TestHelperUtil::allocator())); } } @@ -851,10 +869,10 @@ static void test11_sectionSize() << "size from " << test.d_start << " to " << test.d_end); - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::fromString(&blob, test.d_blobPattern, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); const BlobSection section(test.d_start, test.d_end); int size = 0; @@ -908,10 +926,10 @@ static void test12_compareSection() << test.d_length << " bytes with '" << test.d_data << "' starting from " << test.d_pos); - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::fromString(&blob, test.d_blobPattern, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); int cmpResult = 0; const int rc = bmqu::BlobUtil::compareSection(&cmpResult, @@ -984,10 +1002,10 @@ static void test13_copyToRawBufferFromIndex() << "' blob starting from (" << test.d_index << ", " << test.d_byte << ") position"); - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::fromString(&blob, test.d_blobPattern, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::BlobUtil::copyToRawBufferFromIndex(dst + test.d_rawBufferOffset, blob, @@ -996,8 +1014,9 @@ static void test13_copyToRawBufferFromIndex() test.d_length); ASSERT_EQ_D("line " << test.d_line, - bsl::string(dst, NUM, s_allocator_p), - bsl::string(test.d_result, s_allocator_p)); + bsl::string(dst, NUM, bmqtst::TestHelperUtil::allocator()), + bsl::string(test.d_result, + bmqtst::TestHelperUtil::allocator())); } } @@ -1021,9 +1040,11 @@ static void test14_readUpToNBytes() using namespace bmqu; - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); const char* blobPattern = "ab|cde|f|ghiXX"; - bmqtst::BlobTestUtil::fromString(&blob, blobPattern, s_allocator_p); + bmqtst::BlobTestUtil::fromString(&blob, + blobPattern, + bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -1076,8 +1097,11 @@ static void test14_readUpToNBytes() if (test.d_expectedRc == 0) { ASSERT_EQ_D("line " << test.d_line, - bsl::string(buffer, test.d_length, s_allocator_p), - bsl::string(test.d_expected, s_allocator_p)); + bsl::string(buffer, + test.d_length, + bmqtst::TestHelperUtil::allocator()), + bsl::string(test.d_expected, + bmqtst::TestHelperUtil::allocator())); } } } @@ -1102,9 +1126,11 @@ static void test15_readNBytes() using namespace bmqu; - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); const char* blobPattern = "ab|cde|f|ghiXX"; - bmqtst::BlobTestUtil::fromString(&blob, blobPattern, s_allocator_p); + bmqtst::BlobTestUtil::fromString(&blob, + blobPattern, + bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -1159,8 +1185,11 @@ static void test15_readNBytes() if (test.d_expectedRc == 0) { ASSERT_EQ_D("line " << test.d_line, - bsl::string(buffer, test.d_length, s_allocator_p), - bsl::string(test.d_expected, s_allocator_p)); + bsl::string(buffer, + test.d_length, + bmqtst::TestHelperUtil::allocator()), + bsl::string(test.d_expected, + bmqtst::TestHelperUtil::allocator())); } } } @@ -1184,7 +1213,9 @@ static void test16_appendToBlob() using namespace bmqu; - bdlbb::PooledBlobBufferFactory bufferFactory(4, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 4, + bmqtst::TestHelperUtil::allocator()); { PVV("appendToBlob with length"); @@ -1221,28 +1252,32 @@ static void test16_appendToBlob() << test.d_index << ", " << test.d_byte << ") position"); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, - test.d_destPattern, - s_allocator_p); + bdlbb::Blob blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString( + &blob, + test.d_destPattern, + bmqtst::TestHelperUtil::allocator()); - bdlbb::Blob src(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&src, - test.d_srcPattern, - s_allocator_p); + bdlbb::Blob src(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString( + &src, + test.d_srcPattern, + bmqtst::TestHelperUtil::allocator()); const BlobPosition start(test.d_index, test.d_byte); const int rc = bmqu::BlobUtil::appendToBlob(&blob, src, start, test.d_length); - bsl::string resultBlob(s_allocator_p); + bsl::string resultBlob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::toString(&resultBlob, blob, true); ASSERT_EQ_D("line " << test.d_line, rc, test.d_rc); ASSERT_EQ_D("line " << test.d_line, resultBlob, - bsl::string(test.d_resultPattern, s_allocator_p)); + bsl::string(test.d_resultPattern, + bmqtst::TestHelperUtil::allocator())); } } @@ -1277,27 +1312,31 @@ static void test16_appendToBlob() << "' blob starting from (" << test.d_index << ", " << test.d_byte << ") position"); - bdlbb::Blob blob(&bufferFactory, s_allocator_p); - bmqtst::BlobTestUtil::fromString(&blob, - test.d_destPattern, - s_allocator_p); + bdlbb::Blob blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString( + &blob, + test.d_destPattern, + bmqtst::TestHelperUtil::allocator()); - bdlbb::Blob src(s_allocator_p); - bmqtst::BlobTestUtil::fromString(&src, - test.d_srcPattern, - s_allocator_p); + bdlbb::Blob src(bmqtst::TestHelperUtil::allocator()); + bmqtst::BlobTestUtil::fromString( + &src, + test.d_srcPattern, + bmqtst::TestHelperUtil::allocator()); const BlobPosition start(test.d_index, test.d_byte); const int rc = bmqu::BlobUtil::appendToBlob(&blob, src, start); - bsl::string resultBlob(s_allocator_p); + bsl::string resultBlob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::toString(&resultBlob, blob, true); ASSERT_EQ_D("line " << test.d_line, rc, test.d_rc); ASSERT_EQ_D("line " << test.d_line, resultBlob, - bsl::string(test.d_resultPattern, s_allocator_p)); + bsl::string(test.d_resultPattern, + bmqtst::TestHelperUtil::allocator())); } } } @@ -1363,10 +1402,10 @@ static void test17_getAlignedSection() << test.d_byte << ") position with copy: " << test.d_copyFromBlob); - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::fromString(&blob, test.d_blobPattern, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); const BlobPosition start(test.d_index, test.d_byte); @@ -1483,10 +1522,10 @@ static void test18_getAlignedObject() << "from (" << test.d_index << ", " << test.d_byte << ") position with copy: " << test.d_copyFromBlob); - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::fromString(&blob, test.d_blobPattern, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); const BlobPosition start(test.d_index, test.d_byte); @@ -1538,8 +1577,8 @@ static void test19_blobStartHexDumper() { PVV("Print zero length blob"); - bdlbb::Blob blob(s_allocator_p); - bmqu::MemOutStream os(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os << bmqu::BlobStartHexDumper(&blob); ASSERT_EQ(os.str(), ""); @@ -1547,11 +1586,11 @@ static void test19_blobStartHexDumper() { PVV("Print the whole blob (size <= limit)"); - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::fromString(&blob, "abcd|efghXXXX", - s_allocator_p); - bmqu::MemOutStream os(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os << bmqu::BlobStartHexDumper(&blob, 8); ASSERT_EQ(os.str(), @@ -1562,11 +1601,11 @@ static void test19_blobStartHexDumper() { PVV("Print the whole blob (size > limit)"); - bdlbb::Blob blob(s_allocator_p); + bdlbb::Blob blob(bmqtst::TestHelperUtil::allocator()); bmqtst::BlobTestUtil::fromString(&blob, "abcd|efghXXXX", - s_allocator_p); - bmqu::MemOutStream os(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os << bmqu::BlobStartHexDumper(&blob, 6); ASSERT_EQ(os.str(), @@ -1608,7 +1647,7 @@ int main(int argc, char* argv[]) case 1: test1_positionBreathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_blobiterator.t.cpp b/src/groups/bmq/bmqu/bmqu_blobiterator.t.cpp index 04b863c5a..2af810bab 100644 --- a/src/groups/bmq/bmqu/bmqu_blobiterator.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_blobiterator.t.cpp @@ -81,8 +81,10 @@ static void test1_breathingTest() const int BUFFER_SIZE = 10; const int BLOB_LENGTH = 124; - bdlbb::PooledBlobBufferFactory factory(BUFFER_SIZE, s_allocator_p); - bdlbb::Blob blob(&factory, s_allocator_p); + bdlbb::PooledBlobBufferFactory factory( + BUFFER_SIZE, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&factory, bmqtst::TestHelperUtil::allocator()); blob.setLength(BLOB_LENGTH); bmqu::BlobIterator obj(&blob, bmqu::BlobPosition(12, 0), 4, true); @@ -157,8 +159,10 @@ static void test2_advance() for (int dataIdx = 0; dataIdx < NUM_DATA; ++dataIdx) { const TestData& data = DATA[dataIdx]; - bdlbb::PooledBlobBufferFactory factory(BUFFER_SIZE, s_allocator_p); - bdlbb::Blob blob(&factory, s_allocator_p); + bdlbb::PooledBlobBufferFactory factory( + BUFFER_SIZE, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&factory, bmqtst::TestHelperUtil::allocator()); blob.setLength(BLOB_LENGTH); bmqu::BlobPosition startPos(data.d_startBuffer, data.d_startByte); @@ -245,8 +249,10 @@ static void test3_forwardIterator() for (int dataIdx = 0; dataIdx < NUM_DATA; ++dataIdx) { const TestData& data = DATA[dataIdx]; - bdlbb::PooledBlobBufferFactory factory(BUFFER_SIZE, s_allocator_p); - bdlbb::Blob blob(&factory, s_allocator_p); + bdlbb::PooledBlobBufferFactory factory( + BUFFER_SIZE, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&factory, bmqtst::TestHelperUtil::allocator()); blob.setLength(BLOB_LENGTH); bmqu::BlobIterator iter(&blob, bmqu::BlobPosition(data.d_startBuffer, @@ -306,7 +312,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_blobobjectproxy.t.cpp b/src/groups/bmq/bmqu/bmqu_blobobjectproxy.t.cpp index 28b731c88..3400b5487 100644 --- a/src/groups/bmq/bmqu/bmqu_blobobjectproxy.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_blobobjectproxy.t.cpp @@ -104,8 +104,12 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("Breathing Test"); - bdlbb::PooledBlobBufferFactory smallFactory(2, s_allocator_p); - bdlbb::PooledBlobBufferFactory bigFactory(128, s_allocator_p); + bdlbb::PooledBlobBufferFactory smallFactory( + 2, + bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bigFactory( + 128, + bmqtst::TestHelperUtil::allocator()); TestHeader hdr; const char* const ptr = reinterpret_cast(&hdr); @@ -113,7 +117,7 @@ static void test1_breathingTest() { PVV("Test reading a complete, aligned object from blob"); - bdlbb::Blob blob(&bigFactory, s_allocator_p); + bdlbb::Blob blob(&bigFactory, bmqtst::TestHelperUtil::allocator()); hdr.reset(sizeof(hdr), 1, 2); bdlbb::BlobUtil::append(&blob, ptr, sizeof(hdr)); @@ -128,7 +132,7 @@ static void test1_breathingTest() { PVV("Test reading an incomplete object from a blob"); - bdlbb::Blob blob(&bigFactory, s_allocator_p); + bdlbb::Blob blob(&bigFactory, bmqtst::TestHelperUtil::allocator()); hdr.reset(9, 1, 2); bdlbb::BlobUtil::append(&blob, ptr, sizeof(hdr)); @@ -143,7 +147,7 @@ static void test1_breathingTest() { PVV("Test 'resize'"); - bdlbb::Blob blob(&bigFactory, s_allocator_p); + bdlbb::Blob blob(&bigFactory, bmqtst::TestHelperUtil::allocator()); hdr.reset(sizeof(hdr), 1, 2); bdlbb::BlobUtil::append(&blob, ptr, sizeof(hdr)); @@ -164,7 +168,7 @@ static void test1_breathingTest() { PVV("Test writing out changes to the blob"); - bdlbb::Blob blob(&bigFactory, s_allocator_p); + bdlbb::Blob blob(&bigFactory, bmqtst::TestHelperUtil::allocator()); hdr.reset(sizeof(hdr), 1, 2); bdlbb::BlobUtil::append(&blob, ptr, sizeof(hdr)); @@ -203,7 +207,7 @@ static void test1_breathingTest() PVV("Test 'reset' with a blob shorter than specified TYPE's length"); // Create a blob length 1 - bdlbb::Blob blob(&bigFactory, s_allocator_p); + bdlbb::Blob blob(&bigFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, "a", 1); ASSERT_EQ(1, blob.length()); @@ -222,7 +226,7 @@ static void test1_breathingTest() PVV("Test 'reset' with speicfying minimum length to read"); // Create blob containing complete TestHeader - bdlbb::Blob blob(&bigFactory, s_allocator_p); + bdlbb::Blob blob(&bigFactory, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, ptr, sizeof(hdr)); bmqu::BlobObjectProxy pxy; @@ -253,7 +257,7 @@ static void test1_breathingTest() PVV("Test 'loadEndPosition'"); // Create blob containing complete TestHeader - bdlbb::Blob blob(&bigFactory, s_allocator_p); + bdlbb::Blob blob(&bigFactory, bmqtst::TestHelperUtil::allocator()); hdr.reset(1, 2, 3); bdlbb::BlobUtil::append(&blob, ptr, sizeof(hdr)); hdr.reset(4, 5, 6); @@ -303,8 +307,10 @@ static void test2_usageExample1() // First, we initialize our blob by writing a single 'TestHeader' object to // it with some test values. //.. - bdlbb::PooledBlobBufferFactory factory(0xFF, s_allocator_p); - bdlbb::Blob blob(&factory, s_allocator_p); + bdlbb::PooledBlobBufferFactory factory( + 0xFF, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&factory, bmqtst::TestHelperUtil::allocator()); TestHeader hdr; bsl::memset(&hdr, 0, sizeof(hdr)); @@ -401,8 +407,10 @@ static void test3_usageExample2() // efficiently. To do this, we need to create our blob with enough room to // store an instance of our 'TestHeader'. //.. - bdlbb::PooledBlobBufferFactory factory(0xFF, s_allocator_p); - bdlbb::Blob blob(&factory, s_allocator_p); + bdlbb::PooledBlobBufferFactory factory( + 0xFF, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&factory, bmqtst::TestHelperUtil::allocator()); TestHeader hdr; const char* const ptr = reinterpret_cast(&hdr); @@ -430,7 +438,7 @@ static void test3_usageExample2() //.. // Finally, we verify that the blob contains our changes. //.. - bdlbb::Blob expectedBlob(&factory, s_allocator_p); + bdlbb::Blob expectedBlob(&factory, bmqtst::TestHelperUtil::allocator()); bsl::memset(&hdr, 0, sizeof(hdr)); hdr.d_length = sizeof(TestHeader); @@ -456,7 +464,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_memoutstream.t.cpp b/src/groups/bmq/bmqu/bmqu_memoutstream.t.cpp index bdd8e5933..ab01f6c68 100644 --- a/src/groups/bmq/bmqu/bmqu_memoutstream.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_memoutstream.t.cpp @@ -44,7 +44,7 @@ static void test1_breathingTest() // acceptable (and this test driver needs fixing) or BDE will need to // make a new component with the changes and keep // `bdesb_MemOutStreamBuf` as it is. - bslma::TestAllocator alloc(s_allocator_p); + bslma::TestAllocator alloc(bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream obj(&alloc); @@ -106,7 +106,7 @@ static void test2_usageExample() { bmqtst::TestHelper::printTestName("USAGE EXAMPLE"); - bmqu::MemOutStream obj(30, s_allocator_p); + bmqu::MemOutStream obj(30, bmqtst::TestHelperUtil::allocator()); obj << "hello world"; ASSERT_EQ(obj.str(), "hello world"); } @@ -125,7 +125,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_objectplaceholder.t.cpp b/src/groups/bmq/bmqu/bmqu_objectplaceholder.t.cpp index 1908e77bf..c3cff6321 100644 --- a/src/groups/bmq/bmqu/bmqu_objectplaceholder.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_objectplaceholder.t.cpp @@ -240,7 +240,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_operationchain.t.cpp b/src/groups/bmq/bmqu/bmqu_operationchain.t.cpp index 76a796b13..00b39512e 100644 --- a/src/groups/bmq/bmqu/bmqu_operationchain.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_operationchain.t.cpp @@ -304,7 +304,7 @@ static void test1_usageExample() // ------------------------------------------------------------------------ { // create a chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); static const int k_MY_PAYLOAD = 42; static const int k_MY_CLIENT_ID = 42; @@ -350,27 +350,27 @@ static void test2_chain_creators(bdlmt::ThreadPool* threadPool) // constructor #1 { // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // check postconditions ASSERT_EQ(chain.isStarted(), false); ASSERT_EQ(chain.isRunning(), false); ASSERT_EQ(chain.numLinks(), 0u); ASSERT_EQ(chain.numOperations(), 0u); - ASSERT_EQ(chain.allocator(), s_allocator_p); + ASSERT_EQ(chain.allocator(), bmqtst::TestHelperUtil::allocator()); } // constructor #2 { // create chain - bmqu::OperationChain chain(true, s_allocator_p); + bmqu::OperationChain chain(true, bmqtst::TestHelperUtil::allocator()); // check postconditions ASSERT_EQ(chain.isStarted(), true); ASSERT_EQ(chain.isRunning(), false); ASSERT_EQ(chain.numLinks(), 0u); ASSERT_EQ(chain.numOperations(), 0u); - ASSERT_EQ(chain.allocator(), s_allocator_p); + ASSERT_EQ(chain.allocator(), bmqtst::TestHelperUtil::allocator()); } } @@ -399,7 +399,7 @@ static void test3_chain_startStop(bdlmt::ThreadPool* threadPool) bsls::SystemClockType::e_MONOTONIC); // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // number of operations in the chain static const unsigned k_NUM_OPERATIONS = 3; @@ -443,7 +443,7 @@ static void test3_chain_startStop(bdlmt::ThreadPool* threadPool) bsls::SystemClockType::e_MONOTONIC); // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // used for synchronization bslmt::Semaphore semaphore; @@ -512,7 +512,7 @@ static void test4_chain_join(bdlmt::ThreadPool* threadPool) bdlcc::Deque completionIds(bsls::SystemClockType::e_MONOTONIC); // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // number of operations in the chain static const unsigned k_NUM_OPERATIONS = 32; @@ -567,7 +567,7 @@ static void test5_chain_append1(bdlmt::ThreadPool* threadPool) // 1. append single empty link { // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // create empty link bmqu::OperationChainLink link(chain.allocator()); @@ -591,7 +591,7 @@ static void test5_chain_append1(bdlmt::ThreadPool* threadPool) static const unsigned k_NUM_LINKS = 8; // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // append several links bmqu::OperationChainLink link(chain.allocator()); @@ -619,7 +619,7 @@ static void test5_chain_append1(bdlmt::ThreadPool* threadPool) // 3. append non-empty link to a started chain { // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // start executing operations chain.start(); @@ -690,7 +690,7 @@ static void test6_chain_append2(bdlmt::ThreadPool* threadPool) // 1. append empty link list { // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // append links bmqu::OperationChainLink** links = @@ -706,7 +706,7 @@ static void test6_chain_append2(bdlmt::ThreadPool* threadPool) // 2. append non-empty link list containing empty links { // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // create empty links bmqu::OperationChainLink link1(chain.allocator()); @@ -730,7 +730,7 @@ static void test6_chain_append2(bdlmt::ThreadPool* threadPool) // way we know which link is which. // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // create links bmqu::OperationChainLink link1(chain.allocator()); @@ -783,7 +783,7 @@ static void test7_chain_appendInplace(bdlmt::ThreadPool* threadPool) // 1. append-inplace a link { // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // append-inplace a link (use first overload) chain.appendInplace(NullOperation()); @@ -841,7 +841,7 @@ static void test8_chain_popBack(bdlmt::ThreadPool* threadPool) static const unsigned k_NUM_LINKS = 8; // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // append several links bmqu::OperationChainLink link(chain.allocator()); @@ -879,7 +879,7 @@ static void test8_chain_popBack(bdlmt::ThreadPool* threadPool) // 2. try extract last link from an empty chain { // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // try extract link int rc = chain.popBack(); @@ -907,7 +907,7 @@ static void test8_chain_popBack(bdlmt::ThreadPool* threadPool) // 3. try extract last link while associated operations are executing { // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // start executing operations chain.start(); @@ -981,7 +981,7 @@ static void test9_chain_removeAll(bdlmt::ThreadPool* threadPool) // 1. remove all links { // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // number of links and operations in each link static const unsigned k_NUM_LINKS = 3; @@ -1013,7 +1013,7 @@ static void test9_chain_removeAll(bdlmt::ThreadPool* threadPool) // 2. try remove all operations from an empty chain { // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // try remove all links unsigned count = chain.removeAll(); @@ -1023,7 +1023,7 @@ static void test9_chain_removeAll(bdlmt::ThreadPool* threadPool) // 3. try remove all operations while some of them are executing { // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // start executing operations chain.start(); @@ -1084,7 +1084,7 @@ static void test10_chain_serialization(bdlmt::ThreadPool* threadPool) bdlcc::Deque completionIds(bsls::SystemClockType::e_MONOTONIC); // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // number of links and operations in each link static const unsigned k_NUM_LINKS = 8; @@ -1144,7 +1144,7 @@ static void test11_chain_exceptionHandling(bdlmt::ThreadPool* threadPool) BSLS_ASSERT(threadPool); // create chain - bmqu::OperationChain chain(s_allocator_p); + bmqu::OperationChain chain(bmqtst::TestHelperUtil::allocator()); // add several operations, each handling an exception thrown from the // completion callback @@ -1186,17 +1186,17 @@ static void test12_link_creators() // 1. default constructor { // create link - bmqu::OperationChainLink link(s_allocator_p); + bmqu::OperationChainLink link(bmqtst::TestHelperUtil::allocator()); // check postconditions ASSERT_EQ(link.numOperations(), 0u); - ASSERT_EQ(link.allocator(), s_allocator_p); + ASSERT_EQ(link.allocator(), bmqtst::TestHelperUtil::allocator()); } // 2. move constructor { // create link containing several operations - bmqu::OperationChainLink original(s_allocator_p); + bmqu::OperationChainLink original(bmqtst::TestHelperUtil::allocator()); original.insert(NullOperation()); original.insert(NullOperation()); @@ -1205,11 +1205,11 @@ static void test12_link_creators() // the copy now contains the state of the original ASSERT_EQ(copy.numOperations(), 2u); - ASSERT_EQ(original.allocator(), s_allocator_p); + ASSERT_EQ(original.allocator(), bmqtst::TestHelperUtil::allocator()); // the original is left empty ASSERT_EQ(original.numOperations(), 0u); - ASSERT_EQ(original.allocator(), s_allocator_p); + ASSERT_EQ(original.allocator(), bmqtst::TestHelperUtil::allocator()); } } @@ -1232,12 +1232,12 @@ static void test13_link_assignment() // 1. regular move-assignment { // create link containing one operation - bmqu::OperationChainLink link1(s_allocator_p); + bmqu::OperationChainLink link1(bmqtst::TestHelperUtil::allocator()); link1.insert(NullOperation()); // create another link containing two operations - bmqu::OperationChainLink link2(s_allocator_p); + bmqu::OperationChainLink link2(bmqtst::TestHelperUtil::allocator()); link2.insert(NullOperation()); link2.insert(NullOperation()); @@ -1246,17 +1246,17 @@ static void test13_link_assignment() // the first link now contains the state of the second one ASSERT_EQ(link1.numOperations(), 2u); - ASSERT_EQ(link1.allocator(), s_allocator_p); + ASSERT_EQ(link1.allocator(), bmqtst::TestHelperUtil::allocator()); // the second link is left empty ASSERT_EQ(link2.numOperations(), 0u); - ASSERT_EQ(link2.allocator(), s_allocator_p); + ASSERT_EQ(link2.allocator(), bmqtst::TestHelperUtil::allocator()); } // 2. move-assign to self { // create link containing several operations - bmqu::OperationChainLink link(s_allocator_p); + bmqu::OperationChainLink link(bmqtst::TestHelperUtil::allocator()); link.insert(NullOperation()); link.insert(NullOperation()); @@ -1264,7 +1264,7 @@ static void test13_link_assignment() link = bslmf::MovableRefUtil::move(link); // the link is in a valid state - ASSERT_EQ(link.allocator(), s_allocator_p); + ASSERT_EQ(link.allocator(), bmqtst::TestHelperUtil::allocator()); } } @@ -1280,7 +1280,7 @@ static void test14_link_insert() // ------------------------------------------------------------------------ { // create an empty link - bmqu::OperationChainLink link(s_allocator_p); + bmqu::OperationChainLink link(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(link.numOperations(), 0u); static const unsigned k_NUM_OPERATIONS = 10; @@ -1315,7 +1315,7 @@ static void test15_link_removeAll() // ------------------------------------------------------------------------ { // create link containing several operations - bmqu::OperationChainLink link(s_allocator_p); + bmqu::OperationChainLink link(bmqtst::TestHelperUtil::allocator()); link.insert(NullOperation()); link.insert(NullOperation()); @@ -1344,8 +1344,8 @@ static void test16_link_swap() { // both empty { - bmqu::OperationChainLink link1(s_allocator_p); - bmqu::OperationChainLink link2(s_allocator_p); + bmqu::OperationChainLink link1(bmqtst::TestHelperUtil::allocator()); + bmqu::OperationChainLink link2(bmqtst::TestHelperUtil::allocator()); link1.swap(link2); ASSERT_EQ(link1.numOperations(), 0u); @@ -1354,9 +1354,9 @@ static void test16_link_swap() // first empty { - bmqu::OperationChainLink link1(s_allocator_p); + bmqu::OperationChainLink link1(bmqtst::TestHelperUtil::allocator()); - bmqu::OperationChainLink link2(s_allocator_p); + bmqu::OperationChainLink link2(bmqtst::TestHelperUtil::allocator()); link2.insert(NullOperation()); link2.insert(NullOperation()); @@ -1367,11 +1367,11 @@ static void test16_link_swap() // second empty { - bmqu::OperationChainLink link1(s_allocator_p); + bmqu::OperationChainLink link1(bmqtst::TestHelperUtil::allocator()); link1.insert(NullOperation()); link1.insert(NullOperation()); - bmqu::OperationChainLink link2(s_allocator_p); + bmqu::OperationChainLink link2(bmqtst::TestHelperUtil::allocator()); link1.swap(link2); ASSERT_EQ(link1.numOperations(), 0u); @@ -1380,11 +1380,11 @@ static void test16_link_swap() // none empty { - bmqu::OperationChainLink link1(s_allocator_p); + bmqu::OperationChainLink link1(bmqtst::TestHelperUtil::allocator()); link1.insert(NullOperation()); link1.insert(NullOperation()); - bmqu::OperationChainLink link2(s_allocator_p); + bmqu::OperationChainLink link2(bmqtst::TestHelperUtil::allocator()); link2.insert(NullOperation()); link2.insert(NullOperation()); link2.insert(NullOperation()); @@ -1437,7 +1437,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_outstreamformatsaver.t.cpp b/src/groups/bmq/bmqu/bmqu_outstreamformatsaver.t.cpp index 787f6a583..3f3e70f8e 100644 --- a/src/groups/bmq/bmqu/bmqu_outstreamformatsaver.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_outstreamformatsaver.t.cpp @@ -50,7 +50,7 @@ static void test1_breathingTest() const unsigned int k_FIFTY = 50; - bmqu::MemOutStream obj(s_allocator_p); + bmqu::MemOutStream obj(bmqtst::TestHelperUtil::allocator()); { bmqu::OutStreamFormatSaver fmtSaver(obj); @@ -96,7 +96,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_printutil.t.cpp b/src/groups/bmq/bmqu/bmqu_printutil.t.cpp index 4ac243955..e45b4195c 100644 --- a/src/groups/bmq/bmqu/bmqu_printutil.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_printutil.t.cpp @@ -85,7 +85,7 @@ static void test1_prettyNumberInt64() << ", separator: '" << test.d_separator << "', function)"); - bmqu::MemOutStream buf(s_allocator_p); + bmqu::MemOutStream buf(bmqtst::TestHelperUtil::allocator()); bmqu::PrintUtil::prettyNumber(buf, test.d_value, test.d_groupSize, @@ -100,7 +100,7 @@ static void test1_prettyNumberInt64() << ", separator: '" << test.d_separator << "', manipulator)"); - bmqu::MemOutStream buf(s_allocator_p); + bmqu::MemOutStream buf(bmqtst::TestHelperUtil::allocator()); buf << bmqu::PrintUtil::prettyNumber(test.d_value, test.d_groupSize, test.d_separator); @@ -167,7 +167,7 @@ static void test2_prettyNumberDouble() << ", separator: '" << test.d_separator << "', function)"); - bmqu::MemOutStream buf(s_allocator_p); + bmqu::MemOutStream buf(bmqtst::TestHelperUtil::allocator()); bmqu::PrintUtil::prettyNumber(buf, test.d_value, test.d_precision, @@ -184,7 +184,7 @@ static void test2_prettyNumberDouble() << ", separator: '" << test.d_separator << "', manipulator)"); - bmqu::MemOutStream buf(s_allocator_p); + bmqu::MemOutStream buf(bmqtst::TestHelperUtil::allocator()); buf << bmqu::PrintUtil::prettyNumber(test.d_value, test.d_precision, test.d_groupSize, @@ -272,7 +272,7 @@ static void test3_prettyBytes() << " (precision: " << test.d_precision << ", function)"); - bmqu::MemOutStream buf(s_allocator_p); + bmqu::MemOutStream buf(bmqtst::TestHelperUtil::allocator()); bmqu::PrintUtil::prettyBytes(buf, test.d_value, test.d_precision); ASSERT_EQ_D(test.d_line, buf.str(), test.d_expected); } @@ -283,7 +283,7 @@ static void test3_prettyBytes() << " (precision: " << test.d_precision << ", function)"); - bmqu::MemOutStream buf(s_allocator_p); + bmqu::MemOutStream buf(bmqtst::TestHelperUtil::allocator()); buf << bmqu::PrintUtil::prettyBytes(test.d_value, test.d_precision); ASSERT_EQ_D(test.d_line, buf.str(), test.d_expected); @@ -354,7 +354,7 @@ static void test4_prettyTimeInterval() << " (precision: " << test.d_precision << ", function)"); - bmqu::MemOutStream buf(s_allocator_p); + bmqu::MemOutStream buf(bmqtst::TestHelperUtil::allocator()); bmqu::PrintUtil::prettyTimeInterval(buf, test.d_value, test.d_precision); @@ -367,7 +367,7 @@ static void test4_prettyTimeInterval() << " (precision: " << test.d_precision << ", function)"); - bmqu::MemOutStream buf(s_allocator_p); + bmqu::MemOutStream buf(bmqtst::TestHelperUtil::allocator()); buf << bmqu::PrintUtil::prettyTimeInterval(test.d_value, test.d_precision); ASSERT_EQ_D(test.d_line, buf.str(), test.d_expected); @@ -391,7 +391,7 @@ int main(int argc, char* argv[]) case 1: test1_prettyNumberInt64(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_samethreadchecker.t.cpp b/src/groups/bmq/bmqu/bmqu_samethreadchecker.t.cpp index 13ed96204..9fe2359d3 100644 --- a/src/groups/bmq/bmqu/bmqu_samethreadchecker.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_samethreadchecker.t.cpp @@ -62,7 +62,7 @@ static void test1_breathingTest() &thread, bdlf::MemFnUtil::memFn(&bmqu::SameThreadChecker::inSameThread, &sameThreadChecker), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(rc == 0); rc = bslmt::ThreadUtil::join(thread); @@ -86,7 +86,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_sharedresource.t.cpp b/src/groups/bmq/bmqu/bmqu_sharedresource.t.cpp index 0585ae6eb..e93db50c2 100644 --- a/src/groups/bmq/bmqu/bmqu_sharedresource.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_sharedresource.t.cpp @@ -636,7 +636,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_stringutil.t.cpp b/src/groups/bmq/bmqu/bmqu_stringutil.t.cpp index b87bbc2b4..8490e3881 100644 --- a/src/groups/bmq/bmqu/bmqu_stringutil.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_stringutil.t.cpp @@ -65,7 +65,7 @@ static void test1_contains() PVV(test.d_line << ": checking if '" << test.d_substr << "' " << "is a substring of '" << test.d_str << "'"); - bsl::string str(test.d_str, s_allocator_p); + bsl::string str(test.d_str, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D("line " << test.d_line, bmqu::StringUtil::contains(str, test.d_substr), test.d_result); @@ -204,7 +204,7 @@ static void test4_trim() PVV(test.d_line << ": trimming '" << test.d_str << "'"); - bsl::string input(test.d_str, s_allocator_p); + bsl::string input(test.d_str, bmqtst::TestHelperUtil::allocator()); bmqu::StringUtil::trim(&input); ASSERT_EQ_D("line " << test.d_line, input, test.d_expected); } @@ -245,7 +245,7 @@ static void test5_ltrim() PVV(test.d_line << ": ltrimming '" << test.d_str << "'"); - bsl::string input(test.d_str, s_allocator_p); + bsl::string input(test.d_str, bmqtst::TestHelperUtil::allocator()); bmqu::StringUtil::ltrim(&input); ASSERT_EQ_D("line " << test.d_line, input, test.d_expected); } @@ -286,7 +286,7 @@ static void test6_rtrim() PVV(test.d_line << ": rtrimming '" << test.d_str << "'"); - bsl::string input(test.d_str, s_allocator_p); + bsl::string input(test.d_str, bmqtst::TestHelperUtil::allocator()); bmqu::StringUtil::rtrim(&input); ASSERT_EQ_D("line " << test.d_line, input, test.d_expected); } @@ -306,14 +306,14 @@ static void test7_strTokenizeRef() // Proper behavior of the 'strTokenizeRef(str, delims)' method. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // The vector returned by 'bmqu::StringUtil::strTokenizeRef' uses the // default allocator. bmqtst::TestHelper::printTestName("strTokenizeRef"); - bsl::string string(s_allocator_p); - bsl::vector tokens(s_allocator_p); + bsl::string string(bmqtst::TestHelperUtil::allocator()); + bsl::vector tokens(bmqtst::TestHelperUtil::allocator()); struct Test { int d_line; @@ -343,7 +343,7 @@ static void test7_strTokenizeRef() PVV(test.d_line << ": tokenizing '" << test.d_input << "'"); - bsl::string input(test.d_input, s_allocator_p); + bsl::string input(test.d_input, bmqtst::TestHelperUtil::allocator()); tokens = bmqu::StringUtil::strTokenizeRef(input, test.d_delims); ASSERT_EQ_D("line " << test.d_line, tokens.size(), test.d_nbTokens); @@ -505,7 +505,7 @@ static void test9_squeeze() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bsl::string str(test.d_str, s_allocator_p); + bsl::string str(test.d_str, bmqtst::TestHelperUtil::allocator()); PVV(test.d_line << ": squeeze(\"" << str << "\", \"" << test.d_characters << "\")"); @@ -537,7 +537,7 @@ int main(int argc, char* argv[]) case 1: test1_contains(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_throttledaction.t.cpp b/src/groups/bmq/bmqu/bmqu_throttledaction.t.cpp index e5bfb4530..8ae31e554 100644 --- a/src/groups/bmq/bmqu/bmqu_throttledaction.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_throttledaction.t.cpp @@ -148,7 +148,8 @@ static void test2_throttleNoReset() const int k_INTERVAL_MS = 2000; const int k_MAX_COUNT_PER_INTERVAL = 3; - bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, s_allocator_p); + bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, + bmqtst::TestHelperUtil::allocator()); // No more than 3 logs in a 5s timeframe bmqu::ThrottledActionParams obj(k_INTERVAL_MS, k_MAX_COUNT_PER_INTERVAL); @@ -259,7 +260,7 @@ static void test3_throttleWithDefaultReset() // BMQU_THROTTLEDACTION_THROTTLE(P, ACTION) // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -271,7 +272,8 @@ static void test3_throttleWithDefaultReset() const int k_INTERVAL_MS = 2000; const int k_MAX_COUNT_PER_INTERVAL = 3; - bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, s_allocator_p); + bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, + bmqtst::TestHelperUtil::allocator()); // No more than 3 logs in a 5s timeframe bmqu::ThrottledActionParams obj(k_INTERVAL_MS, k_MAX_COUNT_PER_INTERVAL); @@ -326,13 +328,13 @@ static void test3_throttleWithDefaultReset() } // Ensure the default reset function was invoked. - if (s_verbosityLevel >= 1) { + if (bmqtst::TestHelperUtil::verbosityLevel() >= 1) { ASSERT_EQ(logObserver.records().size(), 1U); PV("Logged during reset: " << logObserver.records()[0]); ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( logObserver.records()[0], "'obj'.*2", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); } ASSERT_EQ(n, k_MAX_COUNT_PER_INTERVAL); ASSERT_EQ(obj.d_intervalNano, @@ -348,7 +350,7 @@ static void test3_throttleWithDefaultReset() BMQU_THROTTLEDACTION_THROTTLE(obj, incrementInteger(&n)); BMQU_THROTTLEDACTION_THROTTLE(obj, incrementInteger(&n)); - if (s_verbosityLevel >= 1) { + if (bmqtst::TestHelperUtil::verbosityLevel() >= 1) { ASSERT_EQ(logObserver.records().size(), 1U); } ASSERT_EQ(n, k_MAX_COUNT_PER_INTERVAL); @@ -389,7 +391,7 @@ static void test4_throttleWithCustomReset() // BMQU_THROTTLEDACTION_THROTTLE_WITH_RESET(P, ACTION) // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -399,7 +401,8 @@ static void test4_throttleWithCustomReset() const int k_INTERVAL_MS = 2000; const int k_MAX_COUNT_PER_INTERVAL = 3; - bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, s_allocator_p); + bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, + bmqtst::TestHelperUtil::allocator()); // No more than 3 logs in a 5s timeframe bmqu::ThrottledActionParams obj(k_INTERVAL_MS, k_MAX_COUNT_PER_INTERVAL); @@ -514,7 +517,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_tlsbool.t.cpp b/src/groups/bmq/bmqu/bmqu_tlsbool.t.cpp index 84ea2ac15..903f6c634 100644 --- a/src/groups/bmq/bmqu/bmqu_tlsbool.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_tlsbool.t.cpp @@ -186,7 +186,8 @@ static void test2_isValid() // to the application (e.g. on Darwin limit is 512 but only 509 or 510 are // available, ...). Figure out what that limit is, by creating keys until // creation returns failure. - bsl::vector keys(s_allocator_p); + bsl::vector keys( + bmqtst::TestHelperUtil::allocator()); keys.resize(k_PTHREAD_KEYS_MAX + 1); int createdKeysCount = 0; @@ -265,10 +266,10 @@ static void test2_isValid() static void test3_multithread() { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // TBD: Despite using bindA, the binding uses default allocator to // allocate. - s_ignoreCheckGblAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckGblAlloc() = true; // Can't ensure no global memory is allocated because // 'bslmt::ThreadUtil::create()' uses the global allocator to allocate // memory. @@ -278,29 +279,31 @@ static void test3_multithread() bslmt::Barrier barrier(2); bmqu::TLSBool obj; - bslmt::ThreadGroup threadGroup(s_allocator_p); + bslmt::ThreadGroup threadGroup(bmqtst::TestHelperUtil::allocator()); bool t1Val[] = {false, true, true, true, false, false, true}; bool t2Val[] = {true, true, true, false, true, false, true}; bsl::vector t1Values(t1Val, t1Val + sizeof(t1Val) / sizeof(bool), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bsl::vector t2Values(t2Val, t2Val + sizeof(t2Val) / sizeof(bool), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Create threads - threadGroup.addThread(bdlf::BindUtil::bindS(s_allocator_p, - &threadFunction, - &barrier, - t1Values, - &obj)); - threadGroup.addThread(bdlf::BindUtil::bindS(s_allocator_p, - &threadFunction, - &barrier, - t2Values, - &obj)); + threadGroup.addThread( + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), + &threadFunction, + &barrier, + t1Values, + &obj)); + threadGroup.addThread( + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), + &threadFunction, + &barrier, + t2Values, + &obj)); threadGroup.joinAll(); } @@ -319,7 +322,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqu/bmqu_weakmemfn.t.cpp b/src/groups/bmq/bmqu/bmqu_weakmemfn.t.cpp index 93d64e27d..f7925853e 100644 --- a/src/groups/bmq/bmqu/bmqu_weakmemfn.t.cpp +++ b/src/groups/bmq/bmqu/bmqu_weakmemfn.t.cpp @@ -346,7 +346,7 @@ int main(int argc, char* argv[]) default: { bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << bsl::endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqvt/bmqvt_propertybag.t.cpp b/src/groups/bmq/bmqvt/bmqvt_propertybag.t.cpp index b85583d38..e81ee4c7b 100644 --- a/src/groups/bmq/bmqvt/bmqvt_propertybag.t.cpp +++ b/src/groups/bmq/bmqvt/bmqvt_propertybag.t.cpp @@ -88,11 +88,11 @@ static void test1_breathingTest() const bslstl::StringRef k_strVal("theQuickBrownFoxJumped"); bsl::shared_ptr intSp; - intSp.createInplace(s_allocator_p, 1); + intSp.createInplace(bmqtst::TestHelperUtil::allocator(), 1); - PropertyBag obj(s_allocator_p); + PropertyBag obj(bmqtst::TestHelperUtil::allocator()); - ASSERT_EQ(obj.allocator(), s_allocator_p); + ASSERT_EQ(obj.allocator(), bmqtst::TestHelperUtil::allocator()); // Set a value and read it back obj.set("intVal", 1) @@ -156,14 +156,14 @@ static void test2_copyAndAssignment() const bslstl::StringRef k_strVal("theQuickBrownFoxJumped"); bsl::shared_ptr intSp; - intSp.createInplace(s_allocator_p, 1); + intSp.createInplace(bmqtst::TestHelperUtil::allocator(), 1); - PropertyBag obj1(s_allocator_p); + PropertyBag obj1(bmqtst::TestHelperUtil::allocator()); obj1.set("intVal", 5).set("strVal", k_strVal).set("ptrVal", intSp); { PV("Copy PropertyBag and check values in copied object"); - PropertyBag obj2(obj1, s_allocator_p); + PropertyBag obj2(obj1, bmqtst::TestHelperUtil::allocator()); checkValue(L_, obj2, "intVal", 5); checkValue(L_, obj2, "strVal", k_strVal); checkValueSp(L_, obj2, "ptrVal", intSp); @@ -176,7 +176,7 @@ static void test2_copyAndAssignment() { PV("Assignment"); - PropertyBag obj3(s_allocator_p); + PropertyBag obj3(bmqtst::TestHelperUtil::allocator()); obj3.set("someIntVal", 3); obj3 = obj1; @@ -192,7 +192,7 @@ static void test2_copyAndAssignment() static void test3_print() { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // We can't use 'bmqu::MemOutStream' because bmqu is above bmqvt, so use // a 'ostringstream', which allocates its string using the default // allocator. @@ -201,7 +201,7 @@ static void test3_print() const bslstl::StringRef k_strVal("theQuickBrownFox"); - PropertyBag obj(s_allocator_p); + PropertyBag obj(bmqtst::TestHelperUtil::allocator()); obj.set("IntVal", 5).set("strVal", k_strVal); { @@ -209,7 +209,7 @@ static void test3_print() bsl::ostringstream out; bsl::string expected("[ strVal = \"theQuickBrownFox\" ]", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr bagValue; obj.load(&bagValue, "strVal"); @@ -235,7 +235,7 @@ static void test3_print() bsl::ostringstream out; bsl::string expected("[ strVal = \"theQuickBrownFox\" IntVal = 5 ]", - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); out.setstate(bsl::ios_base::badbit); obj.print(out, 0, -1); @@ -257,13 +257,14 @@ static void test4_loadAllImport() { bmqtst::TestHelper::printTestName("loadAll/import"); - PropertyBag obj(s_allocator_p); - PropertyBag obj2(s_allocator_p); + PropertyBag obj(bmqtst::TestHelperUtil::allocator()); + PropertyBag obj2(bmqtst::TestHelperUtil::allocator()); obj.set("int1", 1); obj.set("int2", 2); - bsl::vector > values(s_allocator_p); + bsl::vector > values( + bmqtst::TestHelperUtil::allocator()); obj.loadAll(&values); ASSERT_EQ(static_cast(values.size()), 2); @@ -271,7 +272,7 @@ static void test4_loadAllImport() checkValue(L_, obj2, "int1", 1); checkValue(L_, obj2, "int2", 2); - PropertyBag obj3(s_allocator_p); + PropertyBag obj3(bmqtst::TestHelperUtil::allocator()); obj3.import(*values[0]); obj3.import(*values[1]); checkValue(L_, obj3, "int1", 1); @@ -288,7 +289,7 @@ static void test5_propertyBagUtil() bslstl::StringRef longStr( "theQuickBrownFoxALongStringThatWillForceAllocation"); - PropertyBag obj(s_allocator_p); + PropertyBag obj(bmqtst::TestHelperUtil::allocator()); obj.set("int1", 1).set("int2", 2).set("str1", "abc").set("str2", longStr); bdlma::LocalSequentialAllocator<10 * 1024> arena; @@ -358,7 +359,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqvt/bmqvt_rcdescriptionerror.t.cpp b/src/groups/bmq/bmqvt/bmqvt_rcdescriptionerror.t.cpp index b8bd5f350..9addc4d81 100644 --- a/src/groups/bmq/bmqvt/bmqvt_rcdescriptionerror.t.cpp +++ b/src/groups/bmq/bmqvt/bmqvt_rcdescriptionerror.t.cpp @@ -44,7 +44,7 @@ static void test1_breathingTest() { PV("Default constructor"); - bmqvt::RcDescriptionError obj(s_allocator_p); + bmqvt::RcDescriptionError obj(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.rc(), 0); ASSERT_EQ(obj.description(), ""); } @@ -52,7 +52,9 @@ static void test1_breathingTest() { PV("With value constructor"); - bmqvt::RcDescriptionError obj(123, "abc", s_allocator_p); + bmqvt::RcDescriptionError obj(123, + "abc", + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj.rc(), 123); ASSERT_EQ(obj.description(), "abc"); } @@ -60,13 +62,19 @@ static void test1_breathingTest() { PV("Copy constructor and assignment operator"); - bmqvt::RcDescriptionError obj(123, "abc", s_allocator_p); + bmqvt::RcDescriptionError obj(123, + "abc", + bmqtst::TestHelperUtil::allocator()); - bmqvt::RcDescriptionError copy(obj, s_allocator_p); + bmqvt::RcDescriptionError copy(obj, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(copy.rc(), 123); ASSERT_EQ(copy.description(), "abc"); - bmqvt::RcDescriptionError assignment(987, "zyx", s_allocator_p); + bmqvt::RcDescriptionError assignment( + 987, + "zyx", + bmqtst::TestHelperUtil::allocator()); assignment = obj; ASSERT_EQ(assignment.rc(), 123); ASSERT_EQ(assignment.description(), "abc"); @@ -108,10 +116,10 @@ static void test2_equality() bmqvt::RcDescriptionError lhs(test.d_lrc, test.d_ldescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqvt::RcDescriptionError rhs(test.d_rrc, test.d_rdescription, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ_D("line " << test.d_line, test.d_equal, lhs == rhs); ASSERT_NE_D("line " << test.d_line, test.d_equal, lhs != rhs); } @@ -134,8 +142,10 @@ static void test3_print() { PV("Explicit print"); - bmqvt::RcDescriptionError obj(123, "abc", s_allocator_p); - bmqu::MemOutStream os(s_allocator_p); + bmqvt::RcDescriptionError obj(123, + "abc", + bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); bmqvt::RcDescriptionError::print(os, obj, 0, 0); ASSERT_EQ(os.str(), "[\nrc = 123\ndescription = \"abc\"\n]\n"); } @@ -143,8 +153,10 @@ static void test3_print() { PV("operator<<"); - bmqvt::RcDescriptionError obj(123, "abc", s_allocator_p); - bmqu::MemOutStream os(s_allocator_p); + bmqvt::RcDescriptionError obj(123, + "abc", + bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os << obj; ASSERT_EQ(os.str(), "[ rc = 123 description = \"abc\" ]"); @@ -153,8 +165,10 @@ static void test3_print() { PV("Invalid stream ('badbit' set)"); - bmqvt::RcDescriptionError obj(123, "abc", s_allocator_p); - bmqu::MemOutStream os(s_allocator_p); + bmqvt::RcDescriptionError obj(123, + "abc", + bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os.setstate(bsl::ios_base::badbit); bmqvt::RcDescriptionError::print(os, obj, 0, 0); @@ -178,7 +192,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/bmq/bmqvt/bmqvt_valueorerror.t.cpp b/src/groups/bmq/bmqvt/bmqvt_valueorerror.t.cpp index 0445f6398..60fd4abd2 100644 --- a/src/groups/bmq/bmqvt/bmqvt_valueorerror.t.cpp +++ b/src/groups/bmq/bmqvt/bmqvt_valueorerror.t.cpp @@ -40,15 +40,15 @@ const char* k_LONG_STRING = "12345678901234567890123456789001234567890"; class CustomValueType { public: CustomValueType() - : d_foo(k_LONG_STRING, s_allocator_p) - , d_bar(k_LONG_STRING, s_allocator_p) + : d_foo(k_LONG_STRING, bmqtst::TestHelperUtil::allocator()) + , d_bar(k_LONG_STRING, bmqtst::TestHelperUtil::allocator()) { PVV("CustomValueType(bslma::Allocator *)"); } CustomValueType(const bsl::string& src) - : d_foo(k_LONG_STRING, s_allocator_p) - , d_bar(k_LONG_STRING, s_allocator_p) + : d_foo(k_LONG_STRING, bmqtst::TestHelperUtil::allocator()) + , d_bar(k_LONG_STRING, bmqtst::TestHelperUtil::allocator()) { PVV("CustomValueType(const bsl::string&)"); @@ -57,8 +57,8 @@ class CustomValueType { } CustomValueType(const CustomValueType& rhs) - : d_foo(rhs.d_foo, s_allocator_p) - , d_bar(rhs.d_bar, s_allocator_p) + : d_foo(rhs.d_foo, bmqtst::TestHelperUtil::allocator()) + , d_bar(rhs.d_bar, bmqtst::TestHelperUtil::allocator()) { PVV("CustomValueType(const CustomValueType& , bslma::Allocator *)"); } @@ -123,27 +123,27 @@ bool operator==(const CustomAllocValueType& lhs, bsl::string formatError(const int rc) { - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os << "error: " << rc << "(" << k_LONG_STRING << ")"; - return bsl::string(os.str(), s_allocator_p); + return bsl::string(os.str(), bmqtst::TestHelperUtil::allocator()); } class CustomErrorType { public: CustomErrorType() - : d_error(k_LONG_STRING, s_allocator_p) + : d_error(k_LONG_STRING, bmqtst::TestHelperUtil::allocator()) , d_rc(-2) { } CustomErrorType(const int rc) - : d_error(formatError(rc), s_allocator_p) + : d_error(formatError(rc), bmqtst::TestHelperUtil::allocator()) , d_rc(rc) { } CustomErrorType(const CustomErrorType& rhs) - : d_error(rhs.d_error, s_allocator_p) + : d_error(rhs.d_error, bmqtst::TestHelperUtil::allocator()) , d_rc(rhs.d_rc) { } @@ -207,7 +207,7 @@ template T makeObjectCase(const V& value, BSLS_ANNOTATION_UNUSED bsl::true_type uses_allocator) { - return T(value, s_allocator_p); + return T(value, bmqtst::TestHelperUtil::allocator()); } template @@ -227,7 +227,7 @@ T makeObject(const V& value) template T makeObjectCase(BSLS_ANNOTATION_UNUSED bsl::true_type uses_allocator) { - return T(s_allocator_p); + return T(bmqtst::TestHelperUtil::allocator()); } template @@ -265,13 +265,13 @@ static void test_ops_generic() typedef typename T::ErrorType Error; PVV("Test ValueOrError(bslma::Allocator *) and operator<<"); - T value(s_allocator_p); + T value(bmqtst::TestHelperUtil::allocator()); ASSERT(value.isUndefined()); ASSERT(!value.isValue()); ASSERT(!value.isError()); { - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); os << value; ASSERT_EQ(os.str(), "[ UNDEFINED ]"); } @@ -285,7 +285,8 @@ static void test_ops_generic() ASSERT(value.isValue()); ASSERT(!value.isError()); { - bmqu::MemOutStream expected(s_allocator_p), actual(s_allocator_p); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()), + actual(bmqtst::TestHelperUtil::allocator()); expected << "[ value = " << refValue << " ]"; actual << value; @@ -303,7 +304,8 @@ static void test_ops_generic() ASSERT(!value.isValue()); ASSERT(value.isError()); { - bmqu::MemOutStream expected(s_allocator_p), actual(s_allocator_p); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()), + actual(bmqtst::TestHelperUtil::allocator()); expected << "[ error = " << refError << " ]"; actual << value; @@ -329,7 +331,7 @@ static void test_ops_generic() Value srcValue(makeObject("src")); { - T src(s_allocator_p); + T src(bmqtst::TestHelperUtil::allocator()); src.makeValue(srcValue); value = src; } @@ -339,7 +341,7 @@ static void test_ops_generic() ASSERT_EQ(value.value(), srcValue); PVV("Test copy constructor"); - T copy(value, s_allocator_p); + T copy(value, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(copy.value(), value.value()); // Temporary workaround to suppress the 'unused operator @@ -347,13 +349,13 @@ static void test_ops_generic() // // TBD: figure out the right way to fix this. - CustomAllocValueType dummy1(s_allocator_p); + CustomAllocValueType dummy1(bmqtst::TestHelperUtil::allocator()); static_cast( static_cast >( dummy1)); - CustomAllocErrorType dummy2(s_allocator_p); + CustomAllocErrorType dummy2(bmqtst::TestHelperUtil::allocator()); static_cast( static_cast >( @@ -594,7 +596,7 @@ static void test7_explicit_print() TypeUnderTest value; value.makeValue(12); - bmqu::MemOutStream os(s_allocator_p); + bmqu::MemOutStream os(bmqtst::TestHelperUtil::allocator()); TypeUnderTest::print(os, value, 0, 0); ASSERT_EQ(os.str(), "[ value = 12 ]\n"); } @@ -618,7 +620,7 @@ int main(int argc, char* argv[]) case 1: test1_ops_on_string_int(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqba/mqba_adminsession.t.cpp b/src/groups/mqb/mqba/mqba_adminsession.t.cpp index 4cf5ecfae..ede166991 100644 --- a/src/groups/mqb/mqba/mqba_adminsession.t.cpp +++ b/src/groups/mqb/mqba/mqba_adminsession.t.cpp @@ -226,7 +226,8 @@ static void test1_watermark() { bmqtst::TestHelper::printTestName("ADMIN SESSION HIGH WATERMARK"); - const bsl::string command("sample command", s_allocator_p); + const bsl::string command("sample command", + bmqtst::TestHelperUtil::allocator()); const size_t numMessages = 64; const int rId = 678098; @@ -239,10 +240,11 @@ static void test1_watermark() bdlf::PlaceHolders::_1, // source bdlf::PlaceHolders::_2, // cmd bdlf::PlaceHolders::_3), // onProcessedCb - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Prepare sample admin command control message event - bdlma::LocalSequentialAllocator<2048> localAllocator(s_allocator_p); + bdlma::LocalSequentialAllocator<2048> localAllocator( + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::ControlMessage admin(&localAllocator); admin.rId() = rId; @@ -256,7 +258,8 @@ static void test1_watermark() int rc = builder.setMessage(admin, bmqp::EventType::e_CONTROL); ASSERT_EQ(rc, 0); - bmqp::Event adminEvent(&builder.blob(), s_allocator_p); + bmqp::Event adminEvent(&builder.blob(), + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(adminEvent.isValid()); BSLS_ASSERT(adminEvent.isControlEvent()); @@ -278,7 +281,7 @@ static void test1_watermark() // Sanity check for the first admin response bmqp::Event adminResponseEvent(&tb.d_channel->writeCalls().at(0).d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(adminResponseEvent.isValid()); BSLS_ASSERT(adminResponseEvent.isControlEvent()); @@ -298,14 +301,14 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); bmqp::Crc32c::initialize(); { - bmqp::ProtocolUtil::initialize(s_allocator_p); - bmqsys::Time::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); + bmqsys::Time::initialize(bmqtst::TestHelperUtil::allocator()); - mqbcfg::AppConfig brokerConfig(s_allocator_p); + mqbcfg::AppConfig brokerConfig(bmqtst::TestHelperUtil::allocator()); mqbcfg::BrokerConfig::set(brokerConfig); mqbu::MessageGUIDUtil::initialize(); @@ -315,7 +318,7 @@ int main(int argc, char* argv[]) case 1: test1_watermark(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqba/mqba_application.t.cpp b/src/groups/mqb/mqba/mqba_application.t.cpp index 96d99bf1a..3e5497bfc 100644 --- a/src/groups/mqb/mqba/mqba_application.t.cpp +++ b/src/groups/mqb/mqba/mqba_application.t.cpp @@ -54,18 +54,18 @@ static void test1_breathingTest() bmqtst::TestHelper::printTestName("breathing test"); // Create a default application, make sure it can start/stop - mqbcfg::AppConfig cfg(s_allocator_p); + mqbcfg::AppConfig cfg(bmqtst::TestHelperUtil::allocator()); cfg.networkInterfaces().tcpInterface().makeValue(); mqbcfg::BrokerConfig::set(cfg); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); scheduler.start(); mqba::Application obj(&scheduler, 0, // no allocatorsStatContext - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - // bmqs::MemOutStream error(s_allocator_p); + // bmqs::MemOutStream error(bmqtst::TestHelperUtil::allocator()); // int rc = obj.start(error); // ASSERT_EQ(rc, 0); // obj.stop(); @@ -80,7 +80,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); // Force initialize protocolUtil before any 'mqba::Application' object // gets created, so that we can pass in the test allocator, instead of // having 'mqba::Application' initializing it with the global @@ -91,7 +91,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqba/mqba_clientsession.t.cpp b/src/groups/mqb/mqba/mqba_clientsession.t.cpp index 352ec5103..fd280523a 100644 --- a/src/groups/mqb/mqba/mqba_clientsession.t.cpp +++ b/src/groups/mqb/mqba/mqba_clientsession.t.cpp @@ -610,7 +610,8 @@ class MyMockDomain : public mqbmock::Domain { bmqp_ctrlmsg::Status status(d_allocator_p); status.category() = bmqp_ctrlmsg::StatusCategory::E_SUCCESS; - bmqp_ctrlmsg::OpenQueueResponse openQueueResponse(s_allocator_p); + bmqp_ctrlmsg::OpenQueueResponse openQueueResponse( + bmqtst::TestHelperUtil::allocator()); openQueueResponse.routingConfiguration() = d_routingConfiguration; callback(status, @@ -704,11 +705,13 @@ class TestBench { // // TBD: figure out the right way to "fix" this. - bmqp_ctrlmsg::QueueHandleParameters dummyParameters(s_allocator_p); + bmqp_ctrlmsg::QueueHandleParameters dummyParameters( + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr clientContext( - new (*s_allocator_p) - mqbi::QueueHandleRequesterContext(s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + mqbi::QueueHandleRequesterContext( + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); clientContext->setClient(0); bsl::shared_ptr queue( @@ -719,7 +722,7 @@ class TestBench { clientContext, static_cast(0), dummyParameters, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // NOTE: use '1' to fool the assert of d_queue_sp in // MockQueueHandle constructor. static_cast( @@ -873,7 +876,8 @@ class TestBench { // Internal-ticket D167598037. // Verify that PutMessageIterator does not change the input. - bmqp::Event rawEvent(eventBlob.get(), s_allocator_p); + bmqp::Event rawEvent(eventBlob.get(), + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(rawEvent.isValid()); BSLS_ASSERT(rawEvent.isPutEvent()); @@ -931,7 +935,8 @@ class TestBench { { ASSERT(d_channel->waitFor(1, false)); // isFinal = false ConstWriteCall& openQueueCall = d_channel->writeCalls()[0]; - bmqp::Event openQueueEvent(&openQueueCall.d_blob, s_allocator_p); + bmqp::Event openQueueEvent(&openQueueCall.d_blob, + bmqtst::TestHelperUtil::allocator()); PVV("Event 1: " << openQueueEvent); ASSERT(openQueueEvent.isControlEvent()); } @@ -967,7 +972,8 @@ class TestBench { ASSERT(d_channel->waitFor(eventIndex + 1, isFinal)); ConstWriteCall& ackCall = d_channel->writeCalls()[eventIndex]; - bmqp::Event ackEvent(&ackCall.d_blob, s_allocator_p); + bmqp::Event ackEvent(&ackCall.d_blob, + bmqtst::TestHelperUtil::allocator()); PVV("Event " << eventIndex + 1 << ": " << ackEvent); ASSERT(ackEvent.isAckEvent()); @@ -1012,7 +1018,7 @@ class TestBench { ASSERT(d_channel->waitFor(last + 1, false)); bmqp::Event pushEvent(&d_channel->writeCalls()[last].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT(pushEvent.isPushEvent()); @@ -1074,14 +1080,15 @@ void test(ClientType clientType, const Spec spec = findSpec(clientType, atMostOnce, putAction, ackRequested, ackSuccess); - const bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + const bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); const int queueId = 4; // A queue number int correlationId = 0; // A correlation id bmqt::MessageGUID guid; // Unset TestBench tb(client(clientType), atMostOnce == e_AtMostOnce, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Send an 'OpenQueue` request. tb.openQueue(uri, queueId); @@ -1168,14 +1175,15 @@ void testInvalidPut(ClientType clientType, const InvalidPutSpec spec = findInvalidPutSpec(clientType, atMostOnce, ackRequested, invalidPut); - const bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + const bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); int queueId = 4; // A queue number int correlationId = 0; // A correlation id bmqt::MessageGUID guid; // Unset TestBench tb(client(clientType), atMostOnce == e_AtMostOnce, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Send an 'OpenQueue` request. tb.openQueue(uri, queueId); @@ -1242,7 +1250,8 @@ void testGuidCollision(ClientType clientType, atMostOnce, ackRequested); - const bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + const bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); const int queueId = 4; // A queue number int correlationId = 0; // A correlation id bmqt::MessageGUID guid1; // Unset @@ -1250,7 +1259,7 @@ void testGuidCollision(ClientType clientType, TestBench tb(client(clientType), atMostOnce == e_AtMostOnce, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Send an 'OpenQueue` request. tb.openQueue(uri, queueId); @@ -1354,14 +1363,15 @@ void testFirstHopUnsetGUID(AtMostOnce atMostOnce, AckRequested ackRequested) << " atMostOnce: " << atMostOnce << " and ackRequested: " << ackRequested); - const bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + const bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); const int correlationId = 0; // A correlation id const int queueId = 4; // A queue number bmqt::MessageGUID guid; // Unset TestBench tb(client(e_FirstHop), atMostOnce == e_AtMostOnce, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Send an 'OpenQueue` request. tb.openQueue(uri, queueId); @@ -1558,7 +1568,8 @@ static void test4_ackRequestedNullCorrelationId() bmqtst::TestHelper::printTestName( "TESTS ACK REQUESTED NULL CORRELATION ID"); - const bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + const bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); const int queueId = 4; // A queue number const int correlationId = 0; // A correlation id const bool isAtMostOnce = false; @@ -1567,7 +1578,7 @@ static void test4_ackRequestedNullCorrelationId() TestBench tb(client(e_FirstHopCorrelationIds), isAtMostOnce, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Send an 'OpenQueue` request. tb.openQueue(uri, queueId); @@ -1622,7 +1633,8 @@ static void test5_ackNotRequestedNotNullCorrelationId() bmqtst::TestHelper::printTestName( "TESTS ACK NOT REQUESTED NOT NULL CORRELATION ID"); - const bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + const bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); const int queueId = 4; // A queue number const int correlationId = 2; // A correlation id const bool isAtMostOnce = false; @@ -1631,7 +1643,7 @@ static void test5_ackNotRequestedNotNullCorrelationId() TestBench tb(client(e_FirstHopCorrelationIds), isAtMostOnce, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Send an 'OpenQueue` request. tb.openQueue(uri, queueId); @@ -1715,14 +1727,17 @@ static void test7_oldStylePut() { bmqtst::TestHelper::printTestName("TESTS CONVERSION FROM OLD STYLE PUT"); - const bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + const bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); const int queueId = 4; // A queue number const int correlationId = 2; // A correlation id const bool isAtMostOnce = false; const bool isAckRequested = false; bmqt::MessageGUID guid; // Unset - TestBench tb(client(e_FirstHop), isAtMostOnce, s_allocator_p); + TestBench tb(client(e_FirstHop), + isAtMostOnce, + bmqtst::TestHelperUtil::allocator()); // Send an 'OpenQueue` request. tb.openQueue(uri, queueId); @@ -1732,7 +1747,7 @@ static void test7_oldStylePut() tb.assertOpenQueueResponse(); // Send PUT. - bmqp::MessageProperties in(s_allocator_p); + bmqp::MessageProperties in(bmqtst::TestHelperUtil::allocator()); encode(&in); tb.sendOldPut(queueId, guid, correlationId, isAckRequested, in); @@ -1745,7 +1760,7 @@ static void test7_oldStylePut() postMessages[0].d_putHeader.flags(), bmqp::PutHeaderFlags::e_MESSAGE_PROPERTIES)); - bmqp::MessageProperties out(s_allocator_p); + bmqp::MessageProperties out(bmqtst::TestHelperUtil::allocator()); const bdlbb::Blob* payloadBlob = postMessages[0].d_appData.get(); const bmqp::MessagePropertiesInfo& logic(postMessages[0].d_putHeader); ASSERT_EQ(0, out.streamIn(*payloadBlob, logic.isExtended())); @@ -1789,14 +1804,17 @@ static void test8_oldStyleCompressedPut() bmqtst::TestHelper::printTestName( "TESTS OLD STYLE COMPRESSED PUT CONVERSION"); - const bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + const bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); const int queueId = 4; // A queue number const int correlationId = 2; // A correlation id const bool isAtMostOnce = false; const bool isAckRequested = false; bmqt::MessageGUID guid; // Unset - TestBench tb(client(e_FirstHop), isAtMostOnce, s_allocator_p); + TestBench tb(client(e_FirstHop), + isAtMostOnce, + bmqtst::TestHelperUtil::allocator()); // Send an 'OpenQueue` request. tb.openQueue(uri, queueId); @@ -1806,7 +1824,7 @@ static void test8_oldStyleCompressedPut() tb.assertOpenQueueResponse(); // Send PUT. - bmqp::MessageProperties in(s_allocator_p); + bmqp::MessageProperties in(bmqtst::TestHelperUtil::allocator()); encode(&in); tb.sendOldPut(queueId, @@ -1827,7 +1845,7 @@ static void test8_oldStyleCompressedPut() ASSERT_EQ(postMessages[0].d_putHeader.compressionAlgorithmType(), bmqt::CompressionAlgorithmType::e_NONE); - bmqp::MessageProperties out(s_allocator_p); + bmqp::MessageProperties out(bmqtst::TestHelperUtil::allocator()); const bdlbb::Blob* payloadBlob = postMessages[0].d_appData.get(); const bmqp::MessagePropertiesInfo& logic(postMessages[0].d_putHeader); @@ -1869,12 +1887,15 @@ static void test9_newStylePush() bmqtst::TestHelper::printTestName( "TESTS OLD STYLE COMPRESSED PUT CONVERSION"); - const bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + const bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); const int queueId = 4; // A queue number const bool isAtMostOnce = false; bmqt::MessageGUID guid = bmqp::MessageGUIDGenerator::testGUID(); - TestBench tb(client(e_FirstHop), isAtMostOnce, s_allocator_p); + TestBench tb(client(e_FirstHop), + isAtMostOnce, + bmqtst::TestHelperUtil::allocator()); // Send an 'OpenQueue` request. tb.openQueue(uri, queueId); @@ -1884,11 +1905,13 @@ static void test9_newStylePush() tb.assertOpenQueueResponse(); // Send PUT. - bmqp::MessageProperties in(s_allocator_p); + bmqp::MessageProperties in(bmqtst::TestHelperUtil::allocator()); encode(&in); - bmqp::PutEventBuilder peb(&tb.d_bufferFactory, s_allocator_p); - bdlbb::Blob payload(&tb.d_bufferFactory, s_allocator_p); + bmqp::PutEventBuilder peb(&tb.d_bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(&tb.d_bufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqp::PutTester::populateBlob(&payload, 99); @@ -1903,18 +1926,21 @@ static void test9_newStylePush() ASSERT_EQ(bmqt::EventBuilderResult::e_SUCCESS, rc); - mqbi::DispatcherEvent putEvent(s_allocator_p); - bmqp::Event rawEvent(&peb.blob(), s_allocator_p); + mqbi::DispatcherEvent putEvent(bmqtst::TestHelperUtil::allocator()); + bmqp::Event rawEvent(&peb.blob(), bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(rawEvent.isValid()); BSLS_ASSERT(rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIt(&tb.d_bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIt(&tb.d_bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIt, false); BSLS_ASSERT(putIt.next()); bsl::shared_ptr blobSp; - blobSp.createInplace(s_allocator_p, &tb.d_bufferFactory, s_allocator_p); + blobSp.createInplace(bmqtst::TestHelperUtil::allocator(), + &tb.d_bufferFactory, + bmqtst::TestHelperUtil::allocator()); *blobSp = peb.blob(); putEvent.setType(mqbi::DispatcherEventType::e_PUT) @@ -1937,7 +1963,7 @@ static void test9_newStylePush() ASSERT_EQ(postMessages[0].d_putHeader.compressionAlgorithmType(), bmqt::CompressionAlgorithmType::e_NONE); - bmqp::MessageProperties out(s_allocator_p); + bmqp::MessageProperties out(bmqtst::TestHelperUtil::allocator()); const bdlbb::Blob* payloadBlob = postMessages[0].d_appData.get(); const bmqp::MessagePropertiesInfo& logic(postMessages[0].d_putHeader); ASSERT_EQ(0, out.streamIn(*payloadBlob, logic.isExtended())); @@ -1976,12 +2002,15 @@ static void test10_newStyleCompressedPush() bmqtst::TestHelper::printTestName( "TESTS OLD STYLE COMPRESSED PUT CONVERSION"); - const bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + const bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); const int queueId = 4; // A queue number const bool isAtMostOnce = false; bmqt::MessageGUID guid = bmqp::MessageGUIDGenerator::testGUID(); - TestBench tb(client(e_FirstHop), isAtMostOnce, s_allocator_p); + TestBench tb(client(e_FirstHop), + isAtMostOnce, + bmqtst::TestHelperUtil::allocator()); // Send an 'OpenQueue` request. tb.openQueue(uri, queueId); @@ -1991,11 +2020,13 @@ static void test10_newStyleCompressedPush() tb.assertOpenQueueResponse(); // Send PUT. - bmqp::MessageProperties in(s_allocator_p); + bmqp::MessageProperties in(bmqtst::TestHelperUtil::allocator()); encode(&in); - bmqp::PutEventBuilder peb(&tb.d_bufferFactory, s_allocator_p); - bdlbb::Blob payload(&tb.d_bufferFactory, s_allocator_p); + bmqp::PutEventBuilder peb(&tb.d_bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob payload(&tb.d_bufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqp::PutTester::populateBlob( &payload, @@ -2011,18 +2042,21 @@ static void test10_newStyleCompressedPush() ASSERT_EQ(bmqt::EventBuilderResult::e_SUCCESS, rc); - mqbi::DispatcherEvent putEvent(s_allocator_p); - bmqp::Event rawEvent(&peb.blob(), s_allocator_p); + mqbi::DispatcherEvent putEvent(bmqtst::TestHelperUtil::allocator()); + bmqp::Event rawEvent(&peb.blob(), bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT(rawEvent.isValid()); BSLS_ASSERT(rawEvent.isPutEvent()); - bmqp::PutMessageIterator putIt(&tb.d_bufferFactory, s_allocator_p); + bmqp::PutMessageIterator putIt(&tb.d_bufferFactory, + bmqtst::TestHelperUtil::allocator()); rawEvent.loadPutMessageIterator(&putIt, false); BSLS_ASSERT(putIt.next()); bsl::shared_ptr blobSp; - blobSp.createInplace(s_allocator_p, &tb.d_bufferFactory, s_allocator_p); + blobSp.createInplace(bmqtst::TestHelperUtil::allocator(), + &tb.d_bufferFactory, + bmqtst::TestHelperUtil::allocator()); *blobSp = peb.blob(); putEvent.setType(mqbi::DispatcherEventType::e_PUT) @@ -2046,7 +2080,7 @@ static void test10_newStyleCompressedPush() ASSERT_EQ(postMessages[0].d_putHeader.compressionAlgorithmType(), bmqt::CompressionAlgorithmType::e_ZLIB); - bmqp::MessageProperties out(s_allocator_p); + bmqp::MessageProperties out(bmqtst::TestHelperUtil::allocator()); const bdlbb::Blob* payloadBlob = postMessages[0].d_appData.get(); const bmqp::MessagePropertiesInfo& logic(postMessages[0].d_putHeader); @@ -2082,7 +2116,8 @@ static void test11_initiateShutdown() { bmqtst::TestHelper::printTestName("TESTS SHUTTING DOWN"); - const bsl::string uri("bmq://my.domain/queue-foo-bar", s_allocator_p); + const bsl::string uri("bmq://my.domain/queue-foo-bar", + bmqtst::TestHelperUtil::allocator()); const int queueId = 4; // A queue number const bool isAtMostOnce = false; @@ -2093,7 +2128,7 @@ static void test11_initiateShutdown() bslmt::TimedSemaphore semaphore; bmqt::MessageGUID guid = bmqp::MessageGUIDGenerator::testGUID(); mqbi::StorageMessageAttributes messageAttributes; - bmqp::Protocol::MsgGroupId msgGroupId(s_allocator_p); + bmqp::Protocol::MsgGroupId msgGroupId(bmqtst::TestHelperUtil::allocator()); const unsigned int subscriptionId = bmqp::Protocol::k_DEFAULT_SUBSCRIPTION_ID; const unsigned int subQueueId = bmqp::QueueId::k_DEFAULT_SUBQUEUE_ID; @@ -2101,12 +2136,14 @@ static void test11_initiateShutdown() bmqp::Protocol::SubQueueInfosArray subQueueInfos( 1, bmqp::SubQueueInfo(subscriptionId), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr blob; PV("Shutdown without unconfirmed messages"); { - TestBench tb(client(e_FirstHop), isAtMostOnce, s_allocator_p); + TestBench tb(client(e_FirstHop), + isAtMostOnce, + bmqtst::TestHelperUtil::allocator()); bsls::AtomicInt callbackCounter(0); // Send an 'OpenQueue` request. @@ -2139,7 +2176,9 @@ static void test11_initiateShutdown() PV("Shutdown with unconfirmed messages and timeout"); { - TestBench tb(client(e_FirstHop), isAtMostOnce, s_allocator_p); + TestBench tb(client(e_FirstHop), + isAtMostOnce, + bmqtst::TestHelperUtil::allocator()); bsls::AtomicInt callbackCounter(0); // Send an 'OpenQueue` request. @@ -2194,7 +2233,9 @@ static void test11_initiateShutdown() PV("Confirm a messsage while shutting down"); { - TestBench tb(client(e_FirstHop), isAtMostOnce, s_allocator_p); + TestBench tb(client(e_FirstHop), + isAtMostOnce, + bmqtst::TestHelperUtil::allocator()); bsls::AtomicInt callbackCounter(0); // Send an 'OpenQueue` request. @@ -2256,9 +2297,12 @@ static void test11_initiateShutdown() PV("Confirm multiple messsages while shutting down"); { const int NUM_MESSAGES = 5; - TestBench tb(client(e_FirstHop), isAtMostOnce, s_allocator_p); + TestBench tb(client(e_FirstHop), + isAtMostOnce, + bmqtst::TestHelperUtil::allocator()); bsls::AtomicInt callbackCounter(0); - bsl::vector guids(s_allocator_p); + bsl::vector guids( + bmqtst::TestHelperUtil::allocator()); guids.reserve(NUM_MESSAGES); // Send an 'OpenQueue` request. @@ -2578,21 +2622,23 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); bmqp::Crc32c::initialize(); { - bmqp::ProtocolUtil::initialize(s_allocator_p); - bmqsys::Time::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); + bmqsys::Time::initialize(bmqtst::TestHelperUtil::allocator()); - mqbcfg::AppConfig brokerConfig(s_allocator_p); + mqbcfg::AppConfig brokerConfig(bmqtst::TestHelperUtil::allocator()); brokerConfig.brokerVersion() = 999999; // required for test case 8 // to convert msg properties // from v1 to v2 mqbcfg::BrokerConfig::set(brokerConfig); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); mqbu::MessageGUIDUtil::initialize(); @@ -2614,7 +2660,7 @@ int main(int argc, char* argv[]) case -3: testN3_guidCollisionConfiguration(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqba/mqba_dispatcher.t.cpp b/src/groups/mqb/mqba/mqba_dispatcher.t.cpp index bc0280b97..35493c6fe 100644 --- a/src/groups/mqb/mqba/mqba_dispatcher.t.cpp +++ b/src/groups/mqb/mqba/mqba_dispatcher.t.cpp @@ -114,11 +114,13 @@ static void test1_breathingTest() dispatcherConfig.clusters().numProcessors() = 1; bdlmt::EventScheduler eventScheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); eventScheduler.start(); { - mqba::Dispatcher obj(dispatcherConfig, &eventScheduler, s_allocator_p); + mqba::Dispatcher obj(dispatcherConfig, + &eventScheduler, + bmqtst::TestHelperUtil::allocator()); } eventScheduler.stop(); @@ -184,7 +186,7 @@ static void test3_executorsSupport() // create / start a scheduler bdlmt::EventScheduler eventScheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); int rc = eventScheduler.start(); BSLS_ASSERT_OPT(rc == 0); @@ -212,23 +214,23 @@ static void test3_executorsSupport() mqba::Dispatcher dispatcher(dispatcherConfig, &eventScheduler, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // start the dispatcher - bsl::stringstream startErr(s_allocator_p); + bsl::stringstream startErr(bmqtst::TestHelperUtil::allocator()); rc = dispatcher.start(startErr); ASSERT(rc == 0); // register first client (of type 'e_SESSION') - mqbmock::DispatcherClient client1(s_allocator_p); + mqbmock::DispatcherClient client1(bmqtst::TestHelperUtil::allocator()); dispatcher.registerClient(&client1, mqbi::DispatcherClientType::e_SESSION); // register second client (of type 'e_SESSION') - mqbmock::DispatcherClient client2(s_allocator_p); + mqbmock::DispatcherClient client2(bmqtst::TestHelperUtil::allocator()); dispatcher.registerClient(&client2, mqbi::DispatcherClientType::e_SESSION); // register third client (of type 'e_QUEUE') - mqbmock::DispatcherClient client3(s_allocator_p); + mqbmock::DispatcherClient client3(bmqtst::TestHelperUtil::allocator()); dispatcher.registerClient(&client3, mqbi::DispatcherClientType::e_QUEUE); // test regular executor @@ -275,20 +277,20 @@ static void test3_executorsSupport() // submit two functors to be executed on the same processor using the // executor's 'post' function, and wait for the completion of submitted // functors - bmqex::ExecutionUtil::execute(bmqex::ExecutionPolicyUtil::twoWay() - .neverBlocking() - .useExecutor(executor1) - .useAllocator(s_allocator_p), - bdlf::BindUtil::bind(LoadSelfThreadId(), - &threadId1)) + bmqex::ExecutionUtil::execute( + bmqex::ExecutionPolicyUtil::twoWay() + .neverBlocking() + .useExecutor(executor1) + .useAllocator(bmqtst::TestHelperUtil::allocator()), + bdlf::BindUtil::bind(LoadSelfThreadId(), &threadId1)) .wait(); - bmqex::ExecutionUtil::execute(bmqex::ExecutionPolicyUtil::twoWay() - .neverBlocking() - .useExecutor(executor1) - .useAllocator(s_allocator_p), - bdlf::BindUtil::bind(LoadSelfThreadId(), - &threadId2)) + bmqex::ExecutionUtil::execute( + bmqex::ExecutionPolicyUtil::twoWay() + .neverBlocking() + .useExecutor(executor1) + .useAllocator(bmqtst::TestHelperUtil::allocator()), + bdlf::BindUtil::bind(LoadSelfThreadId(), &threadId2)) .wait(); // both functors were invoked in the same thread that is not this @@ -312,20 +314,20 @@ static void test3_executorsSupport() // submit two functors to be executed on the same processor using the // executor's 'dispatch' function, and wait for the completion of // submitted functors - bmqex::ExecutionUtil::execute(bmqex::ExecutionPolicyUtil::twoWay() - .possiblyBlocking() - .useExecutor(executor2) - .useAllocator(s_allocator_p), - bdlf::BindUtil::bind(LoadSelfThreadId(), - &threadId1)) + bmqex::ExecutionUtil::execute( + bmqex::ExecutionPolicyUtil::twoWay() + .possiblyBlocking() + .useExecutor(executor2) + .useAllocator(bmqtst::TestHelperUtil::allocator()), + bdlf::BindUtil::bind(LoadSelfThreadId(), &threadId1)) .wait(); - bmqex::ExecutionUtil::execute(bmqex::ExecutionPolicyUtil::twoWay() - .possiblyBlocking() - .useExecutor(executor2) - .useAllocator(s_allocator_p), - bdlf::BindUtil::bind(LoadSelfThreadId(), - &threadId2)) + bmqex::ExecutionUtil::execute( + bmqex::ExecutionPolicyUtil::twoWay() + .possiblyBlocking() + .useExecutor(executor2) + .useAllocator(bmqtst::TestHelperUtil::allocator()), + bdlf::BindUtil::bind(LoadSelfThreadId(), &threadId2)) .wait(); // both functors were invoked in the same thread that is not this @@ -344,12 +346,12 @@ static void test3_executorsSupport() bmqex::ExecutionPolicyUtil::oneWay() .alwaysBlocking() .useExecutor(executor1) - .useAllocator(s_allocator_p), + .useAllocator(bmqtst::TestHelperUtil::allocator()), bmqex::BindUtil::bindExecute( bmqex::ExecutionPolicyUtil::oneWay() .alwaysBlocking() .useExecutor(executor3) - .useAllocator(s_allocator_p), + .useAllocator(bmqtst::TestHelperUtil::allocator()), bdlf::BindUtil::bind(LoadSelfThreadId(), &threadId1))); // the nested functor was invoked in-place (we know that because @@ -398,20 +400,20 @@ static void test3_executorsSupport() // submit two functors to be executed on the same processor and by the // same client using the executor's 'post' function, and wait for the // completion of submitted functors - bmqex::ExecutionUtil::execute(bmqex::ExecutionPolicyUtil::twoWay() - .neverBlocking() - .useExecutor(executor1) - .useAllocator(s_allocator_p), - bdlf::BindUtil::bind(LoadSelfThreadId(), - &threadId1)) + bmqex::ExecutionUtil::execute( + bmqex::ExecutionPolicyUtil::twoWay() + .neverBlocking() + .useExecutor(executor1) + .useAllocator(bmqtst::TestHelperUtil::allocator()), + bdlf::BindUtil::bind(LoadSelfThreadId(), &threadId1)) .wait(); - bmqex::ExecutionUtil::execute(bmqex::ExecutionPolicyUtil::twoWay() - .neverBlocking() - .useExecutor(executor1) - .useAllocator(s_allocator_p), - bdlf::BindUtil::bind(LoadSelfThreadId(), - &threadId2)) + bmqex::ExecutionUtil::execute( + bmqex::ExecutionPolicyUtil::twoWay() + .neverBlocking() + .useExecutor(executor1) + .useAllocator(bmqtst::TestHelperUtil::allocator()), + bdlf::BindUtil::bind(LoadSelfThreadId(), &threadId2)) .wait(); // both functors were invoked in the same thread that is not this @@ -435,20 +437,20 @@ static void test3_executorsSupport() // submit two functors to be executed on the same processor and by the // same client using the executor's 'dispatch' function, and wait for // the completion of submitted functors - bmqex::ExecutionUtil::execute(bmqex::ExecutionPolicyUtil::twoWay() - .possiblyBlocking() - .useExecutor(executor2) - .useAllocator(s_allocator_p), - bdlf::BindUtil::bind(LoadSelfThreadId(), - &threadId1)) + bmqex::ExecutionUtil::execute( + bmqex::ExecutionPolicyUtil::twoWay() + .possiblyBlocking() + .useExecutor(executor2) + .useAllocator(bmqtst::TestHelperUtil::allocator()), + bdlf::BindUtil::bind(LoadSelfThreadId(), &threadId1)) .wait(); - bmqex::ExecutionUtil::execute(bmqex::ExecutionPolicyUtil::twoWay() - .possiblyBlocking() - .useExecutor(executor2) - .useAllocator(s_allocator_p), - bdlf::BindUtil::bind(LoadSelfThreadId(), - &threadId2)) + bmqex::ExecutionUtil::execute( + bmqex::ExecutionPolicyUtil::twoWay() + .possiblyBlocking() + .useExecutor(executor2) + .useAllocator(bmqtst::TestHelperUtil::allocator()), + bdlf::BindUtil::bind(LoadSelfThreadId(), &threadId2)) .wait(); // both functors were invoked in the same thread that is not this @@ -463,12 +465,12 @@ static void test3_executorsSupport() bmqex::ExecutionPolicyUtil::oneWay() .alwaysBlocking() .useExecutor(executor1) - .useAllocator(s_allocator_p), + .useAllocator(bmqtst::TestHelperUtil::allocator()), bmqex::BindUtil::bindExecute( bmqex::ExecutionPolicyUtil::oneWay() .alwaysBlocking() .useExecutor(executor2) - .useAllocator(s_allocator_p), + .useAllocator(bmqtst::TestHelperUtil::allocator()), bdlf::BindUtil::bind(LoadSelfThreadId(), &threadId1))); // the nested functor was invoked in-place (we know that because @@ -500,7 +502,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqba/mqba_domainresolver.h b/src/groups/mqb/mqba/mqba_domainresolver.h index 7fd0c5364..cb2ce0c2e 100644 --- a/src/groups/mqb/mqba/mqba_domainresolver.h +++ b/src/groups/mqb/mqba/mqba_domainresolver.h @@ -114,10 +114,6 @@ class DomainResolver { mqbconfm::DomainResolver d_data; // Cached response data. - bdlt::Datetime d_scriptTimestamp; - // Last modification timestamp of the script - // at the time this data was generated. - bdlt::Datetime d_cfgDirTimestamp; // Last modification timestamp of the config // directory at the time this data was diff --git a/src/groups/mqb/mqbblp/mqbblp_clusterstatemonitor.t.cpp b/src/groups/mqb/mqbblp/mqbblp_clusterstatemonitor.t.cpp index 085999e84..03c143ab7 100644 --- a/src/groups/mqb/mqbblp/mqbblp_clusterstatemonitor.t.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_clusterstatemonitor.t.cpp @@ -134,12 +134,13 @@ struct TestHelper { // CREATORS TestHelper() - : d_bufferFactory(1024, s_allocator_p) + : d_bufferFactory(1024, bmqtst::TestHelperUtil::allocator()) , d_cluster_mp(0) - , d_nodes(s_allocator_p) - , d_tempDir(s_allocator_p) + , d_nodes(bmqtst::TestHelperUtil::allocator()) + , d_tempDir(bmqtst::TestHelperUtil::allocator()) { - mqbmock::Cluster::ClusterNodeDefs clusterNodeDefs(s_allocator_p); + mqbmock::Cluster::ClusterNodeDefs clusterNodeDefs( + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, @@ -147,47 +148,48 @@ struct TestHelper { "US-EAST", 41234, mqbmock::Cluster::k_LEADER_NODE_ID, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "testNode2", "US-EAST", 41235, mqbmock::Cluster::k_LEADER_NODE_ID + 1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "testNode3", "US-WEST", 41236, mqbmock::Cluster::k_LEADER_NODE_ID + 2, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "testNode4", "US-WEST", 41237, mqbmock::Cluster::k_LEADER_NODE_ID + 3, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "testNode5", "US-WEST", 41238, mqbmock::Cluster::k_LEADER_NODE_ID + 4, - s_allocator_p); - - d_cluster_mp.load(new (*s_allocator_p) - mqbmock::Cluster(&d_bufferFactory, - s_allocator_p, - true, // isClusterMember - false, // isLeader - false, // isCSLMode - false, // isFSMWorkflow - clusterNodeDefs, - "testCluster", - d_tempDir.path()), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + + d_cluster_mp.load( + new (*bmqtst::TestHelperUtil::allocator()) + mqbmock::Cluster(&d_bufferFactory, + bmqtst::TestHelperUtil::allocator(), + true, // isClusterMember + false, // isLeader + false, // isCSLMode + false, // isFSMWorkflow + clusterNodeDefs, + "testCluster", + d_tempDir.path()), + bmqtst::TestHelperUtil::allocator()); bmqsys::Time::initialize( bdlf::BindUtil::bind(&mqbmock::Cluster::getTime, @@ -273,8 +275,8 @@ static void test1_breathingTest() bmqtst::TestHelper::printTestName("BREATHING TEST"); bmqtst::ScopedLogObserver logObserver(ball::Severity::ERROR, - s_allocator_p); - NotificationEvaluator notifications(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + NotificationEvaluator notifications(bmqtst::TestHelperUtil::allocator()); TestHelper helper; @@ -288,7 +290,7 @@ static void test1_breathingTest() mqbblp::ClusterStateMonitor monitor(helper.d_cluster_mp->_clusterData(), &helper.d_cluster_mp->_state(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); monitor.registerObserver(¬ifications); bmqu::MemOutStream dummy; @@ -336,8 +338,8 @@ static void test2_checkAlarmsWithResetTest() bmqtst::TestHelper::printTestName("CHECK ALARMS WITH RESET"); bmqtst::ScopedLogObserver logObserver(ball::Severity::ERROR, - s_allocator_p); - NotificationEvaluator notifications(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + NotificationEvaluator notifications(bmqtst::TestHelperUtil::allocator()); TestHelper helper; @@ -354,7 +356,7 @@ static void test2_checkAlarmsWithResetTest() mqbblp::ClusterStateMonitor monitor(helper.d_cluster_mp->_clusterData(), &helper.d_cluster_mp->_state(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); monitor.registerObserver(¬ifications); bmqu::MemOutStream dummy; @@ -555,8 +557,8 @@ static void test3_alwaysInvalidStateTest() bmqtst::TestHelper::printTestName("ALWAYS INVALID STATE"); bmqtst::ScopedLogObserver logObserver(ball::Severity::ERROR, - s_allocator_p); - NotificationEvaluator notifications(s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + NotificationEvaluator notifications(bmqtst::TestHelperUtil::allocator()); TestHelper helper; @@ -580,7 +582,7 @@ static void test3_alwaysInvalidStateTest() mqbblp::ClusterStateMonitor monitor(helper.d_cluster_mp->_clusterData(), &helper.d_cluster_mp->_state(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); monitor.registerObserver(¬ifications); bmqu::MemOutStream dummy; @@ -712,13 +714,15 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); { - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); - mqbcfg::AppConfig brokerConfig(s_allocator_p); + mqbcfg::AppConfig brokerConfig(bmqtst::TestHelperUtil::allocator()); mqbcfg::BrokerConfig::set(brokerConfig); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -727,7 +731,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbblp/mqbblp_localqueue.cpp b/src/groups/mqb/mqbblp/mqbblp_localqueue.cpp index fbb74f790..1c6bb7835 100644 --- a/src/groups/mqb/mqbblp/mqbblp_localqueue.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_localqueue.cpp @@ -66,7 +66,6 @@ LocalQueue::LocalQueue(QueueState* state, bslma::Allocator* allocator) , d_state_p(state) , d_queueEngine_mp(0) , d_throttledFailedPutMessages(5000, 1) // 1 log per 5s interval -, d_hasNewMessages(false) , d_throttledDuplicateMessages() , d_haveStrongConsistency(false) { @@ -140,6 +139,7 @@ int LocalQueue::configure(bsl::ostream& errorDescription, bool isReconfigure) d_state_p->setStorage(storageMp); } else { + d_state_p->storage()->setConsistency(domainCfg.consistency()); rc = d_state_p->storage()->configure(errorDescription, domainCfg.storage().config(), domainCfg.storage().queueLimits(), @@ -284,7 +284,7 @@ void LocalQueue::configureHandle( // to it. We need to make sure that storage/replication is in sync, and // thus, we force-flush the file store. - d_state_p->storage()->dispatcherFlush(true, false); + d_state_p->storage()->flushStorage(); // Attempt to deliver all data in the storage. Otherwise, broadcast // can get dropped if the incoming configure request removes consumers. @@ -306,7 +306,7 @@ void LocalQueue::releaseHandle( BSLS_ASSERT_SAFE(d_state_p->queue()->dispatcher()->inDispatcherThread( d_state_p->queue())); - d_state_p->storage()->dispatcherFlush(true, false); + d_state_p->storage()->flushStorage(); d_queueEngine_mp->releaseHandle(handle, handleParameters, @@ -375,8 +375,8 @@ void LocalQueue::flush() // until it gets rolled back. If 'flush' gets called in between, the queue // may have no storage. if (d_state_p->storage()) { - d_state_p->storage()->dispatcherFlush(true, false); - // See notes in 'FileStore::dispatcherFlush' for motivation behind + d_state_p->storage()->flushStorage(); + // See notes in 'FileStore::flushStorage' for motivation behind // this flush. } @@ -502,8 +502,7 @@ void LocalQueue::postMessage(const bmqp::PutHeader& putHeader, if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY(res == mqbi::StorageResult::e_SUCCESS)) { // Message has been saved in the storage, but we don't indicate the - // engine yet of the new message, instead we just update the - // 'd_hasNewMessages' flag. This is because storage (replicated) + // engine yet of the new message. This is because storage (replicated) // messages are nagled, and we don't want to indicate to a peer to // deliver a particular guid downstream, before actually replicating // that message. So notification to deliver a particular guid @@ -514,10 +513,6 @@ void LocalQueue::postMessage(const bmqp::PutHeader& putHeader, d_state_p->stats()->onEvent( mqbstat::QueueStatsDomain::EventType::e_PUT, appData->length()); - - if (haveReceipt && refCount) { - d_hasNewMessages = true; - } } else { BSLS_PERFORMANCEHINT_UNLIKELY_HINT; @@ -536,10 +531,6 @@ void LocalQueue::postMessage(const bmqp::PutHeader& putHeader, 1); } } - - // If 'FileStore::d_storageEventBuilder' is flushed, flush all relevant - // queues (call 'afterNewMessage' to deliver accumulated data) - d_state_p->storage()->dispatcherFlush(false, true); } void LocalQueue::onPushMessage( @@ -573,8 +564,6 @@ void LocalQueue::onReceipt(const bmqt::MessageGUID& msgGUID, // filled downstream. qH->onAckMessage(ackMessage); } // else the handle is gone - - d_hasNewMessages = true; } void LocalQueue::onRemoval(const bmqt::MessageGUID& msgGUID, @@ -602,12 +591,8 @@ void LocalQueue::deliverIfNeeded() { // Now that storage messages have been flushed, notify the engine (and thus // any peer or downstream client) to deliver next applicable message. - - if (d_hasNewMessages) { - d_hasNewMessages = false; - d_queueEngine_mp->afterNewMessage(bmqt::MessageGUID(), - static_cast(0)); - } + d_queueEngine_mp->afterNewMessage(bmqt::MessageGUID(), + static_cast(0)); } void LocalQueue::confirmMessage(const bmqt::MessageGUID& msgGUID, diff --git a/src/groups/mqb/mqbblp/mqbblp_localqueue.h b/src/groups/mqb/mqbblp/mqbblp_localqueue.h index 21bb29447..ecb23bb32 100644 --- a/src/groups/mqb/mqbblp/mqbblp_localqueue.h +++ b/src/groups/mqb/mqbblp/mqbblp_localqueue.h @@ -85,7 +85,6 @@ class LocalQueue BSLS_CPP11_FINAL { QueueState* d_state_p; bslma::ManagedPtr d_queueEngine_mp; bmqu::ThrottledActionParams d_throttledFailedPutMessages; - bool d_hasNewMessages; bdlmt::Throttle d_throttledDuplicateMessages; // Throttler for duplicates. bool d_haveStrongConsistency; diff --git a/src/groups/mqb/mqbblp/mqbblp_messagegroupidmanager.t.cpp b/src/groups/mqb/mqbblp/mqbblp_messagegroupidmanager.t.cpp index 30aedf449..c9dc36502 100644 --- a/src/groups/mqb/mqbblp/mqbblp_messagegroupidmanager.t.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_messagegroupidmanager.t.cpp @@ -71,9 +71,9 @@ Handle _(const int handle) MsgGroupId msgGroupIdFromInt(const int id) { - bmqu::MemOutStream ss(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); ss << id; - return MsgGroupId(ss.str(), s_allocator_p); + return MsgGroupId(ss.str(), bmqtst::TestHelperUtil::allocator()); } void addHandles(MessageGroupIdManager* obj, const int handles = 1000) @@ -97,7 +97,8 @@ void allocateSomeGroups(MessageGroupIdManager* obj, BSLS_ASSERT_SAFE((groups % handles) == 0); // Add a few handles - bsl::vector handlesBefore(handles, s_allocator_p); + bsl::vector handlesBefore(handles, + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < groups; ++i) { const Handle h = obj->getHandle(msgGroupIdFromInt(i), k_T0); if (i < handles) { @@ -112,7 +113,7 @@ void allocateSomeGroups(MessageGroupIdManager* obj, // We expect 'groups' equally assigned to 'handles' handles. const int groupsPerHandle = groups / handles; for (int i = 0; i < handles; ++i) { - IdsForHandle gids(s_allocator_p); + IdsForHandle gids(bmqtst::TestHelperUtil::allocator()); obj->idsForHandle(&gids, _(i)); ASSERT_EQ(static_cast(gids.size()), groupsPerHandle); for (IdsForHandle::const_iterator j = gids.begin(); j != gids.end(); @@ -209,7 +210,7 @@ static void test1_sameGroupIdSameHandleTest() MessageGroupIdManager obj(k_TIMEOUT, k_MAX_NUMBER_OF_MAPPINGS, MessageGroupIdManager::k_REBALANCE_OFF, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); const int k_NUMBER_OF_HANDLES = 5; addHandles(&obj, k_NUMBER_OF_HANDLES); @@ -245,7 +246,7 @@ static void test2_differentGroupIdsHaveDifferentHandlesTest() MessageGroupIdManager obj(k_TIMEOUT, k_MAX_NUMBER_OF_MAPPINGS, MessageGroupIdManager::k_REBALANCE_OFF, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); addHandles(&obj); const Handle h1 = obj.getHandle(*k_GID1, k_T0); @@ -276,7 +277,7 @@ static void test3_timeoutOldMappingsTest() MessageGroupIdManager obj(k_TIMEOUT, k_MAX_NUMBER_OF_MAPPINGS, MessageGroupIdManager::k_REBALANCE_OFF, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); addHandles(&obj); const Handle h1 = obj.getHandle(*k_GID1, k_T0); @@ -311,7 +312,7 @@ static void test4_groupIdExpiresAfterTtlTest() MessageGroupIdManager obj(k_TIMEOUT, k_MAX_NUMBER_OF_MAPPINGS, MessageGroupIdManager::k_REBALANCE_OFF, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); addHandles(&obj); const Handle h1 = obj.getHandle(*k_GID1, k_T0); @@ -352,7 +353,7 @@ static void test5_longLivedMoreThanMaxGroupsGcTest() MessageGroupIdManager obj(k_TIMEOUT, k_MY_MAX_NUMBER_OF_MAPPINGS, MessageGroupIdManager::k_REBALANCE_ON, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); addHandles(&obj); const Handle h1 = obj.getHandle(*k_GID1, k_T0 + 1); @@ -392,7 +393,7 @@ static void test6_shortLivedMoreThanMaxGroupsGcTest() MessageGroupIdManager obj(k_TIMEOUT, k_MY_MAX_NUMBER_OF_MAPPINGS, MessageGroupIdManager::k_REBALANCE_OFF, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); addHandles(&obj); const Handle h1 = obj.getHandle(*k_GID1, k_T0); @@ -443,7 +444,7 @@ static void test7_retrievesGroupIdsFromHandlesTest() MessageGroupIdManager obj(k_TIMEOUT, k_MAX_NUMBER_OF_MAPPINGS, MessageGroupIdManager::k_REBALANCE_ON, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); const int JUST_FEW = 2; addHandles(&obj, JUST_FEW); @@ -457,7 +458,8 @@ static void test7_retrievesGroupIdsFromHandlesTest() ASSERT_NE(h1, h2); // Confirm the handle view is as expected - MessageGroupIdManager::IdsForHandle gids(s_allocator_p); + MessageGroupIdManager::IdsForHandle gids( + bmqtst::TestHelperUtil::allocator()); obj.idsForHandle(&gids, h1); ASSERT_EQ(gids.size(), 2u); @@ -512,14 +514,15 @@ static void test8_rebalanceWhenAddingHandleTest() MessageGroupIdManager obj(k_TIMEOUT, k_MAX_NUMBER_OF_MAPPINGS, MessageGroupIdManager::k_REBALANCE_ON, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); addHandles(&obj, k_HANDLES_LIMIT_BEFORE); allocateSomeGroups(&obj, k_HANDLES_LIMIT_BEFORE, k_MSG_GROUP_IDS_COUNT); BSLS_ASSERT_SAFE((k_MSG_GROUP_IDS_COUNT % k_HANDLES_LIMIT_AFTER) == 0); - bsl::vector before(k_HANDLES_LIMIT_BEFORE, s_allocator_p); + bsl::vector before(k_HANDLES_LIMIT_BEFORE, + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < k_HANDLES_LIMIT_BEFORE; ++i) { obj.idsForHandle(&before[i], _(i)); } @@ -531,7 +534,8 @@ static void test8_rebalanceWhenAddingHandleTest() const unsigned k_GROUPS_PER_HANDLE_AFTER = k_MSG_GROUP_IDS_COUNT / k_HANDLES_LIMIT_AFTER; - bsl::vector after(k_HANDLES_LIMIT_AFTER, s_allocator_p); + bsl::vector after(k_HANDLES_LIMIT_AFTER, + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < k_HANDLES_LIMIT_AFTER; ++i) { obj.idsForHandle(&after[i], _(i)); @@ -543,7 +547,8 @@ static void test8_rebalanceWhenAddingHandleTest() for (int i = 0; i < k_HANDLES_LIMIT_BEFORE; ++i) { typedef bsl::vector IntersectionType; - IntersectionType intersection(k_MSG_GROUP_IDS_COUNT, s_allocator_p); + IntersectionType intersection(k_MSG_GROUP_IDS_COUNT, + bmqtst::TestHelperUtil::allocator()); const IntersectionType::const_iterator end = bsl::set_intersection( before[i].begin(), before[i].end(), @@ -593,11 +598,12 @@ static void test9_noRebalanceWhenRemovingHandleTest() k_MAX_NUMBER_OF_MAPPINGS, (rebalanceMode == 0 ? MessageGroupIdManager::k_REBALANCE_OFF : MessageGroupIdManager::k_REBALANCE_ON), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); addHandles(&obj, HANDLES_LIMIT_BEFORE); allocateSomeGroups(&obj, HANDLES_LIMIT_BEFORE, MSG_GROUP_IDS_COUNT); - bsl::vector before(HANDLES_LIMIT_BEFORE, s_allocator_p); + bsl::vector before(HANDLES_LIMIT_BEFORE, + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < HANDLES_LIMIT_BEFORE; ++i) { obj.idsForHandle(&before[i], _(i)); } @@ -608,7 +614,8 @@ static void test9_noRebalanceWhenRemovingHandleTest() // Message Group Ids should remain the same as before with the // exception of the removed handle - bsl::vector after(HANDLES_LIMIT_BEFORE, s_allocator_p); + bsl::vector after(HANDLES_LIMIT_BEFORE, + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < HANDLES_LIMIT_BEFORE; ++i) { obj.idsForHandle(&after[i], _(i)); if (i == toRemove) { @@ -650,7 +657,7 @@ static void test10_chooseLeastUsedHandleAfterRemoveTest() k_MAX_NUMBER_OF_MAPPINGS, (rebalanceMode == 0 ? MessageGroupIdManager::k_REBALANCE_OFF : MessageGroupIdManager::k_REBALANCE_ON), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); obj.addHandle(_(1), k_T0); obj.addHandle(_(2), k_T0); @@ -707,7 +714,7 @@ static void test11_stronglyUnbalancedChainOnRebalanceTest() MessageGroupIdManager obj(k_TIMEOUT, k_MAX_NUMBER_OF_MAPPINGS, MessageGroupIdManager::k_REBALANCE_ON, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Add handles for (int i = 0; i < HANDLES_COUNT; ++i) { @@ -738,7 +745,7 @@ static void test11_stronglyUnbalancedChainOnRebalanceTest() // h0 h1 h2 obj.getHandle(msgGroupIdFromInt(0), k_T0 + k_TIMEOUT); - IdsForHandle gids(s_allocator_p); + IdsForHandle gids(bmqtst::TestHelperUtil::allocator()); obj.idsForHandle(&gids, _(0)); ASSERT_EQ(GROUP_IDS_PER_HANDLE, static_cast(gids.size())); ASSERT_EQ(GROUP_IDS_PER_HANDLE, obj.msgGroupIdsCount()); @@ -770,23 +777,30 @@ static void test12_printerTest() MessageGroupIdManager obj(k_TIMEOUT, k_MAX_NUMBER_OF_MAPPINGS, MessageGroupIdManager::k_REBALANCE_ON, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); typedef bsl::shared_ptr QueuePtr; - QueuePtr queue(new (*s_allocator_p) mqbmock::Queue(0, s_allocator_p), - s_allocator_p); + QueuePtr queue(new (*bmqtst::TestHelperUtil::allocator()) + mqbmock::Queue(0, bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); // Add handles MyDispatcherClient dc1("1"), dc2("2"), dc3("3"); bsl::shared_ptr context1( - new (*s_allocator_p) mqbi::QueueHandleRequesterContext(s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + mqbi::QueueHandleRequesterContext( + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr context2( - new (*s_allocator_p) mqbi::QueueHandleRequesterContext(s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + mqbi::QueueHandleRequesterContext( + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr context3( - new (*s_allocator_p) mqbi::QueueHandleRequesterContext(s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + mqbi::QueueHandleRequesterContext( + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); context1->setClient(&dc1); context2->setClient(&dc2); context3->setClient(&dc3); @@ -813,8 +827,8 @@ static void test12_printerTest() // Dump internals const Time k_at = k_T0 + 5; - bmqu::MemOutStream ss(s_allocator_p); - mqbcmd::Result result(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); + mqbcmd::Result result(bmqtst::TestHelperUtil::allocator()); obj.loadInternals(&result.makeMessageGroupIdHelper(), k_at); mqbcmd::HumanPrinter::print(ss, result, 1); @@ -870,14 +884,16 @@ static void test13_largeMessageGroupIdsUseAllocator() k_MAX_NUMBER_OF_MAPPINGS, (rebalanceMode == 0 ? MessageGroupIdManager::k_REBALANCE_OFF : MessageGroupIdManager::k_REBALANCE_ON), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); addHandles(&obj, 3); for (int i = 0; i < 10; ++i) { - bmqu::MemOutStream ss(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); ss << "01234567890123456789012345678901234567890123456789" << i; - (void)obj.getHandle(bsl::string(ss.str(), s_allocator_p), k_T0); + (void)obj.getHandle( + bsl::string(ss.str(), bmqtst::TestHelperUtil::allocator()), + k_T0); } // Remove a handle @@ -894,12 +910,12 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); - const MsgGroupId gid1("1", s_allocator_p); - const MsgGroupId gid2("2", s_allocator_p); - const MsgGroupId gid3("3", s_allocator_p); - const MsgGroupId gid4("4", s_allocator_p); + const MsgGroupId gid1("1", bmqtst::TestHelperUtil::allocator()); + const MsgGroupId gid2("2", bmqtst::TestHelperUtil::allocator()); + const MsgGroupId gid3("3", bmqtst::TestHelperUtil::allocator()); + const MsgGroupId gid4("4", bmqtst::TestHelperUtil::allocator()); k_GID1 = &gid1; k_GID2 = &gid2; @@ -923,7 +939,7 @@ int main(int argc, char* argv[]) case 1: test1_sameGroupIdSameHandleTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbblp/mqbblp_pushstream.cpp b/src/groups/mqb/mqbblp/mqbblp_pushstream.cpp index 37265b7ba..e7f79048d 100644 --- a/src/groups/mqb/mqbblp/mqbblp_pushstream.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_pushstream.cpp @@ -130,9 +130,8 @@ void PushStreamIterator::removeCurrentElement() d_currentElement = d_currentElement->next(); ++d_currentOrdinal; - d_owner_p->remove(del); - d_owner_p->destroy(del, true); - // doKeepGuid because of the d_iterator + d_owner_p->remove(del, false); + // cannot erase the GUID because of the d_iterator if (d_iterator->second.numElements() == 0) { BSLS_ASSERT_SAFE(d_currentElement == 0); @@ -291,9 +290,8 @@ bool VirtualPushStreamIterator::advance() d_currentElement = d_currentElement->nextInApp(); - d_owner_p->remove(del); - d_owner_p->destroy(del, false); - // do not keep Guid + d_owner_p->remove(del, true); + // can erase GUID if (atEnd()) { return false; diff --git a/src/groups/mqb/mqbblp/mqbblp_pushstream.h b/src/groups/mqb/mqbblp/mqbblp_pushstream.h index 9fc594b1e..4a39a99f0 100644 --- a/src/groups/mqb/mqbblp/mqbblp_pushstream.h +++ b/src/groups/mqb/mqbblp/mqbblp_pushstream.h @@ -194,9 +194,11 @@ struct PushStream { void add(Element* element); /// Remove the specified `element` from both GUID and App corresponding to - /// the `element` (and specified when constructing the `element`). - /// Return the number of remaining Elements in the corresponding GUID. - unsigned int remove(Element* element); + /// the `element` (and specified when constructing the `element`). If + /// there are no more elements in the App, erase the App. If the specified + /// `canEraseGuid` is `true` and there are no more elements in the GUID, + /// erase the GUID. + void remove(Element* element, bool canEraseGuid); /// Remove all PushStream Elements corresponding to the specified /// `upstreamSubQueueId`. Erase each corresponding GUIDs from the @@ -218,9 +220,6 @@ struct PushStream { Element* create(const bmqp::SubQueueInfo& info, const iterator& iterator, const Apps::iterator& iteratorApp); - - /// Destroy the specified `element` - void destroy(Element* element, bool doKeepGuid); }; // ======================== @@ -605,6 +604,7 @@ inline void PushStream::App::add(Element* element) { d_elements.add(element, e_APP); } + inline void PushStream::App::remove(Element* element) { d_elements.remove(element, e_APP); @@ -631,19 +631,6 @@ PushStream::create(const bmqp::SubQueueInfo& subscription, return element; } -inline void PushStream::destroy(Element* element, bool doKeepGuid) -{ - if (element->app().d_elements.numElements() == 0) { - element->eraseApp(d_apps); - } - - if (!doKeepGuid && element->guid().numElements() == 0) { - element->eraseGuid(d_stream); - } - - d_pushElementsPool_sp->deallocate(element); -} - inline PushStream::iterator PushStream::findOrAppendMessage(const bmqt::MessageGUID& guid) { @@ -662,7 +649,7 @@ inline void PushStream::add(Element* element) element->app().add(element); } -inline unsigned int PushStream::remove(Element* element) +inline void PushStream::remove(Element* element, bool canEraseGuid) { BSLS_ASSERT_SAFE(element); BSLS_ASSERT_SAFE(!element->equal(d_stream.end())); @@ -673,7 +660,15 @@ inline unsigned int PushStream::remove(Element* element) // remove from the guid element->guid().remove(element, e_GUID); - return element->guid().numElements(); + if (element->app().d_elements.numElements() == 0) { + element->eraseApp(d_apps); + } + + if (canEraseGuid && element->guid().numElements() == 0) { + element->eraseGuid(d_stream); + } + + d_pushElementsPool_sp->deallocate(element); } inline unsigned int PushStream::removeApp(unsigned int upstreamSubQueueId) @@ -695,10 +690,9 @@ inline unsigned int PushStream::removeApp(Apps::iterator itApp) for (unsigned int count = 0; count < numElements; ++count) { Element* element = itApp->second.d_elements.front(); - remove(element); - - destroy(element, false); - // do not keep Guid + remove(element, true); + // do not keep Guid. This relies on either 'beforeOneAppRemoved' or + // resetting iterator(s). } return numElements; diff --git a/src/groups/mqb/mqbblp/mqbblp_pushstream.t.cpp b/src/groups/mqb/mqbblp/mqbblp_pushstream.t.cpp index f6506be07..a3a060f28 100644 --- a/src/groups/mqb/mqbblp/mqbblp_pushstream.t.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_pushstream.t.cpp @@ -39,10 +39,12 @@ static void test1_basic() { bmqtst::TestHelper::printTestName("PushStream basic test"); - bdlma::ConcurrentPool pushElementsPool(sizeof(mqbblp::PushStream::Element), - s_allocator_p); + bdlma::ConcurrentPool pushElementsPool( + sizeof(mqbblp::PushStream::Element), + bmqtst::TestHelperUtil::allocator()); - mqbblp::PushStream ps(&pushElementsPool, s_allocator_p); + mqbblp::PushStream ps(&pushElementsPool, + bmqtst::TestHelperUtil::allocator()); unsigned int subQueueId = 0; bsl::shared_ptr app; // unused bmqp::SubQueueInfo subscription; @@ -58,8 +60,7 @@ static void test1_basic() itApp); ps.add(element); - ps.remove(element); - ps.destroy(element, false); + ps.remove(element, true); } static void test2_iterations() @@ -69,7 +70,7 @@ static void test2_iterations() // Imitate {m1, a1}, {m2, a2}, {m1, a2}, {m2, a1} mqbblp::PushStream ps(bsl::optional(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); unsigned int subQueueId1 = 1; unsigned int subQueueId2 = 2; @@ -114,16 +115,18 @@ static void test2_iterations() ps.add(element4); - mqbu::CapacityMeter dummyCapacityMeter("dummy", s_allocator_p); - bmqt::Uri dummyUri("dummy", s_allocator_p); - mqbconfm::Domain dummyDomain(s_allocator_p); + mqbu::CapacityMeter dummyCapacityMeter( + "dummy", + bmqtst::TestHelperUtil::allocator()); + bmqt::Uri dummyUri("dummy", bmqtst::TestHelperUtil::allocator()); + mqbconfm::Domain dummyDomain(bmqtst::TestHelperUtil::allocator()); mqbs::InMemoryStorage dummyStorage(dummyUri, mqbu::StorageKey::k_NULL_KEY, mqbs::DataStore::k_INVALID_PARTITION_ID, dummyDomain, &dummyCapacityMeter, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbconfm::Storage config; mqbconfm::Limits limits; @@ -133,7 +136,7 @@ static void test2_iterations() limits.messages() = bsl::numeric_limits::max(); limits.bytes() = bsl::numeric_limits::max(); - bmqu::MemOutStream errorDescription(s_allocator_p); + bmqu::MemOutStream errorDescription(bmqtst::TestHelperUtil::allocator()); dummyStorage.configure(errorDescription, config, limits, @@ -183,10 +186,8 @@ static void test2_iterations() ASSERT(vit.atEnd()); } - ps.remove(element2); - ps.destroy(element2, false); - ps.remove(element3); - ps.destroy(element3, false); + ps.remove(element2, true); + ps.remove(element3, true); } // ============================================================================ @@ -197,7 +198,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -205,7 +206,7 @@ int main(int argc, char* argv[]) case 2: test2_iterations(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbblp/mqbblp_queueconsumptionmonitor.t.cpp b/src/groups/mqb/mqbblp/mqbblp_queueconsumptionmonitor.t.cpp index a196b8e35..af9a53487 100644 --- a/src/groups/mqb/mqbblp/mqbblp_queueconsumptionmonitor.t.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_queueconsumptionmonitor.t.cpp @@ -87,11 +87,11 @@ struct Test : bmqtst::Test { Test::Test() : d_id() -, d_dispatcher(s_allocator_p) -, d_bufferFactory(1024, s_allocator_p) -, d_cluster(&d_bufferFactory, s_allocator_p) -, d_domain(&d_cluster, s_allocator_p) -, d_queue(&d_domain, s_allocator_p) +, d_dispatcher(bmqtst::TestHelperUtil::allocator()) +, d_bufferFactory(1024, bmqtst::TestHelperUtil::allocator()) +, d_cluster(&d_bufferFactory, bmqtst::TestHelperUtil::allocator()) +, d_domain(&d_cluster, bmqtst::TestHelperUtil::allocator()) +, d_queue(&d_domain, bmqtst::TestHelperUtil::allocator()) , d_queueState(&d_queue, bmqt::Uri("bmq://bmq.test.local/test_queue"), 802701, @@ -99,26 +99,26 @@ Test::Test() 1, &d_domain, d_cluster._resources(), - s_allocator_p) + bmqtst::TestHelperUtil::allocator()) , d_monitor(&d_queueState, bdlf::BindUtil::bind(&Test::loggingCb, this, bdlf::PlaceHolders::_1, // id bdlf::PlaceHolders::_2), // enableLog - s_allocator_p) + bmqtst::TestHelperUtil::allocator()) , d_storage(d_queue.uri(), mqbu::StorageKey::k_NULL_KEY, mqbs::DataStore::k_INVALID_PARTITION_ID, getDomainConfig(), d_domain.capacityMeter(), - s_allocator_p) -, d_haveUndelivered(s_allocator_p) + bmqtst::TestHelperUtil::allocator()) +, d_haveUndelivered(bmqtst::TestHelperUtil::allocator()) { d_dispatcher._setInDispatcherThread(true); d_queue._setDispatcher(&d_dispatcher); - bmqu::MemOutStream errorDescription(s_allocator_p); + bmqu::MemOutStream errorDescription(bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr queueMp(&d_queue, 0, @@ -188,7 +188,8 @@ TEST_F(Test, doNotMonitor) { putMessage(); - bmqtst::ScopedLogObserver observer(ball::Severity::INFO, s_allocator_p); + bmqtst::ScopedLogObserver observer(ball::Severity::INFO, + bmqtst::TestHelperUtil::allocator()); d_monitor.registerSubStream(d_id); @@ -211,7 +212,8 @@ TEST_F(Test, emptyQueue) // Plan: Start monitoring, make time pass, state should remain ALIVE. // ------------------------------------------------------------------------ { - bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, s_allocator_p); + bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, + bmqtst::TestHelperUtil::allocator()); size_t expectedLogRecords = 0U; const bsls::Types::Int64 k_MAX_IDLE_TIME = 10; @@ -241,7 +243,8 @@ TEST_F(Test, putAliveIdleSendAlive) // pass, check that state remains 'alive'. // ------------------------------------------------------------------------ { - bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, s_allocator_p); + bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, + bmqtst::TestHelperUtil::allocator()); size_t expectedLogRecords = 0U; const bsls::Types::Int64 k_MAX_IDLE_TIME = 10; @@ -270,7 +273,7 @@ TEST_F(Test, putAliveIdleSendAlive) ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( logObserver.records().back(), "ALARM \\[QUEUE_STUCK\\]", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); d_monitor.onTimer(2 * k_MAX_IDLE_TIME + 2); ASSERT_EQ(d_monitor.state(d_id), QueueConsumptionMonitor::State::e_IDLE); @@ -284,7 +287,7 @@ TEST_F(Test, putAliveIdleSendAlive) ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( logObserver.records().back(), "no longer appears to be stuck", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(d_monitor.state(d_id), QueueConsumptionMonitor::State::e_ALIVE); } @@ -341,7 +344,8 @@ TEST_F(Test, changeMaxIdleTime) d_monitor.onTimer(k_MAX_IDLE_TIME + 1); ASSERT_EQ(d_monitor.state(d_id), QueueConsumptionMonitor::State::e_IDLE); - bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, s_allocator_p); + bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, + bmqtst::TestHelperUtil::allocator()); d_monitor.setMaxIdleTime(k_MAX_IDLE_TIME * 2); ASSERT_EQ(d_monitor.state(d_id), QueueConsumptionMonitor::State::e_ALIVE); @@ -377,7 +381,8 @@ TEST_F(Test, reset) d_monitor.onTimer(0); ASSERT_EQ(d_monitor.state(d_id), QueueConsumptionMonitor::State::e_ALIVE); - bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, s_allocator_p); + bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, + bmqtst::TestHelperUtil::allocator()); d_monitor.reset(); d_monitor.onTimer(k_MAX_IDLE_TIME + 1); @@ -396,7 +401,8 @@ TEST_F(Test, putAliveIdleSendAliveTwoSubstreams) // pass, check that state remains 'alive'. // ------------------------------------------------------------------------ { - bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, s_allocator_p); + bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, + bmqtst::TestHelperUtil::allocator()); size_t expectedLogRecords = 0U; const bsls::Types::Int64 k_MAX_IDLE_TIME = 10; @@ -409,7 +415,7 @@ TEST_F(Test, putAliveIdleSendAliveTwoSubstreams) d_monitor.setMaxIdleTime(k_MAX_IDLE_TIME); - bmqu::MemOutStream errorDescription(s_allocator_p); + bmqu::MemOutStream errorDescription(bmqtst::TestHelperUtil::allocator()); d_storage.addVirtualStorage(errorDescription, id1, key1); d_storage.addVirtualStorage(errorDescription, id2, key2); @@ -444,7 +450,7 @@ TEST_F(Test, putAliveIdleSendAliveTwoSubstreams) ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( logObserver.records().rbegin()[i], "ALARM \\[QUEUE_STUCK\\]", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); } d_monitor.onTimer(2 * k_MAX_IDLE_TIME + 2); @@ -462,7 +468,7 @@ TEST_F(Test, putAliveIdleSendAliveTwoSubstreams) logObserver.records().back(), "Queue 'bmq://bmq.test.local/test_queue\\?id=app1' no longer appears " "to be stuck.", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(d_monitor.state(id1), QueueConsumptionMonitor::State::e_ALIVE); ASSERT_EQ(d_monitor.state(id2), QueueConsumptionMonitor::State::e_IDLE); @@ -474,7 +480,7 @@ TEST_F(Test, putAliveIdleSendAliveTwoSubstreams) logObserver.records().back(), "Queue 'bmq://bmq.test.local/test_queue\\?id=app2' no longer appears " "to be stuck.", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(d_monitor.state(id1), QueueConsumptionMonitor::State::e_ALIVE); ASSERT_EQ(d_monitor.state(id2), QueueConsumptionMonitor::State::e_ALIVE); } @@ -489,7 +495,8 @@ TEST_F(Test, usage) { #define monitor d_monitor - bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, s_allocator_p); + bmqtst::ScopedLogObserver logObserver(ball::Severity::INFO, + bmqtst::TestHelperUtil::allocator()); monitor.setMaxIdleTime(20); @@ -542,7 +549,7 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); ball::LoggerManager::singleton().setDefaultThresholdLevels( ball::Severity::OFF, @@ -550,11 +557,13 @@ int main(int argc, char* argv[]) ball::Severity::OFF, ball::Severity::OFF); { - mqbcfg::AppConfig brokerConfig(s_allocator_p); + mqbcfg::AppConfig brokerConfig(bmqtst::TestHelperUtil::allocator()); mqbcfg::BrokerConfig::set(brokerConfig); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); bmqtst::runTest(_testCase); } diff --git a/src/groups/mqb/mqbblp/mqbblp_queueenginetester.cpp b/src/groups/mqb/mqbblp/mqbblp_queueenginetester.cpp index ccdd413ca..85763337d 100644 --- a/src/groups/mqb/mqbblp/mqbblp_queueenginetester.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_queueenginetester.cpp @@ -539,6 +539,7 @@ void QueueEngineTester::init(const mqbconfm::Domain& domainConfig, limits.messages() = bsl::numeric_limits::max(); limits.bytes() = bsl::numeric_limits::max(); + storage_p->setConsistency(domainConfig.consistency()); rc = storage_p->configure(errorDescription, config, limits, diff --git a/src/groups/mqb/mqbblp/mqbblp_queueengineutil.cpp b/src/groups/mqb/mqbblp/mqbblp_queueengineutil.cpp index 92c7876ff..023b3169f 100644 --- a/src/groups/mqb/mqbblp/mqbblp_queueengineutil.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_queueengineutil.cpp @@ -633,7 +633,8 @@ QueueEngineUtil_AppsDeliveryContext::QueueEngineUtil_AppsDeliveryContext( mqbi::Queue* queue, bslma::Allocator* allocator) : d_consumers(allocator) -, d_isReady(false) +, d_numApps(0) +, d_numStops(0) , d_currentMessage(0) , d_queue_p(queue) , d_timeDelta() @@ -652,25 +653,26 @@ QueueEngineUtil_AppsDeliveryContext::QueueEngineUtil_AppsDeliveryContext( BSLS_ASSERT_SAFE(queue); } -void QueueEngineUtil_AppsDeliveryContext::start() -{ - d_isReady = true; -} - bool QueueEngineUtil_AppsDeliveryContext::reset( mqbi::StorageIterator* currentMessage) { d_consumers.clear(); d_timeDelta.reset(); - if (!d_isReady) { - return false; // RETURN + bool result = false; + + if (haveProgress() && currentMessage && currentMessage->hasReceipt()) { + d_currentMessage = currentMessage; + result = true; + } + else { + d_currentMessage = 0; } - d_currentMessage = currentMessage; - d_isReady = false; + d_numApps = 0; + d_numStops = 0; - return d_currentMessage ? d_currentMessage->hasReceipt() : false; + return result; } bool QueueEngineUtil_AppsDeliveryContext::processApp( @@ -679,12 +681,12 @@ bool QueueEngineUtil_AppsDeliveryContext::processApp( { BSLS_ASSERT_SAFE(d_currentMessage->hasReceipt()); + ++d_numApps; + if (d_queue_p->isDeliverAll()) { // collect all handles app.routing()->iterateConsumers(d_broadcastVisitor, d_currentMessage); - d_isReady = true; - // Broadcast does not need stats nor any special per-message treatment. return false; // RETURN } @@ -695,6 +697,7 @@ bool QueueEngineUtil_AppsDeliveryContext::processApp( // The queue iterator can advance leaving the 'app' behind. app.setResumePoint(d_currentMessage->guid()); } + ++d_numStops; // else the existing resumePoint is earlier (if authorized) return false; // RETURN } @@ -703,7 +706,6 @@ bool QueueEngineUtil_AppsDeliveryContext::processApp( ordinal); if (!appView.isNew()) { - d_isReady = true; return true; // RETURN } @@ -736,7 +738,9 @@ bool QueueEngineUtil_AppsDeliveryContext::processApp( // Early return. // If all Apps return 'e_NO_CAPACITY_ALL', stop the iteration - // (d_isReady == false). + // (d_numApps == 0). + + ++d_numStops; return false; // RETURN } @@ -750,7 +754,6 @@ bool QueueEngineUtil_AppsDeliveryContext::processApp( } // Still making progress (result != Routers::e_NO_CAPACITY_ALL) - d_isReady = true; return (result == Routers::e_SUCCESS); } @@ -811,7 +814,7 @@ void QueueEngineUtil_AppsDeliveryContext::deliverMessage() } } - if (d_isReady) { + if (haveProgress()) { d_currentMessage->advance(); } @@ -823,6 +826,11 @@ bool QueueEngineUtil_AppsDeliveryContext::isEmpty() const return d_consumers.empty(); } +bool QueueEngineUtil_AppsDeliveryContext::haveProgress() const +{ + return (d_numStops < d_numApps || d_numApps == 0); +} + bsls::Types::Int64 QueueEngineUtil_AppsDeliveryContext::timeDelta() { if (!d_timeDelta.has_value()) { diff --git a/src/groups/mqb/mqbblp/mqbblp_queueengineutil.h b/src/groups/mqb/mqbblp/mqbblp_queueengineutil.h index c6b0f95c7..9f9dfe2d3 100644 --- a/src/groups/mqb/mqbblp/mqbblp_queueengineutil.h +++ b/src/groups/mqb/mqbblp/mqbblp_queueengineutil.h @@ -599,7 +599,8 @@ struct QueueEngineUtil_AppsDeliveryContext { private: Consumers d_consumers; - bool d_isReady; + int d_numApps; + int d_numStops; // Apps not moving mqbi::StorageIterator* d_currentMessage; mqbi::Queue* d_queue_p; bsl::optional d_timeDelta; @@ -626,9 +627,6 @@ struct QueueEngineUtil_AppsDeliveryContext { QueueEngineUtil_AppsDeliveryContext(mqbi::Queue* queue, bslma::Allocator* allocator); - /// Start delivery cycle(s). - void start(); - /// Prepare the context to process next message. /// Return `true` if the delivery can continue iterating dataStream /// The `false` return value indicates either the end of the dataStream or @@ -662,6 +660,9 @@ struct QueueEngineUtil_AppsDeliveryContext { /// Return `true` if there is at least one delivery target selected. bool isEmpty() const; + /// Return `true` if not all Apps are at capacity or there are no Apps. + bool haveProgress() const; + bsls::Types::Int64 timeDelta(); }; diff --git a/src/groups/mqb/mqbblp/mqbblp_relayqueueengine.cpp b/src/groups/mqb/mqbblp/mqbblp_relayqueueengine.cpp index 80d8232fa..84f1d802e 100644 --- a/src/groups/mqb/mqbblp/mqbblp_relayqueueengine.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_relayqueueengine.cpp @@ -580,8 +580,6 @@ void RelayQueueEngine::deliverMessages() // 1. End of storage; or // 2. All subStreams return 'e_NO_CAPACITY_ALL' - d_appsDeliveryContext.start(); - while (d_appsDeliveryContext.reset(d_storageIter_mp.get())) { // Assume, all Apps need to deliver (some may be at capacity) unsigned int numApps = d_storageIter_mp->numApps(); @@ -604,14 +602,13 @@ void RelayQueueEngine::deliverMessages() d_storageIter_mp->removeCurrentElement(); } - - if (d_appsDeliveryContext.processApp(*app, i)) { + else if (d_appsDeliveryContext.processApp(*app, i)) { // The current element has made it either to delivery or - // putAside or resumerPoint and it can be removed + // putAside and it can be removed d_storageIter_mp->removeCurrentElement(); } - // Else, the current element has made it to resumerPoint and - // it cannot be removed + // Else, the current element has made it to resumePoint and it + // cannot be removed. } d_appsDeliveryContext.deliverMessage(); } @@ -1919,14 +1916,22 @@ void RelayQueueEngine::storePush(mqbi::StorageMessageAttributes* attributes, void RelayQueueEngine::beforeOneAppRemoved(unsigned int upstreamSubQueueId) { while (!d_storageIter_mp->atEnd()) { - if (d_storageIter_mp->numApps() > 1) { + const int numApps = d_storageIter_mp->numApps(); + if (numApps > 1) { // Removal of App's elements will not invalidate 'd_storageIter_mp' break; } + if (numApps == 1) { + const PushStream::Element* element = d_storageIter_mp->element(0); + if (element->app().d_app->upstreamSubQueueId() != + upstreamSubQueueId) { + break; + } + } + else { + BSLS_ASSERT_SAFE(numApps == 0); - const PushStream::Element* element = d_storageIter_mp->element(0); - if (element->app().d_app->upstreamSubQueueId() != upstreamSubQueueId) { - break; + // The case when 'advance' does not follow 'removeCurrentElement' } d_storageIter_mp->advance(); diff --git a/src/groups/mqb/mqbblp/mqbblp_relayqueueengine.t.cpp b/src/groups/mqb/mqbblp/mqbblp_relayqueueengine.t.cpp index a73db2885..bbd6daef4 100644 --- a/src/groups/mqb/mqbblp/mqbblp_relayqueueengine.t.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_relayqueueengine.t.cpp @@ -82,7 +82,7 @@ static void test1_breathingTest() // Basic functionality // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -93,7 +93,7 @@ static void test1_breathingTest() mqbblp::QueueEngineTester tester(domainConfig, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -163,7 +163,7 @@ static void test2_aggregateDownstream() // consumers // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -174,7 +174,7 @@ static void test2_aggregateDownstream() mqbblp::QueueEngineTester tester(domainConfig, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -334,7 +334,7 @@ static void test3_reconfigure() // - 'configureHandle()' // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks // from 'mqbi' methods print with ball, which allocates. @@ -345,7 +345,7 @@ static void test3_reconfigure() mqbblp::QueueEngineTester tester(domainConfig, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -473,7 +473,7 @@ static void test4_cannotDeliver() // more highest priority consumers. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -484,7 +484,7 @@ static void test4_cannotDeliver() mqbblp::QueueEngineTester tester(domainConfig, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -588,7 +588,7 @@ static void test5_localRedelivery() // when other consumers are available and able to receive messages. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -599,7 +599,7 @@ static void test5_localRedelivery() mqbblp::QueueEngineTester tester(domainConfig, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -668,7 +668,7 @@ static void test6_clearDeliveryStateWhenLostReaders() // message lists when it loses the last consumer. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -679,7 +679,7 @@ static void test6_clearDeliveryStateWhenLostReaders() mqbblp::QueueEngineTester tester(domainConfig, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -738,19 +738,19 @@ static void test7_broadcastMode() // RelayQueueEngine is sending to all handlers if mode is broadcast. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. bmqtst::TestHelper::printTestName("BROADCAST MODE"); - mqbconfm::Domain domainConfig(s_allocator_p); + mqbconfm::Domain domainConfig(bmqtst::TestHelperUtil::allocator()); domainConfig.mode().makeBroadcast(); domainConfig.storage().config().makeInMemory(); mqbblp::QueueEngineTester tester(domainConfig, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -830,19 +830,19 @@ static void test8_priority_beforeMessageRemoved_garbageCollection() // - 'beforeMessageRemoved()' // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. bmqtst::TestHelper::printTestName("BEFORE MESSAGE REMOVED - GARBAGE " "COLLECTION"); - mqbconfm::Domain domainConfig(s_allocator_p); + mqbconfm::Domain domainConfig(bmqtst::TestHelperUtil::allocator()); domainConfig.mode().makePriority(); mqbblp::QueueEngineTester tester(domainConfig, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -906,16 +906,18 @@ static void test9_releaseHandle_isDeletedFlag() // const mqbi::QueueHandle::HandleReleasedCallback& releasedCb) // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. bmqtst::TestHelper::printTestName("RELEASE HANDLE - IS-DELETED FLAG"); - mqbconfm::Domain domainConfig(s_allocator_p); + mqbconfm::Domain domainConfig(bmqtst::TestHelperUtil::allocator()); domainConfig.mode().makePriority(); - mqbblp::QueueEngineTester tester(domainConfig, false, s_allocator_p); + mqbblp::QueueEngineTester tester(domainConfig, + false, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); // 1. Bring up a consumer C1 with writeCount=1, a consumer C2 with @@ -969,14 +971,16 @@ static void test10_configureFanoutAppIds() // const mqbi::QueueHandle::HandleConfiguredCallback&); // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. bmqtst::TestHelper::printTestName( "CONFIGURING DIFFERENT APPIDs FOR UPSTREAM"); - mqbblp::QueueEngineTester tester(fanoutConfig(), false, s_allocator_p); + mqbblp::QueueEngineTester tester(fanoutConfig(), + false, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); // 1. Bring up a producer and 3 fanout consumers. @@ -1055,7 +1059,7 @@ static void test11_roundRobinAndRedelivery() // 'getHandle' and 'configureHandle' for multiple distinct appIds. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1069,7 +1073,7 @@ static void test11_roundRobinAndRedelivery() mqbblp::QueueEngineTester tester(config, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); // 1. Bring up a consumer C1 with appId 'a', 'b', and 'c'. @@ -1159,16 +1163,18 @@ static void test12_redeliverAfterGc() // them. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. bmqtst::TestHelper::printTestName("REDELIVERY AFTER GC"); - mqbconfm::Domain domainConfig(s_allocator_p); + mqbconfm::Domain domainConfig(bmqtst::TestHelperUtil::allocator()); domainConfig.mode().makePriority(); - mqbblp::QueueEngineTester tester(domainConfig, false, s_allocator_p); + mqbblp::QueueEngineTester tester(domainConfig, + false, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); // 1) @@ -1229,14 +1235,16 @@ static void test13_deconfigureWhenOpen() // const mqbi::QueueHandle::HandleConfiguredCallback&); // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. bmqtst::TestHelper::printTestName( "DECONFIGURE IN BETWEEN OPEN AND CONFIGURE"); - mqbblp::QueueEngineTester tester(fanoutConfig(), false, s_allocator_p); + mqbblp::QueueEngineTester tester(fanoutConfig(), + false, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); // 1. Bring up 1st consumer. @@ -1284,7 +1292,7 @@ static void test14_throttleRedeliveryPriority() // rda reaches 2. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1294,7 +1302,9 @@ static void test14_throttleRedeliveryPriority() config.mode().makePriority(); config.maxDeliveryAttempts() = 5; - mqbblp::TimeControlledQueueEngineTester tester(config, s_allocator_p); + mqbblp::TimeControlledQueueEngineTester tester( + config, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1379,7 +1389,7 @@ static void test15_throttleRedeliveryFanout() // rda reaches 2. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1392,7 +1402,9 @@ static void test15_throttleRedeliveryFanout() appIDs.push_back("c"); config.maxDeliveryAttempts() = 5; - mqbblp::TimeControlledQueueEngineTester tester(config, s_allocator_p); + mqbblp::TimeControlledQueueEngineTester tester( + config, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1522,7 +1534,7 @@ static void test16_throttleRedeliveryCancelledDelay() // mqbblp::QueueEngine cancelThrottle on a delayed message. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1532,7 +1544,9 @@ static void test16_throttleRedeliveryCancelledDelay() config.mode().makePriority(); config.maxDeliveryAttempts() = 5; - mqbblp::TimeControlledQueueEngineTester tester(config, s_allocator_p); + mqbblp::TimeControlledQueueEngineTester tester( + config, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1615,7 +1629,7 @@ static void test17_throttleRedeliveryNewHandle() // for the current message. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1625,7 +1639,9 @@ static void test17_throttleRedeliveryNewHandle() config.mode().makePriority(); config.maxDeliveryAttempts() = 5; - mqbblp::TimeControlledQueueEngineTester tester(config, s_allocator_p); + mqbblp::TimeControlledQueueEngineTester tester( + config, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1677,7 +1693,7 @@ static void test18_throttleRedeliveryNoMoreHandles() // should end the delay for the current message. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1687,7 +1703,9 @@ static void test18_throttleRedeliveryNoMoreHandles() config.mode().makePriority(); config.maxDeliveryAttempts() = 5; - mqbblp::TimeControlledQueueEngineTester tester(config, s_allocator_p); + mqbblp::TimeControlledQueueEngineTester tester( + config, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1747,14 +1765,16 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); { - bmqt::UriParser::initialize(s_allocator_p); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); - mqbcfg::AppConfig brokerConfig(s_allocator_p); + mqbcfg::AppConfig brokerConfig(bmqtst::TestHelperUtil::allocator()); mqbcfg::BrokerConfig::set(brokerConfig); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -1778,7 +1798,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbblp/mqbblp_remotequeue.cpp b/src/groups/mqb/mqbblp/mqbblp_remotequeue.cpp index 3a25c20d8..9c8057c5e 100644 --- a/src/groups/mqb/mqbblp/mqbblp_remotequeue.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_remotequeue.cpp @@ -124,6 +124,7 @@ int RemoteQueue::configureAsProxy(bsl::ostream& errorDescription, limits.messages() = bsl::numeric_limits::max(); limits.bytes() = bsl::numeric_limits::max(); + storageMp->setConsistency(domainCfg.consistency()); int rc = storageMp->configure(errorDescription, config, limits, @@ -243,6 +244,7 @@ int RemoteQueue::configureAsClusterMember(bsl::ostream& errorDescription, d_allocator_p); } else { + d_state_p->storage()->setConsistency(domainCfg.consistency()); rc = d_state_p->storage()->configure( errorDescription, domainCfg.storage().config(), diff --git a/src/groups/mqb/mqbblp/mqbblp_remotequeue.t.cpp b/src/groups/mqb/mqbblp/mqbblp_remotequeue.t.cpp index 439d4ef11..e173cf320 100644 --- a/src/groups/mqb/mqbblp/mqbblp_remotequeue.t.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_remotequeue.t.cpp @@ -468,14 +468,17 @@ static void test1_fanoutBasic() { bmqtst::TestHelper::printTestName("basic tests using fanout"); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); - TestBench theBench(s_allocator_p); + TestBench theBench(bmqtst::TestHelperUtil::allocator()); - bmqt::Uri uri("bmq://bmq.test.local/test_queue", s_allocator_p); + bmqt::Uri uri("bmq://bmq.test.local/test_queue", + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::RoutingConfiguration routingConfig; size_t ackWindowSize = 1000; int timeout = 10; @@ -486,8 +489,10 @@ static void test1_fanoutBasic() routingConfig); bsl::shared_ptr clientContext_sp( - new (*s_allocator_p) mqbi::QueueHandleRequesterContext(s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + mqbi::QueueHandleRequesterContext( + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); TestQueueHandle x(theQueue.d_queue_sp, theBench, clientContext_sp); TestQueueHandle y(theQueue.d_queue_sp, theBench, clientContext_sp); @@ -610,14 +615,17 @@ static void test2_broadcastBasic() { bmqtst::TestHelper::printTestName("basic tests using broadcast"); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); - TestBench theBench(s_allocator_p); + TestBench theBench(bmqtst::TestHelperUtil::allocator()); - bmqt::Uri uri("bmq://bmq.test.local/test_queue", s_allocator_p); + bmqt::Uri uri("bmq://bmq.test.local/test_queue", + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::RoutingConfiguration routingConfig; bmqp::RoutingConfigurationUtils::setAtMostOnce(&routingConfig); @@ -631,8 +639,10 @@ static void test2_broadcastBasic() routingConfig); bsl::shared_ptr clientContext_sp( - new (*s_allocator_p) mqbi::QueueHandleRequesterContext(s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + mqbi::QueueHandleRequesterContext( + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); theQueue.d_queue_sp->_setAtMostOnce(true); @@ -898,14 +908,17 @@ static void test3_close() { bmqtst::TestHelper::printTestName("close queue with pending messages"); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); - TestBench theBench(s_allocator_p); + TestBench theBench(bmqtst::TestHelperUtil::allocator()); - bmqt::Uri uri("bmq://bmq.test.local/test_queue", s_allocator_p); + bmqt::Uri uri("bmq://bmq.test.local/test_queue", + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::RoutingConfiguration routingConfig; size_t ackWindowSize = 1000; int timeout = 10; @@ -916,8 +929,10 @@ static void test3_close() routingConfig); bsl::shared_ptr clientContext_sp( - new (*s_allocator_p) mqbi::QueueHandleRequesterContext(s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + mqbi::QueueHandleRequesterContext( + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); TestQueueHandle x(theQueue.d_queue_sp, theBench, clientContext_sp); TestQueueHandle y(theQueue.d_queue_sp, theBench, clientContext_sp); @@ -953,14 +968,17 @@ static void test4_buffering() { bmqtst::TestHelper::printTestName("buffering"); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); - TestBench theBench(s_allocator_p); + TestBench theBench(bmqtst::TestHelperUtil::allocator()); - bmqt::Uri uri("bmq://bmq.test.local/test_queue", s_allocator_p); + bmqt::Uri uri("bmq://bmq.test.local/test_queue", + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::RoutingConfiguration routingConfig; size_t ackWindowSize = 1000; int timeout = 10; @@ -971,8 +989,10 @@ static void test4_buffering() routingConfig); bsl::shared_ptr clientContext_sp( - new (*s_allocator_p) mqbi::QueueHandleRequesterContext(s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + mqbi::QueueHandleRequesterContext( + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); TestQueueHandle x(theQueue.d_queue_sp, theBench, clientContext_sp); TestQueueHandle y(theQueue.d_queue_sp, theBench, clientContext_sp); @@ -1050,14 +1070,17 @@ static void test5_reopen_failure() { bmqtst::TestHelper::printTestName("buffering"); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); - TestBench theBench(s_allocator_p); + TestBench theBench(bmqtst::TestHelperUtil::allocator()); - bmqt::Uri uri("bmq://bmq.test.local/test_queue", s_allocator_p); + bmqt::Uri uri("bmq://bmq.test.local/test_queue", + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::RoutingConfiguration routingConfig; size_t ackWindowSize = 1000; int timeout = 10; @@ -1068,8 +1091,10 @@ static void test5_reopen_failure() routingConfig); bsl::shared_ptr clientContext_sp( - new (*s_allocator_p) mqbi::QueueHandleRequesterContext(s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + mqbi::QueueHandleRequesterContext( + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); TestQueueHandle x(theQueue.d_queue_sp, theBench, clientContext_sp); TestQueueHandle y(theQueue.d_queue_sp, theBench, clientContext_sp); @@ -1136,7 +1161,7 @@ int main(int argc, char* argv[]) case 5: test5_reopen_failure(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbblp/mqbblp_rootqueueengine.cpp b/src/groups/mqb/mqbblp/mqbblp_rootqueueengine.cpp index 21896d5b2..14f25e609 100644 --- a/src/groups/mqb/mqbblp/mqbblp_rootqueueengine.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_rootqueueengine.cpp @@ -1253,7 +1253,7 @@ void RootQueueEngine::onHandleUsable(mqbi::QueueHandle* handle, } // Before attempting to deliver any messages, flush the storage. - d_queueState_p->queue()->storage()->dispatcherFlush(true, false); + d_queueState_p->queue()->storage()->flushStorage(); unsigned int upstreamSubQueueId = 0; if (d_queueState_p->routingContext().onUsable(&upstreamSubQueueId, @@ -1276,7 +1276,6 @@ void RootQueueEngine::afterNewMessage( d_queueState_p->queue())); // Deliver new messages to active (alive and capable to deliver) consumers - d_appsDeliveryContext.start(); while (d_appsDeliveryContext.reset(d_storageIter_mp.get())) { // Assume, all Apps need to deliver (some may be at capacity) diff --git a/src/groups/mqb/mqbblp/mqbblp_rootqueueengine.t.cpp b/src/groups/mqb/mqbblp/mqbblp_rootqueueengine.t.cpp index abc1844ad..9523f7303 100644 --- a/src/groups/mqb/mqbblp/mqbblp_rootqueueengine.t.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_rootqueueengine.t.cpp @@ -65,7 +65,7 @@ const mqbmock::QueueHandle* k_nullMockHandle_p = 0; mqbconfm::Domain broadcastConfig() { - mqbconfm::Domain domainConfig(s_allocator_p); + mqbconfm::Domain domainConfig(bmqtst::TestHelperUtil::allocator()); domainConfig.mode().makeBroadcast(); domainConfig.storage().config().makeInMemory(); return domainConfig; @@ -529,7 +529,7 @@ void regress(Operations* operations, // Setup testbench with proper tester infrastructure and a model. mqbblp::QueueEngineTester tester(broadcastConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -651,7 +651,7 @@ static void test1_broadcastBreathingTest() // Basic functionality. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -659,7 +659,7 @@ static void test1_broadcastBreathingTest() mqbblp::QueueEngineTester tester(broadcastConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -716,7 +716,7 @@ static void test2_broadcastConfirmAssertFails() // Calling confirm assert fails. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -724,7 +724,7 @@ static void test2_broadcastConfirmAssertFails() mqbblp::QueueEngineTester tester(broadcastConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -771,7 +771,7 @@ static void test3_broadcastCannotDeliver() // more highest priority consumers. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -779,7 +779,7 @@ static void test3_broadcastCannotDeliver() mqbblp::QueueEngineTester tester(broadcastConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -880,7 +880,7 @@ static void test4_broadcastPostAfterResubscribe() // Queue Engine delivery when we have re-subscription // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -888,7 +888,7 @@ static void test4_broadcastPostAfterResubscribe() mqbblp::QueueEngineTester tester(broadcastConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -949,17 +949,17 @@ static void test5_broadcastReleaseHandle_isDeletedFlag() // const mqbi::QueueHandle::HandleReleasedCallback& releasedCb) // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. bmqtst::TestHelper::printTestName("RELEASE HANDLE - IS-DELETED FLAG"); - mqbconfm::Domain domainConfig(s_allocator_p); + mqbconfm::Domain domainConfig(bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTester tester(broadcastConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1016,7 +1016,7 @@ static void test6_broadcastDynamicPriorities() // Queue Engine delivery when consumer priorities can change. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1024,7 +1024,7 @@ static void test6_broadcastDynamicPriorities() mqbblp::QueueEngineTester tester(broadcastConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1117,7 +1117,7 @@ static void test7_broadcastPriorityFailover() // unsubscribe or become busy gradually. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1125,7 +1125,7 @@ static void test7_broadcastPriorityFailover() mqbblp::QueueEngineTester tester(broadcastConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1206,7 +1206,7 @@ static void testN1_broadcastExhaustiveSubscriptions() // That the queue works with any permutation of basic operations. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1249,7 +1249,7 @@ static void testN2_broadcastExhaustiveCanDeliver() // clients being unable to process data (e.g. due to high watermark). // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1296,7 +1296,7 @@ static void testN3_broadcastExhaustiveConsumerPriority() // consumers of various priorities are being added. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1348,7 +1348,7 @@ static void test8_priorityBreathingTest() // Basic functionality // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1356,7 +1356,7 @@ static void test8_priorityBreathingTest() mqbblp::QueueEngineTester tester(priorityDomainConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1418,7 +1418,7 @@ static void test9_priorityCreateAndConfigure() // messageReferenceCount // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1450,18 +1450,19 @@ static void test9_priorityCreateAndConfigure() mqbconfm::Domain domainConfig; domainConfig.mode().makePriority(); - PriorityQueueEngineTester tester(domainConfig, s_allocator_p); + PriorityQueueEngineTester tester(domainConfig, + bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr queueEngineMp; BSLS_ASSERT_OPT(!queueEngineMp); // 1. Create PriorityQueueEngine - tester.create(&queueEngineMp, s_allocator_p); + tester.create(&queueEngineMp, bmqtst::TestHelperUtil::allocator()); ASSERT(queueEngineMp.get() != 0); // 2. Verify that the created PriorityQueueEngine is functional by // configuring it successfully - bmqu::MemOutStream errorDescription(s_allocator_p); + bmqu::MemOutStream errorDescription(bmqtst::TestHelperUtil::allocator()); errorDescription.reset(); int rc = queueEngineMp->configure(errorDescription, false); @@ -1498,7 +1499,7 @@ static void test10_priorityAggregateDownstream() // consumers // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1506,7 +1507,7 @@ static void test10_priorityAggregateDownstream() mqbblp::QueueEngineTester tester(priorityDomainConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1666,7 +1667,7 @@ static void test11_priorityReconfigure() // - 'configureHandle()' // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks // from 'mqbi' methods print with ball, which allocates. @@ -1674,7 +1675,7 @@ static void test11_priorityReconfigure() mqbblp::QueueEngineTester tester(priorityDomainConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1802,7 +1803,7 @@ static void test12_priorityCannotDeliver() // more highest priority consumers. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1810,7 +1811,7 @@ static void test12_priorityCannotDeliver() mqbblp::QueueEngineTester tester(priorityDomainConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1916,7 +1917,7 @@ static void test13_priorityRedeliverToFirstConsumerUp() // before the first next consumer comes up. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1924,7 +1925,7 @@ static void test13_priorityRedeliverToFirstConsumerUp() mqbblp::QueueEngineTester tester(priorityDomainConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -1982,7 +1983,7 @@ static void test14_priorityRedeliverToOtherConsumers() // when other consumers are available and able to receive messages. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -1990,7 +1991,7 @@ static void test14_priorityRedeliverToOtherConsumers() mqbblp::QueueEngineTester tester(priorityDomainConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -2062,7 +2063,7 @@ static void test15_priorityReleaseActiveConsumerWithoutNullReconfigure() // parameters. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -2070,10 +2071,10 @@ static void test15_priorityReleaseActiveConsumerWithoutNullReconfigure() " RECONFIGURE"); bmqtst::ScopedLogObserver logObserver(ball::Severity::ERROR, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTester tester(priorityDomainConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -2160,7 +2161,7 @@ static void test16_priorityReleaseDormantConsumerWithoutNullReconfigure() // stream parameters. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -2168,10 +2169,10 @@ static void test16_priorityReleaseDormantConsumerWithoutNullReconfigure() " RECONFIGURE"); bmqtst::ScopedLogObserver logObserver(ball::Severity::ERROR, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTester tester(priorityDomainConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -2260,7 +2261,7 @@ static void test17_priorityBeforeMessageRemoved_garbageCollection() // - 'beforeMessageRemoved()' // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -2269,7 +2270,7 @@ static void test17_priorityBeforeMessageRemoved_garbageCollection() mqbblp::QueueEngineTester tester(priorityDomainConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -2328,7 +2329,7 @@ static void test18_priorityAfterQueuePurged_queueStreamResets() // messages. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -2337,7 +2338,7 @@ static void test18_priorityAfterQueuePurged_queueStreamResets() mqbblp::QueueEngineTester tester(priorityDomainConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -2437,17 +2438,17 @@ static void test19_priorityReleaseHandle_isDeletedFlag() // const mqbi::QueueHandle::HandleReleasedCallback& releasedCb) // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. bmqtst::TestHelper::printTestName("RELEASE HANDLE - IS-DELETED FLAG"); - mqbconfm::Domain domainConfig(s_allocator_p); + mqbconfm::Domain domainConfig(bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTester tester(domainConfig, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -2505,7 +2506,7 @@ static void test20_priorityRedeliverAfterGc() // them. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -2513,7 +2514,7 @@ static void test20_priorityRedeliverAfterGc() mqbblp::QueueEngineTester tester(priorityDomainConfig(), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -2579,7 +2580,7 @@ static void test21_breathingTest() // Basic functionality // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -2587,7 +2588,7 @@ static void test21_breathingTest() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -2737,7 +2738,7 @@ static void test22_createAndConfigure() // configure // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -2766,18 +2767,19 @@ static void test22_createAndConfigure() ~FanoutQueueEngineTester() {} }; - FanoutQueueEngineTester tester(fanoutConfig("a,b,c,d,e"), s_allocator_p); + FanoutQueueEngineTester tester(fanoutConfig("a,b,c,d,e"), + bmqtst::TestHelperUtil::allocator()); bslma::ManagedPtr queueEngineMp; BSLS_ASSERT_OPT(!queueEngineMp); // 1. Create FanoutQueueEngine - tester.create(&queueEngineMp, s_allocator_p); + tester.create(&queueEngineMp, bmqtst::TestHelperUtil::allocator()); ASSERT(queueEngineMp.get() != 0); // 2. Verify that the created FanoutQueueEngine is functional by // configuring it successfully - bmqu::MemOutStream errorDescription(s_allocator_p); + bmqu::MemOutStream errorDescription(bmqtst::TestHelperUtil::allocator()); errorDescription.reset(); int rc = queueEngineMp->configure(errorDescription, false); @@ -2801,7 +2803,7 @@ static void test23_loadRoutingConfiguration() // loadRoutingConfiguration // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -2809,7 +2811,7 @@ static void test23_loadRoutingConfiguration() mqbblp::QueueEngineTester tester(fanoutConfig("a"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); // 1. @@ -2863,7 +2865,7 @@ static void test24_getHandleDuplicateAppId() // 'getHandle' for an appId that was already opened. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -2871,7 +2873,7 @@ static void test24_getHandleDuplicateAppId() mqbblp::QueueEngineTester tester(fanoutConfig("a"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -2909,7 +2911,7 @@ static void test25_getHandleSameHandleMultipleAppIds() // 'getHandle' for multiple distinct appIds succeeds. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -2917,7 +2919,7 @@ static void test25_getHandleSameHandleMultipleAppIds() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -2954,7 +2956,7 @@ static void test26_getHandleUnauthorizedAppId() // getHandle for an unauthorized appId // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -2962,7 +2964,7 @@ static void test26_getHandleUnauthorizedAppId() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -3004,7 +3006,7 @@ static void test27_configureHandleMultipleAppIds() // 'configureHandle' for multiple distinct appIds. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -3012,7 +3014,7 @@ static void test27_configureHandleMultipleAppIds() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -3098,7 +3100,7 @@ static void test28_releaseHandle() // const mqbi::QueueHandle::HandleReleasedCallback& releasedCb) // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -3106,7 +3108,7 @@ static void test28_releaseHandle() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -3183,7 +3185,7 @@ static void test29_releaseHandleMultipleProducers() // const mqbi::QueueHandle::HandleReleasedCallback& releasedCb) // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -3191,7 +3193,7 @@ static void test29_releaseHandleMultipleProducers() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -3252,7 +3254,7 @@ static void test30_releaseHandle_isDeletedFlag() // const mqbi::QueueHandle::HandleReleasedCallback& releasedCb) // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -3260,7 +3262,7 @@ static void test30_releaseHandle_isDeletedFlag() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c,d"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -3354,7 +3356,7 @@ static void test31_afterNewMessageDeliverToAllActiveConsumers() // mqbi::QueueHandle *source) // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -3363,7 +3365,7 @@ static void test31_afterNewMessageDeliverToAllActiveConsumers() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c,d,e"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -3500,7 +3502,7 @@ static void test32_afterNewMessageRespectsFlowControl() // virtual void onHandleUsable // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -3509,7 +3511,7 @@ static void test32_afterNewMessageRespectsFlowControl() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c,d,e"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -3800,7 +3802,7 @@ static void test33_consumerUpAfterMessagePosted() // onConfirmMessage // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -3809,7 +3811,7 @@ static void test33_consumerUpAfterMessagePosted() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c,d,e"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -3940,7 +3942,7 @@ static void test34_beforeMessageRemoved_deadConsumers() // with regards to configured consumers that are not alive at the time. // - 'beforeMessageRemoved()' { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -3949,7 +3951,7 @@ static void test34_beforeMessageRemoved_deadConsumers() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -4025,7 +4027,7 @@ static void test35_beforeMessageRemoved_withActiveConsumers() // - 'beforeMessageRemoved()' // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -4034,7 +4036,7 @@ static void test35_beforeMessageRemoved_withActiveConsumers() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -4115,7 +4117,7 @@ static void test36_afterQueuePurged_queueStreamResets() // - 'afterQueuePurged()' // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -4124,7 +4126,7 @@ static void test36_afterQueuePurged_queueStreamResets() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -4280,7 +4282,7 @@ static void test37_afterQueuePurged_specificSubStreamResets() // specific subStream of the queue. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -4289,7 +4291,7 @@ static void test37_afterQueuePurged_specificSubStreamResets() mqbblp::QueueEngineTester tester(fanoutConfig("a,b,c"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -4431,7 +4433,7 @@ static void test38_unauthorizedAppIds() // mqbi::QueueHandle *source) // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -4440,7 +4442,7 @@ static void test38_unauthorizedAppIds() mqbblp::QueueEngineTester tester(fanoutConfig("a"), false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -4510,7 +4512,7 @@ static void test39_maxConsumersProducers() // 'getHandle' for multiple distinct appIds. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -4524,7 +4526,7 @@ static void test39_maxConsumersProducers() mqbblp::QueueEngineTester tester(config, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -4573,7 +4575,7 @@ static void test40_roundRobinAndRedelivery() // 'getHandle' and 'configureHandle' for multiple distinct appIds. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -4583,7 +4585,7 @@ static void test40_roundRobinAndRedelivery() mqbblp::QueueEngineTester tester(config, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -4674,7 +4676,7 @@ static void test41_redeliverAfterGc() // them. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -4684,7 +4686,7 @@ static void test41_redeliverAfterGc() mqbblp::QueueEngineTester tester(config, false, // start scheduler - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -4753,7 +4755,7 @@ static void test42_throttleRedeliveryPriority() // rda reaches 2. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -4762,7 +4764,9 @@ static void test42_throttleRedeliveryPriority() mqbconfm::Domain config = priorityDomainConfig(); config.maxDeliveryAttempts() = 5; - mqbblp::TimeControlledQueueEngineTester tester(config, s_allocator_p); + mqbblp::TimeControlledQueueEngineTester tester( + config, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -4845,7 +4849,7 @@ static void test43_throttleRedeliveryFanout() // rda reaches 2. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -4854,7 +4858,9 @@ static void test43_throttleRedeliveryFanout() mqbconfm::Domain config = fanoutConfig("a,b,c"); config.maxDeliveryAttempts() = 5; - mqbblp::TimeControlledQueueEngineTester tester(config, s_allocator_p); + mqbblp::TimeControlledQueueEngineTester tester( + config, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -4982,7 +4988,7 @@ static void test44_throttleRedeliveryCancelledDelay() // mqbblp::QueueEngine cancelThrottle on a delayed message. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -4991,7 +4997,9 @@ static void test44_throttleRedeliveryCancelledDelay() mqbconfm::Domain config = priorityDomainConfig(); config.maxDeliveryAttempts() = 5; - mqbblp::TimeControlledQueueEngineTester tester(config, s_allocator_p); + mqbblp::TimeControlledQueueEngineTester tester( + config, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -5073,7 +5081,7 @@ static void test45_throttleRedeliveryNewHandle() // for the current message. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -5082,7 +5090,9 @@ static void test45_throttleRedeliveryNewHandle() mqbconfm::Domain config = priorityDomainConfig(); config.maxDeliveryAttempts() = 5; - mqbblp::TimeControlledQueueEngineTester tester(config, s_allocator_p); + mqbblp::TimeControlledQueueEngineTester tester( + config, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -5134,7 +5144,7 @@ static void test46_throttleRedeliveryNoMoreHandles() // should end the delay for the current message. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Can't check the default allocator: 'mqbblp::QueueEngine' and mocks from // 'mqbi' methods print with ball, which allocates. @@ -5143,7 +5153,9 @@ static void test46_throttleRedeliveryNoMoreHandles() mqbconfm::Domain config = priorityDomainConfig(); config.maxDeliveryAttempts() = 5; - mqbblp::TimeControlledQueueEngineTester tester(config, s_allocator_p); + mqbblp::TimeControlledQueueEngineTester tester( + config, + bmqtst::TestHelperUtil::allocator()); mqbblp::QueueEngineTesterGuard guard(&tester); @@ -5209,15 +5221,17 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); - mqbcfg::AppConfig brokerConfig(s_allocator_p); + mqbcfg::AppConfig brokerConfig(bmqtst::TestHelperUtil::allocator()); mqbcfg::BrokerConfig::set(brokerConfig); { bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -5278,7 +5292,7 @@ int main(int argc, char* argv[]) case -3: testN3_broadcastExhaustiveConsumerPriority(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } } diff --git a/src/groups/mqb/mqbblp/mqbblp_routers.t.cpp b/src/groups/mqb/mqbblp/mqbblp_routers.t.cpp index 8b4351851..ef0c1779a 100644 --- a/src/groups/mqb/mqbblp/mqbblp_routers.t.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_routers.t.cpp @@ -167,7 +167,7 @@ static void test1_registry() { typedef mqbblp::Routers::Registry Registry; - Registry registry(s_allocator_p); + Registry registry(bmqtst::TestHelperUtil::allocator()); Item value13(13); Item value14(14); int key12 = 12; @@ -196,27 +196,31 @@ static void test2_priority() // reference to Consumer. // ------------------------------------------------------------------------ { - mqbblp::Routers::Expressions expressions(s_allocator_p); + mqbblp::Routers::Expressions expressions( + bmqtst::TestHelperUtil::allocator()); - expressions.record(bmqp_ctrlmsg::Expression(s_allocator_p), - mqbblp::Routers::Expression()); + expressions.record( + bmqp_ctrlmsg::Expression(bmqtst::TestHelperUtil::allocator()), + mqbblp::Routers::Expression()); mqbi::QueueHandle* handle = 0; ++handle; - const bmqp_ctrlmsg::StreamParameters streamParameters(s_allocator_p); - mqbblp::Routers::Consumers consumers(s_allocator_p); + const bmqp_ctrlmsg::StreamParameters streamParameters( + bmqtst::TestHelperUtil::allocator()); + mqbblp::Routers::Consumers consumers(bmqtst::TestHelperUtil::allocator()); const unsigned int subQueueId = 13; mqbblp::Routers::Consumers::SharedItem consumer = consumers.record( handle, mqbblp::Routers::Consumer(streamParameters, subQueueId, - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); - mqbblp::Routers::Priority priority(s_allocator_p); + mqbblp::Routers::Priority priority(bmqtst::TestHelperUtil::allocator()); - priority.d_subscribers.record(handle, - mqbblp::Routers::Subscriber(consumer, - s_allocator_p)); + priority.d_subscribers.record( + handle, + mqbblp::Routers::Subscriber(consumer, + bmqtst::TestHelperUtil::allocator())); } static void test3_parse() @@ -230,18 +234,21 @@ static void test3_parse() // different priorities. // ------------------------------------------------------------------------ { - bmqp_ctrlmsg::StreamParameters streamParams(s_allocator_p); - bmqp::SchemaLearner schemaLearner(s_allocator_p); - mqbblp::Routers::QueueRoutingContext queueContext(schemaLearner, - s_allocator_p); + bmqp_ctrlmsg::StreamParameters streamParams( + bmqtst::TestHelperUtil::allocator()); + bmqp::SchemaLearner schemaLearner(bmqtst::TestHelperUtil::allocator()); + mqbblp::Routers::QueueRoutingContext queueContext( + schemaLearner, + bmqtst::TestHelperUtil::allocator()); unsigned int subQueueId = 13; - TestStorage storage(subQueueId, s_allocator_p); + TestStorage storage(subQueueId, bmqtst::TestHelperUtil::allocator()); mqbmock::QueueHandle handle1 = storage.getHandle(); - bmqp_ctrlmsg::SubQueueIdInfo subStreamInfo1(s_allocator_p); + bmqp_ctrlmsg::SubQueueIdInfo subStreamInfo1( + bmqtst::TestHelperUtil::allocator()); - bsl::string appId("foo", s_allocator_p); + bsl::string appId("foo", bmqtst::TestHelperUtil::allocator()); unsigned int upstreamSubQueueId = 1; subStreamInfo1.appId() = appId; subStreamInfo1.subId() = subQueueId; @@ -278,9 +285,11 @@ static void test3_parse() // One consumer with one subscription { - mqbblp::Routers::AppContext appContext(queueContext, - s_allocator_p); - bmqu::MemOutStream errorStream(s_allocator_p); + mqbblp::Routers::AppContext appContext( + queueContext, + bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream errorStream( + bmqtst::TestHelperUtil::allocator()); appContext.load(&handle1, &errorStream, subStreamInfo1.subId(), @@ -313,9 +322,11 @@ static void test3_parse() } handle1.setStreamParameters(streamParams); { - mqbblp::Routers::AppContext appContext(queueContext, - s_allocator_p); - bmqu::MemOutStream errorStream(s_allocator_p); + mqbblp::Routers::AppContext appContext( + queueContext, + bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream errorStream( + bmqtst::TestHelperUtil::allocator()); appContext.load(&handle1, &errorStream, @@ -341,7 +352,8 @@ static void test3_parse() } // Two consumers with two subscriptions mqbmock::QueueHandle handle2 = storage.getHandle(); - bmqp_ctrlmsg::SubQueueIdInfo subStreamInfo2(s_allocator_p); + bmqp_ctrlmsg::SubQueueIdInfo subStreamInfo2( + bmqtst::TestHelperUtil::allocator()); subStreamInfo2.appId() = appId; subStreamInfo2.subId() = 14; @@ -353,9 +365,11 @@ static void test3_parse() handle2.setStreamParameters(streamParams); { - mqbblp::Routers::AppContext appContext(queueContext, - s_allocator_p); - bmqu::MemOutStream errorStream(s_allocator_p); + mqbblp::Routers::AppContext appContext( + queueContext, + bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream errorStream( + bmqtst::TestHelperUtil::allocator()); mqbblp::Routers::RoundRobin router(appContext.d_priorities); @@ -437,15 +451,18 @@ static void test4_generate() // accumulated consumers. // ------------------------------------------------------------------------ { - bmqp_ctrlmsg::StreamParameters in(s_allocator_p); - bmqp::SchemaLearner schemaLearner(s_allocator_p); - mqbblp::Routers::QueueRoutingContext queueContext(schemaLearner, - s_allocator_p); + bmqp_ctrlmsg::StreamParameters in(bmqtst::TestHelperUtil::allocator()); + bmqp::SchemaLearner schemaLearner(bmqtst::TestHelperUtil::allocator()); + mqbblp::Routers::QueueRoutingContext queueContext( + schemaLearner, + bmqtst::TestHelperUtil::allocator()); unsigned int upstreamSubQueueId = 1; - mqbblp::Routers::AppContext appContext(queueContext, s_allocator_p); - bmqu::MemOutStream errorStream(s_allocator_p); + mqbblp::Routers::AppContext appContext( + queueContext, + bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream errorStream(bmqtst::TestHelperUtil::allocator()); - bsl::string appId("foo", s_allocator_p); + bsl::string appId("foo", bmqtst::TestHelperUtil::allocator()); int priorityCount = 2; int priority = 2; mqbmock::QueueHandle* handle = 0; @@ -484,7 +501,7 @@ static void test4_generate() ASSERT_EQ(errorStream.str(), ""); ASSERT_EQ(appContext.finalize(), 2 * size_t(priorityCount)); - bmqp_ctrlmsg::StreamParameters out(s_allocator_p); + bmqp_ctrlmsg::StreamParameters out(bmqtst::TestHelperUtil::allocator()); appContext.generate(&out); ASSERT_EQ(out.subscriptions().size(), size_t(1)); @@ -516,10 +533,10 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); - bmqt::UriParser::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); - mqbcfg::AppConfig brokerConfig(s_allocator_p); + mqbcfg::AppConfig brokerConfig(bmqtst::TestHelperUtil::allocator()); mqbcfg::BrokerConfig::set(brokerConfig); // expect BALL_LOG_ERROR switch (_testCase) { @@ -530,7 +547,7 @@ int main(int argc, char* argv[]) case 4: test4_generate(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbblp/mqbblp_storagemanager.cpp b/src/groups/mqb/mqbblp/mqbblp_storagemanager.cpp index dcd41f5e1..29a66d27b 100644 --- a/src/groups/mqb/mqbblp/mqbblp_storagemanager.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_storagemanager.cpp @@ -408,15 +408,12 @@ void StorageManager::queueCreationCb(int* status, status, &d_storages[partitionId], &d_storagesLock, - &d_appKeysVec[partitionId], - &d_appKeysLock, d_domainFactory_p, d_clusterData_p->identity().description(), partitionId, uri, queueKey, - appIdKeyPairs, - d_cluster_p->isCSLModeEnabled()); + appIdKeyPairs); } void StorageManager::queueDeletionCb(int* status, @@ -446,8 +443,6 @@ void StorageManager::queueDeletionCb(int* status, &d_storages[partitionId], &d_storagesLock, d_fileStores[partitionId].get(), - &d_appKeysVec[partitionId], - &d_appKeysLock, d_clusterData_p->identity().description(), partitionId, uri, @@ -479,8 +474,6 @@ void StorageManager::recoveredQueuesCb(int partitionId, &d_storages[partitionId], &d_storagesLock, d_fileStores[partitionId].get(), - &d_appKeysVec[partitionId], - &d_appKeysLock, d_domainFactory_p, &d_unrecognizedDomainsLock, &d_unrecognizedDomains[partitionId], @@ -1002,8 +995,6 @@ StorageManager::StorageManager( , d_partitionPrimaryStatusCb(partitionPrimaryStatusCb) , d_storagesLock() , d_storages(allocator) -, d_appKeysLock() -, d_appKeysVec(allocator) , d_storageMonitorEventHandle() , d_gcMessagesEventHandle() , d_recoveredPrimaryLeaseIds(allocator) @@ -1025,7 +1016,6 @@ StorageManager::StorageManager( d_storages.resize(partitionCfg.numPartitions()); d_recoveredPrimaryLeaseIds.resize(partitionCfg.numPartitions()); d_partitionInfoVec.resize(partitionCfg.numPartitions()); - d_appKeysVec.resize(partitionCfg.numPartitions()); d_minimumRequiredDiskSpace = mqbc::StorageUtil::findMinReqDiskSpace( partitionCfg); @@ -1066,8 +1056,6 @@ void StorageManager::registerQueue(const bmqt::Uri& uri, &d_storages[partitionId], &d_storagesLock, d_fileStores[partitionId].get(), - &d_appKeysVec[partitionId], - &d_appKeysLock, &d_allocators, processorForPartition(partitionId), uri, @@ -1123,15 +1111,12 @@ int StorageManager::updateQueuePrimary(const bmqt::Uri& uri, &d_storages[partitionId], &d_storagesLock, d_fileStores[partitionId].get(), - &d_appKeysVec[partitionId], - &d_appKeysLock, d_clusterData_p->identity().description(), uri, queueKey, partitionId, addedIdKeyPairs, - removedIdKeyPairs, - d_cluster_p->isCSLModeEnabled()); + removedIdKeyPairs); } void StorageManager::registerQueueReplica(int partitionId, @@ -1211,8 +1196,6 @@ void StorageManager::unregisterQueueReplica(int partitionId, &d_storages[partitionId], &d_storagesLock, d_fileStores[partitionId].get(), - &d_appKeysVec[partitionId], - &d_appKeysLock, d_clusterData_p->identity().description(), partitionId, uri, @@ -1256,15 +1239,12 @@ void StorageManager::updateQueueReplica(int partitionId, static_cast(0), &d_storages[partitionId], &d_storagesLock, - &d_appKeysVec[partitionId], - &d_appKeysLock, d_domainFactory_p, d_clusterData_p->identity().description(), partitionId, uri, queueKey, appIdKeyPairs, - d_cluster_p->isCSLModeEnabled(), domain, allowDuplicate)); diff --git a/src/groups/mqb/mqbblp/mqbblp_storagemanager.h b/src/groups/mqb/mqbblp/mqbblp_storagemanager.h index 6ff9ba213..12e877f17 100644 --- a/src/groups/mqb/mqbblp/mqbblp_storagemanager.h +++ b/src/groups/mqb/mqbblp/mqbblp_storagemanager.h @@ -272,8 +272,7 @@ class StorageManager : public mqbi::StorageManager { mutable bslmt::Mutex d_storagesLock; // Mutex to protect access to // 'd_storages' and its elements. See - // comments for 'd_storages' and - // 'd_appKeysLock' variables as well. + // comments for 'd_storages'. StorageSpMapVec d_storages; // Vector of (CanonicalQueueUri -> @@ -288,39 +287,6 @@ class StorageManager : public mqbi::StorageManager { // partitions' dispatcher threads, as // well as cluster dispatcher thread. - bslmt::Mutex d_appKeysLock; - // Mutex to protect access to - // 'd_appKeysVec' and its elements. - // Note that when acquiring this lock, - // *if* 'd_storagesLock' needs to be - // acquired as well, 'd_storagesLock' - // must be acquired before - // 'd_appKeysLock' in order to respect - // hierarchy of locks and avoid - // deadlock. Also note that it is not - // necessary to acquire one when - // acquiring the other. - - AppKeysVec d_appKeysVec; - // Vector of set of AppKeys which are - // currently active. Vector is indexed - // on the partitionId, and the inner - // set contains a unique list of - // appKeys of virtual storages of the - // physical storages assigned to that - // partition. Contains appKeys for - // *both* in-memory as well as - // file-backed 'physical' storages. - // Note that the corresponding virtual - // storages are owned by the physical - // storage. Also note that - // 'd_appKeysLock' must be held while - // accessing this container and any of - // its elements, because they are - // accessed from partitions' dispatcher - // threads as well as cluster - // dispatcher threads. - RecurringEventHandle d_storageMonitorEventHandle; RecurringEventHandle d_gcMessagesEventHandle; diff --git a/src/groups/mqb/mqbc/mqbc_clusterstateledger.t.cpp b/src/groups/mqb/mqbc/mqbc_clusterstateledger.t.cpp index a41e442dd..b32af2960 100644 --- a/src/groups/mqb/mqbc/mqbc_clusterstateledger.t.cpp +++ b/src/groups/mqb/mqbc/mqbc_clusterstateledger.t.cpp @@ -173,8 +173,8 @@ static void test1_clusterStateLedger_protocol() bmqtst::TestHelper::printTestName("CLUSTER STATE LEDGER - PROTOCOL TEST"); PV("Creating a test object"); - bsls::ProtocolTest testObj(s_verbosityLevel > - 2); + bsls::ProtocolTest testObj( + bmqtst::TestHelperUtil::verbosityLevel() > 2); PV("Verify that the protocol is abstract"); ASSERT(testObj.testAbstract()); @@ -306,7 +306,7 @@ static void test3_commitStatus_toAscii() PVV(test.d_line << ": Testing: toAscii(" << test.d_value << ") == " << test.d_expected); - bsl::string ascii(s_allocator_p); + bsl::string ascii(bmqtst::TestHelperUtil::allocator()); ascii = mqbc::ClusterStateLedgerCommitStatus::toAscii( mqbc::ClusterStateLedgerCommitStatus::Enum(test.d_value)); @@ -353,7 +353,7 @@ static void test4_commitStatus_print() << ") == " << test.d_expected); // 1. - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); mqbc::ClusterStateLedgerCommitStatus::Enum obj( static_cast( test.d_value)); @@ -363,7 +363,7 @@ static void test4_commitStatus_print() PVV(test.d_line << ": '" << out.str()); - bsl::string expected(s_allocator_p); + bsl::string expected(bmqtst::TestHelperUtil::allocator()); expected.assign(test.d_expected); expected.append("\n"); ASSERT_EQ_D(test.d_line, out.str(), expected); @@ -475,7 +475,7 @@ static void test6_clusterStateLedgerConsistency_toAscii() PVV(test.d_line << ": Testing: toAscii(" << test.d_value << ") == " << test.d_expected); - bsl::string ascii(s_allocator_p); + bsl::string ascii(bmqtst::TestHelperUtil::allocator()); ascii = mqbc::ClusterStateLedgerConsistency::toAscii( mqbc::ClusterStateLedgerConsistency::Enum(test.d_value)); @@ -523,7 +523,7 @@ static void test7_clusterStateLedgerConsistency_print() << ") == " << test.d_expected); // 1. - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); mqbc::ClusterStateLedgerConsistency::Enum obj( static_cast( test.d_value)); @@ -533,7 +533,7 @@ static void test7_clusterStateLedgerConsistency_print() PVV(test.d_line << ": '" << out.str()); - bsl::string expected(s_allocator_p); + bsl::string expected(bmqtst::TestHelperUtil::allocator()); expected.assign(test.d_expected); expected.append("\n"); ASSERT_EQ_D(test.d_line, out.str(), expected); @@ -572,7 +572,7 @@ int main(int argc, char* argv[]) case 1: test1_clusterStateLedger_protocol(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbc/mqbc_clusterstateledgeriterator.t.cpp b/src/groups/mqb/mqbc/mqbc_clusterstateledgeriterator.t.cpp index 07487d3b8..ea3389dc8 100644 --- a/src/groups/mqb/mqbc/mqbc_clusterstateledgeriterator.t.cpp +++ b/src/groups/mqb/mqbc/mqbc_clusterstateledgeriterator.t.cpp @@ -147,7 +147,7 @@ static void test1_clusterStateLedgerIterator_protocol() PV("Creating a test object"); bsls::ProtocolTest testObj( - s_verbosityLevel > 2); + bmqtst::TestHelperUtil::verbosityLevel() > 2); PV("Verify that the protocol is abstract"); ASSERT(testObj.testAbstract()); @@ -162,7 +162,7 @@ static void test1_clusterStateLedgerIterator_protocol() PV("Verify that methods are public and virtual"); mqbmock::ClusterStateLedgerIterator::LedgerRecords records( - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbmock::ClusterStateLedgerIterator cslIter(records); bmqp_ctrlmsg::ClusterMessage clusterMessage; bmqu::MemOutStream os; @@ -189,7 +189,7 @@ int main(int argc, char* argv[]) case 1: test1_clusterStateLedgerIterator_protocol(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbc/mqbc_clusterstateledgerprotocol.t.cpp b/src/groups/mqb/mqbc/mqbc_clusterstateledgerprotocol.t.cpp index e22e757d0..92f5b02c2 100644 --- a/src/groups/mqb/mqbc/mqbc_clusterstateledgerprotocol.t.cpp +++ b/src/groups/mqb/mqbc/mqbc_clusterstateledgerprotocol.t.cpp @@ -134,8 +134,8 @@ static void printEnumHelper(ARRAY (&data)[SIZE]) PVVV("Line [" << test.d_line << "]"); - bmqu::MemOutStream out(s_allocator_p); - bmqu::MemOutStream expected(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream expected(bmqtst::TestHelperUtil::allocator()); typedef typename ENUM_TYPE::Enum T; @@ -216,7 +216,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbc/mqbc_clusterstateledgerutil.t.cpp b/src/groups/mqb/mqbc/mqbc_clusterstateledgerutil.t.cpp index 1881ce711..6ad721df6 100644 --- a/src/groups/mqb/mqbc/mqbc_clusterstateledgerutil.t.cpp +++ b/src/groups/mqb/mqbc/mqbc_clusterstateledgerutil.t.cpp @@ -102,7 +102,7 @@ struct Tester { public: // CREATORS - Tester(bslma::Allocator* allocator = s_allocator_p) + Tester(bslma::Allocator* allocator = bmqtst::TestHelperUtil::allocator()) : d_config(allocator) , d_ledger_mp(0) , d_tempDir(allocator) @@ -354,7 +354,8 @@ static void test4_validateLog() AdvisoryType::e_PARTITION_PRIMARY, lms1); - bdlbb::Blob record1(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob record1(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); rc = mqbc::ClusterStateLedgerUtil::appendRecord( &record1, msg1, @@ -380,7 +381,8 @@ static void test4_validateLog() AdvisoryType::e_QUEUE_ASSIGNMENT, lms2); - bdlbb::Blob record2(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob record2(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); rc = mqbc::ClusterStateLedgerUtil::appendRecord( &record2, msg2, @@ -404,7 +406,8 @@ static void test4_validateLog() bmqp_ctrlmsg::ClusterMessage msg3; Tester::createClusterMessage(&msg3, AdvisoryType::e_COMMIT, lms3); - bdlbb::Blob record3(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob record3(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); rc = mqbc::ClusterStateLedgerUtil::appendRecord( &record3, msg3, @@ -428,7 +431,8 @@ static void test4_validateLog() PVV("offset: " << offset); // 4. Write an invalid record - bdlbb::Blob record4(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob record4(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterStateRecordHeader recordHeader; recordHeader .setHeaderWords(mqbc::ClusterStateRecordHeader::k_HEADER_NUM_WORDS) @@ -486,7 +490,8 @@ static void test5_validateLog_invalidCrc32c() AdvisoryType::e_QUEUE_ASSIGNMENT, lms1); - bdlbb::Blob record1(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob record1(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); rc = mqbc::ClusterStateLedgerUtil::appendRecord( &record1, msg1, @@ -518,7 +523,8 @@ static void test5_validateLog_invalidCrc32c() AdvisoryType::e_QUEUE_ASSIGNMENT, lms2); - bdlbb::Blob record2(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob record2(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); rc = mqbc::ClusterStateLedgerUtil::appendRecord( &record2, msg2, @@ -610,7 +616,8 @@ static void test7_appendRecord() bmqp_ctrlmsg::ClusterMessage msg; Tester::createClusterMessage(&msg, AdvisoryType::e_QUEUE_ASSIGNMENT, lms); - bdlbb::Blob record(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob record(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); int rc = mqbc::ClusterStateLedgerUtil::appendRecord( &record, msg, @@ -676,7 +683,8 @@ static void test8_loadClusterMessageLedger() bmqp_ctrlmsg::ClusterMessage msg; Tester::createClusterMessage(&msg, AdvisoryType::e_QUEUE_ASSIGNMENT, lms); - bdlbb::Blob record(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob record(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); int rc = mqbc::ClusterStateLedgerUtil::appendRecord( &record, msg, @@ -751,7 +759,8 @@ static void test9_loadClusterMessageBlob() bmqp_ctrlmsg::ClusterMessage msg; Tester::createClusterMessage(&msg, AdvisoryType::e_QUEUE_ASSIGNMENT, lms); - bdlbb::Blob record(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob record(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); int rc = mqbc::ClusterStateLedgerUtil::appendRecord( &record, msg, @@ -832,8 +841,8 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqsys::Time::initialize(s_allocator_p); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqsys::Time::initialize(bmqtst::TestHelperUtil::allocator()); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); bmqp::Crc32c::initialize(); switch (_testCase) { @@ -850,7 +859,7 @@ int main(int argc, char* argv[]) case 10: test10_recordSize(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbc/mqbc_clusterstatemanager.t.cpp b/src/groups/mqb/mqbc/mqbc_clusterstatemanager.t.cpp index 24d31a1a5..6733ff85e 100644 --- a/src/groups/mqb/mqbc/mqbc_clusterstatemanager.t.cpp +++ b/src/groups/mqb/mqbc/mqbc_clusterstatemanager.t.cpp @@ -96,55 +96,57 @@ struct Tester { public: // CREATORS Tester(bool isLeader) - : d_bufferFactory(1024, s_allocator_p) - , d_tempDir(s_allocator_p) + : d_bufferFactory(1024, bmqtst::TestHelperUtil::allocator()) + , d_tempDir(bmqtst::TestHelperUtil::allocator()) , d_cluster_mp(0) , d_clusterStateLedger_p(0) , d_clusterStateManager_mp(0) , d_storageManager() { // Create the cluster - mqbmock::Cluster::ClusterNodeDefs clusterNodeDefs(s_allocator_p); + mqbmock::Cluster::ClusterNodeDefs clusterNodeDefs( + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "E1", "US-EAST", 41234, mqbmock::Cluster::k_LEADER_NODE_ID, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "E2", "US-EAST", 41235, mqbmock::Cluster::k_LEADER_NODE_ID + 1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "W1", "US-WEST", 41236, mqbmock::Cluster::k_LEADER_NODE_ID + 2, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "W2", "US-WEST", 41237, mqbmock::Cluster::k_LEADER_NODE_ID + 3, - s_allocator_p); - - d_cluster_mp.load(new (*s_allocator_p) - mqbmock::Cluster(&d_bufferFactory, - s_allocator_p, - true, // isClusterMember - isLeader, - true, // isCSLMode - true, // isFSMWorkflow - clusterNodeDefs, - "testCluster", - d_tempDir.path()), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + + d_cluster_mp.load( + new (*bmqtst::TestHelperUtil::allocator()) + mqbmock::Cluster(&d_bufferFactory, + bmqtst::TestHelperUtil::allocator(), + true, // isClusterMember + isLeader, + true, // isCSLMode + true, // isFSMWorkflow + clusterNodeDefs, + "testCluster", + d_tempDir.path()), + bmqtst::TestHelperUtil::allocator()); d_cluster_mp->_clusterData()->stats().setIsMember(true); BSLS_ASSERT_OPT(d_cluster_mp->_channels().size() > 0); @@ -153,28 +155,29 @@ struct Tester { &bsls::SystemTime::nowRealtimeClock, bdlf::BindUtil::bind(&Tester::nowMonotonicClock, this), bdlf::BindUtil::bind(&Tester::highResolutionTimer, this), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Create the cluster state ledger ClusterStateLedgerMp clusterStateLedger_mp( - new (*s_allocator_p) - mqbmock::ClusterStateLedger(d_cluster_mp->_clusterData(), - s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + mqbmock::ClusterStateLedger( + d_cluster_mp->_clusterData(), + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); d_clusterStateLedger_p = dynamic_cast( clusterStateLedger_mp.get()); // Create the cluster state manager d_clusterStateManager_mp.load( - new (*s_allocator_p) + new (*bmqtst::TestHelperUtil::allocator()) mqbc::ClusterStateManager(d_cluster_mp->_clusterDefinition(), d_cluster_mp.get(), d_cluster_mp->_clusterData(), &d_cluster_mp->_state(), clusterStateLedger_mp, k_WATCHDOG_TIMEOUT_DURATION, - s_allocator_p), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); d_clusterStateManager_mp->setStorageManager(&d_storageManager); // Start the cluster and the cluster state manager @@ -303,7 +306,7 @@ struct Tester { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message.choice().clusterMessage(), expectedMessage); } } @@ -335,7 +338,7 @@ struct Tester { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message, expectedMessage); } else { @@ -366,7 +369,7 @@ struct Tester { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message, expectedMessage); } else { @@ -403,7 +406,7 @@ struct Tester { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message.choice().clusterMessage(), expectedMessage); } else { @@ -436,7 +439,7 @@ struct Tester { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message, expectedMessage); } else { @@ -487,7 +490,7 @@ struct Tester { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(message.choice().clusterMessage() == expectedFollowerClusterStateRequest); } @@ -531,7 +534,7 @@ struct Tester { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message, expectedMessage); } else { @@ -2590,7 +2593,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); bmqp::Crc32c::initialize(); switch (_testCase) { @@ -2622,7 +2625,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTestLeader(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbc/mqbc_clusterutil.cpp b/src/groups/mqb/mqbc/mqbc_clusterutil.cpp index 8b9ae5668..63172674e 100644 --- a/src/groups/mqb/mqbc/mqbc_clusterutil.cpp +++ b/src/groups/mqb/mqbc/mqbc_clusterutil.cpp @@ -1197,32 +1197,6 @@ void ClusterUtil::registerQueueInfo(ClusterState* clusterState, queueAssigningCb(uri, false); // processingPendingRequests } -void ClusterUtil::populateAppInfos(AppInfos* appInfos, - const mqbconfm::QueueMode& domainConfig) -{ - // PRECONDITIONS - BSLS_ASSERT_SAFE(appInfos && appInfos->empty()); - - if (domainConfig.isFanoutValue()) { - const bsl::vector& cfgAppIds = - domainConfig.fanout().appIDs(); - bsl::unordered_set appKeys; - - for (bsl::vector::const_iterator cit = cfgAppIds.begin(); - cit != cfgAppIds.end(); - ++cit) { - mqbu::StorageKey appKey; - mqbs::StorageUtil::generateStorageKey(&appKey, &appKeys, *cit); - - appInfos->insert(AppInfo(*cit, appKey)); - } - } - else { - appInfos->insert(AppInfo(bmqp::ProtocolUtil::k_DEFAULT_APP_ID, - mqbi::QueueEngine::k_DEFAULT_APP_KEY)); - } -} - void ClusterUtil::populateAppInfos( bsl::vector* appInfos, const mqbconfm::QueueMode& domainConfig) diff --git a/src/groups/mqb/mqbc/mqbc_clusterutil.h b/src/groups/mqb/mqbc/mqbc_clusterutil.h index 3eb4f648e..171416a17 100644 --- a/src/groups/mqb/mqbc/mqbc_clusterutil.h +++ b/src/groups/mqb/mqbc/mqbc_clusterutil.h @@ -276,8 +276,6 @@ struct ClusterUtil { /// Generate appKeys based on the appIds in the specified `domainConfig` /// and populate them into the specified `appIdInfos`. - static void populateAppInfos(AppInfos* appIdInfos, - const mqbconfm::QueueMode& domainConfig); static void populateAppInfos(bsl::vector* appIdInfos, const mqbconfm::QueueMode& domainConfig); diff --git a/src/groups/mqb/mqbc/mqbc_incoreclusterstateledger.t.cpp b/src/groups/mqb/mqbc/mqbc_incoreclusterstateledger.t.cpp index 13700f07d..102849872 100644 --- a/src/groups/mqb/mqbc/mqbc_incoreclusterstateledger.t.cpp +++ b/src/groups/mqb/mqbc/mqbc_incoreclusterstateledger.t.cpp @@ -204,57 +204,61 @@ struct Tester { public: // CREATORS Tester(bool isLeader = true, const bslstl::StringRef& location = "") - : d_bufferFactory(1024, s_allocator_p) + : d_bufferFactory(1024, bmqtst::TestHelperUtil::allocator()) , d_consistencyLevel(mqbc::ClusterStateLedgerConsistency::e_EVENTUAL) - , d_tempDir(s_allocator_p) - , d_location(!location.empty() ? bsl::string(location, s_allocator_p) - : d_tempDir.path()) + , d_tempDir(bmqtst::TestHelperUtil::allocator()) + , d_location( + !location.empty() + ? bsl::string(location, bmqtst::TestHelperUtil::allocator()) + : d_tempDir.path()) , d_cluster_mp(0) , d_clusterStateLedger_mp(0) - , d_committedMessages(s_allocator_p) + , d_committedMessages(bmqtst::TestHelperUtil::allocator()) , d_commitCounter(0) { - mqbmock::Cluster::ClusterNodeDefs clusterNodeDefs(s_allocator_p); + mqbmock::Cluster::ClusterNodeDefs clusterNodeDefs( + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "E1", "US-EAST", 41234, mqbmock::Cluster::k_LEADER_NODE_ID, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "E2", "US-EAST", 41235, mqbmock::Cluster::k_LEADER_NODE_ID + 1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "W1", "US-WEST", 41236, mqbmock::Cluster::k_LEADER_NODE_ID + 2, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "W2", "US-WEST", 41237, mqbmock::Cluster::k_LEADER_NODE_ID + 3, - s_allocator_p); - - d_cluster_mp.load(new (*s_allocator_p) - mqbmock::Cluster(&d_bufferFactory, - s_allocator_p, - true, // isClusterMember - isLeader, - true, // isCSLMode - false, // isFSMWorkflow - clusterNodeDefs, - "testCluster", - d_location), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + + d_cluster_mp.load( + new (*bmqtst::TestHelperUtil::allocator()) + mqbmock::Cluster(&d_bufferFactory, + bmqtst::TestHelperUtil::allocator(), + true, // isClusterMember + isLeader, + true, // isCSLMode + false, // isFSMWorkflow + clusterNodeDefs, + "testCluster", + d_location), + bmqtst::TestHelperUtil::allocator()); // Set cluster state's leader node: One node is selected to serve as // leader (1st among the nodes of the cluster) @@ -282,14 +286,15 @@ struct Tester { } d_clusterStateLedger_mp.load( - new (*s_allocator_p) mqbc::IncoreClusterStateLedger( - d_cluster_mp->_clusterDefinition(), - d_consistencyLevel, - d_cluster_mp->_clusterData(), - &d_cluster_mp->_state(), - d_cluster_mp->_bufferFactory(), - s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + mqbc::IncoreClusterStateLedger( + d_cluster_mp->_clusterDefinition(), + d_consistencyLevel, + d_cluster_mp->_clusterData(), + &d_cluster_mp->_state(), + d_cluster_mp->_bufferFactory(), + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); d_clusterStateLedger_mp->setCommitCb( bdlf::BindUtil::bind(&Tester::onCommitCb, this, @@ -334,7 +339,8 @@ struct Tester { BSLS_ASSERT_OPT(event); // Create ledger record - bdlbb::Blob record(d_cluster_mp->_bufferFactory(), s_allocator_p); + bdlbb::Blob record(d_cluster_mp->_bufferFactory(), + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT( mqbc::ClusterStateLedgerUtil::appendRecord(&record, clusterMessage, @@ -434,7 +440,8 @@ struct Tester { } } - bdlbb::Blob record(d_cluster_mp->_bufferFactory(), s_allocator_p); + bdlbb::Blob record(d_cluster_mp->_bufferFactory(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&record, *blob, sizeof(bmqp::EventHeader)); bmqp_ctrlmsg::ControlMessage controlMessage; @@ -455,12 +462,12 @@ struct Tester { ~Tester() { - bsl::string pattern(s_allocator_p); + bsl::string pattern(bmqtst::TestHelperUtil::allocator()); pattern.append( d_cluster_mp->_clusterDefinition().partitionConfig().location()); pattern.append("bmq_cs_*.bmq"); - bsl::vector files(s_allocator_p); + bsl::vector files(bmqtst::TestHelperUtil::allocator()); bdls::FilesystemUtil::findMatchingPaths(&files, pattern.c_str()); for (size_t i = 0; i < files.size(); ++i) { bsl::remove(files[i].c_str()); @@ -792,7 +799,7 @@ static void test7_apply_ClusterStateRecord() updateMessage.choice().makePartitionPrimaryAdvisory(pmAdvisory); bdlbb::Blob updateEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&updateEvent, updateMessage, pmAdvisory.sequenceNumber(), @@ -840,7 +847,7 @@ static void test7_apply_ClusterStateRecord() snapshotMessage.choice().makeLeaderAdvisory(leaderAdvisory); bdlbb::Blob snapshotEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&snapshotEvent, snapshotMessage, leaderAdvisory.sequenceNumber(), @@ -922,7 +929,8 @@ static void test8_apply_ClusterStateRecordAck() bmqp_ctrlmsg::ClusterMessage message; message.choice().makeLeaderAdvisoryAck(ack); - bdlbb::Blob ackEvent(tester.d_cluster_mp->_bufferFactory(), s_allocator_p); + bdlbb::Blob ackEvent(tester.d_cluster_mp->_bufferFactory(), + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&ackEvent, message, ack.sequenceNumberAcked(), @@ -972,7 +980,7 @@ static void test9_apply_ClusterStateRecordCommit() advisoryMessage.choice().makePartitionPrimaryAdvisory(advisory); bdlbb::Blob advisoryEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&advisoryEvent, advisoryMessage, advisory.sequenceNumber(), @@ -998,7 +1006,7 @@ static void test9_apply_ClusterStateRecordCommit() commitMessage.choice().makeLeaderAdvisoryCommit(commit); bdlbb::Blob commitEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&commitEvent, commitMessage, commit.sequenceNumber(), @@ -1298,7 +1306,7 @@ static void test11_persistanceFollower() .nextLeaderMessageSequence(&pmAdvisory.sequenceNumber()); bdlbb::Blob pmAdvisoryEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&pmAdvisoryEvent, pmAdvisoryMsg, pmAdvisory.sequenceNumber(), @@ -1327,7 +1335,7 @@ static void test11_persistanceFollower() qAssignAdvisory.queues().push_back(qinfo); bdlbb::Blob qAssignAdvisoryEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&qAssignAdvisoryEvent, qAssignAdvisoryMsg, qAssignAdvisory.sequenceNumber(), @@ -1349,7 +1357,7 @@ static void test11_persistanceFollower() qUnassignedAdvisory.queues().push_back(qinfo); bdlbb::Blob qUnassignedAdvisoryEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&qUnassignedAdvisoryEvent, qUnassignedAdvisoryMsg, qUnassignedAdvisory.sequenceNumber(), @@ -1394,7 +1402,7 @@ static void test11_persistanceFollower() qUpdateAdvisory.queueUpdates().push_back(qupdate); bdlbb::Blob qUpdateAdvisoryEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&qUpdateAdvisoryEvent, qUpdateAdvisoryMsg, qUpdateAdvisory.sequenceNumber(), @@ -1428,7 +1436,7 @@ static void test11_persistanceFollower() .nextLeaderMessageSequence(&leaderAdvisory.sequenceNumber()); bdlbb::Blob leaderAdvisoryEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&leaderAdvisoryEvent, leaderAdvisoryMsg, leaderAdvisory.sequenceNumber(), @@ -1449,7 +1457,7 @@ static void test11_persistanceFollower() commit.sequenceNumberCommitted() = leaderAdvisory.sequenceNumber(); bdlbb::Blob commitEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&commitEvent, commitMsg, commit.sequenceNumber(), @@ -1581,7 +1589,7 @@ static void test12_persistanceAcrossRollover() // Build 'QueueAssignmentAdvisory' bmqp_ctrlmsg::QueueAssignmentAdvisory qadvisory; for (size_t i = 0; i < 50; ++i) { - bmqu::MemOutStream uriStream(s_allocator_p); + bmqu::MemOutStream uriStream(bmqtst::TestHelperUtil::allocator()); uriStream << "bmq://bmq.test.mmap.priority/q" << i; bmqp_ctrlmsg::QueueInfo qinfo; @@ -1629,7 +1637,8 @@ static void test12_persistanceAcrossRollover() sleep(1); // 2. Apply some more advisories and "save" them in a list - bsl::vector lastAdvisories(s_allocator_p); + bsl::vector lastAdvisories( + bmqtst::TestHelperUtil::allocator()); bmqp_ctrlmsg::ControlMessage advisoryToCauseRollover; advisoryToCauseRollover.choice() @@ -1830,7 +1839,8 @@ static void test13_rolloverUncommittedAdvisories() ASSERT_EQ(obj->ledger()->numLogs(), 1U); // 1. Apply some advisory to remain uncommitted - bsl::vector uncommittedAdvisories(s_allocator_p); + bsl::vector uncommittedAdvisories( + bmqtst::TestHelperUtil::allocator()); // Apply 'PartitionPrimaryAdvisory' bmqp_ctrlmsg::PartitionPrimaryInfo pinfo; @@ -1847,7 +1857,7 @@ static void test13_rolloverUncommittedAdvisories() .nextLeaderMessageSequence(&pmAdvisory.sequenceNumber()); bdlbb::Blob pmAdvisoryEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&pmAdvisoryEvent, pmAdvisoryMsg, pmAdvisory.sequenceNumber(), @@ -1889,7 +1899,7 @@ static void test13_rolloverUncommittedAdvisories() qUnassignedAdvisory.queues().push_back(qinfo); bdlbb::Blob qUnassignedAdvisoryEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&qUnassignedAdvisoryEvent, qUnassignedAdvisoryMsg, qUnassignedAdvisory.sequenceNumber(), @@ -1936,7 +1946,7 @@ static void test13_rolloverUncommittedAdvisories() .nextLeaderMessageSequence(&leaderAdvisory.sequenceNumber()); bdlbb::Blob leaderAdvisoryEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&leaderAdvisoryEvent, leaderAdvisoryMsg, leaderAdvisory.sequenceNumber(), @@ -1967,7 +1977,7 @@ static void test13_rolloverUncommittedAdvisories() bmqp_ctrlmsg::QueueAssignmentAdvisory& qAssignAdvisory = qAssignAdvisoryMsg.choice().makeQueueAssignmentAdvisory(); for (size_t i = 0; i < 50; ++i) { - bmqu::MemOutStream uriStream(s_allocator_p); + bmqu::MemOutStream uriStream(bmqtst::TestHelperUtil::allocator()); uriStream << "bmq://bmq.test.mmap.priority/q" << i; bmqp_ctrlmsg::QueueInfo queueInfo; @@ -1998,7 +2008,7 @@ static void test13_rolloverUncommittedAdvisories() .nextLeaderMessageSequence(&qAssignAdvisory.sequenceNumber()); bdlbb::Blob qAssignAdvisoryEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&qAssignAdvisoryEvent, qAssignAdvisoryMsg, qAssignAdvisory.sequenceNumber(), @@ -2016,7 +2026,7 @@ static void test13_rolloverUncommittedAdvisories() commit.sequenceNumberCommitted() = qAssignAdvisory.sequenceNumber(); bdlbb::Blob commitEvent(tester.d_cluster_mp->_bufferFactory(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); tester.constructEventBlob(&commitEvent, commitMsg, commit.sequenceNumber(), @@ -2127,10 +2137,10 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqsys::Time::initialize(s_allocator_p); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqsys::Time::initialize(bmqtst::TestHelperUtil::allocator()); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); bmqp::Crc32c::initialize(); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -2149,7 +2159,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbc/mqbc_incoreclusterstateledgeriterator.t.cpp b/src/groups/mqb/mqbc/mqbc_incoreclusterstateledgeriterator.t.cpp index ddf2ff07b..af6f372db 100644 --- a/src/groups/mqb/mqbc/mqbc_incoreclusterstateledgeriterator.t.cpp +++ b/src/groups/mqb/mqbc/mqbc_incoreclusterstateledgeriterator.t.cpp @@ -213,7 +213,7 @@ void writeRecord(bsl::vector* recordInfos, const mqbc::ClusterStateRecordType::Enum recordType = createClusterMessage(&msg, advisoryType, sequenceNumber); - bdlbb::Blob record(bufferFactory, s_allocator_p); + bdlbb::Blob record(bufferFactory, bmqtst::TestHelperUtil::allocator()); int rc = mqbc::ClusterStateLedgerUtil::appendRecord(&record, msg, sequenceNumber, @@ -249,7 +249,7 @@ struct Tester { public: // CREATORS Tester(bsls::Types::Int64 maxLogSize = k_LOG_MAX_SIZE, - bslma::Allocator* allocator = s_allocator_p) + bslma::Allocator* allocator = bmqtst::TestHelperUtil::allocator()) : d_logIdGenerator_sp(0) , d_logFactory_sp(0) , d_tempDir(allocator) @@ -454,8 +454,8 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqsys::Time::initialize(s_allocator_p); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqsys::Time::initialize(bmqtst::TestHelperUtil::allocator()); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); bmqp::Crc32c::initialize(); switch (_testCase) { @@ -463,7 +463,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbc/mqbc_storagemanager.cpp b/src/groups/mqb/mqbc/mqbc_storagemanager.cpp index fcd681715..860937cc8 100644 --- a/src/groups/mqb/mqbc/mqbc_storagemanager.cpp +++ b/src/groups/mqb/mqbc/mqbc_storagemanager.cpp @@ -143,8 +143,6 @@ void StorageManager::recoveredQueuesCb(int partitionId, StorageUtil::recoveredQueuesCb(&d_storages[partitionId], &d_storagesLock, d_fileStores[partitionId].get(), - &d_appKeysVec[partitionId], - &d_appKeysLock, d_domainFactory_p, &d_unrecognizedDomainsLock, &d_unrecognizedDomains[partitionId], @@ -3357,8 +3355,6 @@ StorageManager::StorageManager( , d_partitionPrimaryStatusCb(partitionPrimaryStatusCb) , d_storagesLock() , d_storages(allocator) -, d_appKeysLock() -, d_appKeysVec(allocator) , d_partitionInfoVec(allocator) , d_partitionFSMVec(allocator) , d_bufferedPrimaryStatusAdvisoryInfosVec(allocator) @@ -3391,7 +3387,6 @@ StorageManager::StorageManager( d_unrecognizedDomains.resize(partitionCfg.numPartitions()); d_fileStores.resize(partitionCfg.numPartitions()); d_storages.resize(partitionCfg.numPartitions()); - d_appKeysVec.resize(partitionCfg.numPartitions()); d_partitionInfoVec.resize(partitionCfg.numPartitions()); d_bufferedPrimaryStatusAdvisoryInfosVec.resize( partitionCfg.numPartitions(), @@ -3678,8 +3673,6 @@ void StorageManager::registerQueue( &d_storages[partitionId], &d_storagesLock, d_fileStores[partitionId].get(), - &d_appKeysVec[partitionId], - &d_appKeysLock, &d_allocators, processorForPartition(partitionId), uri, @@ -3735,15 +3728,12 @@ int StorageManager::updateQueuePrimary(const bmqt::Uri& uri, &d_storages[partitionId], &d_storagesLock, d_fileStores[partitionId].get(), - &d_appKeysVec[partitionId], - &d_appKeysLock, d_clusterData_p->identity().description(), uri, queueKey, partitionId, addedIdKeyPairs, - removedIdKeyPairs, - true); // isCSLMode + removedIdKeyPairs); } void StorageManager::registerQueueReplica(int partitionId, @@ -3805,8 +3795,6 @@ void StorageManager::unregisterQueueReplica(int partitionId, &d_storages[partitionId], &d_storagesLock, d_fileStores[partitionId].get(), - &d_appKeysVec[partitionId], - &d_appKeysLock, d_clusterData_p->identity().description(), partitionId, uri, @@ -3842,15 +3830,12 @@ void StorageManager::updateQueueReplica(int partitionId, static_cast(0), &d_storages[partitionId], &d_storagesLock, - &d_appKeysVec[partitionId], - &d_appKeysLock, d_domainFactory_p, d_clusterData_p->identity().description(), partitionId, uri, queueKey, appIdKeyPairs, - true, // isCSLMode domain, allowDuplicate)); diff --git a/src/groups/mqb/mqbc/mqbc_storagemanager.h b/src/groups/mqb/mqbc/mqbc_storagemanager.h index 5ba16299b..7a23cfc69 100644 --- a/src/groups/mqb/mqbc/mqbc_storagemanager.h +++ b/src/groups/mqb/mqbc/mqbc_storagemanager.h @@ -285,8 +285,7 @@ class StorageManager mutable bslmt::Mutex d_storagesLock; // Mutex to protect access to // 'd_storages' and its elements. See - // comments for 'd_storages' and - // 'd_appKeysLock' variables as well. + // comments for 'd_storages'. StorageSpMapVec d_storages; // Vector of (CanonicalQueueUri -> @@ -303,41 +302,6 @@ class StorageManager // // THREAD: Protected by 'd_storagesLock'. - bslmt::Mutex d_appKeysLock; - // Mutex to protect access to - // 'd_appKeysVec' and its elements. - // Note that when acquiring this lock, - // *if* 'd_storagesLock' needs to be - // acquired as well, 'd_storagesLock' - // must be acquired before - // 'd_appKeysLock' in order to respect - // hierarchy of locks and avoid - // deadlock. Also note that it is not - // necessary to acquire one when - // acquiring the other. - - AppKeysVec d_appKeysVec; - // Vector of set of AppKeys which are - // currently active. Vector is indexed - // on the partitionId, and the inner - // set contains a unique list of - // appKeys of virtual storages of the - // physical storages assigned to that - // partition. Contains appKeys for - // *both* in-memory as well as - // file-backed 'physical' storages. - // Note that the corresponding virtual - // storages are owned by the physical - // storage. Also note that - // 'd_appKeysLock' must be held while - // accessing this container and any of - // its elements, because they are - // accessed from partitions' dispatcher - // threads as well as cluster - // dispatcher threads. - // - // THREAD: Protected by 'd_appKeysLock' - PartitionInfoVec d_partitionInfoVec; // Vector of 'PartitionInfo' indexed by // partitionId diff --git a/src/groups/mqb/mqbc/mqbc_storagemanager.t.cpp b/src/groups/mqb/mqbc/mqbc_storagemanager.t.cpp index 94916c3e4..6ad079e99 100644 --- a/src/groups/mqb/mqbc/mqbc_storagemanager.t.cpp +++ b/src/groups/mqb/mqbc/mqbc_storagemanager.t.cpp @@ -135,54 +135,56 @@ struct TestHelper { // CREATORS TestHelper() - : d_bufferFactory(1024, s_allocator_p) + : d_bufferFactory(1024, bmqtst::TestHelperUtil::allocator()) , d_cluster_mp(0) - , d_tempDir(s_allocator_p) - , d_tempArchiveDir(s_allocator_p) + , d_tempDir(bmqtst::TestHelperUtil::allocator()) + , d_tempArchiveDir(bmqtst::TestHelperUtil::allocator()) { // Create the cluster - mqbmock::Cluster::ClusterNodeDefs clusterNodeDefs(s_allocator_p); + mqbmock::Cluster::ClusterNodeDefs clusterNodeDefs( + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "E1", "US-EAST", 41234, mqbmock::Cluster::k_LEADER_NODE_ID, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "E2", "US-EAST", 41235, mqbmock::Cluster::k_LEADER_NODE_ID + 1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "W1", "US-WEST", 41236, mqbmock::Cluster::k_LEADER_NODE_ID + 2, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, "W2", "US-WEST", 41237, mqbmock::Cluster::k_LEADER_NODE_ID + 3, - s_allocator_p); - - d_cluster_mp.load(new (*s_allocator_p) - mqbmock::Cluster(&d_bufferFactory, - s_allocator_p, - true, // isClusterMember - false, // isLeader - true, // isCSLMode - true, // isFSMWorkflow - clusterNodeDefs, - "testCluster", - d_tempDir.path(), - d_tempArchiveDir.path()), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + + d_cluster_mp.load( + new (*bmqtst::TestHelperUtil::allocator()) + mqbmock::Cluster(&d_bufferFactory, + bmqtst::TestHelperUtil::allocator(), + true, // isClusterMember + false, // isLeader + true, // isCSLMode + true, // isFSMWorkflow + clusterNodeDefs, + "testCluster", + d_tempDir.path(), + d_tempArchiveDir.path()), + bmqtst::TestHelperUtil::allocator()); d_cluster_mp->_clusterData()->stats().setIsMember(true); @@ -192,7 +194,7 @@ struct TestHelper { &bsls::SystemTime::nowRealtimeClock, bdlf::BindUtil::bind(&TestHelper::nowMonotonicClock, this), bdlf::BindUtil::bind(&TestHelper::highResolutionTimer, this), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); // Start the cluster bmqu::MemOutStream errorDescription; @@ -248,7 +250,7 @@ struct TestHelper { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message.choice().clusterMessage(), expectedMessage); if (reqIdToNodeIdMap) { @@ -306,15 +308,17 @@ struct TestHelper { // - replicaCit->second.sequenceNumber(); bsl::shared_ptr blob_sp; - blob_sp.createInplace(s_allocator_p, s_allocator_p); + blob_sp.createInplace(bmqtst::TestHelperUtil::allocator(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append( blob_sp.get(), cit->second->writeCalls()[1].d_blob, 0, cit->second->writeCalls()[1].d_blob.length(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - bmqp::Event event(blob_sp.get(), s_allocator_p); + bmqp::Event event(blob_sp.get(), + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_SAFE(event.isPartitionSyncEvent()); bmqp::StorageMessageIterator iter; @@ -466,7 +470,7 @@ struct TestHelper { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[expectedNumDataChunks].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message.choice().clusterMessage(), expectedMessage); */ } @@ -508,7 +512,7 @@ struct TestHelper { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message.choice().clusterMessage(), expectedMessage); } else { @@ -547,7 +551,7 @@ struct TestHelper { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); replicaDataRequest.beginSequenceNumber() = destinationReplicas.at(cit->first->nodeId()); ASSERT_EQ(message.choice().clusterMessage(), expectedMessage); @@ -582,7 +586,7 @@ struct TestHelper { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message, failureMessage); } else { @@ -615,7 +619,7 @@ struct TestHelper { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message, failureMessage); } else { @@ -652,7 +656,7 @@ struct TestHelper { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message.choice().clusterMessage(), expectedMessage); } else { @@ -689,7 +693,7 @@ struct TestHelper { mqbc::ClusterUtil::extractMessage( &message, cit->second->writeCalls()[0].d_blob, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(message.choice().clusterMessage(), expectedMessage); } else { @@ -740,7 +744,8 @@ struct TestHelper { // Write a queue creation record to the specified 'fs', and load the // record into the specified 'handle'. Return the queue key. - bsl::string uri("bmq://si.amw.bmq.stats/queue0", s_allocator_p); + bsl::string uri("bmq://si.amw.bmq.stats/queue0", + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream osstr; // Generate queue-key. @@ -754,7 +759,8 @@ struct TestHelper { queueKeyStr.substr(0, mqbu::StorageKey::e_KEY_LENGTH_BINARY) .c_str()); - mqbs::FileStoreTestUtil_Record rec(s_allocator_p); + mqbs::FileStoreTestUtil_Record rec( + bmqtst::TestHelperUtil::allocator()); rec.d_recordType = mqbs::RecordType::e_QUEUE_OP; rec.d_queueOpType = mqbs::QueueOpType::e_CREATION; rec.d_uri = uri; @@ -762,7 +768,7 @@ struct TestHelper { rec.d_timestamp = bdlt::EpochUtil::convertToTimeT64( bdlt::CurrentTime::utc()); - bmqt::Uri uri_t(rec.d_uri, s_allocator_p); + bmqt::Uri uri_t(rec.d_uri, bmqtst::TestHelperUtil::allocator()); const int rc = fs->writeQueueCreationRecord( handle, uri_t, @@ -787,7 +793,8 @@ struct TestHelper { // Write a message record. mqbs::DataStoreRecordHandle handle; - mqbs::FileStoreTestUtil_Record rec(s_allocator_p); + mqbs::FileStoreTestUtil_Record rec( + bmqtst::TestHelperUtil::allocator()); rec.d_recordType = mqbs::RecordType::e_MESSAGE; rec.d_queueKey = queueKey; bmqp::MessagePropertiesInfo mpsInfo; @@ -803,10 +810,12 @@ struct TestHelper { bsl::numeric_limits::max() / recNum); // crc value mqbu::MessageGUIDUtil::generateGUID(&rec.d_guid); - rec.d_appData_sp.createInplace(s_allocator_p, + rec.d_appData_sp.createInplace(bmqtst::TestHelperUtil::allocator(), &d_bufferFactory, - s_allocator_p); - bsl::string payloadStr(recNum * 10, 'x', s_allocator_p); + bmqtst::TestHelperUtil::allocator()); + bsl::string payloadStr(recNum * 10, + 'x', + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(rec.d_appData_sp.get(), payloadStr.c_str(), payloadStr.length()); @@ -865,7 +874,9 @@ struct TestHelper { .setMaxQlistFileSize(partitionCfg.maxQlistFileSize()) .setMaxArchivedFileSets(partitionCfg.maxArchivedFileSets()); - bdlmt::FixedThreadPool threadPool(1, 100, s_allocator_p); + bdlmt::FixedThreadPool threadPool(1, + 100, + bmqtst::TestHelperUtil::allocator()); threadPool.start(); mqbs::FileStore fs(dsCfg, @@ -879,7 +890,7 @@ struct TestHelper { d_cluster_mp->isCSLModeEnabled(), d_cluster_mp->isFSMWorkflow(), 1, // replicationFactor - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); dynamic_cast(d_cluster_mp->netCluster()) ._setDisableBroadcast(true); @@ -953,7 +964,7 @@ static void test1_breathingTest() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -1002,7 +1013,7 @@ static void test2_unknownDetectSelfPrimary() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -1072,7 +1083,7 @@ static void test3_unknownDetectSelfReplica() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -1145,7 +1156,7 @@ static void test4_primaryHealingStage1DetectSelfReplica() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -1245,7 +1256,7 @@ static void test5_primaryHealingStage1ReceivesReplicaStateRqst() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -1358,7 +1369,7 @@ static void test6_primaryHealingStage1ReceivesReplicaStateRspnQuorum() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -1466,7 +1477,7 @@ static void test7_primaryHealingStage1ReceivesPrimaryStateRequestQuorum() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -1580,7 +1591,7 @@ static void test8_primaryHealingStage1ReceivesPrimaryStateRqst() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -1691,7 +1702,7 @@ static void test9_primaryHealingStage1ReceivesReplicaStateRspnNoQuorum() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -1807,7 +1818,7 @@ static void test10_primaryHealingStage1QuorumSendsReplicaDataRequestPull() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -1931,7 +1942,7 @@ static void test11_primaryHealingStage2DetectSelfReplica() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -2079,7 +2090,7 @@ static void test12_replicaHealingDetectSelfPrimary() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -2178,7 +2189,7 @@ static void test13_replicaHealingReceivesReplicaStateRqst() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -2286,7 +2297,7 @@ static void test14_replicaHealingReceivesPrimaryStateRspn() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -2392,7 +2403,7 @@ static void test15_replicaHealingReceivesFailedPrimaryStateRspn() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -2487,7 +2498,7 @@ static void test16_replicaHealingReceivesPrimaryStateRqst() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -2611,7 +2622,7 @@ static void test17_replicaHealingReceivesReplicaDataRqstPull() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); static const int k_PARTITION_ID = 1; @@ -2764,7 +2775,7 @@ static void test18_primaryHealingStage1SelfHighestSendsDataChunks() k_WATCHDOG_TIMEOUT_DURATION, mockOnRecoveryStatus, mockOnPartitionPrimaryStatus, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream errorDescription; @@ -2889,8 +2900,8 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); - bmqt::UriParser::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -2928,7 +2939,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbc/mqbc_storageutil.cpp b/src/groups/mqb/mqbc/mqbc_storageutil.cpp index 82e859973..649ec946a 100644 --- a/src/groups/mqb/mqbc/mqbc_storageutil.cpp +++ b/src/groups/mqb/mqbc/mqbc_storageutil.cpp @@ -170,7 +170,7 @@ void StorageUtil::registerQueueDispatched( // partition, we want to make sure that queue creation record written to // the partition above is sent to the replicas as soon as possible. - fs->dispatcherFlush(true, false); + fs->flushStorage(); BALL_LOG_INFO << clusterDescription << ": Partition [" << partitionId << "] registered [" << storage->queueUri() << "], queueKey [" @@ -182,14 +182,11 @@ void StorageUtil::updateQueuePrimaryDispatched( mqbs::ReplicatedStorage* storage, bslmt::Mutex* storagesLock, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, const bsl::string& clusterDescription, int partitionId, const AppInfos& addedIdKeyPairs, const AppInfos& removedIdKeyPairs, - bool isFanout, - bool isCSLMode) + bool isFanout) { // executed by *QUEUE_DISPATCHER* thread with the specified 'partitionId' @@ -204,26 +201,20 @@ void StorageUtil::updateQueuePrimaryDispatched( // Simply forward to 'updateQueuePrimaryRaw'. updateQueuePrimaryRaw(storage, fs, - appKeys, - appKeysLock, clusterDescription, partitionId, addedIdKeyPairs, removedIdKeyPairs, - isFanout, - isCSLMode); + isFanout); } int StorageUtil::updateQueuePrimaryRaw(mqbs::ReplicatedStorage* storage, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, const bsl::string& clusterDescription, int partitionId, const AppInfos& addedIdKeyPairs, const AppInfos& removedIdKeyPairs, - bool isFanout, - bool isCSLMode) + bool isFanout) { // executed by *QUEUE_DISPATCHER* thread with the specified 'partitionId' @@ -232,7 +223,6 @@ int StorageUtil::updateQueuePrimaryRaw(mqbs::ReplicatedStorage* storage, BSLS_ASSERT_SAFE(fs); BSLS_ASSERT_SAFE(fs->inDispatcherThread()); BSLS_ASSERT_SAFE(storage); - BSLS_ASSERT_SAFE(appKeys); int rc = 0; bsls::Types::Uint64 timestamp = bdlt::EpochUtil::convertToTimeT64( @@ -264,13 +254,10 @@ int StorageUtil::updateQueuePrimaryRaw(mqbs::ReplicatedStorage* storage, storage->addQueueOpRecordHandle(handle); rc = addVirtualStoragesInternal(storage, - appKeys, - appKeysLock, addedIdKeyPairs, clusterDescription, partitionId, - isFanout, - isCSLMode); + isFanout); if (0 != rc) { return rc; // RETURN } @@ -316,8 +303,6 @@ int StorageUtil::updateQueuePrimaryRaw(mqbs::ReplicatedStorage* storage, storage->addQueueOpRecordHandle(handle); rc = removeVirtualStorageInternal(storage, - appKeys, - appKeysLock, cit->second, partitionId); if (0 != rc) { @@ -347,7 +332,7 @@ int StorageUtil::updateQueuePrimaryRaw(mqbs::ReplicatedStorage* storage, // Flush the partition for records written above to reach replicas right // away. - fs->dispatcherFlush(true, false); + fs->flushStorage(); bmqu::Printer printer1(&addedIdKeyPairs); bmqu::Printer printer2(&removedIdKeyPairs); @@ -362,20 +347,16 @@ int StorageUtil::updateQueuePrimaryRaw(mqbs::ReplicatedStorage* storage, int StorageUtil::addVirtualStoragesInternal( mqbs::ReplicatedStorage* storage, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, const AppInfos& appIdKeyPairs, const bsl::string& clusterDescription, int partitionId, - bool isFanout, - bool isCSLMode) + bool isFanout) { // executed by *QUEUE_DISPATCHER* thread with the specified 'partitionId' // PRECONDITIONS BSLS_ASSERT_SAFE(0 <= partitionId); BSLS_ASSERT_SAFE(storage); - BSLS_ASSERT_SAFE(appKeys); enum { rc_SUCCESS = 0, @@ -383,29 +364,14 @@ int StorageUtil::addVirtualStoragesInternal( rc_VIRTUAL_STORAGE_CREATION_FAILURE = -2 }; - bslmt::LockGuard appLockGuard(appKeysLock); // LOCK - int rc = -1; bmqu::MemOutStream errorDesc; if (isFanout) { - // Register appKeys with 'appKeys' and then with the underlying - // physical 'storage'. + // Register appKeys with with the underlying physical 'storage'. for (AppInfosCIter cit = appIdKeyPairs.begin(); cit != appIdKeyPairs.end(); ++cit) { - AppKeysInsertRc irc = appKeys->insert(cit->second); - if (!irc.second && isCSLMode) { - BALL_LOG_WARN << clusterDescription << " Partition [" - << partitionId << "]: AppKey [" << cit->second - << "] already exists, while attempting to add " - << "appId [" << cit->first << "], for queue [" - << storage->queueUri() << "], queueKey [" - << storage->queueKey() << "]."; - - return rc_APP_KEY_COLLISION; // RETURN - } - if (0 != (rc = storage->addVirtualStorage(errorDesc, cit->first, cit->second))) { @@ -435,9 +401,7 @@ int StorageUtil::addVirtualStoragesInternal( } int StorageUtil::removeVirtualStorageInternal(mqbs::ReplicatedStorage* storage, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, - const mqbu::StorageKey& appKey, + const mqbu::StorageKey& appKey, int partitionId) { // executed by *QUEUE_DISPATCHER* thread with the specified 'partitionId' @@ -445,32 +409,17 @@ int StorageUtil::removeVirtualStorageInternal(mqbs::ReplicatedStorage* storage, // PRECONDITIONS BSLS_ASSERT_SAFE(0 <= partitionId); BSLS_ASSERT_SAFE(storage); - BSLS_ASSERT_SAFE(appKeys); BSLS_ASSERT_SAFE(!appKey.isNull()); // We should never have to remove a default appKey (for non-fanout queues) BSLS_ASSERT_SAFE(appKey != mqbi::QueueEngine::k_DEFAULT_APP_KEY); - enum { - rc_SUCCESS = 0, - rc_VIRTUAL_STORAGE_DOES_NOT_EXIST = -1, - rc_APP_KEY_NOT_PRESENT = -2 - }; - - bslmt::LockGuard appLockGuard(appKeysLock); // LOCK + enum { rc_SUCCESS = 0, rc_VIRTUAL_STORAGE_DOES_NOT_EXIST = -1 }; bool existed = storage->removeVirtualStorage(appKey); if (!existed) { return rc_VIRTUAL_STORAGE_DOES_NOT_EXIST; // RETURN } - if (1 != appKeys->erase(appKey)) { - // This appKey is not present in the global data structure of appKeys. - // This really means that this node is out of sync with the cluster - // state. - - return rc_APP_KEY_NOT_PRESENT; // RETURN - } - return rc_SUCCESS; } @@ -1380,8 +1329,6 @@ void StorageUtil::recoveredQueuesCb( StorageSpMap* storageMap, bslmt::Mutex* storagesLock, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, mqbi::DomainFactory* domainFactory, bslmt::Mutex* unrecognizedDomainsLock, DomainQueueMessagesCountMap* unrecognizedDomains, @@ -1395,7 +1342,6 @@ void StorageUtil::recoveredQueuesCb( // PRECONDITIONS BSLS_ASSERT_SAFE(storageMap); BSLS_ASSERT_SAFE(fs); - BSLS_ASSERT_SAFE(appKeys); BSLS_ASSERT_SAFE(unrecognizedDomainsLock); BSLS_ASSERT_SAFE(unrecognizedDomains && unrecognizedDomains->empty()); BSLS_ASSERT_SAFE(0 <= partitionId); @@ -1430,9 +1376,7 @@ void StorageUtil::recoveredQueuesCb( // 'mqbi::Domain'. Additionally, also ensure that if a fanout queue has // appId/appKey pairs associated with it, they are unique. We don't have // a global list of AppIds (in fact, we can't have that, because AppIds can - // clash), so we check uniqueness of AppIds only for a given queue. But we - // do have a global unique list of AppKeys ('appKeys'), so we check each - // queue's AppKey against that list. + // clash), so we check uniqueness of AppIds only for a given queue. for (QueueKeyInfoMapConstIter qit = queueKeyInfoMap.begin(); qit != queueKeyInfoMap.end(); @@ -1475,29 +1419,6 @@ void StorageUtil::recoveredQueuesCb( mqbu::ExitCode::e_RECOVERY_FAILURE); // EXIT } - - bslmt::LockGuard appLockGuard(appKeysLock); - // LOCK - - AppKeysInsertRc appKeysIrc = appKeys->insert(p.second); - if (!appKeysIrc.second && !isCSLMode) { - // Duplicate AppKey. Error in non-csl mode. In CSL mode, - // this can occur because this queue (and thus its appIds & - // appKeys) could be assigned at node startup, via - // CQH::onQueueAssigned -> - // StorageMgr::register/UpdateQueueReplica. - BMQTSK_ALARMLOG_ALARM("RECOVERY") - << clusterDescription << ": Partition [" << partitionId - << "]: " - << "encountered a duplicate AppKey while processing " - << "recovered queue [" << uri << "], queueKey [" - << qit->first << "]. AppKey [" << *(appKeysIrc.first) - << "]. AppId [" << p.first << "]." - << BMQTSK_ALARMLOG_END; - mqbu::ExitUtil::terminate( - mqbu::ExitCode::e_RECOVERY_FAILURE); - // EXIT - } } } @@ -2237,14 +2158,12 @@ void StorageUtil::shutdown(int partitionId, latch->arrive(); } -mqbu::StorageKey StorageUtil::generateAppKey(AppKeys* appKeys, - bslmt::Mutex* appKeysLock, - const bsl::string& appId) +mqbu::StorageKey +StorageUtil::generateAppKey(bsl::unordered_set* appKeys, + const bsl::string& appId) { // executed by *QUEUE_DISPATCHER* thread or by *CLUSTER DISPATCHER* thread. - bslmt::LockGuard guard(appKeysLock); // LOCK - mqbu::StorageKey appKey; mqbs::StorageUtil::generateStorageKey(&appKey, appKeys, appId); BSLS_ASSERT_SAFE(!appKey.isNull()); @@ -2259,8 +2178,6 @@ void StorageUtil::registerQueue( StorageSpMap* storageMap, bslmt::Mutex* storagesLock, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, bmqma::CountingAllocatorStore* allocators, const mqbi::Dispatcher::ProcessorHandle& processor, const bmqt::Uri& uri, @@ -2278,7 +2195,6 @@ void StorageUtil::registerQueue( BSLS_ASSERT_SAFE(dispatcher->inDispatcherThread(cluster)); BSLS_ASSERT_SAFE(storageMap); BSLS_ASSERT_SAFE(fs); - BSLS_ASSERT_SAFE(appKeys); BSLS_ASSERT_SAFE(allocators); BSLS_ASSERT_SAFE(uri.isValid()); BSLS_ASSERT_SAFE( @@ -2390,14 +2306,11 @@ void StorageUtil::registerQueue( storageSp.get(), storagesLock, fs, - appKeys, - appKeysLock, clusterDescription, partitionId, addedAppInfos, removedAppInfos, - domain->config().mode().isFanoutValue(), - cluster->isCSLModeEnabled())); + domain->config().mode().isFanoutValue())); dispatcher->dispatchEvent(queueEvent, mqbi::DispatcherClientType::e_QUEUE, @@ -2438,16 +2351,25 @@ void StorageUtil::registerQueue( storageMap->insert(bsl::make_pair(uri, storageSp)); bmqu::MemOutStream errorDesc; - int rc = 0; + bool result = true; AppInfos appIdKeyPairsToUse; if (queueMode.isFanoutValue()) { if (cluster->isCSLModeEnabled() || !appIdKeyPairs.empty()) { for (AppInfosCIter citer = appIdKeyPairs.begin(); citer != appIdKeyPairs.end(); ++citer) { - rc = storageSp->addVirtualStorage(errorDesc, - citer->first, - citer->second); + int rc = storageSp->addVirtualStorage(errorDesc, + citer->first, + citer->second); + if (rc) { + BMQTSK_ALARMLOG_ALARM("STORAGE") + << "Partition [" << partitionId + << "] VirtualStorage creation error " << rc + << " while registering App ['" << citer->first << "', " + << citer->second << "] for '" << uri << "', queueKey '" + << queueKey << "." << BMQTSK_ALARMLOG_END; + result = false; + } } appIdKeyPairsToUse = appIdKeyPairs; @@ -2460,17 +2382,30 @@ void StorageUtil::registerQueue( const mqbconfm::QueueModeFanout& fanoutMode = queueMode.fanout(); const bsl::vector& cfgAppIds = fanoutMode.appIDs(); + // TODO: use allocator once this is 'StorageManager' + bsl::unordered_set appKeys; typedef bsl::vector::const_iterator ConstIter; for (ConstIter citer = cfgAppIds.begin(); citer != cfgAppIds.end(); ++citer) { - mqbu::StorageKey appKey = generateAppKey(appKeys, - appKeysLock, - *citer); - - rc = storageSp->addVirtualStorage(errorDesc, *citer, appKey); + mqbu::StorageKey appKey = generateAppKey(&appKeys, *citer); appIdKeyPairsToUse.emplace(bsl::make_pair(*citer, appKey)); + + int rc = storageSp->addVirtualStorage(errorDesc, + *citer, + appKey); + + if (rc) { + BMQTSK_ALARMLOG_ALARM("STORAGE") + << "Partition [" << partitionId + << "] VirtualStorage creation error " << rc + << " while registering App ['" << *citer << "', " + << appKey << "] for '" << uri << "', queueKey '" + << queueKey << "." << BMQTSK_ALARMLOG_END; + + result = false; + } } } } @@ -2481,14 +2416,23 @@ void StorageUtil::registerQueue( // VirtualStorage to the storage - just like in the Fanout case, // except it is harcoded '__default' appId. - rc = storageSp->addVirtualStorage( + int rc = storageSp->addVirtualStorage( errorDesc, bmqp::ProtocolUtil::k_DEFAULT_APP_ID, mqbi::QueueEngine::k_DEFAULT_APP_KEY); + + if (rc) { + BMQTSK_ALARMLOG_ALARM("STORAGE") + << "Partition [" << partitionId + << "] VirtualStorage creation error " << rc + << " while registering the default for '" << uri + << "', queueKey '" << queueKey << "." << BMQTSK_ALARMLOG_END; + result = false; + } } - BSLS_ASSERT_SAFE(rc == 0); - static_cast(rc); + BSLS_ASSERT_SAFE(result); + static_cast(result); // Dispatch the registration of storage with the partition in appropriate // thread. @@ -2654,21 +2598,18 @@ void StorageUtil::unregisterQueueDispatched( // that the partition is flushed and the QueueDeletion record reaches // replicas. - fs->dispatcherFlush(true, false); + fs->flushStorage(); } int StorageUtil::updateQueuePrimary(StorageSpMap* storageMap, bslmt::Mutex* storagesLock, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, const bsl::string& clusterDescription, const bmqt::Uri& uri, const mqbu::StorageKey& queueKey, int partitionId, const AppInfos& addedIdKeyPairs, - const AppInfos& removedIdKeyPairs, - bool isCSLMode) + const AppInfos& removedIdKeyPairs) { // executed by *QUEUE_DISPATCHER* thread with the specified 'partitionId' @@ -2676,7 +2617,6 @@ int StorageUtil::updateQueuePrimary(StorageSpMap* storageMap, BSLS_ASSERT_SAFE(fs); BSLS_ASSERT_SAFE(fs->inDispatcherThread()); BSLS_ASSERT_SAFE(storageMap); - BSLS_ASSERT_SAFE(appKeys); BSLS_ASSERT_SAFE(0 <= partitionId); if (addedIdKeyPairs.empty() && removedIdKeyPairs.empty()) { @@ -2705,14 +2645,11 @@ int StorageUtil::updateQueuePrimary(StorageSpMap* storageMap, return updateQueuePrimaryRaw(storageSp.get(), fs, - appKeys, - appKeysLock, clusterDescription, partitionId, addedIdKeyPairs, removedIdKeyPairs, - true, // isFanout - isCSLMode); + true); // isFanout } void StorageUtil::registerQueueReplicaDispatched( @@ -2881,8 +2818,6 @@ void StorageUtil::unregisterQueueReplicaDispatched( StorageSpMap* storageMap, bslmt::Mutex* storagesLock, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, const bsl::string& clusterDescription, int partitionId, const bmqt::Uri& uri, @@ -2896,7 +2831,6 @@ void StorageUtil::unregisterQueueReplicaDispatched( BSLS_ASSERT_SAFE(fs); BSLS_ASSERT_SAFE(fs->inDispatcherThread()); BSLS_ASSERT_SAFE(storageMap); - BSLS_ASSERT_SAFE(appKeys); BSLS_ASSERT_SAFE(0 <= partitionId); BSLS_ASSERT_SAFE(uri.isValid()); BSLS_ASSERT_SAFE(!queueKey.isNull()); @@ -2998,11 +2932,7 @@ void StorageUtil::unregisterQueueReplicaDispatched( rs->purge(appKey); } - int rc = removeVirtualStorageInternal(rs, - appKeys, - appKeysLock, - appKey, - partitionId); + int rc = removeVirtualStorageInternal(rs, appKey, partitionId); if (0 != rc) { BMQTSK_ALARMLOG_ALARM("REPLICATION") << clusterDescription << " Partition [" << partitionId @@ -3031,15 +2961,12 @@ void StorageUtil::updateQueueReplicaDispatched( int* status, StorageSpMap* storageMap, bslmt::Mutex* storagesLock, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, mqbi::DomainFactory* domainFactory, const bsl::string& clusterDescription, int partitionId, const bmqt::Uri& uri, const mqbu::StorageKey& queueKey, const AppInfos& appIdKeyPairs, - bool isCSLMode, mqbi::Domain* domain, bool allowDuplicate) { @@ -3048,7 +2975,6 @@ void StorageUtil::updateQueueReplicaDispatched( // PRECONDITIONS BSLS_ASSERT_SAFE(0 <= partitionId); BSLS_ASSERT_SAFE(storageMap); - BSLS_ASSERT_SAFE(appKeys); BSLS_ASSERT_SAFE(domainFactory); BSLS_ASSERT_SAFE(uri.isValid()); BSLS_ASSERT_SAFE(!queueKey.isNull()); @@ -3093,13 +3019,10 @@ void StorageUtil::updateQueueReplicaDispatched( int rc = addVirtualStoragesInternal( storage, - appKeys, - appKeysLock, appIdKeyPairs, clusterDescription, partitionId, - domain->config().mode().isFanoutValue(), - isCSLMode); + domain->config().mode().isFanoutValue()); if (rc != 0) { if (!allowDuplicate) { bmqu::Printer printer(&appIdKeyPairs); @@ -3210,6 +3133,8 @@ int StorageUtil::makeStorage(bsl::ostream& errorDescription, // Configure the storage. Note that if a queue calls 'makeStorage' twice, // its storage will be configured twice as things are currently. + // Do not change consistency level of `storageSp`, use the one provided on + // construction instead. const int rc = storageSp->configure(errorDescription, storageDef.config(), storageDef.queueLimits(), diff --git a/src/groups/mqb/mqbc/mqbc_storageutil.h b/src/groups/mqb/mqbc/mqbc_storageutil.h index 3f6e6cfe4..dd4f801e0 100644 --- a/src/groups/mqb/mqbc/mqbc_storageutil.h +++ b/src/groups/mqb/mqbc/mqbc_storageutil.h @@ -109,9 +109,6 @@ struct StorageUtil { typedef mqbi::StorageManager::AppIdsIter AppIdsIter; typedef mqbi::StorageManager::AppIdsInsertRc AppIdsInsertRc; - typedef mqbi::StorageManager::AppKeys AppKeys; - typedef mqbi::StorageManager::AppKeysInsertRc AppKeysInsertRc; - typedef mqbi::StorageManager::StorageSp StorageSp; typedef mqbi::StorageManager::StorageSpMap StorageSpMap; typedef mqbi::StorageManager::StorageSpMapVec StorageSpMapVec; @@ -184,11 +181,8 @@ struct StorageUtil { /// Load into the specified `addedAppInfos` and /// `removedAppInfos` the appId/key pairs which have been added and /// removed respectively for the specified `storage` based on the - /// specified `newAppInfos` or `cfgAppIds`, as well as the - /// specified `isCSLMode` mode. If new app keys are generated, load - /// them into the specified `appKeys`. If the optionally specified - /// `appKeysLock` is provided, lock it. Return true if there are any - /// added or removed appId/key pairs, false otherwise. + /// specified `newAppInfos`. Return true if there are any added or removed + /// appId/key pairs, false otherwise. /// /// THREAD: Executed by the cluster dispatcher thread. static bool loadUpdatedAppInfos(AppInfos* addedAppInfos, @@ -211,14 +205,11 @@ struct StorageUtil { mqbs::ReplicatedStorage* storage, bslmt::Mutex* storagesLock, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, const bsl::string& clusterDescription, int partitionId, const AppInfos& addedIdKeyPairs, const AppInfos& removedIdKeyPairs, - bool isFanout, - bool isCSLMode); + bool isFanout); /// StorageManager's storages lock must be locked before calling this /// method. @@ -226,29 +217,21 @@ struct StorageUtil { /// THREAD: Executed by the Queue's dispatcher thread. static int updateQueuePrimaryRaw(mqbs::ReplicatedStorage* storage, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, const bsl::string& clusterDescription, int partitionId, const AppInfos& addedIdKeyPairs, const AppInfos& removedIdKeyPairs, - bool isFanout, - bool isCSLMode); + bool isFanout); static int addVirtualStoragesInternal(mqbs::ReplicatedStorage* storage, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, const AppInfos& appIdKeyPairs, const bsl::string& clusterDescription, int partitionId, - bool isFanout, - bool isCSLMode); + bool isFanout); static int removeVirtualStorageInternal(mqbs::ReplicatedStorage* storage, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, - const mqbu::StorageKey& appKey, + const mqbu::StorageKey& appKey, int partitionId); /// Load the list of queue storages on the partition from the specified @@ -558,8 +541,6 @@ struct StorageUtil { recoveredQueuesCb(StorageSpMap* storageMap, bslmt::Mutex* storagesLock, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, mqbi::DomainFactory* domainFactory, bslmt::Mutex* unrecognizedDomainsLock, DomainQueueMessagesCountMap* unrecognizedDomains, @@ -607,12 +588,11 @@ struct StorageUtil { const mqbcfg::ClusterDefinition& clusterConfig); /// Return a unique appKey for the specified `appId` for a queue, and - /// load the appKey into the specified `appKeys` while locking the - /// optionally specified `appKeysLock`. This routine can be invoked by - /// any thread. - static mqbu::StorageKey generateAppKey(AppKeys* appKeys, - bslmt::Mutex* appKeysLock, - const bsl::string& appId); + /// load the appKey into the specified `appKeys`. This routine can be + /// invoked by any thread. + static mqbu::StorageKey + generateAppKey(bsl::unordered_set* appKeys, + const bsl::string& appId); /// Register a queue with the specified `uri`, `queueKey` and /// `partitionId`, having the specified `appIdKeyPairs`, and belonging to @@ -626,8 +606,6 @@ struct StorageUtil { StorageSpMap* storageMap, bslmt::Mutex* storagesLock, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, bmqma::CountingAllocatorStore* allocators, const mqbi::Dispatcher::ProcessorHandle& processor, const bmqt::Uri& uri, @@ -660,15 +638,12 @@ struct StorageUtil { static int updateQueuePrimary(StorageSpMap* storageMap, bslmt::Mutex* storagesLock, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, const bsl::string& clusterDescription, const bmqt::Uri& uri, const mqbu::StorageKey& queueKey, int partitionId, const AppInfos& addedIdKeyPairs, - const AppInfos& removedIdKeyPairs, - bool isCSLMode); + const AppInfos& removedIdKeyPairs); static void registerQueueReplicaDispatched(int* status, @@ -689,8 +664,6 @@ struct StorageUtil { StorageSpMap* storageMap, bslmt::Mutex* storagesLock, mqbs::FileStore* fs, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, const bsl::string& clusterDescription, int partitionId, const bmqt::Uri& uri, @@ -702,15 +675,12 @@ struct StorageUtil { updateQueueReplicaDispatched(int* status, StorageSpMap* storageMap, bslmt::Mutex* storagesLock, - AppKeys* appKeys, - bslmt::Mutex* appKeysLock, mqbi::DomainFactory* domainFactory, const bsl::string& clusterDescription, int partitionId, const bmqt::Uri& uri, const mqbu::StorageKey& queueKey, const AppInfos& addedIdKeyPairs, - bool isCSLMode, mqbi::Domain* domain = 0, bool allowDuplicate = false); diff --git a/src/groups/mqb/mqbc/test/mqbc_clusterstate.t.cpp b/src/groups/mqb/mqbc/test/mqbc_clusterstate.t.cpp index db614a389..de54e8f73 100644 --- a/src/groups/mqb/mqbc/test/mqbc_clusterstate.t.cpp +++ b/src/groups/mqb/mqbc/test/mqbc_clusterstate.t.cpp @@ -44,14 +44,23 @@ static void test1_partitionIdExtractor() // PartitionIdExtractor // ------------------------------------------------------------------------ { - mqbc::ClusterState::PartitionIdExtractor extractor(s_allocator_p); + mqbc::ClusterState::PartitionIdExtractor extractor( + bmqtst::TestHelperUtil::allocator()); - TestData testData(s_allocator_p); - testData.emplace(bsl::string("test", s_allocator_p), -1); - testData.emplace(bsl::string("123", s_allocator_p), -1); - testData.emplace(bsl::string("test.123.test", s_allocator_p), -1); - testData.emplace(bsl::string("test.123.test.test", s_allocator_p), 123); - testData.emplace(bsl::string("test.-1.test.test", s_allocator_p), -1); + TestData testData(bmqtst::TestHelperUtil::allocator()); + testData.emplace(bsl::string("test", bmqtst::TestHelperUtil::allocator()), + -1); + testData.emplace(bsl::string("123", bmqtst::TestHelperUtil::allocator()), + -1); + testData.emplace(bsl::string("test.123.test", + bmqtst::TestHelperUtil::allocator()), + -1); + testData.emplace(bsl::string("test.123.test.test", + bmqtst::TestHelperUtil::allocator()), + 123); + testData.emplace(bsl::string("test.-1.test.test", + bmqtst::TestHelperUtil::allocator()), + -1); TestData::const_iterator cIt = testData.begin(); for (; cIt != testData.end(); ++cIt) { @@ -73,7 +82,7 @@ int main(int argc, char* argv[]) case 1: test1_partitionIdExtractor(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbcmd/mqbcmd_parseutil.t.cpp b/src/groups/mqb/mqbcmd/mqbcmd_parseutil.t.cpp index 12fe53cdd..db8cf0517 100644 --- a/src/groups/mqb/mqbcmd/mqbcmd_parseutil.t.cpp +++ b/src/groups/mqb/mqbcmd/mqbcmd_parseutil.t.cpp @@ -395,7 +395,7 @@ int main(int argc, char* argv[]) case 3: test3_parseFailsWithExtra(); break; default: bsl::cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND.\n"; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } TEST_EPILOG(bmqtst::TestHelper::e_DEFAULT); diff --git a/src/groups/mqb/mqbi/mqbi_queue.t.cpp b/src/groups/mqb/mqbi/mqbi_queue.t.cpp index 2d2188f9c..d99a82c1b 100644 --- a/src/groups/mqb/mqbi/mqbi_queue.t.cpp +++ b/src/groups/mqb/mqbi/mqbi_queue.t.cpp @@ -86,7 +86,7 @@ static void test1_hashAppendSubQueueIdInfo() const size_t k_NUM_ITERATIONS = 1000; - bmqp_ctrlmsg::SubQueueIdInfo obj(s_allocator_p); + bmqp_ctrlmsg::SubQueueIdInfo obj(bmqtst::TestHelperUtil::allocator()); obj.appId() = "foobar"; obj.subId() = generateRandomInteger(1, 100); // same as: bslh::Hash<> hasher; @@ -108,18 +108,20 @@ static void test1_hashAppendSubQueueIdInfo() PV("SUBQUEUE-ID-INFO IS A HASHABLE KEY"); // obj1 == obj2 != obj3 - bmqp_ctrlmsg::SubQueueIdInfo obj1(s_allocator_p); + bmqp_ctrlmsg::SubQueueIdInfo obj1(bmqtst::TestHelperUtil::allocator()); obj1.appId() = "foo"; obj1.subId() = 1; - bmqp_ctrlmsg::SubQueueIdInfo obj2(obj1, s_allocator_p); + bmqp_ctrlmsg::SubQueueIdInfo obj2(obj1, + bmqtst::TestHelperUtil::allocator()); - bmqp_ctrlmsg::SubQueueIdInfo obj3(s_allocator_p); + bmqp_ctrlmsg::SubQueueIdInfo obj3(bmqtst::TestHelperUtil::allocator()); obj3.appId() = "bar"; obj3.subId() = 2; // Verify - bsl::unordered_set infos(s_allocator_p); + bsl::unordered_set infos( + bmqtst::TestHelperUtil::allocator()); infos.insert(obj1); // success ASSERT_EQ(infos.count(obj1), static_cast(1)); @@ -160,7 +162,7 @@ int main(int argc, char* argv[]) case 1: test1_hashAppendSubQueueIdInfo(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbi/mqbi_queueengine.t.cpp b/src/groups/mqb/mqbi/mqbi_queueengine.t.cpp index a96e3e3af..43a3eed04 100644 --- a/src/groups/mqb/mqbi/mqbi_queueengine.t.cpp +++ b/src/groups/mqb/mqbi/mqbi_queueengine.t.cpp @@ -54,19 +54,22 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - bsl::string emptyString("", s_allocator_p); + bsl::string emptyString("", bmqtst::TestHelperUtil::allocator()); // App id ASSERT(emptyString == bmqp::ProtocolUtil::k_NULL_APP_ID); ASSERT(emptyString != bmqp_ctrlmsg::SubQueueIdInfo::DEFAULT_INITIALIZER_APP_ID); - ASSERT_NE(bsl::string(bmqp::ProtocolUtil::k_DEFAULT_APP_ID, s_allocator_p), - bsl::string(bmqp::ProtocolUtil::k_NULL_APP_ID, s_allocator_p)); + ASSERT_NE(bsl::string(bmqp::ProtocolUtil::k_DEFAULT_APP_ID, + bmqtst::TestHelperUtil::allocator()), + bsl::string(bmqp::ProtocolUtil::k_NULL_APP_ID, + bmqtst::TestHelperUtil::allocator())); ASSERT_EQ( - bsl::string(bmqp::ProtocolUtil::k_DEFAULT_APP_ID, s_allocator_p), + bsl::string(bmqp::ProtocolUtil::k_DEFAULT_APP_ID, + bmqtst::TestHelperUtil::allocator()), bsl::string(bmqp_ctrlmsg::SubQueueIdInfo ::DEFAULT_INITIALIZER_APP_ID, - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); // App key ASSERT_EQ(mqbi::QueueEngine::k_DEFAULT_APP_KEY, @@ -88,7 +91,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbi/mqbi_storage.h b/src/groups/mqb/mqbi/mqbi_storage.h index 08b95c609..f20d161d3 100644 --- a/src/groups/mqb/mqbi/mqbi_storage.h +++ b/src/groups/mqb/mqbi/mqbi_storage.h @@ -408,6 +408,10 @@ class Storage { const bsls::Types::Int64 messageTtl, const int maxDeliveryAttempts) = 0; + /// Set the consistency level associated to this storage to the specified + /// `value`. + virtual void setConsistency(const mqbconfm::Consistency& value) = 0; + virtual void setQueue(mqbi::Queue* queue) = 0; /// Close this storage. @@ -503,11 +507,9 @@ class Storage { /// * e_APPKEY_NOT_FOUND : Invalid `appKey` specified virtual StorageResult::Enum removeAll(const mqbu::StorageKey& appKey) = 0; - /// If the specified `storage` is `true`, flush any buffered replication - /// messages to the peers. If the specified `queues` is `true`, `flush` - /// all associated queues. Behavior is undefined unless this node is - /// the primary for this partition. - virtual void dispatcherFlush(bool storage, bool queues) = 0; + /// Flush any buffered replication messages to the peers. Behaviour is + /// undefined unless this cluster node is the primary for this partition. + virtual void flushStorage() = 0; /// Return the resource capacity meter associated to this storage. virtual mqbu::CapacityMeter* capacityMeter() = 0; diff --git a/src/groups/mqb/mqbi/mqbi_storagemanager.h b/src/groups/mqb/mqbi/mqbi_storagemanager.h index 4d5ee2bec..58591e9d0 100644 --- a/src/groups/mqb/mqbi/mqbi_storagemanager.h +++ b/src/groups/mqb/mqbi/mqbi_storagemanager.h @@ -176,15 +176,6 @@ class StorageManager { typedef AppIds::const_iterator AppIdsConstIter; typedef bsl::pair AppIdsInsertRc; - typedef bsl::unordered_set AppKeys; - typedef AppKeys::iterator AppKeysIter; - typedef AppKeys::const_iterator AppKeysConstIter; - typedef bsl::pair AppKeysInsertRc; - - typedef bsl::vector AppKeysVec; - typedef AppKeysVec::iterator AppKeysVecIter; - typedef AppKeysVec::const_iterator AppKeysVecConstIter; - typedef bsl::shared_ptr StorageSp; /// Map of QueueUri -> ReplicatedStorageSp diff --git a/src/groups/mqb/mqbnet/mqbnet_channel.t.cpp b/src/groups/mqb/mqbnet/mqbnet_channel.t.cpp index 2af80dba0..ce852cca7 100644 --- a/src/groups/mqb/mqbnet/mqbnet_channel.t.cpp +++ b/src/groups/mqb/mqbnet/mqbnet_channel.t.cpp @@ -724,23 +724,37 @@ static void test1_write() // // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(k_BUFFER_SIZE, s_allocator_p); - mqbnet::Channel channel(&bufferFactory, "test", s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + k_BUFFER_SIZE, + bmqtst::TestHelperUtil::allocator()); + mqbnet::Channel channel(&bufferFactory, + "test", + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr testChannel( - new (*s_allocator_p) - bmqio::TestChannelEx(channel, &bufferFactory, s_allocator_p), - s_allocator_p); - - Tester put(channel, bufferFactory, s_allocator_p); - Tester push(channel, bufferFactory, s_allocator_p); - Tester ack(channel, bufferFactory, s_allocator_p); - Tester confirm(channel, - bufferFactory, - s_allocator_p); - Tester reject(channel, - bufferFactory, - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bmqio::TestChannelEx(channel, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); + + Tester put(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester push(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester ack(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester confirm( + channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester reject( + channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); channel.setChannel(bsl::weak_ptr(testChannel)); @@ -790,24 +804,40 @@ static void test2_highWatermark() // // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(k_BUFFER_SIZE, s_allocator_p); - mqbnet::Channel channel(&bufferFactory, "test", s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + k_BUFFER_SIZE, + bmqtst::TestHelperUtil::allocator()); + mqbnet::Channel channel(&bufferFactory, + "test", + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr testChannel( - new (*s_allocator_p) - bmqio::TestChannelEx(channel, &bufferFactory, s_allocator_p), - s_allocator_p); - - Tester put(channel, bufferFactory, s_allocator_p); - Tester push(channel, bufferFactory, s_allocator_p); - Tester ack(channel, bufferFactory, s_allocator_p); - Tester confirm(channel, - bufferFactory, - s_allocator_p); - Tester control(channel, bufferFactory, s_allocator_p); - Tester reject(channel, - bufferFactory, - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bmqio::TestChannelEx(channel, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); + + Tester put(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester push(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester ack(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester confirm( + channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester control(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester reject( + channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); bslmt::Barrier phase1(6 + 1); bslmt::Barrier phase2(6 + 1); @@ -880,23 +910,37 @@ static void test3_highWatermarkInWriteCb() // // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(k_BUFFER_SIZE, s_allocator_p); - mqbnet::Channel channel(&bufferFactory, "test", s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + k_BUFFER_SIZE, + bmqtst::TestHelperUtil::allocator()); + mqbnet::Channel channel(&bufferFactory, + "test", + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr testChannel( - new (*s_allocator_p) - bmqio::TestChannelEx(channel, &bufferFactory, s_allocator_p), - s_allocator_p); - - Tester put(channel, bufferFactory, s_allocator_p); - Tester push(channel, bufferFactory, s_allocator_p); - Tester ack(channel, bufferFactory, s_allocator_p); - Tester confirm(channel, - bufferFactory, - s_allocator_p); - Tester reject(channel, - bufferFactory, - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bmqio::TestChannelEx(channel, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); + + Tester put(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester push(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester ack(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester confirm( + channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester reject( + channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); bslmt::Barrier phase1(5 + 1); bslmt::Barrier phase2(5 + 1); @@ -970,23 +1014,37 @@ static void test4_controlBlob() // // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(k_BUFFER_SIZE, s_allocator_p); - mqbnet::Channel channel(&bufferFactory, "test", s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + k_BUFFER_SIZE, + bmqtst::TestHelperUtil::allocator()); + mqbnet::Channel channel(&bufferFactory, + "test", + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr testChannel( - new (*s_allocator_p) - bmqio::TestChannelEx(channel, &bufferFactory, s_allocator_p), - s_allocator_p); - - Tester put(channel, bufferFactory, s_allocator_p); - Tester push(channel, bufferFactory, s_allocator_p); - Tester ack(channel, bufferFactory, s_allocator_p); - Tester confirm(channel, - bufferFactory, - s_allocator_p); - Tester reject(channel, - bufferFactory, - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bmqio::TestChannelEx(channel, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); + + Tester put(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester push(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester ack(channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester confirm( + channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); + Tester reject( + channel, + bufferFactory, + bmqtst::TestHelperUtil::allocator()); channel.setChannel(bsl::weak_ptr(testChannel)); @@ -998,7 +1056,8 @@ static void test4_controlBlob() // cannot assert 'writeCalls().size() == 0' because of auto-flushing - bdlbb::Blob payload = bdlbb::Blob(&bufferFactory, s_allocator_p); + bdlbb::Blob payload = bdlbb::Blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer blobBuffer; bufferFactory.allocate(&blobBuffer); @@ -1039,18 +1098,25 @@ static void test5_reconnect() // // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(k_BUFFER_SIZE, s_allocator_p); - mqbnet::Channel channel(&bufferFactory, "test", s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + k_BUFFER_SIZE, + bmqtst::TestHelperUtil::allocator()); + mqbnet::Channel channel(&bufferFactory, + "test", + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr testChannel( - new (*s_allocator_p) - bmqio::TestChannelEx(channel, &bufferFactory, s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bmqio::TestChannelEx(channel, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); channel.setChannel(bsl::weak_ptr(testChannel)); { - bdlbb::Blob payload = bdlbb::Blob(&bufferFactory, s_allocator_p); + bdlbb::Blob payload = bdlbb::Blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer blobBuffer; bufferFactory.allocate(&blobBuffer); @@ -1070,7 +1136,8 @@ static void test5_reconnect() testChannel->setWriteStatus(bmqio::StatusCategory::e_CONNECTION); { - bdlbb::Blob payload = bdlbb::Blob(&bufferFactory, s_allocator_p); + bdlbb::Blob payload = bdlbb::Blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer blobBuffer; bufferFactory.allocate(&blobBuffer); @@ -1089,7 +1156,8 @@ static void test5_reconnect() testChannel->setWriteStatus(bmqio::StatusCategory::e_SUCCESS); { - bdlbb::Blob payload = bdlbb::Blob(&bufferFactory, s_allocator_p); + bdlbb::Blob payload = bdlbb::Blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer blobBuffer; bufferFactory.allocate(&blobBuffer); @@ -1118,13 +1186,19 @@ static void test6_weakData() // // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory bufferFactory(k_BUFFER_SIZE, s_allocator_p); - mqbnet::Channel channel(&bufferFactory, "test", s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + k_BUFFER_SIZE, + bmqtst::TestHelperUtil::allocator()); + mqbnet::Channel channel(&bufferFactory, + "test", + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr testChannel( - new (*s_allocator_p) - bmqio::TestChannelEx(channel, &bufferFactory, s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bmqio::TestChannelEx(channel, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); channel.setChannel(bsl::weak_ptr(testChannel)); @@ -1133,12 +1207,14 @@ static void test6_weakData() { bsl::shared_ptr payload( - new (*s_allocator_p) bdlbb::Blob(&bufferFactory, s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bdlbb::Blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer blobBuffer; - bsl::shared_ptr state(new (*s_allocator_p) - bmqu::AtomicState, - s_allocator_p); + bsl::shared_ptr state( + new (*bmqtst::TestHelperUtil::allocator()) bmqu::AtomicState, + bmqtst::TestHelperUtil::allocator()); bmqp::PutHeader ph; bufferFactory.allocate(&blobBuffer); @@ -1156,12 +1232,14 @@ static void test6_weakData() // Next write { bsl::shared_ptr payload( - new (*s_allocator_p) bdlbb::Blob(&bufferFactory, s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bdlbb::Blob(&bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobBuffer blobBuffer; - bsl::shared_ptr state(new (*s_allocator_p) - bmqu::AtomicState, - s_allocator_p); + bsl::shared_ptr state( + new (*bmqtst::TestHelperUtil::allocator()) bmqu::AtomicState, + bmqtst::TestHelperUtil::allocator()); bmqp::PutHeader ph; bufferFactory.allocate(&blobBuffer); @@ -1192,7 +1270,7 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); // expect BALL_LOG_ERROR switch (_testCase) { case 0: @@ -1204,7 +1282,7 @@ int main(int argc, char* argv[]) case 6: test6_weakData(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbnet/mqbnet_cluster.t.cpp b/src/groups/mqb/mqbnet/mqbnet_cluster.t.cpp index 46853c437..a7aee7fbf 100644 --- a/src/groups/mqb/mqbnet/mqbnet_cluster.t.cpp +++ b/src/groups/mqb/mqbnet/mqbnet_cluster.t.cpp @@ -220,7 +220,8 @@ static void test1_ClusterObserver() bmqtst::TestHelper::printTestName("ClusterObserver"); PV("Creating a test object"); - bsls::ProtocolTest testObj(s_verbosityLevel > 2); + bsls::ProtocolTest testObj( + bmqtst::TestHelperUtil::verbosityLevel() > 2); // NOTE: 'ClusterObserver' is purposely not a pure protocol, each method // has a default no-op implementation. @@ -287,7 +288,8 @@ static void test2_ClusterNode() bmqtst::TestHelper::printTestName("ClusterNode"); PV("Creating a test object"); - bsls::ProtocolTest testObj(s_verbosityLevel > 2); + bsls::ProtocolTest testObj( + bmqtst::TestHelperUtil::verbosityLevel() > 2); PV("Verify that the protocol is abstract"); ASSERT(testObj.testAbstract()); @@ -368,7 +370,8 @@ static void test3_Cluster() bmqtst::TestHelper::printTestName("Cluster"); PV("Creating a test object"); - bsls::ProtocolTest testObj(s_verbosityLevel > 2); + bsls::ProtocolTest testObj( + bmqtst::TestHelperUtil::verbosityLevel() > 2); PV("Verify that the protocol is abstract"); ASSERT(testObj.testAbstract()); @@ -435,7 +438,7 @@ int main(int argc, char* argv[]) case 1: test1_ClusterObserver(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbnet/mqbnet_dummysession.t.cpp b/src/groups/mqb/mqbnet/mqbnet_dummysession.t.cpp index e20a2e68d..cc882a823 100644 --- a/src/groups/mqb/mqbnet/mqbnet_dummysession.t.cpp +++ b/src/groups/mqb/mqbnet/mqbnet_dummysession.t.cpp @@ -45,32 +45,38 @@ static void test1_BreathingTest() bmqtst::TestHelper::printTestName("BreathingTest"); // Create some needed dummy/mocked objects - bsl::string description("DummyDescription", s_allocator_p); + bsl::string description("DummyDescription", + bmqtst::TestHelperUtil::allocator()); - bmqp_ctrlmsg::NegotiationMessage negotiationMessage(s_allocator_p); + bmqp_ctrlmsg::NegotiationMessage negotiationMessage( + bmqtst::TestHelperUtil::allocator()); negotiationMessage.makeClientIdentity().hostName() = "dummyIdentity"; - mqbcfg::ClusterDefinition clusterConfig(s_allocator_p); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - mqbnet::MockCluster mockCluster(clusterConfig, + mqbcfg::ClusterDefinition clusterConfig( + bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + mqbnet::MockCluster mockCluster(clusterConfig, &bufferFactory, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - mqbcfg::ClusterNode clusterNodeConfig(s_allocator_p); - mqbnet::MockClusterNode mockClusterNode(&mockCluster, - clusterNodeConfig, - &bufferFactory, - s_allocator_p); + mqbcfg::ClusterNode clusterNodeConfig(bmqtst::TestHelperUtil::allocator()); + mqbnet::MockClusterNode mockClusterNode( + &mockCluster, + clusterNodeConfig, + &bufferFactory, + bmqtst::TestHelperUtil::allocator()); bsl::shared_ptr testChannel; - testChannel.createInplace(s_allocator_p); + testChannel.createInplace(bmqtst::TestHelperUtil::allocator()); // Create a test object mqbnet::DummySession obj(testChannel, negotiationMessage, &mockClusterNode, description, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); { PV("Test Accessors"); @@ -82,7 +88,7 @@ static void test1_BreathingTest() { PV("Ensure that processEvent asserts"); - bmqp::Event event(s_allocator_p); + bmqp::Event event(bmqtst::TestHelperUtil::allocator()); ASSERT_OPT_FAIL(obj.processEvent(event, &mockClusterNode)); } @@ -105,7 +111,7 @@ int main(int argc, char* argv[]) case 1: test1_BreathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbnet/mqbnet_elector.t.cpp b/src/groups/mqb/mqbnet/mqbnet_elector.t.cpp index aa85907f2..c94b57bab 100644 --- a/src/groups/mqb/mqbnet/mqbnet_elector.t.cpp +++ b/src/groups/mqb/mqbnet/mqbnet_elector.t.cpp @@ -196,7 +196,7 @@ static void test1_breathingTest() ExpectedState exState; // Default construct the state machine - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(false, sm.isEnabled()); ELECTOR_VALIDATE(exState, sm); @@ -248,7 +248,7 @@ static void test2() // wait time, then becomes leader. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -262,7 +262,7 @@ static void test2() const int k_INACTIVITY_INTV_MS = 6 * bdlt::TimeUnitRatio::k_MS_PER_S; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -401,7 +401,7 @@ static void test3() // wait time, then becomes leader. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -415,7 +415,7 @@ static void test3() const int k_INACTIVITY_INTV_MS = 6 * bdlt::TimeUnitRatio::k_MS_PER_S; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -541,7 +541,7 @@ static void test4() // and goes back to being a follower (this occurs 2-3 times). // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -558,7 +558,7 @@ static void test4() s_electorClock->reset(); bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -846,7 +846,7 @@ static void test5() // beat with higher term and sends leadership cession event. // ------------------------------------------------------------------------- { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -860,7 +860,7 @@ static void test5() const int k_INACTIVITY_INTV_MS = 6 * bdlt::TimeUnitRatio::k_MS_PER_S; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -996,7 +996,7 @@ static void test6() // all 3 cases. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1010,7 +1010,7 @@ static void test6() const int k_INACTIVITY_INTV_MS = 6 * bdlt::TimeUnitRatio::k_MS_PER_S; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -1183,7 +1183,7 @@ static void test7() // becomes unavailable) and emits a leadership cession event. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1197,7 +1197,7 @@ static void test7() const int k_INACTIVITY_INTV_MS = 6 * bdlt::TimeUnitRatio::k_MS_PER_S; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -1335,7 +1335,7 @@ static void test8() // from a follower and emits a leadership cession event. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1349,7 +1349,7 @@ static void test8() const int k_INACTIVITY_INTV_MS = 6 * bdlt::TimeUnitRatio::k_MS_PER_S; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -1485,7 +1485,7 @@ static void test9() // leader. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1499,7 +1499,7 @@ static void test9() const int k_INACTIVITY_INTV_MS = 6 * bdlt::TimeUnitRatio::k_MS_PER_S; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -1561,7 +1561,7 @@ static void test10() // ends up getting election response from its peers. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1575,7 +1575,7 @@ static void test10() const int k_INACTIVITY_INTV_MS = 6 * bdlt::TimeUnitRatio::k_MS_PER_S; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -1646,7 +1646,7 @@ static void test11() // * Quorum == 3 // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1664,7 +1664,7 @@ static void test11() s_electorClock->reset(); bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -1814,7 +1814,7 @@ static void test12() // leader. The node must send out voting support event to the leader. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1827,7 +1827,7 @@ static void test12() const int k_INVALID_NODE = ElectorStateMachine::k_INVALID_NODE_ID; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -1871,7 +1871,7 @@ static void test13() // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1884,7 +1884,7 @@ static void test13() const int k_INVALID_NODE = ElectorStateMachine::k_INVALID_NODE_ID; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -1948,7 +1948,7 @@ static void test14() // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -1961,7 +1961,7 @@ static void test14() const int k_INVALID_NODE = ElectorStateMachine::k_INVALID_NODE_ID; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -2060,7 +2060,7 @@ static void test15() // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -2073,7 +2073,7 @@ static void test15() const int k_INVALID_NODE = ElectorStateMachine::k_INVALID_NODE_ID; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ElectorStateMachineOutput output; bsls::Types::Uint64 term = 0; @@ -2147,7 +2147,7 @@ static void test16() // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -2160,7 +2160,7 @@ static void test16() const int k_INVALID_NODE = ElectorStateMachine::k_INVALID_NODE_ID; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ElectorStateMachineOutput output; bsls::Types::Uint64 term = 0; @@ -2251,7 +2251,7 @@ static void test17() // // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -2264,7 +2264,7 @@ static void test17() const int k_INVALID_NODE = ElectorStateMachine::k_INVALID_NODE_ID; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ElectorStateMachineOutput output; bsls::Types::Uint64 term = 0; @@ -2355,7 +2355,7 @@ static void test18() // receives heartbeat from it (follower submits to leader). // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -2368,7 +2368,7 @@ static void test18() const int k_INVALID_NODE = ElectorStateMachine::k_INVALID_NODE_ID; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -2449,7 +2449,7 @@ static void test19() // following the leader). // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -2462,7 +2462,7 @@ static void test19() const int k_INVALID_NODE = ElectorStateMachine::k_INVALID_NODE_ID; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -2524,7 +2524,7 @@ static void test20() // heartbeat in return so that sender node can follow self. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -2538,7 +2538,7 @@ static void test20() const int k_INACTIVITY_INTV_MS = 6 * bdlt::TimeUnitRatio::k_MS_PER_S; bsls::Types::Uint64 age = 0; - ElectorStateMachine sm(s_allocator_p); + ElectorStateMachine sm(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ElectorState::e_DORMANT, sm.state()); @@ -2670,7 +2670,8 @@ int main(int argc, char* argv[]) using namespace mqbnet; // Setup the test clock (once per task) - s_electorClock = new (*s_allocator_p) bmqsys::MockTime; + s_electorClock = new (*bmqtst::TestHelperUtil::allocator()) + bmqsys::MockTime; switch (_testCase) { case 0: @@ -2696,11 +2697,11 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } - s_allocator_p->deallocate(s_electorClock); + bmqtst::TestHelperUtil::allocator()->deallocate(s_electorClock); TEST_EPILOG(bmqtst::TestHelper::e_CHECK_DEF_GBL_ALLOC); } diff --git a/src/groups/mqb/mqbnet/mqbnet_multirequestmanager.t.cpp b/src/groups/mqb/mqbnet/mqbnet_multirequestmanager.t.cpp index 7ba1e4156..ad2d5b0a3 100644 --- a/src/groups/mqb/mqbnet/mqbnet_multirequestmanager.t.cpp +++ b/src/groups/mqb/mqbnet/mqbnet_multirequestmanager.t.cpp @@ -406,7 +406,7 @@ TestContext::generateNodeDefs(int nodesCount, bslma::Allocator* allocator) ASSERT_GT(nodesCount, 0); mqbmock::Cluster::ClusterNodeDefs clusterNodeDefs(allocator); for (int i = 0; i < nodesCount; ++i) { - bsl::ostringstream nodeName(s_allocator_p); + bsl::ostringstream nodeName(bmqtst::TestHelperUtil::allocator()); nodeName << "testNode" << i; mqbc::ClusterUtil::appendClusterNode( &clusterNodeDefs, @@ -429,7 +429,8 @@ void TestContext::populateRequest(const ReqSp& request, { bmqp_ctrlmsg::OpenQueue& req = request->request().choice().makeOpenQueue(); - bmqp_ctrlmsg::QueueHandleParameters params(s_allocator_p); + bmqp_ctrlmsg::QueueHandleParameters params( + bmqtst::TestHelperUtil::allocator()); bmqt::QueueFlagsUtil::setWriter(&flags); bmqt::QueueFlagsUtil::setAck(&flags); @@ -458,19 +459,23 @@ static void test1_contextTest() { ReqContextSp reqContext; - ASSERT_PASS( - reqContext = bsl::make_shared(s_allocator_p)); + ASSERT_PASS(reqContext = bsl::make_shared( + bmqtst::TestHelperUtil::allocator())); - ReqSp request = bsl::make_shared(s_allocator_p); + ReqSp request = bsl::make_shared( + bmqtst::TestHelperUtil::allocator()); TestContext::populateRequest(request); ASSERT_PASS(reqContext->request() = request->request()); - mqbmock::Cluster::ClusterNodeDefs defs = - TestContext::generateNodeDefs(5, s_allocator_p); - bdlbb::PooledBlobBufferFactory blobBufferFactory(1024, s_allocator_p); - bmqu::TempDirectory tempDir(s_allocator_p); - mqbmock::Cluster cluster(&blobBufferFactory, - s_allocator_p, + mqbmock::Cluster::ClusterNodeDefs defs = TestContext::generateNodeDefs( + 5, + bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory blobBufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bmqu::TempDirectory tempDir(bmqtst::TestHelperUtil::allocator()); + mqbmock::Cluster cluster(&blobBufferFactory, + bmqtst::TestHelperUtil::allocator(), true, // isClusterMember false, // isLeader false, // isCSLMode @@ -478,7 +483,9 @@ static void test1_contextTest() defs, "testCluster", tempDir.path()); - Nodes nodes = TestContext::clusterNodes(&cluster, s_allocator_p); + Nodes nodes = TestContext::clusterNodes( + &cluster, + bmqtst::TestHelperUtil::allocator()); ASSERT_PASS(reqContext->setDestinationNodes(nodes)); NodeResponses responses = reqContext->response(); ASSERT_EQ(nodes.size(), responses.size()); @@ -492,7 +499,8 @@ static void test1_contextTest() reqContext->clear(); // Check that the MultiRequestManagerRequestContext object returned to // the default state - ASSERT_EQ(reqContext->request(), Mes(s_allocator_p)); + ASSERT_EQ(reqContext->request(), + Mes(bmqtst::TestHelperUtil::allocator())); ASSERT(reqContext->response().empty()); } } @@ -507,14 +515,15 @@ static void test2_creatorsTest() { // Null RequestManager pointer - ASSERT_SAFE_FAIL(MultiReqManagerType(NULL, s_allocator_p)); + ASSERT_SAFE_FAIL( + MultiReqManagerType(NULL, bmqtst::TestHelperUtil::allocator())); } { // Success creation - TestContext context(5, s_allocator_p); - ASSERT_PASS( - MultiReqManagerType(context.manager().get(), s_allocator_p)); + TestContext context(5, bmqtst::TestHelperUtil::allocator()); + ASSERT_PASS(MultiReqManagerType(context.manager().get(), + bmqtst::TestHelperUtil::allocator())); } } @@ -528,7 +537,7 @@ static void test3_sendRequestTest() { // Send one request and check it was delivered - TestContext context(5, s_allocator_p); + TestContext context(5, bmqtst::TestHelperUtil::allocator()); ReqSp req = context.createRequest(); context.populateRequest(req); @@ -556,7 +565,7 @@ static void test4_handleResponseTest() { // Successfully receive responses from all the nodes - TestContext context(5, s_allocator_p); + TestContext context(5, bmqtst::TestHelperUtil::allocator()); ReqSp req = context.createRequest(); context.populateRequest(req); bool called = false; @@ -565,7 +574,7 @@ static void test4_handleResponseTest() bdlf::PlaceHolders::_1)); context.sendRequest(req); - bsl::vector responses(s_allocator_p); + bsl::vector responses(bmqtst::TestHelperUtil::allocator()); responses.reserve(context.nodes().size()); NodesIt it = context.nodes().begin(); for (; it != context.nodes().end(); ++it) { @@ -596,7 +605,7 @@ static void test4_handleResponseTest() { // No responses from the nodes - TestContext context(5, s_allocator_p); + TestContext context(5, bmqtst::TestHelperUtil::allocator()); ReqSp req = context.createRequest(); context.populateRequest(req); bool called = false; @@ -614,10 +623,10 @@ static void test4_handleResponseTest() // Concurrency test. Create a lot of nodes and process their responses // from different threads. bslmt::Mutex responsesLock; - MesQue responses(s_allocator_p); + MesQue responses(bmqtst::TestHelperUtil::allocator()); const int nodesCount = 500; const int threadsCount = 10; - bslmt::ThreadGroup threadGroup(s_allocator_p); + bslmt::ThreadGroup threadGroup(bmqtst::TestHelperUtil::allocator()); bslmt::Barrier barrier(threadsCount + 1); /// Take one response from the specified `responses` queue and @@ -653,7 +662,7 @@ static void test4_handleResponseTest() } }; - TestContext context(nodesCount, s_allocator_p); + TestContext context(nodesCount, bmqtst::TestHelperUtil::allocator()); ReqSp req = context.createRequest(); context.populateRequest(req); bool called = false; @@ -699,8 +708,8 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqsys::Time::initialize(s_allocator_p); - bmqp::ProtocolUtil::initialize(s_allocator_p); + bmqsys::Time::initialize(bmqtst::TestHelperUtil::allocator()); + bmqp::ProtocolUtil::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -710,7 +719,7 @@ int main(int argc, char* argv[]) case 1: test1_contextTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbnet/mqbnet_negotiator.t.cpp b/src/groups/mqb/mqbnet/mqbnet_negotiator.t.cpp index ae042fa82..3d6893b80 100644 --- a/src/groups/mqb/mqbnet/mqbnet_negotiator.t.cpp +++ b/src/groups/mqb/mqbnet/mqbnet_negotiator.t.cpp @@ -120,7 +120,8 @@ static void test1_Negotiator() bmqtst::TestHelper::printTestName("Negotiator"); PV("Creating a test object"); - bsls::ProtocolTest testObj(s_verbosityLevel > 2); + bsls::ProtocolTest testObj( + bmqtst::TestHelperUtil::verbosityLevel() > 2); PV("Verify that the protocol is abstract"); ASSERT(testObj.testAbstract()); @@ -207,7 +208,7 @@ int main(int argc, char* argv[]) case 1: test1_Negotiator(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbnet/mqbnet_session.t.cpp b/src/groups/mqb/mqbnet/mqbnet_session.t.cpp index 55f944496..3fd0b35b1 100644 --- a/src/groups/mqb/mqbnet/mqbnet_session.t.cpp +++ b/src/groups/mqb/mqbnet/mqbnet_session.t.cpp @@ -154,8 +154,8 @@ static void test1_SessionEventProcessor() bmqtst::TestHelper::printTestName("SessionEventProcessor"); PV("Creating a test object"); - bsls::ProtocolTest testObj(s_verbosityLevel > - 2); + bsls::ProtocolTest testObj( + bmqtst::TestHelperUtil::verbosityLevel() > 2); PV("Verify that the protocol is abstract"); ASSERT(testObj.testAbstract()); @@ -220,7 +220,8 @@ static void test2_Session() bmqtst::TestHelper::printTestName("Session"); PV("Creating a test object"); - bsls::ProtocolTest testObj(s_verbosityLevel > 2); + bsls::ProtocolTest testObj( + bmqtst::TestHelperUtil::verbosityLevel() > 2); PV("Verify that the protocol is abstract"); ASSERT(testObj.testAbstract()); @@ -263,7 +264,7 @@ int main(int argc, char* argv[]) case 1: test1_SessionEventProcessor(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp b/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp index f9696c4f7..12fddeaf5 100644 --- a/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp +++ b/src/groups/mqb/mqbnet/mqbnet_tcpsessionfactory.cpp @@ -35,10 +35,6 @@ #include // BMQ -#include -#include -#include - #include #include #include @@ -46,7 +42,11 @@ #include #include #include +#include #include +#include +#include +#include #include #include #include @@ -67,6 +67,7 @@ #include #include #include +#include #include #include #include @@ -262,6 +263,24 @@ struct PortMatcher { } }; +template +T* channelCast(bmqio::Channel* base) +{ + bmqio::Channel* alias = base; + while (alias) { + T* target = dynamic_cast(alias); + if (target) { + return target; + } + bmqio::DecoratingChannelPartialImp* decorated = + dynamic_cast(alias); + if (!decorated) { + return NULL; + } + alias = decorated->base(); + } +} + } // close unnamed namespace // ----------------------------------------- diff --git a/src/groups/mqb/mqbs/mqbs_datafileiterator.t.cpp b/src/groups/mqb/mqbs/mqbs_datafileiterator.t.cpp index d51e597d3..94acc8059 100644 --- a/src/groups/mqb/mqbs/mqbs_datafileiterator.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_datafileiterator.t.cpp @@ -172,7 +172,7 @@ static void test1_breathingTest() // No records FileHeader fh; MappedFileDescriptor mfd; - char* p = addRecords(s_allocator_p, + char* p = addRecords(bmqtst::TestHelperUtil::allocator(), &mfd, &fh, NULL, // No messages @@ -182,13 +182,13 @@ static void test1_breathingTest() ASSERT_EQ(true, it.isValid()); ASSERT_EQ(-2, it.nextRecord()); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { // No records - reset FileHeader fh; MappedFileDescriptor mfd; - char* p = addRecords(s_allocator_p, + char* p = addRecords(bmqtst::TestHelperUtil::allocator(), &mfd, &fh, NULL, // No messages @@ -202,7 +202,7 @@ static void test1_breathingTest() ASSERT_EQ(true, it.isValid()); ASSERT_EQ(-2, it.nextRecord()); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } } @@ -237,8 +237,11 @@ static void test2_forwardIteration() FileHeader fileHeader; MappedFileDescriptor mfd; - char* p = - addRecords(s_allocator_p, &mfd, &fileHeader, MESSAGES, k_NUM_MSGS); + char* p = addRecords(bmqtst::TestHelperUtil::allocator(), + &mfd, + &fileHeader, + MESSAGES, + k_NUM_MSGS); ASSERT(p != 0); ASSERT_GT(mfd.fileSize(), 0ULL); @@ -280,7 +283,7 @@ static void test2_forwardIteration() ASSERT(it.nextRecord() != 1); ASSERT(!it.isValid()); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test3_reverseIteration() @@ -314,8 +317,11 @@ static void test3_reverseIteration() FileHeader fileHeader; MappedFileDescriptor mfd; - char* p = - addRecords(s_allocator_p, &mfd, &fileHeader, MESSAGES, k_NUM_MSGS); + char* p = addRecords(bmqtst::TestHelperUtil::allocator(), + &mfd, + &fileHeader, + MESSAGES, + k_NUM_MSGS); ASSERT(p != 0); ASSERT_GT(mfd.fileSize(), 0ULL); @@ -381,7 +387,7 @@ static void test3_reverseIteration() ASSERT_EQ(i, k_NUM_MSGS - 1); ASSERT_EQ(it.isValid(), false); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } // ============================================================================ @@ -399,7 +405,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_datastore.h b/src/groups/mqb/mqbs/mqbs_datastore.h index 67e7845a7..3de503c96 100644 --- a/src/groups/mqb/mqbs/mqbs_datastore.h +++ b/src/groups/mqb/mqbs/mqbs_datastore.h @@ -684,9 +684,11 @@ class DataStore : public mqbi::DispatcherClient { /// If the specified `storage` is `true`, flush any buffered replication /// messages to the peers. If the specified `queues` is `true`, `flush` - /// all associated queues. Behavior is undefined unless this node is - /// the primary for this partition. - virtual void dispatcherFlush(bool storage, bool queues) = 0; + /// all associated queues. + + /// Flush any buffered replication messages to the peers. Behaviour is + /// undefined unless this cluster node is the primary for this partition. + virtual void flushStorage() = 0; // ACCESSORS diff --git a/src/groups/mqb/mqbs/mqbs_datastore.t.cpp b/src/groups/mqb/mqbs/mqbs_datastore.t.cpp index 2a1fe2c14..e9ef843f2 100644 --- a/src/groups/mqb/mqbs/mqbs_datastore.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_datastore.t.cpp @@ -126,7 +126,7 @@ static void test2_defaultHashUniqueness() // hash. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Because there is no emplace on unordered_map, the temporary list // created upon insertion of objects in the map uses the default // allocator. @@ -151,7 +151,8 @@ static void test2_defaultHashUniqueness() typedef bsl::vector Keys; // hash -> vector of corresponding DataStoreRecordKeys - bsl::unordered_map hashes(s_allocator_p); + bsl::unordered_map hashes( + bmqtst::TestHelperUtil::allocator()); hashes.reserve(k_NUM_KEYS); bsl::hash hasher; @@ -179,7 +180,8 @@ static void test2_defaultHashUniqueness() ASSERT_LT(maxCollisions, k_MAX_EXPECTED_COLLISIONS); - if (s_verbosityLevel >= 1 || maxCollisions >= k_MAX_EXPECTED_COLLISIONS) { + if (bmqtst::TestHelperUtil::verbosityLevel() >= 1 || + maxCollisions >= k_MAX_EXPECTED_COLLISIONS) { cout << "Hash collision percentage..........: " << 100 - 100.0f * hashes.size() / k_NUM_KEYS << "%" << endl << "Max collisions.....................: " << maxCollisions @@ -212,7 +214,7 @@ static void test3_customHashUniqueness() // Hash uniqueness of the generated GUIDs. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Because there is no emplace on unordered_map, the temporary list // created upon insertion of objects in the map uses the default // allocator. @@ -234,7 +236,8 @@ static void test3_customHashUniqueness() typedef bsl::vector Keys; // hash -> vector of corresponding Keys - bsl::unordered_map hashes(s_allocator_p); + bsl::unordered_map hashes( + bmqtst::TestHelperUtil::allocator()); hashes.reserve(k_NUM_KEYS); @@ -263,7 +266,8 @@ static void test3_customHashUniqueness() ASSERT_LT(maxCollisions, k_MAX_EXPECTED_COLLISIONS); - if (s_verbosityLevel >= 1 || maxCollisions >= k_MAX_EXPECTED_COLLISIONS) { + if (bmqtst::TestHelperUtil::verbosityLevel() >= 1 || + maxCollisions >= k_MAX_EXPECTED_COLLISIONS) { cout << "Hash collision percentage..........: " << 100 - 100.0f * hashes.size() / k_NUM_KEYS << "%" << endl << "Max collisions.....................: " << maxCollisions @@ -364,8 +368,9 @@ static void testN3_orderedMapWithDefaultHashBenchmark() const size_t k_NUM_ELEMS = 10000000; // 10M mqbs::DataStoreRecordKey key; - bmqc::OrderedHashMap ht(k_NUM_ELEMS, - s_allocator_p); + bmqc::OrderedHashMap ht( + k_NUM_ELEMS, + bmqtst::TestHelperUtil::allocator()); // Warmup for (size_t i = 1; i <= 1000; ++i) { ht.insert(bsl::make_pair(mqbs::DataStoreRecordKey(i, 7), i)); @@ -408,7 +413,7 @@ static void testN4_orderedMapWithCustomHashBenchmark() bmqc::OrderedHashMap - ht(k_NUM_ELEMS, s_allocator_p); + ht(k_NUM_ELEMS, bmqtst::TestHelperUtil::allocator()); // Warmup for (size_t i = 1; i <= 1000; ++i) { @@ -501,8 +506,9 @@ static void testN3_orderedMapWithDefaultHashBenchmark_GoogleBenchmark( mqbs::DataStoreRecordKey key; - bmqc::OrderedHashMap ht(state.range(0), - s_allocator_p); + bmqc::OrderedHashMap ht( + state.range(0), + bmqtst::TestHelperUtil::allocator()); // Warmup for (size_t i = 1; i <= 1000; ++i) { ht.insert(bsl::make_pair(mqbs::DataStoreRecordKey(i, 7), i)); @@ -536,7 +542,7 @@ static void testN4_orderedMapWithCustomHashBenchmark_GoogleBenchmark( bmqc::OrderedHashMap - ht(state.range(0), s_allocator_p); + ht(state.range(0), bmqtst::TestHelperUtil::allocator()); // Warmup for (size_t i = 1; i <= 1000; ++i) { @@ -590,7 +596,7 @@ int main(int argc, char* argv[]) break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } #ifdef BSLS_PLATFORM_OS_LINUX diff --git a/src/groups/mqb/mqbs/mqbs_filebackedstorage.cpp b/src/groups/mqb/mqbs/mqbs_filebackedstorage.cpp index fd84ad73e..5f00072ac 100644 --- a/src/groups/mqb/mqbs/mqbs_filebackedstorage.cpp +++ b/src/groups/mqb/mqbs/mqbs_filebackedstorage.cpp @@ -250,6 +250,14 @@ int FileBackedStorage::configure( return 0; } +void FileBackedStorage::setConsistency(const mqbconfm::Consistency& value) +{ + // PRECONDITIONS + BSLS_ASSERT_SAFE(value.isEventualValue() || value.isStrongValue()); + + d_hasReceipts = value.isEventualValue(); +} + void FileBackedStorage::setQueue(mqbi::Queue* queue) { d_virtualStorageCatalog.setQueue(queue); @@ -580,7 +588,7 @@ FileBackedStorage::removeAll(const mqbu::StorageKey& appKey) if (appKey.isNull()) { purgeCommon(appKey); // or 'mqbu::StorageKey::k_NULL_KEY' - dispatcherFlush(true, false); + flushStorage(); d_isEmpty.storeRelaxed(1); return mqbi::StorageResult::e_SUCCESS; // RETURN @@ -591,7 +599,7 @@ FileBackedStorage::removeAll(const mqbu::StorageKey& appKey) d_virtualStorageCatalog.removeAll(appKey); // This will call back 'releaseRef' - dispatcherFlush(true, false); + flushStorage(); if (d_handles.empty()) { d_isEmpty.storeRelaxed(1); @@ -604,9 +612,9 @@ FileBackedStorage::removeAll(const mqbu::StorageKey& appKey) return mqbi::StorageResult::e_SUCCESS; } -void FileBackedStorage::dispatcherFlush(bool storage, bool queues) +void FileBackedStorage::flushStorage() { - d_store_p->dispatcherFlush(storage, queues); + d_store_p->flushStorage(); } int FileBackedStorage::gcExpiredMessages( diff --git a/src/groups/mqb/mqbs/mqbs_filebackedstorage.h b/src/groups/mqb/mqbs/mqbs_filebackedstorage.h index befe1dab9..e42977401 100644 --- a/src/groups/mqb/mqbs/mqbs_filebackedstorage.h +++ b/src/groups/mqb/mqbs/mqbs_filebackedstorage.h @@ -204,7 +204,7 @@ class FileBackedStorage BSLS_KEYWORD_FINAL : public ReplicatedStorage { bmqp::SchemaLearner::Context d_schemaLearnerContext; // Context for replicated data. - const bool d_hasReceipts; + bool d_hasReceipts; bmqt::MessageGUID d_currentlyAutoConfirming; // Message being evaluated and possibly auto confirmed. @@ -368,6 +368,11 @@ class FileBackedStorage BSLS_KEYWORD_FINAL : public ReplicatedStorage { const bsls::Types::Int64 messageTtl, int maxDeliveryAttempts) BSLS_KEYWORD_OVERRIDE; + /// Set the consistency level associated to this storage to the specified + /// `value`. + void + setConsistency(const mqbconfm::Consistency& value) BSLS_KEYWORD_OVERRIDE; + /// Return the resource capacity meter associated to this storage. virtual mqbu::CapacityMeter* capacityMeter() BSLS_KEYWORD_OVERRIDE; @@ -469,12 +474,9 @@ class FileBackedStorage BSLS_KEYWORD_FINAL : public ReplicatedStorage { virtual mqbi::StorageResult::Enum removeAll(const mqbu::StorageKey& appKey) BSLS_KEYWORD_OVERRIDE; - /// If the specified `storage` is `true`, flush any buffered replication - /// messages to the peers. If the specified `queues` is `true`, `flush` - /// all associated queues. Behavior is undefined unless this node is - /// the primary for this partition. - virtual void dispatcherFlush(bool storage, - bool queues) BSLS_KEYWORD_OVERRIDE; + /// Flush any buffered replication messages to the peers. Behaviour is + /// undefined unless this cluster node is the primary for this partition. + void flushStorage() BSLS_KEYWORD_OVERRIDE; /// Attempt to garbage-collect messages for which TTL has expired, and /// return the number of messages garbage-collected. Populate the diff --git a/src/groups/mqb/mqbs/mqbs_filebackedstorage.t.cpp b/src/groups/mqb/mqbs/mqbs_filebackedstorage.t.cpp index 03b3504c4..46024f384 100644 --- a/src/groups/mqb/mqbs/mqbs_filebackedstorage.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_filebackedstorage.t.cpp @@ -408,7 +408,7 @@ class MockDataStore : public mqbs::DataStore { void clearPrimary() BSLS_KEYWORD_OVERRIDE {} - void dispatcherFlush(bool, bool) BSLS_KEYWORD_OVERRIDE {} + void flushStorage() BSLS_KEYWORD_OVERRIDE {} bool isOpen() const BSLS_KEYWORD_OVERRIDE { return true; } @@ -510,16 +510,16 @@ struct Tester { domainCfg.deduplicationTimeMs() = 0; // No history domainCfg.messageTtl() = ttlSeconds; - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); d_mockDomain.configure(errDescription, domainCfg); d_replicatedStorage_mp.load( - new (*d_allocator_p) - mqbs::FileBackedStorage(&d_dataStore, - bmqt::Uri(uri, s_allocator_p), - queueKey, - &d_mockDomain, - d_allocator_p), + new (*d_allocator_p) mqbs::FileBackedStorage( + &d_dataStore, + bmqt::Uri(uri, bmqtst::TestHelperUtil::allocator()), + queueKey, + &d_mockDomain, + d_allocator_p), d_allocator_p); d_replicatedStorage_mp->setQueue(&d_mockQueue); @@ -552,7 +552,7 @@ struct Tester { limits.bytes() = byteCapacity; limits.bytesWatermarkRatio() = byteWatermarkRatio; - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); return d_replicatedStorage_mp->configure(errDescription, config, limits, @@ -607,9 +607,10 @@ struct Tester { bmqt::CompressionAlgorithmType::e_NONE); const bsl::shared_ptr appDataPtr( - new (*s_allocator_p) - bdlbb::Blob(&d_bufferFactory, s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bdlbb::Blob(&d_bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&(*appDataPtr), reinterpret_cast(&data), @@ -675,7 +676,7 @@ struct Test : bmqtst::Test { // ----------- // CREATORS Test::Test() -: d_tester(s_allocator_p, +: d_tester(bmqtst::TestHelperUtil::allocator(), k_PARTITION_ID, k_URI_STR, k_QUEUE_KEY, @@ -711,7 +712,7 @@ TEST(breathingTest) { bmqtst::TestHelper::printTestName("BREATHING TEST"); - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); mqbs::ReplicatedStorage& storage = tester.storage(); @@ -726,7 +727,7 @@ TEST(breathingTest) ASSERT_NE(storage.queue(), static_cast(0)); // Queue has been set via call to 'setQueue' - ASSERT_PASS(storage.dispatcherFlush(true, false)); + ASSERT_PASS(storage.flushStorage()); // Does nothing, at the time of this writing ASSERT_EQ(storage.queueOpRecordHandles().empty(), true); @@ -748,7 +749,7 @@ TEST(configure) { bmqtst::TestHelper::printTestName("CONFIGURE"); - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_DEFAULT_MSG, k_DEFAULT_BYTES) == 0); @@ -844,7 +845,7 @@ TEST_F(Test, put_noVirtualStorage) { bmqtst::TestHelper::printTestName("PUT - WITH NO VIRTUAL STORAGES"); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); const int k_MSG_COUNT = 10; @@ -881,7 +882,7 @@ TEST_F(Test, getMessageSize) { bmqtst::TestHelper::printTestName("GET MESSAGE SIZE"); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); const int k_MSG_COUNT = 10; @@ -919,7 +920,7 @@ TEST_F(Test, get_noVirtualStorages) { bmqtst::TestHelper::printTestName("GET - WITH NO VIRTUAL STORAGES"); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); const int k_MSG_COUNT = 5; @@ -1006,7 +1007,7 @@ TEST_F(Test, removeMessage) const int k_MSG_COUNT = 10; - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Check 'put' - To physical storage (StorageKeys = NULL) BSLS_ASSERT_OPT(d_tester.addMessages(&guids, k_MSG_COUNT) == @@ -1042,8 +1043,8 @@ TEST_F(Test, addVirtualStorage) { bmqtst::TestHelper::printTestName("ADD VIRTUAL STORAGE"); - bmqu::MemOutStream errDescription(s_allocator_p); - bsl::string dummyAppId(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); + bsl::string dummyAppId(bmqtst::TestHelperUtil::allocator()); mqbu::StorageKey dummyAppKey; mqbs::ReplicatedStorage& storage = d_tester.storage(); @@ -1069,8 +1070,8 @@ TEST_F(Test, hasVirtualStorage) { bmqtst::TestHelper::printTestName("HAS VIRTUAL STORAGE"); - bmqu::MemOutStream errDescription(s_allocator_p); - bsl::string dummyAppId(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); + bsl::string dummyAppId(bmqtst::TestHelperUtil::allocator()); mqbu::StorageKey dummyAppKey; mqbs::ReplicatedStorage& storage = d_tester.storage(); @@ -1107,8 +1108,8 @@ TEST_F(Test, removeVirtualStorage) { bmqtst::TestHelper::printTestName("REMOVE VIRTUAL STORAGE"); - bmqu::MemOutStream errDescription(s_allocator_p); - bsl::string dummyAppId(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); + bsl::string dummyAppId(bmqtst::TestHelperUtil::allocator()); mqbs::ReplicatedStorage& storage = d_tester.storage(); @@ -1144,9 +1145,9 @@ TEST(put_withVirtualStorages) const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -1166,7 +1167,7 @@ TEST(put_withVirtualStorages) const bsls::Types::Int64 k_BYTE_PER_MSG = static_cast( sizeof(int)); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Check 'put'- To physical storage (StorageKeys = NULL) ASSERT_EQ(tester.addMessages(&guids, k_MSG_COUNT), @@ -1210,12 +1211,12 @@ TEST(removeAllMessages_appKeyNotFound) bmqtst::TestHelper::printTestName("REMOVE ALL MESSAGES " "- APPKEY NOT FOUND"); - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -1234,7 +1235,7 @@ TEST(removeAllMessages_appKeyNotFound) const bsls::Types::Int64 k_BYTE_PER_MSG = static_cast( sizeof(int)); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); tester.addMessages(&guids, k_MSG_COUNT); // Verify 'removeAll' operation @@ -1260,12 +1261,12 @@ TEST(removeAllMessages) { bmqtst::TestHelper::printTestName("Remove All Messages Test"); - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -1285,7 +1286,7 @@ TEST(removeAllMessages) const bsls::Types::Int64 k_BYTE_PER_MSG = static_cast( sizeof(int)); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(tester.addMessages(&guids, k_MSG_COUNT), mqbi::StorageResult::e_SUCCESS); @@ -1324,12 +1325,12 @@ TEST(get_withVirtualStorages) { bmqtst::TestHelper::printTestName("Get - with Virtual Storage Test"); - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -1340,7 +1341,7 @@ TEST(get_withVirtualStorages) // Scenario // Single Virtual Storages - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Check 'put'- To physical storage (StorageKeys = NULL) ASSERT_EQ(tester.addMessages(&guids, 20), mqbi::StorageResult::e_SUCCESS); @@ -1385,9 +1386,9 @@ TEST(confirm) const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -1408,7 +1409,7 @@ TEST(confirm) const bsls::Types::Int64 k_BYTE_PER_MSG = static_cast( sizeof(int)); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Check 'put': To physical storage (StorageKeys = NULL) ASSERT_EQ(tester.addMessages(&guids, @@ -1467,7 +1468,7 @@ TEST_F(Test, getIterator_noVirtualStorages) const int k_MSG_COUNT = 10; - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Put to physical storage: StorageKeys NULL ASSERT_EQ(d_tester.addMessages(&guids, k_MSG_COUNT), @@ -1536,12 +1537,12 @@ TEST(getIterator_withVirtualStorages) { bmqtst::TestHelper::printTestName("Iterator Test- In presence of Virtual"); - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -1554,7 +1555,7 @@ TEST(getIterator_withVirtualStorages) // Two Virtual Storages // Try iterator for physical storage as well as both of these storages. - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Check 'put': To physical storage (StorageKeys = NULL) ASSERT_EQ(tester.addMessages(&guids, 20), mqbi::StorageResult::e_SUCCESS); @@ -1638,7 +1639,7 @@ TEST_F(Test, capacityMeter_limitMessages) { bmqtst::TestHelper::printTestName("Capacity Meter- Limit Messages"); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Put to physical storage: StorageKeys NULL ASSERT_EQ(d_tester.addMessages(&guids, k_DEFAULT_MSG), @@ -1683,11 +1684,11 @@ TEST(capacityMeter_limitBytes) const bsls::Types::Int64 k_MSG_LIMIT = 30; const bsls::Types::Int64 k_BYTES_LIMIT = 80; - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Insert Max messages possible in 80bytes const int k_MSG_COUNT = 20; @@ -1726,7 +1727,7 @@ TEST(garbageCollect) // input const int k_TTL = 20; - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_DEFAULT_MSG, k_DEFAULT_BYTES, @@ -1734,7 +1735,7 @@ TEST(garbageCollect) k_BYTE_WATERMARK_RATIO, k_TTL) == 0); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); int k_MSG_COUNT = 10; @@ -1807,7 +1808,7 @@ TEST_F(Test, doNotRecordLastConfirmInPriorityMode) "Do Not Record Last Confirm In Priority Mode"); const int k_MSG_COUNT = 1; - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); const MockDataStore& data_store = d_tester.dataStore(); mqbs::ReplicatedStorage& storage = d_tester.storage(); @@ -1835,7 +1836,7 @@ TEST_F(Test, doNotRecordLastConfirmInFanoutMode) { bmqtst::TestHelper::printTestName( "Do Not Record Last Confirm in Fanout Mode"); - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); const MockDataStore& data_store = d_tester.dataStore(); mqbs::ReplicatedStorage& storage = d_tester.storage(); @@ -1851,7 +1852,7 @@ TEST_F(Test, doNotRecordLastConfirmInFanoutMode) const int dataOffset = 0; const bool useSameGuids = false; const int defaultRefCount = 3; - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(data_store.getMessageCounter(), 0ULL); ASSERT_EQ(data_store.getConfirmCounter(), 0ULL); @@ -1904,17 +1905,19 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_CHECK_GBL_ALLOC); - bmqt::UriParser::initialize(s_allocator_p); - bmqsys::Time::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); + bmqsys::Time::initialize(bmqtst::TestHelperUtil::allocator()); mqbu::MessageGUIDUtil::initialize(); { - mqbcfg::AppConfig brokerConfig(s_allocator_p); + mqbcfg::AppConfig brokerConfig(bmqtst::TestHelperUtil::allocator()); mqbcfg::BrokerConfig::set(brokerConfig); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); bmqtst::runTest(_testCase); } diff --git a/src/groups/mqb/mqbs/mqbs_fileset.t.cpp b/src/groups/mqb/mqbs/mqbs_fileset.t.cpp index dad1fad74..628885865 100644 --- a/src/groups/mqb/mqbs/mqbs_fileset.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_fileset.t.cpp @@ -50,9 +50,11 @@ static void test1_breathingTest() bmqtst::TestHelper::printTestName("BREATHING TEST"); // Default constructor - mqbs::FileSet obj(static_cast(0), s_allocator_p); - ASSERT_SAFE_PASS(new (&obj) mqbs::FileSet(static_cast(0), - s_allocator_p)); + mqbs::FileSet obj(static_cast(0), + bmqtst::TestHelperUtil::allocator()); + ASSERT_SAFE_PASS(new (&obj) + mqbs::FileSet(static_cast(0), + bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(obj.d_store_p, static_cast(0)); ASSERT_EQ(obj.d_dataFileKey.isNull(), true); @@ -72,7 +74,7 @@ static void test1_breathingTest() ASSERT_EQ(obj.d_fileSetRolloverPolicyAlarm, false); ASSERT_EQ(obj.d_aliasedBlobBufferCount, 1LL); - ASSERT_EQ(obj.d_allocator_p, s_allocator_p); + ASSERT_EQ(obj.d_allocator_p, bmqtst::TestHelperUtil::allocator()); } // ============================================================================ @@ -88,7 +90,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_filestore.cpp b/src/groups/mqb/mqbs/mqbs_filestore.cpp index e70aded66..197d9cbfe 100644 --- a/src/groups/mqb/mqbs/mqbs_filestore.cpp +++ b/src/groups/mqb/mqbs/mqbs_filestore.cpp @@ -210,6 +210,70 @@ bool compareByByte(const bsl::pair& lhs, return lhs.second.second > rhs.second.second; } +void printRecord(bsl::ostream& stream, const MemoryBlock& mBlock) +{ + OffsetPtr recHeader(mBlock, 0); + + if (mqbs::RecordType::e_MESSAGE == recHeader->type()) { + OffsetPtr mesRec(mBlock, 0); + mesRec->print(stream); + } + else if (mqbs::RecordType::e_CONFIRM == recHeader->type()) { + OffsetPtr confRec(mBlock, 0); + confRec->print(stream); + } + else if (mqbs::RecordType::e_DELETION == recHeader->type()) { + OffsetPtr delRec(mBlock, 0); + delRec->print(stream); + } + else if (mqbs::RecordType::e_JOURNAL_OP == recHeader->type()) { + OffsetPtr jOpRec(mBlock, 0); + jOpRec->print(stream); + } + else { + BSLS_ASSERT_SAFE(mqbs::RecordType::e_QUEUE_OP == recHeader->type()); + OffsetPtr qOpRec(mBlock, 0); + qOpRec->print(stream); + } +} + +void printLastJournalRecord(bsl::ostream& stream, + const MappedFileDescriptor& journal, + const bsls::Types::Uint64& journalPos) +{ + if (journalPos >= FileStoreProtocol::k_JOURNAL_RECORD_SIZE) { + // Create a 'MemoryBlock' for the last record in local journal + MemoryBlock selfBlock(journal.block().base() + journalPos - + FileStoreProtocol::k_JOURNAL_RECORD_SIZE, + FileStoreProtocol::k_JOURNAL_RECORD_SIZE); + stream << "Last record in self journal: \n"; + printRecord(stream, selfBlock); + stream << "\n"; + } + else { + stream << "There are no records in self journal yet\n"; + } +} + +void printNextEventRecord(bsl::ostream& stream, + const bsl::shared_ptr& event, + const bmqu::BlobPosition& recordPosition, + bslma::Allocator* allocator) +{ + char* p = static_cast( + allocator->allocate(FileStoreProtocol::k_JOURNAL_RECORD_SIZE)); + MemoryBlock primaryBlock(p, FileStoreProtocol::k_JOURNAL_RECORD_SIZE); + bmqu::BlobUtil::copyToRawBufferFromIndex( + primaryBlock.base(), + *event, + recordPosition.buffer(), + recordPosition.byte(), + FileStoreProtocol::k_JOURNAL_RECORD_SIZE); + stream << "Next record in primary journal: \n"; + printRecord(stream, primaryBlock); + allocator->deallocate(p); +} + } // close unnamed namespace // ------------------------------------- @@ -4404,14 +4468,19 @@ int FileStore::writeJournalRecord(const bmqp::StorageHeader& header, if (journalPos != primaryJournalOffset) { // Primary's and self views of the journal have diverged. + bsl::ostringstream os; + printLastJournalRecord(os, journal, journalPos); + printNextEventRecord(os, event, recordPosition, d_allocator_p); + BMQTSK_ALARMLOG_ALARM("REPLICATION") << partitionDesc() << "Received journal record of type [" << messageType << "] with journal offset mismatch. Primary's journal offset: " << primaryJournalOffset << ", self journal offset: " << journalPos << ", msg sequence number (" << recHeader.primaryLeaseId() << ", " - << recHeader.sequenceNumber() << "). Ignoring this message." - << BMQTSK_ALARMLOG_END; + << recHeader.sequenceNumber() << "). Ignoring this message.\n" + << os.str() << BMQTSK_ALARMLOG_END; + return rc_JOURNAL_OUT_OF_SYNC; // RETURN } @@ -5116,8 +5185,8 @@ void FileStore::flushIfNeeded(bool immediateFlush) { if (immediateFlush || d_storageEventBuilder.messageCount() >= d_nagglePacketCount) { - dispatcherFlush(true, false); - + // Should notify weak consistency queues after replicated batch + flushStorage(); notifyQueuesOnReplicatedBatch(); } } @@ -5151,6 +5220,7 @@ FileStore::FileStore(const DataStoreConfig& config, , d_lastSyncPtReceived(false) , d_records(10000, d_allocators.get("OutstandingRecords")) , d_unreceipted(d_allocators.get("UnreceiptedRecords")) +, d_replicationNotifications(allocator) , d_replicationFactor(replicationFactor) , d_nodes(allocator) , d_lastRecoveredStrongConsistency() @@ -5560,6 +5630,12 @@ int FileStore::writeMessageRecord(mqbi::StorageMessageAttributes* attributes, attributes->queueHandle()))); flags = bmqp::StorageHeaderFlags::e_RECEIPT_REQUESTED; } + else { + if (d_replicationNotifications.find(queueKey) == + d_replicationNotifications.end()) { + d_replicationNotifications.insert(queueKey); + } + } // Replicate the message. replicateRecord(bmqp::StorageMessageType::e_DATA, @@ -6888,62 +6964,61 @@ void FileStore::clearPrimary() } } -void FileStore::dispatcherFlush(bool storage, bool queues) +void FileStore::flushStorage() { - // 'LocalQueue::flush' invokes 'dispaterFlush'. - // This means that 'dispaterFlush' will be executed more frequently on a + // 'LocalQueue::flush' invokes 'flushStorage'. + // This means that 'flushStorage' will be executed more frequently on a // FileStore than actually applicable. This is ok and has no side effect. - // Note that 'RemoteQueue::dispaterFlush' will not invoke - // 'FileStore::dispaterFlush' because only the partition's primary node - // should invoke 'dispaterFlush' on the FileStore. + // Note that 'RemoteQueue::flush' will not invoke + // 'FileStore::flushStorage' because only the partition's primary node + // should invoke 'flushStorage' on the FileStore. BSLS_ASSERT_SAFE(d_isPrimary); - if (storage) { - if (d_storageEventBuilder.messageCount() != 0) { - BALL_LOG_TRACE << partitionDesc() << "Flushing " - << d_storageEventBuilder.messageCount() - << " STORAGE messages."; - const int maxChannelPendingItems = d_cluster_p->broadcast( - d_storageEventBuilder.blob()); - if (maxChannelPendingItems > 0) { - if (d_nagglePacketCount < k_NAGLE_PACKET_COUNT) { - // back off - ++d_nagglePacketCount; - } - } - else if (d_nagglePacketCount) { - --d_nagglePacketCount; + if (d_storageEventBuilder.messageCount() != 0) { + BALL_LOG_TRACE << partitionDesc() << "Flushing " + << d_storageEventBuilder.messageCount() + << " STORAGE messages."; + const int maxChannelPendingItems = d_cluster_p->broadcast( + d_storageEventBuilder.blob()); + if (maxChannelPendingItems > 0) { + if (d_nagglePacketCount < k_NAGLE_PACKET_COUNT) { + // back off + ++d_nagglePacketCount; } - d_storageEventBuilder.reset(); } - } - if (queues && d_storageEventBuilder.messageCount() == 0) { - // Empty 'd_storageEventBuilder' means it has been flushed and it is a - // good time to flush queues. - for (StorageMapIter it = d_storages.begin(); it != d_storages.end(); - ++it) { - ReplicatedStorage* rs = it->second; - if (rs->queue()) { - rs->queue()->onReplicatedBatch(); - } + else if (d_nagglePacketCount) { + --d_nagglePacketCount; } + d_storageEventBuilder.reset(); } } void FileStore::notifyQueuesOnReplicatedBatch() { - if (d_storageEventBuilder.messageCount() == 0) { + if (BSLS_PERFORMANCEHINT_PREDICT_LIKELY( + d_storageEventBuilder.messageCount() == 0)) { // Empty 'd_storageEventBuilder' means it has been flushed and it is a - // good time to flush queues. - for (StorageMapIter it = d_storages.begin(); it != d_storages.end(); - ++it) { - ReplicatedStorage* rs = it->second; - if (rs->queue()) { - rs->queue()->onReplicatedBatch(); + // good time to flush weak consistency queues. + + for (bsl::unordered_set::iterator it = + d_replicationNotifications.begin(); + it != d_replicationNotifications.end(); + it++) { + // TODO: possible to store ReplicatedStorage directly and have one + // less lookup, but it requires to handle the case when the + // storage was removed before `notifyQueuesOnReplicatedBatch` + // call. + StoragesMap::iterator storageIt = d_storages.find(*it); + if (storageIt != d_storages.end()) { + ReplicatedStorage* rs = storageIt->second; + if (rs->queue()) { + rs->queue()->onReplicatedBatch(); + } } } + d_replicationNotifications.clear(); } } @@ -7018,10 +7093,10 @@ bool FileStore::gcExpiredMessages(const bdlt::Datetime& currentTimeUtc) if (needToFlush) { // Have to explicitly flush 'd_storageEventBuilder', to make sure // deletion records get replicated before queue unassignement. - // If queues are idle, 'dispatcherFlush()' won't get called. + // If queues are idle, 'flushStorage()' won't get called. // Internal-ticket D168465018. - dispatcherFlush(true, false); + flushStorage(); } return haveMore; diff --git a/src/groups/mqb/mqbs/mqbs_filestore.h b/src/groups/mqb/mqbs/mqbs_filestore.h index 1559d05d2..9db6a44de 100644 --- a/src/groups/mqb/mqbs/mqbs_filestore.h +++ b/src/groups/mqb/mqbs/mqbs_filestore.h @@ -330,6 +330,12 @@ class FileStore : public DataStore { // Ordered list of records pending // Receipt. + /// For weak consistency only. + /// The container that holds keys to storages where we put messages since + /// the last storage event builder flush. Used to notify these queues on + /// replication complete, so they change from processing PUTs to PUSHes. + bsl::unordered_set d_replicationNotifications; + int d_replicationFactor; NodeReceiptContexts d_nodes; @@ -866,14 +872,14 @@ class FileStore : public DataStore { /// Clear the current primary associated with this partition. void clearPrimary() BSLS_KEYWORD_OVERRIDE; - /// If the specified `storage` is `true`, flush any buffered replication - /// messages to the peers. If the specified `queues` is `true`, `flush` - /// all associated queues. Behavior is undefined unless this node is - /// the primary for this partition. - void dispatcherFlush(bool storage, bool queues) BSLS_KEYWORD_OVERRIDE; + /// Flush any buffered replication messages to the peers. Behaviour is + /// undefined unless this cluster node is the primary for this partition. + void flushStorage() BSLS_KEYWORD_OVERRIDE; - /// Call `onReplicatedBatch` on all associated queues if the storage - /// builder is empty (just flushed). + /// Flush weak consistency queues that have replicated messages since the + /// last call. This method has no effect if `d_storageEventBuilder` is not + /// empty, and must only be called after `flushStorage`. Behaviour is + /// undefined unless this cluster node is the primary for this partition. void notifyQueuesOnReplicatedBatch(); /// Invoke the specified `functor` with each queue associated to the diff --git a/src/groups/mqb/mqbs/mqbs_filestore.t.cpp b/src/groups/mqb/mqbs/mqbs_filestore.t.cpp index 4acbbfe45..33a176f3b 100644 --- a/src/groups/mqb/mqbs/mqbs_filestore.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_filestore.t.cpp @@ -167,29 +167,30 @@ struct Tester { public: // CREATORS Tester(const char* location) - : d_scheduler(bsls::SystemClockType::e_MONOTONIC, s_allocator_p) - , d_bufferFactory(1024, s_allocator_p) - , d_clusterLocation(location, s_allocator_p) - , d_clusterArchiveLocation(location, s_allocator_p) + : d_scheduler(bsls::SystemClockType::e_MONOTONIC, + bmqtst::TestHelperUtil::allocator()) + , d_bufferFactory(1024, bmqtst::TestHelperUtil::allocator()) + , d_clusterLocation(location, bmqtst::TestHelperUtil::allocator()) + , d_clusterArchiveLocation(location, bmqtst::TestHelperUtil::allocator()) , d_blobSpPool(bdlf::BindUtil::bind(&createBlob, &d_bufferFactory, bdlf::PlaceHolders::_1, // arena bdlf::PlaceHolders::_2), // alloc 1024, // blob pool growth strategy - s_allocator_p) - , d_partitionCfg(s_allocator_p) - , d_clusterCfg(s_allocator_p) - , d_clusterNodesCfg(s_allocator_p) - , d_clusterNodeCfg(s_allocator_p) + bmqtst::TestHelperUtil::allocator()) + , d_partitionCfg(bmqtst::TestHelperUtil::allocator()) + , d_clusterCfg(bmqtst::TestHelperUtil::allocator()) + , d_clusterNodesCfg(bmqtst::TestHelperUtil::allocator()) + , d_clusterNodeCfg(bmqtst::TestHelperUtil::allocator()) , d_clusterStatsRootContext_sp( mqbstat::ClusterStatsUtil::initializeStatContextCluster( 2, - s_allocator_p)) - , d_clusterStats(s_allocator_p) - , d_miscWorkThreadPool(1, 1, s_allocator_p) + bmqtst::TestHelperUtil::allocator())) + , d_clusterStats(bmqtst::TestHelperUtil::allocator()) + , d_miscWorkThreadPool(1, 1, bmqtst::TestHelperUtil::allocator()) , d_dispatcherClientData() - , d_dispatcher(s_allocator_p) - , d_statePool(1024, s_allocator_p) + , d_dispatcher(bmqtst::TestHelperUtil::allocator()) + , d_statePool(1024, bmqtst::TestHelperUtil::allocator()) { bdls::FilesystemUtil::remove(d_clusterLocation, true); bdls::FilesystemUtil::remove(d_clusterArchiveLocation, true); @@ -220,11 +221,12 @@ struct Tester { d_clusterCfg.nodes() = d_clusterNodesCfg; - d_cluster_mp.load(new (*s_allocator_p) - mqbnet::MockCluster(d_clusterCfg, - &d_bufferFactory, - s_allocator_p), - s_allocator_p); + d_cluster_mp.load( + new (*bmqtst::TestHelperUtil::allocator()) + mqbnet::MockCluster(d_clusterCfg, + &d_bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); d_node_p = d_cluster_mp->lookupNode(k_NODE_ID); d_dsCfg @@ -263,8 +265,8 @@ struct Tester { d_clusterStats.initialize("testCluster", 1, // numPartitions d_clusterStatsRootContext_sp.get(), - s_allocator_p); - d_fs_mp.load(new (*s_allocator_p) + bmqtst::TestHelperUtil::allocator()); + d_fs_mp.load(new (*bmqtst::TestHelperUtil::allocator()) mqbs::FileStore(d_dsCfg, 0, // processorId &d_dispatcher, @@ -276,8 +278,8 @@ struct Tester { false, // isCSLModeEnabled false, // isFSMWorkflow 1, // replicationFactor - s_allocator_p), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); } ~Tester() @@ -306,10 +308,12 @@ struct Tester { typedef bsl::map QueueKeyGuidsMap; typedef QueueKeyGuidsMap::iterator QueueKeyGuidsMapIter; - QueueKeyUriMap queueKeyUriMap(s_allocator_p); - QueueKeyGuidsMap queueKeyGuidsMap(s_allocator_p); - QueueKeyGuidsMap queueKeyConfGuidsMap(s_allocator_p); - bsl::string uriBase("bmq://si.amw.bmq.stats/", s_allocator_p); + QueueKeyUriMap queueKeyUriMap(bmqtst::TestHelperUtil::allocator()); + QueueKeyGuidsMap queueKeyGuidsMap(bmqtst::TestHelperUtil::allocator()); + QueueKeyGuidsMap queueKeyConfGuidsMap( + bmqtst::TestHelperUtil::allocator()); + bsl::string uriBase("bmq://si.amw.bmq.stats/", + bmqtst::TestHelperUtil::allocator()); const size_t k_DIVISOR = 7; int rc = 0; int seed = 58133; @@ -328,7 +332,7 @@ struct Tester { if (0 == recType) { // Write a queue creation record. - bsl::string uri(uriBase, s_allocator_p); + bsl::string uri(uriBase, bmqtst::TestHelperUtil::allocator()); bmqu::MemOutStream osstr; osstr << "queue" << i; uri.append(osstr.str().data(), osstr.str().length()); @@ -353,7 +357,7 @@ struct Tester { .c_str()); mqbs::DataStoreRecordHandle handle; - Record rec(s_allocator_p); + Record rec(bmqtst::TestHelperUtil::allocator()); rec.d_recordType = mqbs::RecordType::e_QUEUE_OP; rec.d_queueOpType = mqbs::QueueOpType::e_CREATION; rec.d_uri = uri; @@ -361,13 +365,13 @@ struct Tester { rec.d_timestamp = bdlt::EpochUtil::convertToTimeT64( bdlt::CurrentTime::utc()); - rc = fs->writeQueueCreationRecord(&handle, - bmqt::Uri(rec.d_uri, - s_allocator_p), - rec.d_queueKey, - AppInfos(), - rec.d_timestamp, - true); // isNewQueue + rc = fs->writeQueueCreationRecord( + &handle, + bmqt::Uri(rec.d_uri, bmqtst::TestHelperUtil::allocator()), + rec.d_queueKey, + AppInfos(), + rec.d_timestamp, + true); // isNewQueue if (0 != rc) { bsl::cout @@ -404,7 +408,7 @@ struct Tester { BSLS_ASSERT(!it->second.empty()); mqbs::DataStoreRecordHandle handle; - Record rec(s_allocator_p); + Record rec(bmqtst::TestHelperUtil::allocator()); rec.d_recordType = mqbs::RecordType::e_MESSAGE; rec.d_queueKey = it->first; bmqp::MessagePropertiesInfo messagePropertiesInfo = @@ -420,10 +424,13 @@ struct Tester { bsl::numeric_limits::max() / i); // crc value mqbu::MessageGUIDUtil::generateGUID(&rec.d_guid); - rec.d_appData_sp.createInplace(s_allocator_p, - &d_bufferFactory, - s_allocator_p); - bsl::string payloadStr(i * 10, 'x', s_allocator_p); + rec.d_appData_sp.createInplace( + bmqtst::TestHelperUtil::allocator(), + &d_bufferFactory, + bmqtst::TestHelperUtil::allocator()); + bsl::string payloadStr(i * 10, + 'x', + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(rec.d_appData_sp.get(), payloadStr.c_str(), payloadStr.length()); @@ -481,7 +488,7 @@ struct Tester { BSLS_ASSERT(!guids.empty()); mqbs::DataStoreRecordHandle handle; - Record rec(s_allocator_p); + Record rec(bmqtst::TestHelperUtil::allocator()); rec.d_recordType = mqbs::RecordType::e_CONFIRM; rec.d_guid = guids.back(); rec.d_queueKey = it->first; @@ -550,7 +557,7 @@ struct Tester { Guids& guids = it->second; BSLS_ASSERT(!guids.empty()); - Record rec(s_allocator_p); + Record rec(bmqtst::TestHelperUtil::allocator()); rec.d_recordType = mqbs::RecordType::e_DELETION; rec.d_guid = guids.back(); rec.d_queueKey = it->first; @@ -587,7 +594,8 @@ struct Tester { if (4 == recType) { // Write a SyncPt. - mqbs::FileStoreSet fileSet(s_allocator_p); + mqbs::FileStoreSet fileSet( + bmqtst::TestHelperUtil::allocator()); fs->loadCurrentFiles(&fileSet); BSLS_ASSERT((fileSet.dataFileSize() % @@ -603,7 +611,7 @@ struct Tester { return false; // RETURN } - Record rec(s_allocator_p); + Record rec(bmqtst::TestHelperUtil::allocator()); rec.d_recordType = mqbs::RecordType::e_JOURNAL_OP; rec.d_journalOpType = mqbs::JournalOpType::e_SYNCPOINT; rec.d_syncPtType = mqbs::SyncPointType::e_REGULAR; @@ -648,7 +656,7 @@ struct Tester { BSLS_ASSERT(!it->second.empty()); mqbs::DataStoreRecordHandle handle; - Record rec(s_allocator_p); + Record rec(bmqtst::TestHelperUtil::allocator()); rec.d_recordType = mqbs::RecordType::e_QUEUE_OP; rec.d_queueOpType = mqbs::QueueOpType::e_PURGE; rec.d_queueKey = it->first; @@ -707,7 +715,7 @@ struct Tester { } mqbs::DataStoreRecordHandle handle; - Record rec(s_allocator_p); + Record rec(bmqtst::TestHelperUtil::allocator()); rec.d_recordType = mqbs::RecordType::e_QUEUE_OP; rec.d_queueOpType = mqbs::QueueOpType::e_DELETION; rec.d_queueKey = it->first; @@ -760,7 +768,7 @@ static void test1_breathingTest() // Basic functionality // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; const char k_FILE_STORE_LOCATION[] = "./test-cluster123-1"; @@ -785,7 +793,7 @@ static void test1_breathingTest() // NestedTraitDeclaration' warning/error generated by clang. TBD: figure // out the right way to "fix" this. - Record dummy(s_allocator_p); + Record dummy(bmqtst::TestHelperUtil::allocator()); static_cast( static_cast< bslmf::NestedTraitDeclaration >( @@ -817,13 +825,13 @@ static void test1_breathingTest() // Then close and re-open the partition, and verify that retrieved records // match in-memory stuff. - SyncPointOffsetPairs spOffsetPairs(s_allocator_p); - bsl::vector records(s_allocator_p); + SyncPointOffsetPairs spOffsetPairs(bmqtst::TestHelperUtil::allocator()); + bsl::vector records(bmqtst::TestHelperUtil::allocator()); // Add one SyncPt written by the primary (to both 'spOffsetPairs' and // 'records'). - Record rec(s_allocator_p); + Record rec(bmqtst::TestHelperUtil::allocator()); rec.d_recordType = mqbs::RecordType::e_JOURNAL_OP; rec.d_journalOpType = mqbs::JournalOpType::e_SYNCPOINT; rec.d_syncPtType = mqbs::SyncPointType::e_REGULAR; @@ -887,7 +895,7 @@ static void test2_printTest() { bmqtst::TestHelper::printTestName("PRINT TEST"); - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; const char k_FILE_STORE_LOCATION[] = "./test-cluster123-2"; @@ -901,8 +909,8 @@ static void test2_printTest() fs.setActivePrimary(tester.node(), primaryLeaseId); // Write various records to the partition. - SyncPointOffsetPairs spOffsetPairs(s_allocator_p); - bsl::vector records(s_allocator_p); + SyncPointOffsetPairs spOffsetPairs(bmqtst::TestHelperUtil::allocator()); + bsl::vector records(bmqtst::TestHelperUtil::allocator()); const size_t k_NUM_RECORDS = 10; bsls::Types::Uint64 numRecordsWritten = 0; @@ -914,8 +922,8 @@ static void test2_printTest() &numRecordsWritten, k_NUM_RECORDS)); - bdlpcre::RegEx expectedOut(s_allocator_p); - bsl::string errorMessage(s_allocator_p); + bdlpcre::RegEx expectedOut(bmqtst::TestHelperUtil::allocator()); + bsl::string errorMessage(bmqtst::TestHelperUtil::allocator()); size_t errorOffset; expectedOut.prepare( &errorMessage, @@ -952,7 +960,7 @@ static void test2_printTest() BSLS_ASSERT_OPT(expectedOut.isPrepared()); mqbs::FileStoreIterator fsIt(&fs); - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); while (fsIt.next()) { stream << fsIt << "\n"; } @@ -989,7 +997,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_filestoreprotocol.t.cpp b/src/groups/mqb/mqbs/mqbs_filestoreprotocol.t.cpp index d9e125fe6..20034e8da 100644 --- a/src/groups/mqb/mqbs/mqbs_filestoreprotocol.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_filestoreprotocol.t.cpp @@ -586,7 +586,7 @@ static void test3_printTest() "[ type = MESSAGE flags = 0 primaryLeaseId = 8 sequenceNumber = 33" " timestamp = 123456 ]"; - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); stream << rh; ASSERT_EQ(stream.str(), k_EXPECTED_OUTPUT); stream.reset(); @@ -622,7 +622,7 @@ static void test3_printTest() "messageGUID = ** UNSET ** crc32c = 2333 compressionAlgorithmType " "= ZLIB ]"; - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); stream << msgRec; ASSERT_EQ(stream.str(), k_EXPECTED_OUTPUT); stream.reset(); @@ -654,7 +654,7 @@ static void test3_printTest() "queueKey = DEADFACE13 appKey = FACEDAFACE messageGUID = ** UNSET " "** ]"; - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); stream << confRec; ASSERT_EQ(stream.str(), k_EXPECTED_OUTPUT); stream.reset(); @@ -684,7 +684,7 @@ static void test3_printTest() "IMPLICIT_CONFIRM queueKey = DEADFACE13 messageGUID = " "** UNSET ** ]"; - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); stream << delRec; ASSERT_EQ(stream.str(), k_EXPECTED_OUTPUT); stream.reset(); @@ -716,7 +716,7 @@ static void test3_printTest() "DEADFACE13 appKey = FACEDAFACE type = CREATION " "queueUriRecordOffsetWords = 69 ]"; - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); stream << qOpRec; ASSERT_EQ(stream.str(), k_EXPECTED_OUTPUT); stream.reset(); @@ -752,7 +752,7 @@ static void test3_printTest() "primaryNodeId = 1 primaryLeaseId = 8 dataFileOffsetDwords = 666 " "qlistFileOffsetWords = 23 ]"; - bmqu::MemOutStream stream(s_allocator_p); + bmqu::MemOutStream stream(bmqtst::TestHelperUtil::allocator()); stream << jOpRec; ASSERT_EQ(stream.str(), expectedOut); stream.reset(); @@ -780,7 +780,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_filestoreprotocolutil.t.cpp b/src/groups/mqb/mqbs/mqbs_filestoreprotocolutil.t.cpp index 3eb2b8072..4f1696a50 100644 --- a/src/groups/mqb/mqbs/mqbs_filestoreprotocolutil.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_filestoreprotocolutil.t.cpp @@ -66,14 +66,15 @@ static void test1_hasBmqHeader() { // Sufficient minimum bytes for header but magic mismatch char* p = static_cast( - s_allocator_p->allocate(FileHeader::k_MIN_HEADER_SIZE + 3)); + bmqtst::TestHelperUtil::allocator()->allocate( + FileHeader::k_MIN_HEADER_SIZE + 3)); bsl::memset(p, 0, FileHeader::k_MIN_HEADER_SIZE + 3); MemoryBlock block(p, FileHeader::k_MIN_HEADER_SIZE + 3); MappedFileDescriptor mfd; mfd.setBlock(block); mfd.setFileSize(FileHeader::k_MIN_HEADER_SIZE + 3); ASSERT_EQ(-2, FileStoreProtocolUtil::hasBmqHeader(mfd)); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { @@ -81,7 +82,7 @@ static void test1_hasBmqHeader() // header.headerWords() char* p = static_cast( - s_allocator_p->allocate(sizeof(FileHeader))); + bmqtst::TestHelperUtil::allocator()->allocate(sizeof(FileHeader))); MemoryBlock block(p, sizeof(FileHeader)); MappedFileDescriptor mfd; mfd.setBlock(block); @@ -94,13 +95,14 @@ static void test1_hasBmqHeader() fh->setHeaderWords(block.size() / 4 + 10); ASSERT_EQ(-4, FileStoreProtocolUtil::hasBmqHeader(mfd)); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { // All good char* p = static_cast( - s_allocator_p->allocate(sizeof(FileHeader) + 100)); + bmqtst::TestHelperUtil::allocator()->allocate(sizeof(FileHeader) + + 100)); MemoryBlock block(p, sizeof(FileHeader) + 100); MappedFileDescriptor mfd; mfd.setBlock(block); @@ -110,7 +112,7 @@ static void test1_hasBmqHeader() new (fh.get()) FileHeader(); fh->setFileType(FileType::e_JOURNAL); ASSERT_EQ(0, FileStoreProtocolUtil::hasBmqHeader(mfd)); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } } @@ -131,7 +133,8 @@ static void test2_lastJournalRecord() sizeof(FileHeader) + sizeof(JournalFileHeader) + (numRecords * FileStoreProtocol::k_JOURNAL_RECORD_SIZE); - char* p = static_cast(s_allocator_p->allocate(blockSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(blockSize)); MemoryBlock block(p, blockSize); MappedFileDescriptor mfd; @@ -171,7 +174,7 @@ static void test2_lastJournalRecord() *jfh, 0)); // last journal sync point - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { @@ -182,7 +185,8 @@ static void test2_lastJournalRecord() lastJournalSyncPoint + (2 * FileStoreProtocol::k_JOURNAL_RECORD_SIZE) - 1; - char* p = static_cast(s_allocator_p->allocate(blockSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(blockSize)); MemoryBlock block(p, blockSize); MappedFileDescriptor mfd; @@ -197,7 +201,7 @@ static void test2_lastJournalRecord() fh, jfh, lastJournalSyncPoint)); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { @@ -215,7 +219,8 @@ static void test2_lastJournalRecord() bsls::Types::Uint64 lastValidRecordPos = blockSize - FileStoreProtocol::k_JOURNAL_RECORD_SIZE; - char* p = static_cast(s_allocator_p->allocate(blockSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(blockSize)); MemoryBlock block(p, blockSize); MappedFileDescriptor mfd; @@ -240,7 +245,7 @@ static void test2_lastJournalRecord() ASSERT_EQ(lastValidRecordPos, result); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { @@ -250,7 +255,8 @@ static void test2_lastJournalRecord() bsls::Types::Uint64 blockSize = sizeof(FileHeader) + sizeof(JournalFileHeader); - char* p = static_cast(s_allocator_p->allocate(blockSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(blockSize)); MemoryBlock block(p, blockSize); MappedFileDescriptor mfd; @@ -270,7 +276,7 @@ static void test2_lastJournalRecord() FileStoreProtocolUtil::lastJournalRecord(mfd, *fh, *jfh, 0); ASSERT_EQ(0ULL, result); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } } @@ -291,7 +297,8 @@ static void test3_lastJournalSyncPoint() sizeof(FileHeader) + sizeof(JournalFileHeader) + numRecords * FileStoreProtocol::k_JOURNAL_RECORD_SIZE; - char* p = static_cast(s_allocator_p->allocate(blockSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(blockSize)); MemoryBlock block(p, blockSize); MappedFileDescriptor mfd; @@ -315,7 +322,7 @@ static void test3_lastJournalSyncPoint() ASSERT_EQ(0ULL, FileStoreProtocolUtil::lastJournalSyncPoint(mfd, *fh, *jfh)); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { @@ -326,7 +333,8 @@ static void test3_lastJournalSyncPoint() sizeof(FileHeader) + sizeof(JournalFileHeader) + numRecords * FileStoreProtocol::k_JOURNAL_RECORD_SIZE; - char* p = static_cast(s_allocator_p->allocate(blockSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(blockSize)); MemoryBlock block(p, blockSize); MappedFileDescriptor mfd; @@ -344,7 +352,7 @@ static void test3_lastJournalSyncPoint() ASSERT_EQ(0ULL, FileStoreProtocolUtil::lastJournalSyncPoint(mfd, *fh, *jfh)); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { @@ -356,7 +364,8 @@ static void test3_lastJournalSyncPoint() sizeof(FileHeader) + sizeof(JournalFileHeader) + numRecords * FileStoreProtocol::k_JOURNAL_RECORD_SIZE; - char* p = static_cast(s_allocator_p->allocate(blockSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(blockSize)); MemoryBlock block(p, blockSize); MappedFileDescriptor mfd; @@ -404,7 +413,7 @@ static void test3_lastJournalSyncPoint() ASSERT_EQ(syncPointPos, FileStoreProtocolUtil::lastJournalSyncPoint(mfd, *fh, *jfh)); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { @@ -416,7 +425,8 @@ static void test3_lastJournalSyncPoint() sizeof(FileHeader) + sizeof(JournalFileHeader) + numRecords * FileStoreProtocol::k_JOURNAL_RECORD_SIZE; - char* p = static_cast(s_allocator_p->allocate(blockSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(blockSize)); MemoryBlock block(p, blockSize); MappedFileDescriptor mfd; @@ -442,7 +452,7 @@ static void test3_lastJournalSyncPoint() ASSERT_EQ(0ULL, FileStoreProtocolUtil::lastJournalSyncPoint(mfd, *fh, *jfh)); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { @@ -454,7 +464,8 @@ static void test3_lastJournalSyncPoint() sizeof(FileHeader) + sizeof(JournalFileHeader) + numRecords * FileStoreProtocol::k_JOURNAL_RECORD_SIZE; - char* p = static_cast(s_allocator_p->allocate(blockSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(blockSize)); MemoryBlock block(p, blockSize); MappedFileDescriptor mfd; @@ -491,7 +502,7 @@ static void test3_lastJournalSyncPoint() ASSERT_EQ(syncPointPos, FileStoreProtocolUtil::lastJournalSyncPoint(mfd, *fh, *jfh)); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } } @@ -507,9 +518,10 @@ static void test4_loadAppInfos() { // No appIds. - char* p = static_cast(s_allocator_p->allocate(1)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(1)); mqbs::MemoryBlock mb(p, 1); - AppInfos appIdKeyPairs(s_allocator_p); + AppInfos appIdKeyPairs(bmqtst::TestHelperUtil::allocator()); mqbs::FileStoreProtocolUtil::loadAppInfos(&appIdKeyPairs, mb, @@ -517,7 +529,7 @@ static void test4_loadAppInfos() ASSERT_EQ(0u, appIdKeyPairs.size()); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { @@ -528,7 +540,8 @@ static void test4_loadAppInfos() const size_t numPaddingBytes = 3; const size_t totalSize = sizeof(mqbs::AppIdHeader) + paddedAppIdLen + mqbs::FileStoreProtocol::k_HASH_LENGTH; - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); size_t offset = 0; // Append AppIdHeader. @@ -540,7 +553,7 @@ static void test4_loadAppInfos() offset += sizeof(mqbs::AppIdHeader); // Append AppId. - bsl::string appId(appIdLen, 'g', s_allocator_p); + bsl::string appId(appIdLen, 'g', bmqtst::TestHelperUtil::allocator()); bsl::memcpy(p + offset, appId.c_str(), appIdLen); offset += appIdLen; @@ -563,7 +576,7 @@ static void test4_loadAppInfos() // Test. mqbs::MemoryBlock mb(p, totalSize); - AppInfos appIdKeyPairs(s_allocator_p); + AppInfos appIdKeyPairs(bmqtst::TestHelperUtil::allocator()); mqbs::FileStoreProtocolUtil::loadAppInfos(&appIdKeyPairs, mb, @@ -573,7 +586,7 @@ static void test4_loadAppInfos() ASSERT_EQ(appId, appIdKeyPairs.begin()->first); ASSERT_EQ(appKey, appIdKeyPairs.begin()->second); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } { @@ -581,9 +594,11 @@ static void test4_loadAppInfos() const int numAppIds = 6; size_t totalSize = 0; - bsl::vector appIdLenVec(s_allocator_p); - bsl::vector paddedAppIdLenVec(s_allocator_p); - bsl::vector numPaddingBytesVec(s_allocator_p); + bsl::vector appIdLenVec(bmqtst::TestHelperUtil::allocator()); + bsl::vector paddedAppIdLenVec( + bmqtst::TestHelperUtil::allocator()); + bsl::vector numPaddingBytesVec( + bmqtst::TestHelperUtil::allocator()); for (int n = 0; n < numAppIds; ++n) { size_t appIdLen = (n + 1) * 9 + 3; @@ -601,9 +616,10 @@ static void test4_loadAppInfos() mqbs::FileStoreProtocol::k_HASH_LENGTH; } - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); size_t offset = 0; - AppInfos expectedAppInfos(s_allocator_p); + AppInfos expectedAppInfos(bmqtst::TestHelperUtil::allocator()); for (int n = 0; n < numAppIds; ++n) { // Append AppIdHeader. @@ -620,7 +636,7 @@ static void test4_loadAppInfos() bsl::string appId(appIdLenVec[n], static_cast(n + 1), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); bsl::memcpy(p + offset, appId.c_str(), appIdLenVec[n]); offset += appIdLenVec[n]; @@ -645,13 +661,14 @@ static void test4_loadAppInfos() appHash, mqbs::FileStoreProtocol::k_HASH_LENGTH); - expectedAppInfos.emplace( - AppInfo(bsl::string(appId, s_allocator_p), appKey)); + expectedAppInfos.emplace(AppInfo( + bsl::string(appId, bmqtst::TestHelperUtil::allocator()), + appKey)); offset += mqbs::FileStoreProtocol::k_HASH_LENGTH; } // Test. mqbs::MemoryBlock mb(p, totalSize); - AppInfos appIdKeyPairs(s_allocator_p); + AppInfos appIdKeyPairs(bmqtst::TestHelperUtil::allocator()); mqbs::FileStoreProtocolUtil::loadAppInfos(&appIdKeyPairs, mb, @@ -660,7 +677,7 @@ static void test4_loadAppInfos() ASSERT_EQ(static_cast(numAppIds), appIdKeyPairs.size()); ASSERT_EQ(appIdKeyPairs, expectedAppInfos); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } } @@ -696,7 +713,9 @@ static void jobForThreadPool(const Results* testData, bslmt::Barrier* barrier) // used to start all the jobs simultaneously in the different threads. // ------------------------------------------------------------------------ { - bdlbb::PooledBlobBufferFactory factory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory factory( + 1024, + bmqtst::TestHelperUtil::allocator()); bmqu::BlobPosition startPos; barrier->wait(); @@ -704,10 +723,11 @@ static void jobForThreadPool(const Results* testData, bslmt::Barrier* barrier) for (ResultsIt r = testData->begin(); r != testData->end(); ++r) { const bsl::string& source = r->first; const bsl::string& hex = r->second; - bsl::string expected(s_allocator_p); + bsl::string expected(bmqtst::TestHelperUtil::allocator()); bytesFromHex(&expected, hex); - bdlbb::Blob localBlob(&factory, s_allocator_p); + bdlbb::Blob localBlob(&factory, + bmqtst::TestHelperUtil::allocator()); localBlob.setLength(source.size()); bsl::memcpy(localBlob.buffer(0).data(), source.c_str(), @@ -723,7 +743,7 @@ static void jobForThreadPool(const Results* testData, bslmt::Barrier* barrier) ASSERT_EQ(0, rc); bsl::string result(buffer.buffer(), MD5_DIGEST_BYTES, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(result, expected); } } @@ -739,14 +759,18 @@ static void test5_calculateMd5Digest() { bmqtst::TestHelper::printTestName("CALCULATE MD5 DIGEST"); - bsl::string data("12345678901234567890", s_allocator_p); - bsl::string md5("fd85e62d9beb45428771ec688418b271", s_allocator_p); - bsl::string md5b(s_allocator_p); + bsl::string data("12345678901234567890", + bmqtst::TestHelperUtil::allocator()); + bsl::string md5("fd85e62d9beb45428771ec688418b271", + bmqtst::TestHelperUtil::allocator()); + bsl::string md5b(bmqtst::TestHelperUtil::allocator()); bytesFromHex(&md5b, md5); bmqu::BlobPosition startPos; - bdlbb::PooledBlobBufferFactory myFactory(1024, s_allocator_p); - bdlbb::Blob blob(&myFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory myFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob blob(&myFactory, bmqtst::TestHelperUtil::allocator()); blob.setLength(data.size()); bsl::memcpy(blob.buffer(0).data(), data.c_str(), data.size()); @@ -765,7 +789,7 @@ static void test5_calculateMd5Digest() int rc = mqbs::FileStoreProtocolUtil::calculateMd5Digest( &buffer, - bdlbb::Blob(&myFactory, s_allocator_p), + bdlbb::Blob(&myFactory, bmqtst::TestHelperUtil::allocator()), startPos, data.size()); ASSERT_NE(0, rc); @@ -820,7 +844,9 @@ static void test5_calculateMd5Digest() startPos, data.size()); ASSERT_EQ(0, rc); - bsl::string result(buffer.buffer(), MD5_DIGEST_BYTES, s_allocator_p); + bsl::string result(buffer.buffer(), + MD5_DIGEST_BYTES, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(result, md5b); } @@ -831,9 +857,11 @@ static void test5_calculateMd5Digest() if (data.size() % bufferSize > 0) { ++expected_num; } - bdlbb::PooledBlobBufferFactory myLittleFactory(bufferSize, - s_allocator_p); - bdlbb::Blob chunkedBlob(&myLittleFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory myLittleFactory( + bufferSize, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob chunkedBlob(&myLittleFactory, + bmqtst::TestHelperUtil::allocator()); chunkedBlob.setLength(data.size()); const int num = chunkedBlob.numBuffers(); @@ -852,36 +880,43 @@ static void test5_calculateMd5Digest() startPos, data.size()); ASSERT_EQ(0, rc); - bsl::string result(buffer.buffer(), MD5_DIGEST_BYTES, s_allocator_p); + bsl::string result(buffer.buffer(), + MD5_DIGEST_BYTES, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(result, md5b); } { // Concurrency - Results correctMd5s(s_allocator_p); - correctMd5s.emplace(bsl::string("12345678901234567890", s_allocator_p), + Results correctMd5s(bmqtst::TestHelperUtil::allocator()); + correctMd5s.emplace(bsl::string("12345678901234567890", + bmqtst::TestHelperUtil::allocator()), bsl::string("fd85e62d9beb45428771ec688418b271", - s_allocator_p)); - correctMd5s.emplace(bsl::string("15646546656965165468", s_allocator_p), + bmqtst::TestHelperUtil::allocator())); + correctMd5s.emplace(bsl::string("15646546656965165468", + bmqtst::TestHelperUtil::allocator()), bsl::string("858d54d19e406ddf8442ece8340b41b9", - s_allocator_p)); - correctMd5s.emplace(bsl::string("87849898267587856598", s_allocator_p), + bmqtst::TestHelperUtil::allocator())); + correctMd5s.emplace(bsl::string("87849898267587856598", + bmqtst::TestHelperUtil::allocator()), bsl::string("dca72b4fe4319fdd40ae2153dac62c51", - s_allocator_p)); - correctMd5s.emplace(bsl::string("77777777777777777777", s_allocator_p), + bmqtst::TestHelperUtil::allocator())); + correctMd5s.emplace(bsl::string("77777777777777777777", + bmqtst::TestHelperUtil::allocator()), bsl::string("11f733c0934d3ec1977bf99eceaecdbb", - s_allocator_p)); - correctMd5s.emplace(bsl::string("asdfdasfg456456d4489", s_allocator_p), + bmqtst::TestHelperUtil::allocator())); + correctMd5s.emplace(bsl::string("asdfdasfg456456d4489", + bmqtst::TestHelperUtil::allocator()), bsl::string("a5e05fd2340789b7ecf2c469e9e6fec7", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); const bsl::size_t numThreads = correctMd5s.size(); - bslmt::ThreadGroup threadGroup(s_allocator_p); + bslmt::ThreadGroup threadGroup(bmqtst::TestHelperUtil::allocator()); bslmt::Barrier barrier(numThreads + 1); for (bsl::size_t i = 0; i < numThreads; ++i) { int rc = threadGroup.addThread( - bdlf::BindUtil::bindS(s_allocator_p, + bdlf::BindUtil::bindS(bmqtst::TestHelperUtil::allocator(), &jobForThreadPool, &correctMd5s, &barrier)); @@ -912,7 +947,7 @@ int main(int argc, char* argv[]) case 1: test1_hasBmqHeader(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_filestoreset.t.cpp b/src/groups/mqb/mqbs/mqbs_filestoreset.t.cpp index 063554d01..514eaf771 100644 --- a/src/groups/mqb/mqbs/mqbs_filestoreset.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_filestoreset.t.cpp @@ -55,7 +55,7 @@ static void test1_breathingTest() // Default constructor PV("Default constructor"); - mqbs::FileStoreSet obj1(s_allocator_p); + mqbs::FileStoreSet obj1(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj1.dataFile(), ""); ASSERT_EQ(obj1.journalFile(), ""); @@ -78,7 +78,7 @@ static void test1_breathingTest() // Copy constructor PV("Copy constructor"); - mqbs::FileStoreSet obj2(obj1, s_allocator_p); + mqbs::FileStoreSet obj2(obj1, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(obj1.dataFile(), obj2.dataFile()); ASSERT_EQ(obj1.dataFileSize(), obj2.dataFileSize()); @@ -116,21 +116,21 @@ static void test1_breathingTest() " journalFileSize = 2,048 ]"; { PVV("Print (print function)"); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); obj2.print(out, 0, -1); ASSERT_EQ(out.str(), expected); } { PVV("Print (stream operator)"); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); out << obj2; ASSERT_EQ(out.str(), expected); } { PVV("Print (bad stream)"); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); out.setstate(bsl::ios_base::badbit); obj2.print(out, 0, -1); ASSERT_EQ(out.str(), ""); @@ -150,7 +150,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_inmemorystorage.cpp b/src/groups/mqb/mqbs/mqbs_inmemorystorage.cpp index fe4994b2b..bb454561f 100644 --- a/src/groups/mqb/mqbs/mqbs_inmemorystorage.cpp +++ b/src/groups/mqb/mqbs/mqbs_inmemorystorage.cpp @@ -110,6 +110,17 @@ int InMemoryStorage::configure( return 0; } +void InMemoryStorage::setConsistency(const mqbconfm::Consistency& value) +{ + BALL_LOG_WARN_BLOCK + { + if (value.isStrongValue()) { + BALL_LOG_OUTPUT_STREAM << "Trying to configure strong consistency " + << "for in-memory storage"; + } + } +} + void InMemoryStorage::setQueue(mqbi::Queue* queue) { d_virtualStorageCatalog.setQueue(queue); @@ -412,7 +423,7 @@ InMemoryStorage::removeAll(const mqbu::StorageKey& appKey) return mqbi::StorageResult::e_SUCCESS; } -void InMemoryStorage::dispatcherFlush(bool, bool) +void InMemoryStorage::flushStorage() { // NOTHING } diff --git a/src/groups/mqb/mqbs/mqbs_inmemorystorage.h b/src/groups/mqb/mqbs/mqbs_inmemorystorage.h index 53b916fc2..00b74bc8e 100644 --- a/src/groups/mqb/mqbs/mqbs_inmemorystorage.h +++ b/src/groups/mqb/mqbs/mqbs_inmemorystorage.h @@ -270,6 +270,11 @@ class InMemoryStorage BSLS_KEYWORD_FINAL : public ReplicatedStorage { const bsls::Types::Int64 messageTtl, const int maxDeliveryAttempts) BSLS_KEYWORD_OVERRIDE; + /// Set the consistency level associated to this storage to the specified + /// `value`. + void + setConsistency(const mqbconfm::Consistency& value) BSLS_KEYWORD_OVERRIDE; + virtual void setQueue(mqbi::Queue* queue) BSLS_KEYWORD_OVERRIDE; /// Close this storage. @@ -368,12 +373,9 @@ class InMemoryStorage BSLS_KEYWORD_FINAL : public ReplicatedStorage { virtual mqbi::StorageResult::Enum removeAll(const mqbu::StorageKey& appKey) BSLS_KEYWORD_OVERRIDE; - /// If the specified `storage` is `true`, flush any buffered replication - /// messages to the peers. If the specified `queues` is `true`, `flush` - /// all associated queues. Behavior is undefined unless this node is - /// the primary for this partition. - virtual void dispatcherFlush(bool storage, - bool queues) BSLS_KEYWORD_OVERRIDE; + /// Flush any buffered replication messages to the peers. Behaviour is + /// undefined unless this cluster node is the primary for this partition. + void flushStorage() BSLS_KEYWORD_OVERRIDE; /// Return the resource capacity meter associated to this storage. virtual mqbu::CapacityMeter* capacityMeter() BSLS_KEYWORD_OVERRIDE; diff --git a/src/groups/mqb/mqbs/mqbs_inmemorystorage.t.cpp b/src/groups/mqb/mqbs/mqbs_inmemorystorage.t.cpp index 2673cd861..599c29635 100644 --- a/src/groups/mqb/mqbs/mqbs_inmemorystorage.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_inmemorystorage.t.cpp @@ -201,14 +201,15 @@ struct Tester { domainCfg.deduplicationTimeMs() = 0; // No history domainCfg.messageTtl() = ttlSeconds; - d_replicatedStorage_mp.load(new (*d_allocator_p) mqbs::InMemoryStorage( - bmqt::Uri(uri, s_allocator_p), - queueKey, - partitionId, - domainCfg, - d_mockDomain.capacityMeter(), - d_allocator_p), - d_allocator_p); + d_replicatedStorage_mp.load( + new (*d_allocator_p) mqbs::InMemoryStorage( + bmqt::Uri(uri, bmqtst::TestHelperUtil::allocator()), + queueKey, + partitionId, + domainCfg, + d_mockDomain.capacityMeter(), + d_allocator_p), + d_allocator_p); d_replicatedStorage_mp->setQueue(&d_mockQueue); BSLS_ASSERT_OPT(d_replicatedStorage_mp->queue() == &d_mockQueue); @@ -240,7 +241,7 @@ struct Tester { limits.bytes() = byteCapacity; limits.bytesWatermarkRatio() = byteWatermarkRatio; - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); return d_replicatedStorage_mp->configure(errDescription, config, limits, @@ -295,9 +296,10 @@ struct Tester { bmqt::CompressionAlgorithmType::e_NONE); const bsl::shared_ptr appDataPtr( - new (*s_allocator_p) - bdlbb::Blob(&d_bufferFactory, s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bdlbb::Blob(&d_bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&(*appDataPtr), reinterpret_cast(&data), @@ -361,7 +363,7 @@ struct Test : bmqtst::Test { // ----------- // CREATORS Test::Test() -: d_tester(s_allocator_p, +: d_tester(bmqtst::TestHelperUtil::allocator(), k_PARTITION_ID, k_URI_STR, k_QUEUE_KEY, @@ -397,7 +399,7 @@ TEST(breathingTest) { bmqtst::TestHelper::printTestName("BREATHING TEST"); - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); mqbs::ReplicatedStorage& storage = tester.storage(); @@ -412,7 +414,7 @@ TEST(breathingTest) ASSERT_NE(storage.queue(), static_cast(0)); // Queue has been set via call to 'setQueue' - ASSERT_PASS(storage.dispatcherFlush(true, false)); + ASSERT_PASS(storage.flushStorage()); // Does nothing, at the time of this writing ASSERT_EQ(storage.queueOpRecordHandles().empty(), true); @@ -434,7 +436,7 @@ TEST(configure) { bmqtst::TestHelper::printTestName("CONFIGURE"); - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_DEFAULT_MSG, k_DEFAULT_BYTES) == 0); @@ -502,7 +504,7 @@ TEST_F(Test, put_noVirtualStorage) { bmqtst::TestHelper::printTestName("PUT - WITH NO VIRTUAL STORAGES"); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); const int k_MSG_COUNT = 10; @@ -539,7 +541,7 @@ TEST_F(Test, getMessageSize) { bmqtst::TestHelper::printTestName("GET MESSAGE SIZE"); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); const int k_MSG_COUNT = 10; @@ -577,7 +579,7 @@ TEST_F(Test, get_noVirtualStorages) { bmqtst::TestHelper::printTestName("GET - WITH NO VIRTUAL STORAGES"); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); const int k_MSG_COUNT = 5; @@ -664,7 +666,7 @@ TEST_F(Test, removeMessage) const int k_MSG_COUNT = 10; - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Check 'put' - To physical storage (StorageKeys = NULL) BSLS_ASSERT_OPT(d_tester.addMessages(&guids, k_MSG_COUNT) == @@ -700,8 +702,8 @@ TEST_F(Test, addVirtualStorage) { bmqtst::TestHelper::printTestName("ADD VIRTUAL STORAGE"); - bmqu::MemOutStream errDescription(s_allocator_p); - bsl::string dummyAppId(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); + bsl::string dummyAppId(bmqtst::TestHelperUtil::allocator()); mqbu::StorageKey dummyAppKey; mqbs::ReplicatedStorage& storage = d_tester.storage(); @@ -727,8 +729,8 @@ TEST_F(Test, hasVirtualStorage) { bmqtst::TestHelper::printTestName("HAS VIRTUAL STORAGE"); - bmqu::MemOutStream errDescription(s_allocator_p); - bsl::string dummyAppId(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); + bsl::string dummyAppId(bmqtst::TestHelperUtil::allocator()); mqbu::StorageKey dummyAppKey; mqbs::ReplicatedStorage& storage = d_tester.storage(); @@ -765,8 +767,8 @@ TEST_F(Test, removeVirtualStorage) { bmqtst::TestHelper::printTestName("REMOVE VIRTUAL STORAGE"); - bmqu::MemOutStream errDescription(s_allocator_p); - bsl::string dummyAppId(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); + bsl::string dummyAppId(bmqtst::TestHelperUtil::allocator()); mqbs::ReplicatedStorage& storage = d_tester.storage(); @@ -802,9 +804,9 @@ TEST(put_withVirtualStorages) const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); - Tester tester(s_allocator_p, k_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -824,7 +826,7 @@ TEST(put_withVirtualStorages) const bsls::Types::Int64 k_BYTE_PER_MSG = static_cast( sizeof(int)); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Check 'put'- To physical storage (StorageKeys = NULL) ASSERT_EQ(tester.addMessages(&guids, k_MSG_COUNT), @@ -868,12 +870,12 @@ TEST(removeAllMessages_appKeyNotFound) bmqtst::TestHelper::printTestName("REMOVE ALL MESSAGES " "- APPKEY NOT FOUND"); - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - Tester tester(s_allocator_p, k_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -892,7 +894,7 @@ TEST(removeAllMessages_appKeyNotFound) const bsls::Types::Int64 k_BYTE_PER_MSG = static_cast( sizeof(int)); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); tester.addMessages(&guids, k_MSG_COUNT); // Verify 'removeAll' operation @@ -918,12 +920,12 @@ TEST(removeAllMessages) { bmqtst::TestHelper::printTestName("Remove All Messages Test"); - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -943,7 +945,7 @@ TEST(removeAllMessages) const bsls::Types::Int64 k_BYTE_PER_MSG = static_cast( sizeof(int)); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(tester.addMessages(&guids, k_MSG_COUNT), mqbi::StorageResult::e_SUCCESS); @@ -982,12 +984,12 @@ TEST(get_withVirtualStorages) { bmqtst::TestHelper::printTestName("Get - with Virtual Storage Test"); - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -998,7 +1000,7 @@ TEST(get_withVirtualStorages) // Scenario // Single Virtual Storages - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Check 'put'- To physical storage (StorageKeys = NULL) ASSERT_EQ(tester.addMessages(&guids, 20), mqbi::StorageResult::e_SUCCESS); @@ -1046,9 +1048,9 @@ TEST(confirm) const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -1065,7 +1067,7 @@ TEST(confirm) const bsls::Types::Int64 k_BYTE_PER_MSG = static_cast( sizeof(int)); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Check 'put': To physical storage (StorageKeys = NULL) ASSERT_EQ(tester.addMessages(&guids, k_MSG_COUNT), @@ -1123,7 +1125,7 @@ TEST_F(Test, getIterator_noVirtualStorages) const int k_MSG_COUNT = 10; - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Put to physical storage: StorageKeys NULL ASSERT_EQ(d_tester.addMessages(&guids, k_MSG_COUNT), @@ -1192,12 +1194,12 @@ TEST(getIterator_withVirtualStorages) { bmqtst::TestHelper::printTestName("Iterator Test- In presence of Virtual"); - bmqu::MemOutStream errDescription(s_allocator_p); + bmqu::MemOutStream errDescription(bmqtst::TestHelperUtil::allocator()); const bsls::Types::Int64 k_MSG_LIMIT = 80; const bsls::Types::Int64 k_BYTES_LIMIT = 2048; - Tester tester(s_allocator_p, k_PROXY_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PROXY_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); @@ -1210,7 +1212,7 @@ TEST(getIterator_withVirtualStorages) // Two Virtual Storages // Try iterator for physical storage as well as both of these storages. - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Check 'put': To physical storage (StorageKeys = NULL) ASSERT_EQ(tester.addMessages(&guids, 20), mqbi::StorageResult::e_SUCCESS); @@ -1294,7 +1296,7 @@ TEST_F(Test, capacityMeter_limitMessages) { bmqtst::TestHelper::printTestName("Capacity Meter- Limit Messages"); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Put to physical storage: StorageKeys NULL ASSERT_EQ(d_tester.addMessages(&guids, k_DEFAULT_MSG), @@ -1339,11 +1341,11 @@ TEST(capacityMeter_limitBytes) const bsls::Types::Int64 k_MSG_LIMIT = 30; const bsls::Types::Int64 k_BYTES_LIMIT = 80; - Tester tester(s_allocator_p, k_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_MSG_LIMIT, k_BYTES_LIMIT) == 0); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); // Insert Max messages possible in 80bytes const int k_MSG_COUNT = 20; @@ -1382,7 +1384,7 @@ TEST(garbageCollect) // input const int k_TTL = 20; - Tester tester(s_allocator_p, k_PARTITION_ID); + Tester tester(bmqtst::TestHelperUtil::allocator(), k_PARTITION_ID); BSLS_ASSERT_OPT(tester.configure(k_DEFAULT_MSG, k_DEFAULT_BYTES, @@ -1390,7 +1392,7 @@ TEST(garbageCollect) k_BYTE_WATERMARK_RATIO, k_TTL) == 0); - bsl::vector guids(s_allocator_p); + bsl::vector guids(bmqtst::TestHelperUtil::allocator()); int k_MSG_COUNT = 10; @@ -1467,17 +1469,19 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_CHECK_GBL_ALLOC); - bmqt::UriParser::initialize(s_allocator_p); - bmqsys::Time::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); + bmqsys::Time::initialize(bmqtst::TestHelperUtil::allocator()); mqbu::MessageGUIDUtil::initialize(); { - mqbcfg::AppConfig brokerConfig(s_allocator_p); + mqbcfg::AppConfig brokerConfig(bmqtst::TestHelperUtil::allocator()); mqbcfg::BrokerConfig::set(brokerConfig); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); bmqtst::runTest(_testCase); } diff --git a/src/groups/mqb/mqbs/mqbs_journalfileiterator.t.cpp b/src/groups/mqb/mqbs/mqbs_journalfileiterator.t.cpp index 6e35b65cb..195856f67 100644 --- a/src/groups/mqb/mqbs/mqbs_journalfileiterator.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_journalfileiterator.t.cpp @@ -444,13 +444,14 @@ static void test2_forwardIteration() sizeof(FileHeader) + sizeof(JournalFileHeader) + numRecords * FileStoreProtocol::k_JOURNAL_RECORD_SIZE; - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); MemoryBlock block(p, totalSize); FileHeader fileHeader; bsls::Types::Uint64 lastRecordPos = 0; bsls::Types::Uint64 lastSyncPtPos = 0; - RecordsListType records(s_allocator_p); + RecordsListType records(bmqtst::TestHelperUtil::allocator()); addRecords(&block, &fileHeader, @@ -489,7 +490,7 @@ static void test2_forwardIteration() ASSERT_EQ(i, records.size()); ASSERT_EQ(false, it.isValid()); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test3_forwardIterationWithZeroJournalRecords() @@ -506,7 +507,8 @@ static void test3_forwardIterationWithZeroJournalRecords() bsls::Types::Uint64 totalSize = sizeof(FileHeader) + sizeof(JournalFileHeader); - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); MemoryBlock block(p, totalSize); FileHeader fileHeader; @@ -594,7 +596,7 @@ static void test3_forwardIterationWithZeroJournalRecords() ASSERT_EQ(0U, numRecords); } - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test4_backwardIteration() @@ -613,13 +615,14 @@ static void test4_backwardIteration() sizeof(FileHeader) + sizeof(JournalFileHeader) + k_NUM_RECORDS * FileStoreProtocol::k_JOURNAL_RECORD_SIZE; - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); MemoryBlock block(p, totalSize); FileHeader fileHeader; bsls::Types::Uint64 lastRecordPos = 0; bsls::Types::Uint64 lastSyncPtPos = 0; - RecordsListType records(s_allocator_p); + RecordsListType records(bmqtst::TestHelperUtil::allocator()); addRecords(&block, &fileHeader, @@ -658,7 +661,7 @@ static void test4_backwardIteration() ASSERT_EQ(i, records.size()); ASSERT_EQ(false, it.isValid()); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test5_backwardIterationWithZeroJournalEntries() @@ -675,7 +678,8 @@ static void test5_backwardIterationWithZeroJournalEntries() bsls::Types::Uint64 totalSize = sizeof(FileHeader) + sizeof(JournalFileHeader); - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); MemoryBlock block(p, totalSize); FileHeader fileHeader; @@ -759,7 +763,7 @@ static void test5_backwardIterationWithZeroJournalEntries() ASSERT_EQ(0U, numRecords); } - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test6_forwardIterationOfSparseJournalFileNoRecords() @@ -780,7 +784,8 @@ static void test6_forwardIterationOfSparseJournalFileNoRecords() bsls::Types::Uint64 totalSize = 1024 * 1024 * 10; // 10MB sparse file - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); // When this block gets passed to the JournalFileIterator c'tor, it will // iterate over the record-set and parse the type of each. To avoid reading // uninitialized memory, we zero-out the buffer now. @@ -880,7 +885,7 @@ static void test6_forwardIterationOfSparseJournalFileNoRecords() ASSERT_EQ(0U, numRecords); } - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test7_backwardIterationOfSparseJournalFileNoRecords() @@ -901,7 +906,8 @@ static void test7_backwardIterationOfSparseJournalFileNoRecords() bsls::Types::Uint64 totalSize = 1024 * 1024 * 10; // 10MB sparse file - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); // When this block gets passed to the JournalFileIterator c'tor, it will // iterate over the record-set and parse the type of each. To avoid reading // uninitialized memory, we zero-out the buffer now. @@ -997,7 +1003,7 @@ static void test7_backwardIterationOfSparseJournalFileNoRecords() ASSERT_EQ(0U, numRecords); } - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test8_forwardIterationOfSparseJournalFileWithRecords() @@ -1023,7 +1029,8 @@ static void test8_forwardIterationOfSparseJournalFileWithRecords() k_NUM_RECORDS * FileStoreProtocol::k_JOURNAL_RECORD_SIZE + 1024 * 1024 * 10; // 10MB of sparse area - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); // When this block gets passed to the JournalFileIterator c'tor, it will // iterate over the record-set and parse the type of each. To avoid reading // uninitialized memory, we zero-out the buffer now. @@ -1034,7 +1041,7 @@ static void test8_forwardIterationOfSparseJournalFileWithRecords() bsls::Types::Uint64 lastRecordPos = 0; bsls::Types::Uint64 lastSyncPtPos = 0; - RecordsListType records(s_allocator_p); + RecordsListType records(bmqtst::TestHelperUtil::allocator()); addRecords(&block, &fileHeader, @@ -1072,7 +1079,7 @@ static void test8_forwardIterationOfSparseJournalFileWithRecords() ASSERT_EQ(i, records.size()); ASSERT_EQ(false, it.isValid()); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test9_backwardIterationOfSparseJournalFileWithRecords() @@ -1098,7 +1105,8 @@ static void test9_backwardIterationOfSparseJournalFileWithRecords() k_NUM_RECORDS * FileStoreProtocol::k_JOURNAL_RECORD_SIZE + 1024 * 1024 * 50; // 50MB of sparse area - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); // When this block gets passed to the JournalFileIterator c'tor, it will // iterate over the record-set and parse the type of each. To avoid reading // uninitialized memory, we zero-out the buffer now. @@ -1109,7 +1117,7 @@ static void test9_backwardIterationOfSparseJournalFileWithRecords() bsls::Types::Uint64 lastRecordPos = 0; bsls::Types::Uint64 lastSyncPtPos = 0; - RecordsListType records(s_allocator_p); + RecordsListType records(bmqtst::TestHelperUtil::allocator()); addRecords(&block, &fileHeader, @@ -1148,7 +1156,7 @@ static void test9_backwardIterationOfSparseJournalFileWithRecords() ASSERT_EQ(i, records.size()); ASSERT_EQ(false, it.isValid()); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test10_bidirectionalIteration() @@ -1167,13 +1175,14 @@ static void test10_bidirectionalIteration() sizeof(FileHeader) + sizeof(JournalFileHeader) + +k_NUM_RECORDS * FileStoreProtocol::k_JOURNAL_RECORD_SIZE; - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); MemoryBlock block(p, totalSize); FileHeader fileHeader; bsls::Types::Uint64 lastRecordPos = 0; bsls::Types::Uint64 lastSyncPtPos = 0; - RecordsListType records(s_allocator_p); + RecordsListType records(bmqtst::TestHelperUtil::allocator()); addRecords(&block, &fileHeader, @@ -1258,7 +1267,7 @@ static void test10_bidirectionalIteration() ASSERT_EQ(false, it.isReverseMode()); ASSERT_EQ(false, it.hasRecordSizeRemaining()); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test11_forwardAdvance() @@ -1277,13 +1286,14 @@ static void test11_forwardAdvance() sizeof(FileHeader) + sizeof(JournalFileHeader) + +k_NUM_RECORDS * FileStoreProtocol::k_JOURNAL_RECORD_SIZE; - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); MemoryBlock block(p, totalSize); FileHeader fileHeader; bsls::Types::Uint64 lastRecordPos = 0; bsls::Types::Uint64 lastSyncPtPos = 0; - RecordsListType records(s_allocator_p); + RecordsListType records(bmqtst::TestHelperUtil::allocator()); addRecords(&block, &fileHeader, @@ -1328,7 +1338,7 @@ static void test11_forwardAdvance() // Not enough bytes remaining to advance ASSERT_NE_D(i, 1, (rc = it.advance(increment))); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test12_backwardAdvance() @@ -1347,13 +1357,14 @@ static void test12_backwardAdvance() sizeof(FileHeader) + sizeof(JournalFileHeader) + +k_NUM_RECORDS * FileStoreProtocol::k_JOURNAL_RECORD_SIZE; - char* p = static_cast(s_allocator_p->allocate(totalSize)); + char* p = static_cast( + bmqtst::TestHelperUtil::allocator()->allocate(totalSize)); MemoryBlock block(p, totalSize); FileHeader fileHeader; bsls::Types::Uint64 lastRecordPos = 0; bsls::Types::Uint64 lastSyncPtPos = 0; - RecordsListType records(s_allocator_p); + RecordsListType records(bmqtst::TestHelperUtil::allocator()); addRecords(&block, &fileHeader, @@ -1398,7 +1409,7 @@ static void test12_backwardAdvance() // Not enough bytes remaining to advance ASSERT_NE_D(i, 1, (rc = it.advance(increment))); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } // ============================================================================ @@ -1427,7 +1438,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_mappedfiledescriptor.t.cpp b/src/groups/mqb/mqbs/mqbs_mappedfiledescriptor.t.cpp index 0701317fa..fffe98051 100644 --- a/src/groups/mqb/mqbs/mqbs_mappedfiledescriptor.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_mappedfiledescriptor.t.cpp @@ -146,7 +146,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_memoryblock.t.cpp b/src/groups/mqb/mqbs/mqbs_memoryblock.t.cpp index fbc451e71..af67b6ec9 100644 --- a/src/groups/mqb/mqbs/mqbs_memoryblock.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_memoryblock.t.cpp @@ -134,7 +134,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_memoryblockiterator.t.cpp b/src/groups/mqb/mqbs/mqbs_memoryblockiterator.t.cpp index 0c890913b..3aad42d9a 100644 --- a/src/groups/mqb/mqbs/mqbs_memoryblockiterator.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_memoryblockiterator.t.cpp @@ -204,7 +204,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_offsetptr.t.cpp b/src/groups/mqb/mqbs/mqbs_offsetptr.t.cpp index cfb20b43f..4c910ffdc 100644 --- a/src/groups/mqb/mqbs/mqbs_offsetptr.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_offsetptr.t.cpp @@ -130,7 +130,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_qlistfileiterator.t.cpp b/src/groups/mqb/mqbs/mqbs_qlistfileiterator.t.cpp index b38b16a73..8df9a22d0 100644 --- a/src/groups/mqb/mqbs/mqbs_qlistfileiterator.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_qlistfileiterator.t.cpp @@ -304,13 +304,18 @@ static void test2_backwardIteration() MappedFileDescriptor mfd; FileHeader fh; - bsl::vector queueUris(s_allocator_p); - queueUris.push_back(bmqt::Uri("bmq://my.domain/queue1", s_allocator_p)); - queueUris.push_back(bmqt::Uri("bmq://my.domain/queue2", s_allocator_p)); - queueUris.push_back(bmqt::Uri("bmq://my.domain/queue3", s_allocator_p)); - queueUris.push_back(bmqt::Uri("bmq://my.domain/queue4", s_allocator_p)); - - bsl::vector queueKeys(s_allocator_p); + bsl::vector queueUris(bmqtst::TestHelperUtil::allocator()); + queueUris.push_back(bmqt::Uri("bmq://my.domain/queue1", + bmqtst::TestHelperUtil::allocator())); + queueUris.push_back(bmqt::Uri("bmq://my.domain/queue2", + bmqtst::TestHelperUtil::allocator())); + queueUris.push_back(bmqt::Uri("bmq://my.domain/queue3", + bmqtst::TestHelperUtil::allocator())); + queueUris.push_back(bmqt::Uri("bmq://my.domain/queue4", + bmqtst::TestHelperUtil::allocator())); + + bsl::vector queueKeys( + bmqtst::TestHelperUtil::allocator()); queueKeys.push_back( mqbu::StorageKey(mqbu::StorageKey::HexRepresentation(), "1111111111")); queueKeys.push_back( @@ -320,7 +325,8 @@ static void test2_backwardIteration() queueKeys.push_back( mqbu::StorageKey(mqbu::StorageKey::HexRepresentation(), "4444444444")); - bsl::vector > appIdsVec(s_allocator_p); + bsl::vector > appIdsVec( + bmqtst::TestHelperUtil::allocator()); appIdsVec.resize(queueUris.size()); for (size_t i = 0; i < appIdsVec.size(); ++i) { @@ -330,20 +336,21 @@ static void test2_backwardIteration() // The 1st queue uri (ie, 'i == 0') will have no appIds associated // with it. - bmqu::MemOutStream osstr(s_allocator_p); + bmqu::MemOutStream osstr(bmqtst::TestHelperUtil::allocator()); osstr << "AppId" << i << "_" << j << bsl::ends; appIds.push_back(osstr.str()); } } - bsl::vector > appKeysVec(s_allocator_p); + bsl::vector > appKeysVec( + bmqtst::TestHelperUtil::allocator()); appKeysVec.resize(queueUris.size()); for (size_t i = 0; i < appKeysVec.size(); ++i) { bsl::vector& appKeys = appKeysVec[i]; for (size_t j = 0; j < i; ++j) { - bmqu::MemOutStream osstr(s_allocator_p); + bmqu::MemOutStream osstr(bmqtst::TestHelperUtil::allocator()); osstr << j << j << j << j << j; osstr << j << j << j << j << j; osstr << bsl::ends; @@ -353,7 +360,7 @@ static void test2_backwardIteration() } } - char* p = addRecords(s_allocator_p, + char* p = addRecords(bmqtst::TestHelperUtil::allocator(), &mfd, &fh, queueUris, @@ -438,8 +445,10 @@ static void test2_backwardIteration() typedef QlistFileIterator::AppIdLengthPair AppIdLenPair; - bsl::vector appIdLenPairVector(s_allocator_p); - bsl::vector appKeysVector(s_allocator_p); + bsl::vector appIdLenPairVector( + bmqtst::TestHelperUtil::allocator()); + bsl::vector appKeysVector( + bmqtst::TestHelperUtil::allocator()); it.loadAppIds(&appIdLenPairVector); it.loadAppIdHashes(&appKeysVector); @@ -477,7 +486,7 @@ static void test2_backwardIteration() ASSERT_EQ(it.isValid(), false); ASSERT_EQ(0U, i); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test3_iteratorWithNoRecords() @@ -494,13 +503,15 @@ static void test3_iteratorWithNoRecords() FileHeader fh; char* p = addRecords( - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), &mfd, &fh, - bsl::vector(s_allocator_p), - bsl::vector >(s_allocator_p), - bsl::vector(s_allocator_p), - bsl::vector >(s_allocator_p)); + bsl::vector(bmqtst::TestHelperUtil::allocator()), + bsl::vector >( + bmqtst::TestHelperUtil::allocator()), + bsl::vector(bmqtst::TestHelperUtil::allocator()), + bsl::vector >( + bmqtst::TestHelperUtil::allocator())); QlistFileIterator it(&mfd, fh); ASSERT_EQ(it.isValid(), true); @@ -526,7 +537,7 @@ static void test3_iteratorWithNoRecords() ASSERT_EQ(it.nextRecord(), 0); ASSERT_EQ(it.isValid(), false); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } static void test4_iteratorAppKeys() @@ -542,13 +553,18 @@ static void test4_iteratorAppKeys() MappedFileDescriptor mfd; FileHeader fh; - bsl::vector queueUris(s_allocator_p); - queueUris.push_back(bmqt::Uri("bmq://my.domain/queue1", s_allocator_p)); - queueUris.push_back(bmqt::Uri("bmq://my.domain/queue2", s_allocator_p)); - queueUris.push_back(bmqt::Uri("bmq://my.domain/queue3", s_allocator_p)); - queueUris.push_back(bmqt::Uri("bmq://my.domain/queue4", s_allocator_p)); - - bsl::vector queueKeys(s_allocator_p); + bsl::vector queueUris(bmqtst::TestHelperUtil::allocator()); + queueUris.push_back(bmqt::Uri("bmq://my.domain/queue1", + bmqtst::TestHelperUtil::allocator())); + queueUris.push_back(bmqt::Uri("bmq://my.domain/queue2", + bmqtst::TestHelperUtil::allocator())); + queueUris.push_back(bmqt::Uri("bmq://my.domain/queue3", + bmqtst::TestHelperUtil::allocator())); + queueUris.push_back(bmqt::Uri("bmq://my.domain/queue4", + bmqtst::TestHelperUtil::allocator())); + + bsl::vector queueKeys( + bmqtst::TestHelperUtil::allocator()); queueKeys.push_back( mqbu::StorageKey(mqbu::StorageKey::HexRepresentation(), "1111111111")); queueKeys.push_back( @@ -558,7 +574,8 @@ static void test4_iteratorAppKeys() queueKeys.push_back( mqbu::StorageKey(mqbu::StorageKey::HexRepresentation(), "4444444444")); - bsl::vector > appIdsVec(s_allocator_p); + bsl::vector > appIdsVec( + bmqtst::TestHelperUtil::allocator()); appIdsVec.resize(queueUris.size()); for (size_t i = 0; i < appIdsVec.size(); ++i) { @@ -568,20 +585,21 @@ static void test4_iteratorAppKeys() // The 1st queue uri (ie, 'i == 0') will have no appIds // associated with it. - bmqu::MemOutStream osstr(s_allocator_p); + bmqu::MemOutStream osstr(bmqtst::TestHelperUtil::allocator()); osstr << "AppId" << i << "_" << j << bsl::ends; appIds.push_back(osstr.str()); } } - bsl::vector > appKeysVec(s_allocator_p); + bsl::vector > appKeysVec( + bmqtst::TestHelperUtil::allocator()); appKeysVec.resize(queueUris.size()); for (size_t i = 0; i < appKeysVec.size(); ++i) { bsl::vector& appKeys = appKeysVec[i]; for (size_t j = 0; j < i; ++j) { - bmqu::MemOutStream osstr(s_allocator_p); + bmqu::MemOutStream osstr(bmqtst::TestHelperUtil::allocator()); osstr << j << j << j << j << j; osstr << j << j << j << j << j; osstr << bsl::ends; @@ -591,7 +609,7 @@ static void test4_iteratorAppKeys() } } - char* p = addRecords(s_allocator_p, + char* p = addRecords(bmqtst::TestHelperUtil::allocator(), &mfd, &fh, queueUris, @@ -646,8 +664,10 @@ static void test4_iteratorAppKeys() typedef QlistFileIterator::AppIdLengthPair AppIdLenPair; - bsl::vector appIdLenPairVector(s_allocator_p); - bsl::vector appKeysVector(s_allocator_p); + bsl::vector appIdLenPairVector( + bmqtst::TestHelperUtil::allocator()); + bsl::vector appKeysVector( + bmqtst::TestHelperUtil::allocator()); it.loadAppIds(&appIdLenPairVector); it.loadAppIdHashes(&appKeysVector); @@ -679,7 +699,7 @@ static void test4_iteratorAppKeys() ASSERT_EQ(it.nextRecord(), -3); ASSERT_EQ(queueUris.size(), i); - s_allocator_p->deallocate(p); + bmqtst::TestHelperUtil::allocator()->deallocate(p); } // ============================================================================ @@ -690,7 +710,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -700,7 +720,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_storageprintutil.t.cpp b/src/groups/mqb/mqbs/mqbs_storageprintutil.t.cpp index e1b041f33..302390420 100644 --- a/src/groups/mqb/mqbs/mqbs_storageprintutil.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_storageprintutil.t.cpp @@ -127,9 +127,9 @@ struct Tester { public: // CREATORS Tester() - : d_bufferFactory(1024, s_allocator_p) - , d_guids(s_allocator_p) - , d_capacityMeter("test", s_allocator_p) + : d_bufferFactory(1024, bmqtst::TestHelperUtil::allocator()) + , d_guids(bmqtst::TestHelperUtil::allocator()) + , d_capacityMeter("test", bmqtst::TestHelperUtil::allocator()) { d_capacityMeter.setLimits(k_INT64_MAX, k_INT64_MAX); @@ -138,16 +138,18 @@ struct Tester { domainCfg.messageTtl() = k_INT64_MAX; const bsl::string uri("my.domain/myqueue"); - d_storage_mp.load(new (*s_allocator_p) mqbs::InMemoryStorage( - bmqt::Uri(uri, s_allocator_p), - k_QUEUE_KEY, - 0, - domainCfg, - &d_capacityMeter, - s_allocator_p), - s_allocator_p); - - bmqu::MemOutStream errorDescription(s_allocator_p); + d_storage_mp.load( + new (*bmqtst::TestHelperUtil::allocator()) mqbs::InMemoryStorage( + bmqt::Uri(uri, bmqtst::TestHelperUtil::allocator()), + k_QUEUE_KEY, + 0, + domainCfg, + &d_capacityMeter, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); + + bmqu::MemOutStream errorDescription( + bmqtst::TestHelperUtil::allocator()); d_storage_mp->addVirtualStorage(errorDescription, k_APP_ID1, k_APP_KEY1); @@ -180,9 +182,10 @@ struct Tester { mqbu::MessageGUIDUtil::generateGUID(&guid); bsl::shared_ptr appDataPtr( - new (*s_allocator_p) - bdlbb::Blob(&d_bufferFactory, s_allocator_p), - s_allocator_p); + new (*bmqtst::TestHelperUtil::allocator()) + bdlbb::Blob(&d_bufferFactory, + bmqtst::TestHelperUtil::allocator()), + bmqtst::TestHelperUtil::allocator()); appDataPtr->setLength(i * 10); mqbi::StorageMessageAttributes attributes; @@ -286,7 +289,8 @@ static void test2_listMessages() for (int idx = 0; idx < k_NUM_DATA; ++idx) { const TestData& test = k_DATA[idx]; - mqbcmd::QueueContents queueContents(s_allocator_p); + mqbcmd::QueueContents queueContents( + bmqtst::TestHelperUtil::allocator()); mqbs::StoragePrintUtil::listMessages(&queueContents, test.d_appId, test.d_offset, @@ -304,7 +308,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: @@ -312,7 +316,7 @@ int main(int argc, char* argv[]) case 1: test1_listMessage(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_storageutil.t.cpp b/src/groups/mqb/mqbs/mqbs_storageutil.t.cpp index 5f5c1bc50..258b6022c 100644 --- a/src/groups/mqb/mqbs/mqbs_storageutil.t.cpp +++ b/src/groups/mqb/mqbs/mqbs_storageutil.t.cpp @@ -64,16 +64,17 @@ struct Tester { public: // CREATORS Tester() - : d_domain1("bmq.random.x", s_allocator_p) - , d_domain2("bmq.haha", s_allocator_p) - , d_domain3("bmq.random.y", s_allocator_p) - , d_d1uri1("bmq://bmq.random.x/q1", s_allocator_p) - , d_d1uri2("bmq://bmq.random.x/q2", s_allocator_p) - , d_d1uri3("bmq://bmq.random.x/q3", s_allocator_p) - , d_d2uri1("bmq://bmq.haha/baddie", s_allocator_p) - , d_d2uri2("bmq://bmq.haha/excellent", s_allocator_p) - , d_d2uri3("bmq://bmq.haha/soso", s_allocator_p) - , d_d3uri1("bmq://bmq.random.y/generic", s_allocator_p) + : d_domain1("bmq.random.x", bmqtst::TestHelperUtil::allocator()) + , d_domain2("bmq.haha", bmqtst::TestHelperUtil::allocator()) + , d_domain3("bmq.random.y", bmqtst::TestHelperUtil::allocator()) + , d_d1uri1("bmq://bmq.random.x/q1", bmqtst::TestHelperUtil::allocator()) + , d_d1uri2("bmq://bmq.random.x/q2", bmqtst::TestHelperUtil::allocator()) + , d_d1uri3("bmq://bmq.random.x/q3", bmqtst::TestHelperUtil::allocator()) + , d_d2uri1("bmq://bmq.haha/baddie", bmqtst::TestHelperUtil::allocator()) + , d_d2uri2("bmq://bmq.haha/excellent", bmqtst::TestHelperUtil::allocator()) + , d_d2uri3("bmq://bmq.haha/soso", bmqtst::TestHelperUtil::allocator()) + , d_d3uri1("bmq://bmq.random.y/generic", + bmqtst::TestHelperUtil::allocator()) { // NOTHING } @@ -129,11 +130,13 @@ static void test2_mergeQueueMessagesCountMap() using namespace mqbs; - StorageUtil::QueueMessagesCountMap qs1(s_allocator_p); + StorageUtil::QueueMessagesCountMap qs1( + bmqtst::TestHelperUtil::allocator()); qs1.insert(bsl::make_pair(tester.d_d1uri1, 10)); qs1.insert(bsl::make_pair(tester.d_d1uri2, 20)); - StorageUtil::QueueMessagesCountMap qs2(s_allocator_p); + StorageUtil::QueueMessagesCountMap qs2( + bmqtst::TestHelperUtil::allocator()); qs2.insert(bsl::make_pair(tester.d_d1uri1, 100)); qs2.insert(bsl::make_pair(tester.d_d1uri3, 333)); @@ -163,29 +166,36 @@ static void test3_mergeDomainQueueMessagesCountMap() using namespace mqbs; - StorageUtil::QueueMessagesCountMap qs1(s_allocator_p); + StorageUtil::QueueMessagesCountMap qs1( + bmqtst::TestHelperUtil::allocator()); qs1.insert(bsl::make_pair(tester.d_d1uri1, 10)); qs1.insert(bsl::make_pair(tester.d_d1uri2, 20)); - StorageUtil::QueueMessagesCountMap qs2(s_allocator_p); + StorageUtil::QueueMessagesCountMap qs2( + bmqtst::TestHelperUtil::allocator()); qs2.insert(bsl::make_pair(tester.d_d2uri1, 7777)); - StorageUtil::DomainQueueMessagesCountMap map1(s_allocator_p); + StorageUtil::DomainQueueMessagesCountMap map1( + bmqtst::TestHelperUtil::allocator()); map1.insert(bsl::make_pair(tester.d_domain1, qs1)); map1.insert(bsl::make_pair(tester.d_domain2, qs2)); - StorageUtil::QueueMessagesCountMap qs3(s_allocator_p); + StorageUtil::QueueMessagesCountMap qs3( + bmqtst::TestHelperUtil::allocator()); qs3.insert(bsl::make_pair(tester.d_d1uri1, 100)); qs3.insert(bsl::make_pair(tester.d_d1uri3, 333)); - StorageUtil::QueueMessagesCountMap qs4(s_allocator_p); + StorageUtil::QueueMessagesCountMap qs4( + bmqtst::TestHelperUtil::allocator()); qs4.insert(bsl::make_pair(tester.d_d2uri2, 8888)); qs4.insert(bsl::make_pair(tester.d_d2uri3, 9999)); - StorageUtil::QueueMessagesCountMap qs5(s_allocator_p); + StorageUtil::QueueMessagesCountMap qs5( + bmqtst::TestHelperUtil::allocator()); qs5.insert(bsl::make_pair(tester.d_d3uri1, 1234567)); - StorageUtil::DomainQueueMessagesCountMap map2(s_allocator_p); + StorageUtil::DomainQueueMessagesCountMap map2( + bmqtst::TestHelperUtil::allocator()); map2.insert(bsl::make_pair(tester.d_domain1, qs3)); map2.insert(bsl::make_pair(tester.d_domain2, qs4)); map2.insert(bsl::make_pair(tester.d_domain3, qs5)); @@ -364,7 +374,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); bmqsys::Time::initialize(); switch (_testCase) { @@ -376,7 +386,7 @@ int main(int argc, char* argv[]) case 1: test1_queueMessagesCountComparator(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbs/mqbs_virtualstoragecatalog.cpp b/src/groups/mqb/mqbs/mqbs_virtualstoragecatalog.cpp index 8cd24b5bf..fabab605c 100644 --- a/src/groups/mqb/mqbs/mqbs_virtualstoragecatalog.cpp +++ b/src/groups/mqb/mqbs/mqbs_virtualstoragecatalog.cpp @@ -422,9 +422,10 @@ int VirtualStorageCatalog::addVirtualStorage(bsl::ostream& errorDescription, appOrdinal = d_nextOrdinal++; } else { - appOrdinal = d_availableOrdinals.front(); + AvailableOrdinals::const_iterator first = d_availableOrdinals.cbegin(); + appOrdinal = *first; // There is no conflict because everything 'appOrdinal' was removed. - d_availableOrdinals.pop_front(); + d_availableOrdinals.erase(first); } BSLS_ASSERT_SAFE(appOrdinal <= d_virtualStorages.size()); @@ -468,7 +469,7 @@ bool VirtualStorageCatalog::removeVirtualStorage( removeAll(appKey); const VirtualStorage& vs = *it->value(); - d_availableOrdinals.push_back(vs.ordinal()); + d_availableOrdinals.insert(vs.ordinal()); if (d_queue_p) { BSLS_ASSERT_SAFE(d_queue_p->queueEngine()); diff --git a/src/groups/mqb/mqbs/mqbs_virtualstoragecatalog.h b/src/groups/mqb/mqbs/mqbs_virtualstoragecatalog.h index 94f89762f..ede15bf1f 100644 --- a/src/groups/mqb/mqbs/mqbs_virtualstoragecatalog.h +++ b/src/groups/mqb/mqbs/mqbs_virtualstoragecatalog.h @@ -86,7 +86,7 @@ class VirtualStorageCatalog { typedef bsl::shared_ptr VirtualStorageSp; /// List of available ordinal values for Virtual Storages. - typedef bsl::list AvailableOrdinals; + typedef bsl::set AvailableOrdinals; /// appKey -> virtualStorage typedef bmqc:: diff --git a/src/groups/mqb/mqbsi/mqbsi_ledger.t.cpp b/src/groups/mqb/mqbsi/mqbsi_ledger.t.cpp index 061b5c7ce..aacabe0cb 100644 --- a/src/groups/mqb/mqbsi/mqbsi_ledger.t.cpp +++ b/src/groups/mqb/mqbsi/mqbsi_ledger.t.cpp @@ -206,7 +206,8 @@ static void test1_ledger_protocol() bmqtst::TestHelper::printTestName("LEDGER"); PV("Creating a test object"); - bsls::ProtocolTest testObj(s_verbosityLevel > 2); + bsls::ProtocolTest testObj( + bmqtst::TestHelperUtil::verbosityLevel() > 2); PV("Verify that the protocol is abstract"); ASSERT(testObj.testAbstract()); @@ -231,7 +232,7 @@ int main(int argc, char* argv[]) case 1: test1_ledger_protocol(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbsi/mqbsi_log.t.cpp b/src/groups/mqb/mqbsi/mqbsi_log.t.cpp index df2c2e2ab..b8d57e403 100644 --- a/src/groups/mqb/mqbsi/mqbsi_log.t.cpp +++ b/src/groups/mqb/mqbsi/mqbsi_log.t.cpp @@ -68,7 +68,7 @@ struct LogTestImp : bsls::ProtocolTestImp { public: // CREATORS LogTestImp() - : d_config(0, mqbu::StorageKey(), s_allocator_p) + : d_config(0, mqbu::StorageKey(), bmqtst::TestHelperUtil::allocator()) { // NOTHING } @@ -205,7 +205,8 @@ static void test1_log_protocol() bmqtst::TestHelper::printTestName("LOG"); PV("Creating a test object"); - bsls::ProtocolTest testObj(s_verbosityLevel > 2); + bsls::ProtocolTest testObj( + bmqtst::TestHelperUtil::verbosityLevel() > 2); PV("Verify that the protocol is abstract"); ASSERT(testObj.testAbstract()); @@ -230,7 +231,7 @@ int main(int argc, char* argv[]) case 1: test1_log_protocol(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbsl/mqbsl_inmemorylog.t.cpp b/src/groups/mqb/mqbsl/mqbsl_inmemorylog.t.cpp index 070813608..0938b3094 100644 --- a/src/groups/mqb/mqbsl/mqbsl_inmemorylog.t.cpp +++ b/src/groups/mqb/mqbsl/mqbsl_inmemorylog.t.cpp @@ -116,8 +116,12 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("BREATHING TEST"); - const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, k_LOG_KEY, s_allocator_p); - InMemoryLog log(k_CONFIG, g_bufferFactory_p, s_allocator_p); + const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(k_CONFIG, + g_bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(log.isOpened(), false); ASSERT_EQ(log.open(Log::e_CREATE_IF_MISSING), LogOpResult::e_SUCCESS); @@ -146,8 +150,12 @@ static void test2_doubleOpen() { bmqtst::TestHelper::printTestName("DOUBLE OPEN"); - const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, k_LOG_KEY, s_allocator_p); - InMemoryLog log(k_CONFIG, g_bufferFactory_p, s_allocator_p); + const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(k_CONFIG, + g_bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); ASSERT_EQ(log.open(Log::e_CREATE_IF_MISSING), @@ -167,8 +175,12 @@ static void test3_doubleClose() { bmqtst::TestHelper::printTestName("DOUBLE CLOSE"); - const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, k_LOG_KEY, s_allocator_p); - InMemoryLog log(k_CONFIG, g_bufferFactory_p, s_allocator_p); + const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(k_CONFIG, + g_bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); BSLS_ASSERT_OPT(log.close() == LogOpResult::e_SUCCESS); @@ -188,8 +200,12 @@ static void test4_updateOutstandingNumBytes() { bmqtst::TestHelper::printTestName("UPDATE OUTSTANDING NUM BYTES"); - const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, k_LOG_KEY, s_allocator_p); - InMemoryLog log(k_CONFIG, g_bufferFactory_p, s_allocator_p); + const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(k_CONFIG, + g_bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); BSLS_ASSERT_OPT(log.outstandingNumBytes() == 0); @@ -223,8 +239,12 @@ static void test5_setOutstandingNumBytes() { bmqtst::TestHelper::printTestName("SET OUTSTANDING NUM BYTES"); - const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, k_LOG_KEY, s_allocator_p); - InMemoryLog log(k_CONFIG, g_bufferFactory_p, s_allocator_p); + const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(k_CONFIG, + g_bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); BSLS_ASSERT_OPT(log.outstandingNumBytes() == 0); @@ -261,8 +281,12 @@ static void test6_writeRaw() const bsls::Types::Int64 maxSize = k_NUM_ENTRIES * k_ENTRY_LENGTH + k_LONG_ENTRY_LENGTH + 10; - const mqbsi::LogConfig config(maxSize, k_LOG_KEY, s_allocator_p); - InMemoryLog log(config, g_bufferFactory_p, s_allocator_p); + const mqbsi::LogConfig config(maxSize, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(config, + g_bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); @@ -327,13 +351,18 @@ static void test7_writeBlob() const bsls::Types::Int64 maxSize = k_NUM_ENTRIES * k_ENTRY_LENGTH + k_LONG_ENTRY_LENGTH + 10; - const mqbsi::LogConfig config(maxSize, k_LOG_KEY, s_allocator_p); - InMemoryLog log(config, g_bufferFactory_p, s_allocator_p); + const mqbsi::LogConfig config(maxSize, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(config, + g_bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); // 1. Write a list of entries - bdlbb::Blob blob(g_miniBufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_miniBufferFactory_p, + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < k_NUM_ENTRIES; ++i) { bdlbb::BlobUtil::append(&blob, k_ENTRIES[i], k_ENTRY_LENGTH); @@ -354,7 +383,7 @@ static void test7_writeBlob() // 3. Write a long entry bsls::Types::Int64 currNumBytes = log.totalNumBytes(); - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); ASSERT_EQ(log.write(blob2, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -402,13 +431,18 @@ static void test8_writeBlobSection() const bsls::Types::Int64 maxSize = k_NUM_ENTRIES * k_ENTRY_LENGTH + k_LONG_ENTRY_LENGTH + 10; - const mqbsi::LogConfig config(maxSize, k_LOG_KEY, s_allocator_p); - InMemoryLog log(config, g_bufferFactory_p, s_allocator_p); + const mqbsi::LogConfig config(maxSize, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(config, + g_bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); // 1. Write a list of entries - bdlbb::Blob blob(g_miniBufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_miniBufferFactory_p, + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < k_NUM_ENTRIES; ++i) { bdlbb::BlobUtil::append(&blob, k_ENTRIES[i], k_ENTRY_LENGTH); @@ -430,7 +464,7 @@ static void test8_writeBlobSection() // 3. Write a long entry bsls::Types::Int64 currNumBytes = log.totalNumBytes(); - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY_OFFSET); @@ -472,8 +506,12 @@ static void test9_readRaw() { bmqtst::TestHelper::printTestName("READ RAW"); - const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, k_LOG_KEY, s_allocator_p); - InMemoryLog log(k_CONFIG, g_miniBufferFactory_p, s_allocator_p); + const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(k_CONFIG, + g_miniBufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); @@ -497,7 +535,7 @@ static void test9_readRaw() LogOpResult::e_SUCCESS); // 4. Write a long entry - bdlbb::Blob blob(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); BSLS_ASSERT_OPT(log.write(blob, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -520,7 +558,7 @@ static void test9_readRaw() // 6. Write another long entry const Offset currOffset = static_cast(k_NUM_ENTRIES + 1); - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY2, k_LONG_ENTRY2_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY2_OFFSET); @@ -559,8 +597,12 @@ static void test10_readBlob() { bmqtst::TestHelper::printTestName("READ BLOB"); - const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, k_LOG_KEY, s_allocator_p); - InMemoryLog log(k_CONFIG, g_miniBufferFactory_p, s_allocator_p); + const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(k_CONFIG, + g_miniBufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); @@ -571,7 +613,7 @@ static void test10_readBlob() } // 2. Read each entry in the list of entries - bdlbb::Blob blob(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); blob.setLength(k_LONG_ENTRY_LENGTH); char entry[k_LONG_ENTRY_LENGTH]; @@ -590,7 +632,7 @@ static void test10_readBlob() LogOpResult::e_SUCCESS); // 4. Write a long entry - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); BSLS_ASSERT_OPT(log.write(blob2, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -618,7 +660,7 @@ static void test10_readBlob() // 6. Write another long entry const Offset currOffset = static_cast(k_NUM_ENTRIES + 1); - bdlbb::Blob blob3(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob3(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob3, k_LONG_ENTRY2, k_LONG_ENTRY2_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY2_OFFSET); @@ -659,8 +701,12 @@ static void test11_aliasRaw() { bmqtst::TestHelper::printTestName("ALIAS RAW"); - const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, k_LOG_KEY, s_allocator_p); - InMemoryLog log(k_CONFIG, g_bufferFactory_p, s_allocator_p); + const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(k_CONFIG, + g_bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); @@ -685,8 +731,12 @@ static void test12_aliasBlob() { bmqtst::TestHelper::printTestName("ALIAS BLOB"); - const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, k_LOG_KEY, s_allocator_p); - InMemoryLog log(k_CONFIG, g_miniBufferFactory_p, s_allocator_p); + const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(k_CONFIG, + g_miniBufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); @@ -697,7 +747,7 @@ static void test12_aliasBlob() } // 2. Alias each entry in the list of entries - bdlbb::Blob blob(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); char entry[k_LONG_ENTRY_LENGTH]; for (int i = 0; i < k_NUM_ENTRIES; ++i) { @@ -717,7 +767,7 @@ static void test12_aliasBlob() LogOpResult::e_SUCCESS); // 4. Write a long entry - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); BSLS_ASSERT_OPT(log.write(blob2, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -748,7 +798,7 @@ static void test12_aliasBlob() // 6. Write another long entry const Offset currOffset = static_cast(k_NUM_ENTRIES + 1); - bdlbb::Blob blob3(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob3(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob3, k_LONG_ENTRY2, k_LONG_ENTRY2_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY2_OFFSET); @@ -791,8 +841,12 @@ static void test13_seek() { bmqtst::TestHelper::printTestName("SEEK"); - const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, k_LOG_KEY, s_allocator_p); - InMemoryLog log(k_CONFIG, g_bufferFactory_p, s_allocator_p); + const mqbsi::LogConfig k_CONFIG(k_LOG_MAX_SIZE, + k_LOG_KEY, + bmqtst::TestHelperUtil::allocator()); + InMemoryLog log(k_CONFIG, + g_bufferFactory_p, + bmqtst::TestHelperUtil::allocator()); BSLS_ASSERT_OPT(log.open(Log::e_CREATE_IF_MISSING) == LogOpResult::e_SUCCESS); BSLS_ASSERT_OPT(log.currentOffset() == static_cast(0)); @@ -889,10 +943,12 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); { - bdlbb::PooledBlobBufferFactory bufferFactory(k_LONG_ENTRY_LENGTH * 2, - s_allocator_p); - bdlbb::PooledBlobBufferFactory miniBufferFactory(k_ENTRY_LENGTH, - s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + k_LONG_ENTRY_LENGTH * 2, + bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory miniBufferFactory( + k_ENTRY_LENGTH, + bmqtst::TestHelperUtil::allocator()); g_bufferFactory_p = &bufferFactory; g_miniBufferFactory_p = &miniBufferFactory; @@ -913,7 +969,7 @@ int main(int argc, char* argv[]) case 13: test13_seek(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } } diff --git a/src/groups/mqb/mqbsl/mqbsl_ledger.t.cpp b/src/groups/mqb/mqbsl/mqbsl_ledger.t.cpp index bba4f71c3..536c79bb2 100644 --- a/src/groups/mqb/mqbsl/mqbsl_ledger.t.cpp +++ b/src/groups/mqb/mqbsl/mqbsl_ledger.t.cpp @@ -165,7 +165,7 @@ struct Tester { // CREATORS Tester(bool keepOldLogs = true, bsls::Types::Int64 maxLogSize = k_LOG_MAX_SIZE, - bslma::Allocator* allocator = s_allocator_p) + bslma::Allocator* allocator = bmqtst::TestHelperUtil::allocator()) : d_config(allocator) , d_ledger_mp(0) , d_tempDir(allocator) @@ -405,7 +405,8 @@ static void test3_openMultipleLogsNoKeep() LedgerRecordId obsoleteRecordId(obsoleteLogId, 0); char entry[Tester::k_OLD_LOG_LEN]; - bdlbb::Blob blobEntry(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob blobEntry(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(ledger->updateOutstandingNumBytes(obsoleteLogId, 100), LedgerOpResult::e_LOG_NOT_FOUND); ASSERT_EQ(ledger->setOutstandingNumBytes(obsoleteLogId, 100), @@ -737,7 +738,8 @@ static void test7_writeRecordBlob() oldLogNumBytes + Tester::k_OLD_LOG_LEN); // 1. Write a list of records. - bdlbb::Blob blob(tester.miniBufferFactory(), s_allocator_p); + bdlbb::Blob blob(tester.miniBufferFactory(), + bmqtst::TestHelperUtil::allocator()); LedgerRecordId recordId; for (int i = 0; i < k_NUM_ENTRIES; ++i) { bdlbb::BlobUtil::append(&blob, k_ENTRIES[i], k_ENTRY_LEN); @@ -764,7 +766,8 @@ static void test7_writeRecordBlob() BSLS_ASSERT_OPT(ledger->outstandingNumBytes() == Tester::k_OLD_LOG_LEN); // 3. Write a long record. - bdlbb::Blob blob2(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob blob2(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LEN); ASSERT_EQ(ledger->writeRecord(&recordId, blob2, @@ -783,7 +786,8 @@ static void test7_writeRecordBlob() // 4. Write a record that would trigger rollover and would be written to a // new log. - bdlbb::Blob blob3(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob blob3(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob3, k_EXTRA_ENTRY_1, k_EXTRA_ENTRY_LEN); ASSERT_EQ(ledger->writeRecord(&recordId, blob3, @@ -813,7 +817,8 @@ static void test7_writeRecordBlob() newLogNumBytes + k_LONG_ENTRY_LEN + Tester::k_OLD_LOG_LEN); // 5. Write one more record. - bdlbb::Blob blob4(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob blob4(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob4, k_EXTRA_ENTRY_2, k_EXTRA_ENTRY_LEN); ASSERT_EQ(ledger->writeRecord(&recordId, blob4, @@ -893,7 +898,8 @@ static void test8_writeRecordBlobSection() oldLogNumBytes + Tester::k_OLD_LOG_LEN); // 1. Write a list of records. - bdlbb::Blob blob(tester.miniBufferFactory(), s_allocator_p); + bdlbb::Blob blob(tester.miniBufferFactory(), + bmqtst::TestHelperUtil::allocator()); LedgerRecordId recordId; for (int i = 0; i < k_NUM_ENTRIES; ++i) { bdlbb::BlobUtil::append(&blob, k_ENTRIES[i], k_ENTRY_LEN); @@ -922,7 +928,8 @@ static void test8_writeRecordBlobSection() BSLS_ASSERT_OPT(ledger->outstandingNumBytes() == Tester::k_OLD_LOG_LEN); // 3. Write a long record. - bdlbb::Blob blob2(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob blob2(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LEN); bmqu::BlobPosition start2(0, k_LONG_ENTRY_OFFSET); @@ -942,7 +949,8 @@ static void test8_writeRecordBlobSection() // 4. Write a record that would trigger rollover and would be written to a // new log. - bdlbb::Blob blob3(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob blob3(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob3, k_EXTRA_ENTRY_1, k_EXTRA_ENTRY_LEN); bmqu::BlobPosition start3; @@ -973,7 +981,8 @@ static void test8_writeRecordBlobSection() newLogNumBytes + k_LONG_ENTRY_LEN + Tester::k_OLD_LOG_LEN); // 5. Write one more record. - bdlbb::Blob blob4(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob blob4(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob4, k_EXTRA_ENTRY_2, k_EXTRA_ENTRY_LEN); bmqu::BlobPosition start4; @@ -1194,7 +1203,8 @@ static void test10_readRecordBlob() BSLS_ASSERT_OPT(ledger->totalNumBytes(logId3) == k_EXTRA_ENTRY_LEN * 2); // 1. Read each record in Log 1 - bdlbb::Blob blob(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob blob(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); char entry[k_DUMMY_LOG_MESSAGE_LEN]; // Skip the log ID written at the beginning of the log @@ -1523,7 +1533,8 @@ static void test12_aliasRecordBlob() BSLS_ASSERT_OPT(ledger->totalNumBytes(logId3) == k_EXTRA_ENTRY_LEN * 2); // 1. Read each record in Log 1 - bdlbb::Blob blob(tester.bufferFactory(), s_allocator_p); + bdlbb::Blob blob(tester.bufferFactory(), + bmqtst::TestHelperUtil::allocator()); char entry[k_DUMMY_LOG_MESSAGE_LEN]; // Skip the log ID written at the beginning of the log @@ -1662,7 +1673,7 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqsys::Time::initialize(s_allocator_p); + bmqsys::Time::initialize(bmqtst::TestHelperUtil::allocator()); { switch (_testCase) { @@ -1681,7 +1692,7 @@ int main(int argc, char* argv[]) case 12: test12_aliasRecordBlob(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } } diff --git a/src/groups/mqb/mqbsl/mqbsl_memorymappedondisklog.t.cpp b/src/groups/mqb/mqbsl/mqbsl_memorymappedondisklog.t.cpp index af3264119..b2129abfb 100644 --- a/src/groups/mqb/mqbsl/mqbsl_memorymappedondisklog.t.cpp +++ b/src/groups/mqb/mqbsl/mqbsl_memorymappedondisklog.t.cpp @@ -115,7 +115,7 @@ struct Tester { public: // CREATORS Tester(bsls::Types::Int64 logMaxSize = k_LOG_MAX_SIZE, - bslma::Allocator* allocator = s_allocator_p) + bslma::Allocator* allocator = bmqtst::TestHelperUtil::allocator()) : d_tempDirectory(allocator) , d_config(logMaxSize, k_LOG_KEY, @@ -350,7 +350,8 @@ static void test6_writeBlob() LogOpResult::e_SUCCESS); // 1. Write a list of entries - bdlbb::Blob blob(g_miniBufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_miniBufferFactory_p, + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < k_NUM_ENTRIES; ++i) { bdlbb::BlobUtil::append(&blob, k_ENTRIES[i], k_ENTRY_LENGTH); @@ -372,7 +373,7 @@ static void test6_writeBlob() // 3. Write a long entry bsls::Types::Int64 currNumBytes = log.totalNumBytes(); - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); ASSERT_EQ(log.write(blob2, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -426,7 +427,8 @@ static void test7_writeBlobSection() LogOpResult::e_SUCCESS); // 1. Write a list of entries - bdlbb::Blob blob(g_miniBufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_miniBufferFactory_p, + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < k_NUM_ENTRIES; ++i) { bdlbb::BlobUtil::append(&blob, k_ENTRIES[i], k_ENTRY_LENGTH); @@ -450,7 +452,7 @@ static void test7_writeBlobSection() // 3. Write a long entry bsls::Types::Int64 currNumBytes = log.totalNumBytes(); - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY_OFFSET); @@ -519,7 +521,7 @@ static void test8_readRaw() LogOpResult::e_SUCCESS); // 4. Write a long entry - bdlbb::Blob blob(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); BSLS_ASSERT_OPT(log.write(blob, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -545,7 +547,7 @@ static void test8_readRaw() const Offset currOffset = static_cast( k_NUM_ENTRIES * k_ENTRY_LENGTH + k_LONG_ENTRY_LENGTH); - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY2, k_LONG_ENTRY2_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY2_OFFSET); @@ -596,7 +598,8 @@ static void test9_readBlob() } // 2. Read each entry in the list of entries - bdlbb::Blob blob(g_miniBufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_miniBufferFactory_p, + bmqtst::TestHelperUtil::allocator()); char entry[k_LONG_ENTRY_LENGTH]; for (int i = 0; i < k_NUM_ENTRIES; ++i) { @@ -617,7 +620,7 @@ static void test9_readBlob() LogOpResult::e_SUCCESS); // 4. Write a long entry - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); BSLS_ASSERT_OPT(log.write(blob2, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -651,7 +654,7 @@ static void test9_readBlob() const Offset currOffset = static_cast( k_NUM_ENTRIES * k_ENTRY_LENGTH + k_LONG_ENTRY_LENGTH); - bdlbb::Blob blob3(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob3(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob3, k_LONG_ENTRY2, k_LONG_ENTRY2_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY2_OFFSET); @@ -720,7 +723,7 @@ static void test10_aliasRaw() LogOpResult::e_SUCCESS); // 4. Write a long entry - bdlbb::Blob blob(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); BSLS_ASSERT_OPT(log.write(blob, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -746,7 +749,7 @@ static void test10_aliasRaw() const Offset currOffset = static_cast( k_NUM_ENTRIES * k_ENTRY_LENGTH + k_LONG_ENTRY_LENGTH); - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY2, k_LONG_ENTRY2_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY2_OFFSET); @@ -799,7 +802,7 @@ static void test11_aliasBlob() } // 2. Alias each entry in the list of entries - bdlbb::Blob blob(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); char entry[k_LONG_ENTRY_LENGTH]; for (int i = 0; i < k_NUM_ENTRIES; ++i) { @@ -820,7 +823,7 @@ static void test11_aliasBlob() LogOpResult::e_SUCCESS); // 4. Write a long entry - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); BSLS_ASSERT_OPT(log.write(blob2, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -854,7 +857,7 @@ static void test11_aliasBlob() const Offset currOffset = static_cast( k_NUM_ENTRIES * k_ENTRY_LENGTH + k_LONG_ENTRY_LENGTH); - bdlbb::Blob blob3(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob3(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob3, k_LONG_ENTRY2, k_LONG_ENTRY2_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY2_OFFSET); @@ -930,7 +933,7 @@ static void test12_seek() // overwritten), then subtract `outstandingNumBytes by their total // length char* entry = static_cast( - s_allocator_p->allocate(k_LONG_ENTRY_LENGTH)); + bmqtst::TestHelperUtil::allocator()->allocate(k_LONG_ENTRY_LENGTH)); BSLS_ASSERT_OPT(log.read(static_cast(entry), k_ENTRY_LENGTH, midpoint) == LogOpResult::e_SUCCESS); @@ -997,7 +1000,7 @@ static void test12_seek() ASSERT_EQ(log.currentOffset(), endpoint); BSLS_ASSERT_OPT(log.close() == LogOpResult::e_SUCCESS); - s_allocator_p->deallocate(entry); + bmqtst::TestHelperUtil::allocator()->deallocate(entry); } // ============================================================================ @@ -1009,10 +1012,12 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); { - bdlbb::PooledBlobBufferFactory bufferFactory(k_LONG_ENTRY_LENGTH * 2, - s_allocator_p); - bdlbb::PooledBlobBufferFactory miniBufferFactory(k_ENTRY_LENGTH, - s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + k_LONG_ENTRY_LENGTH * 2, + bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory miniBufferFactory( + k_ENTRY_LENGTH, + bmqtst::TestHelperUtil::allocator()); g_bufferFactory_p = &bufferFactory; g_miniBufferFactory_p = &miniBufferFactory; @@ -1032,7 +1037,7 @@ int main(int argc, char* argv[]) case 12: test12_seek(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } } diff --git a/src/groups/mqb/mqbsl/mqbsl_readwriteondisklog.t.cpp b/src/groups/mqb/mqbsl/mqbsl_readwriteondisklog.t.cpp index 0987278eb..bd8dd39c9 100644 --- a/src/groups/mqb/mqbsl/mqbsl_readwriteondisklog.t.cpp +++ b/src/groups/mqb/mqbsl/mqbsl_readwriteondisklog.t.cpp @@ -131,7 +131,7 @@ struct Tester { public: // CREATORS Tester(bsls::Types::Int64 logMaxSize = k_LOG_MAX_SIZE, - bslma::Allocator* allocator = s_allocator_p) + bslma::Allocator* allocator = bmqtst::TestHelperUtil::allocator()) : d_tempDirectory(allocator) , d_config(logMaxSize, k_LOG_KEY, @@ -365,7 +365,8 @@ static void test6_writeBlob() LogOpResult::e_SUCCESS); // 1. Write a list of entries - bdlbb::Blob blob(g_miniBufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_miniBufferFactory_p, + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < k_NUM_ENTRIES; ++i) { bdlbb::BlobUtil::append(&blob, k_ENTRIES[i], k_ENTRY_LENGTH); @@ -387,7 +388,7 @@ static void test6_writeBlob() // 3. Write a long entry bsls::Types::Int64 currNumBytes = log.totalNumBytes(); - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); ASSERT_EQ(log.write(blob2, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -441,7 +442,8 @@ static void test7_writeBlobSection() LogOpResult::e_SUCCESS); // 1. Write a list of entries - bdlbb::Blob blob(g_miniBufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_miniBufferFactory_p, + bmqtst::TestHelperUtil::allocator()); for (int i = 0; i < k_NUM_ENTRIES; ++i) { bdlbb::BlobUtil::append(&blob, k_ENTRIES[i], k_ENTRY_LENGTH); @@ -465,7 +467,7 @@ static void test7_writeBlobSection() // 3. Write a long entry bsls::Types::Int64 currNumBytes = log.totalNumBytes(); - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY_OFFSET); @@ -534,7 +536,7 @@ static void test8_readRaw() LogOpResult::e_SUCCESS); // 4. Write a long entry - bdlbb::Blob blob(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); BSLS_ASSERT_OPT(log.write(blob, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -560,7 +562,7 @@ static void test8_readRaw() const Offset currOffset = static_cast( k_NUM_ENTRIES * k_ENTRY_LENGTH + k_LONG_ENTRY_LENGTH); - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY2, k_LONG_ENTRY2_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY2_OFFSET); @@ -611,7 +613,8 @@ static void test9_readBlob() } // 2. Read each entry in the list of entries - bdlbb::Blob blob(g_miniBufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_miniBufferFactory_p, + bmqtst::TestHelperUtil::allocator()); char entry[k_LONG_ENTRY_LENGTH]; for (int i = 0; i < k_NUM_ENTRIES; ++i) { @@ -631,7 +634,7 @@ static void test9_readBlob() LogOpResult::e_SUCCESS); // 4. Write a long entry - bdlbb::Blob blob2(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob2(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob2, k_LONG_ENTRY, k_LONG_ENTRY_FULL_LENGTH); BSLS_ASSERT_OPT(log.write(blob2, bmqu::BlobPosition(0, k_LONG_ENTRY_OFFSET), @@ -664,7 +667,7 @@ static void test9_readBlob() const Offset currOffset = static_cast( k_NUM_ENTRIES * k_ENTRY_LENGTH + k_LONG_ENTRY_LENGTH); - bdlbb::Blob blob3(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob3(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); bdlbb::BlobUtil::append(&blob3, k_LONG_ENTRY2, k_LONG_ENTRY2_FULL_LENGTH); bmqu::BlobPosition start(0, k_LONG_ENTRY2_OFFSET); @@ -738,7 +741,7 @@ static void test11_aliasBlob() LogOpResult::e_SUCCESS); // Blob aliasing is not supported - bdlbb::Blob blob(g_bufferFactory_p, s_allocator_p); + bdlbb::Blob blob(g_bufferFactory_p, bmqtst::TestHelperUtil::allocator()); ASSERT_FAIL(log.alias(&blob, k_ENTRY_LENGTH, 0)); BSLS_ASSERT_OPT(log.close() == LogOpResult::e_SUCCESS); @@ -890,12 +893,14 @@ static void test13_readWriteHugeBlob() static const int k_BUFFER_LEN = k_BLOB_MAX_SIZE / k_NUM_BUFFERS; static const int k_HUGE_BLOB_SIZE = k_BUFFER_LEN * k_NUM_BUFFERS; - bdlbb::PooledBlobBufferFactory hugeBufferFactory(k_BUFFER_LEN, - s_allocator_p); - bdlbb::Blob hugeBlob(&hugeBufferFactory, s_allocator_p); + bdlbb::PooledBlobBufferFactory hugeBufferFactory( + k_BUFFER_LEN, + bmqtst::TestHelperUtil::allocator()); + bdlbb::Blob hugeBlob(&hugeBufferFactory, + bmqtst::TestHelperUtil::allocator()); char* entry = static_cast( - s_allocator_p->allocate(k_HUGE_BLOB_SIZE)); + bmqtst::TestHelperUtil::allocator()->allocate(k_HUGE_BLOB_SIZE)); generateRandomString(entry, k_HUGE_BLOB_SIZE); bdlbb::BlobUtil::append(&hugeBlob, entry, k_HUGE_BLOB_SIZE); BSLS_ASSERT_OPT(hugeBlob.numDataBuffers() > IOV_MAX); @@ -912,11 +917,13 @@ static void test13_readWriteHugeBlob() ASSERT_EQ(log.currentOffset(), static_cast(recordSize)); // 3. Read the huge blob entry - bdlbb::Blob outBlob(&hugeBufferFactory, s_allocator_p); + bdlbb::Blob outBlob(&hugeBufferFactory, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(log.read(&outBlob, recordSize, 0), LogOpResult::e_SUCCESS); BSLS_ASSERT_OPT(outBlob.numDataBuffers() > IOV_MAX); - bdlbb::Blob expectedRecord(&hugeBufferFactory, s_allocator_p); + bdlbb::Blob expectedRecord(&hugeBufferFactory, + bmqtst::TestHelperUtil::allocator()); bmqu::BlobUtil::appendToBlob(&expectedRecord, hugeBlob, recordPos, @@ -926,7 +933,7 @@ static void test13_readWriteHugeBlob() BSLS_ASSERT_OPT(log.flush() == LogOpResult::e_SUCCESS); BSLS_ASSERT_OPT(log.close() == LogOpResult::e_SUCCESS); - s_allocator_p->deallocate(entry); + bmqtst::TestHelperUtil::allocator()->deallocate(entry); } // ============================================================================ @@ -938,10 +945,12 @@ int main(int argc, char* argv[]) TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); { - bdlbb::PooledBlobBufferFactory bufferFactory(k_LONG_ENTRY_LENGTH * 2, - s_allocator_p); - bdlbb::PooledBlobBufferFactory miniBufferFactory(k_ENTRY_LENGTH, - s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + k_LONG_ENTRY_LENGTH * 2, + bmqtst::TestHelperUtil::allocator()); + bdlbb::PooledBlobBufferFactory miniBufferFactory( + k_ENTRY_LENGTH, + bmqtst::TestHelperUtil::allocator()); g_bufferFactory_p = &bufferFactory; g_miniBufferFactory_p = &miniBufferFactory; @@ -962,7 +971,7 @@ int main(int argc, char* argv[]) case 13: test13_readWriteHugeBlob(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } } diff --git a/src/groups/mqb/mqbstat/mqbstat_queuestats.t.cpp b/src/groups/mqb/mqbstat/mqbstat_queuestats.t.cpp index adadd0c0e..a091a3e78 100644 --- a/src/groups/mqb/mqbstat/mqbstat_queuestats.t.cpp +++ b/src/groups/mqb/mqbstat/mqbstat_queuestats.t.cpp @@ -62,16 +62,21 @@ static void test1_breathingTest() { bmqtst::TestHelper::printTestName("Breathing Test"); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - mqbmock::Cluster mockCluster(&bufferFactory, s_allocator_p); - mqbmock::Domain mockDomain(&mockCluster, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + mqbmock::Cluster mockCluster(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + mqbmock::Domain mockDomain(&mockCluster, + bmqtst::TestHelperUtil::allocator()); // Create statcontexts const int k_HISTORY_SIZE = 2; bsl::shared_ptr client = - mqbstat::QueueStatsUtil::initializeStatContextClients(k_HISTORY_SIZE, - s_allocator_p); + mqbstat::QueueStatsUtil::initializeStatContextClients( + k_HISTORY_SIZE, + bmqtst::TestHelperUtil::allocator()); bmqst::StatContext* domain = mockDomain.queueStatContext(); using namespace mqbstat; @@ -80,12 +85,13 @@ static void test1_breathingTest() // Create queuestat objects and assert that subcontexts are created QueueStatsClient queueStatsClient; - queueStatsClient.initialize(bmqt::Uri(s_allocator_p), + queueStatsClient.initialize(bmqt::Uri(bmqtst::TestHelperUtil::allocator()), client.get(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - QueueStatsDomain queueStatsDomain(s_allocator_p); - queueStatsDomain.initialize(bmqt::Uri(s_allocator_p), &mockDomain); + QueueStatsDomain queueStatsDomain(bmqtst::TestHelperUtil::allocator()); + queueStatsDomain.initialize(bmqt::Uri(bmqtst::TestHelperUtil::allocator()), + &mockDomain); client->snapshot(); domain->snapshot(); @@ -166,8 +172,9 @@ static void test2_queueStatsClient() // Create statcontexts const int k_HISTORY_SIZE = 3; bsl::shared_ptr client = - mqbstat::QueueStatsUtil::initializeStatContextClients(k_HISTORY_SIZE, - s_allocator_p); + mqbstat::QueueStatsUtil::initializeStatContextClients( + k_HISTORY_SIZE, + bmqtst::TestHelperUtil::allocator()); client->snapshot(); @@ -175,9 +182,9 @@ static void test2_queueStatsClient() typedef QueueStatsClient::Stat ClientStat; QueueStatsClient queueStatsClient; - queueStatsClient.initialize(bmqt::Uri(s_allocator_p), + queueStatsClient.initialize(bmqt::Uri(bmqtst::TestHelperUtil::allocator()), client.get(), - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); const int k_DUMMY = 0; @@ -263,9 +270,13 @@ static void test3_queueStatsDomain() bmqtst::TestHelper::printTestName("QueueStatsDomain"); // Create statcontext - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - mqbmock::Cluster mockCluster(&bufferFactory, s_allocator_p); - mqbmock::Domain mockDomain(&mockCluster, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + mqbmock::Cluster mockCluster(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + mqbmock::Domain mockDomain(&mockCluster, + bmqtst::TestHelperUtil::allocator()); bmqst::StatContext* domain = mockDomain.queueStatContext(); @@ -274,8 +285,9 @@ static void test3_queueStatsDomain() using namespace mqbstat; typedef QueueStatsDomain::Stat DomainStat; - QueueStatsDomain queueStatsDomain(s_allocator_p); - queueStatsDomain.initialize(bmqt::Uri(s_allocator_p), &mockDomain); + QueueStatsDomain queueStatsDomain(bmqtst::TestHelperUtil::allocator()); + queueStatsDomain.initialize(bmqt::Uri(bmqtst::TestHelperUtil::allocator()), + &mockDomain); const int k_DUMMY = 0; @@ -429,13 +441,18 @@ static void test4_queueStatsDomainContent() mqbstat::QueueStatsDomain::Stat::PARAM)); // Create the necessary objects to test - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - mqbmock::Cluster mockCluster(&bufferFactory, s_allocator_p); - mqbmock::Domain mockDomain(&mockCluster, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + mqbmock::Cluster mockCluster(&bufferFactory, + bmqtst::TestHelperUtil::allocator()); + mqbmock::Domain mockDomain(&mockCluster, + bmqtst::TestHelperUtil::allocator()); bmqst::StatContext* sc = mockDomain.queueStatContext(); - mqbstat::QueueStatsDomain obj(s_allocator_p); - obj.initialize(bmqt::Uri(s_allocator_p), &mockDomain); + mqbstat::QueueStatsDomain obj(bmqtst::TestHelperUtil::allocator()); + obj.initialize(bmqt::Uri(bmqtst::TestHelperUtil::allocator()), + &mockDomain); // Initial Snapshot { @@ -532,63 +549,68 @@ static void test5_appIdMetrics() const bool isCSL = false; const bool isFSM = false; - mqbmock::Cluster::ClusterNodeDefs clusterNodeDefs(s_allocator_p); + mqbmock::Cluster::ClusterNodeDefs clusterNodeDefs( + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode(&clusterNodeDefs, "E1", "US-EAST", 41234, mqbmock::Cluster::k_LEADER_NODE_ID, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode(&clusterNodeDefs, "E2", "US-EAST", 41235, mqbmock::Cluster::k_LEADER_NODE_ID + 1, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode(&clusterNodeDefs, "W1", "US-WEST", 41236, mqbmock::Cluster::k_LEADER_NODE_ID + 2, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbc::ClusterUtil::appendClusterNode(&clusterNodeDefs, "W2", "US-WEST", 41237, mqbmock::Cluster::k_LEADER_NODE_ID + 3, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); - mqbmock::Cluster mockCluster(&bufferFactory, - s_allocator_p, + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); + mqbmock::Cluster mockCluster(&bufferFactory, + bmqtst::TestHelperUtil::allocator(), isClusterMember, isLeader, isCSL, isFSM, clusterNodeDefs); - mqbmock::Domain mockDomain(&mockCluster, s_allocator_p); + mqbmock::Domain mockDomain(&mockCluster, + bmqtst::TestHelperUtil::allocator()); // Reconfigure the domain with appIds and enabled appId metrics const char* k_APPID_FOO = "foo"; const char* k_APPID_BAR = "bar"; const char* k_APPID_BAZ = "baz"; - mqbconfm::Domain domainConfig(s_allocator_p); + mqbconfm::Domain domainConfig(bmqtst::TestHelperUtil::allocator()); mqbconfm::QueueModeFanout& mode = domainConfig.mode().makeFanout(); mode.publishAppIdMetrics() = true; mode.appIDs().push_back(k_APPID_FOO); - bmqu::MemOutStream errorDesc(s_allocator_p); + bmqu::MemOutStream errorDesc(bmqtst::TestHelperUtil::allocator()); mockDomain.configure(errorDesc, domainConfig); // Do not use stat context (`mockDomain.queueStatContext()`) declared // within mock domain, since it was not initialized using the proper // config. Init a new stats object from the scratch instead. - mqbstat::QueueStatsDomain stats(s_allocator_p); - stats.initialize(bmqt::Uri("bmq://mock-domain/abc", s_allocator_p), + mqbstat::QueueStatsDomain stats(bmqtst::TestHelperUtil::allocator()); + stats.initialize(bmqt::Uri("bmq://mock-domain/abc", + bmqtst::TestHelperUtil::allocator()), &mockDomain); bmqst::StatContext* sc = stats.statContext(); @@ -612,7 +634,7 @@ static void test5_appIdMetrics() // Reconfigure queue domain stats, by excluding "foo" and including "bar" // and "baz" { - bsl::vector appIds(s_allocator_p); + bsl::vector appIds(bmqtst::TestHelperUtil::allocator()); appIds.push_back(k_APPID_BAR); appIds.push_back(k_APPID_BAZ); @@ -676,14 +698,16 @@ int main(int argc, char* argv[]) { TEST_PROLOG(bmqtst::TestHelper::e_DEFAULT); - bmqt::UriParser::initialize(s_allocator_p); + bmqt::UriParser::initialize(bmqtst::TestHelperUtil::allocator()); { - mqbcfg::AppConfig brokerConfig(s_allocator_p); + mqbcfg::AppConfig brokerConfig(bmqtst::TestHelperUtil::allocator()); mqbcfg::BrokerConfig::set(brokerConfig); bsl::shared_ptr statContext = - mqbstat::BrokerStatsUtil::initializeStatContext(30, s_allocator_p); + mqbstat::BrokerStatsUtil::initializeStatContext( + 30, + bmqtst::TestHelperUtil::allocator()); switch (_testCase) { case 0: case 5: test5_appIdMetrics(); break; @@ -693,7 +717,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } } diff --git a/src/groups/mqb/mqbstat/mqbstat_statcontroller.t.cpp b/src/groups/mqb/mqbstat/mqbstat_statcontroller.t.cpp index 93dfa8309..5ff3d7653 100644 --- a/src/groups/mqb/mqbstat/mqbstat_statcontroller.t.cpp +++ b/src/groups/mqb/mqbstat/mqbstat_statcontroller.t.cpp @@ -77,12 +77,15 @@ static void test1_breathingTest() bmqtst::TestHelper::printTestName("breathing test"); // Create a default StatController, make sure it can start/stop - mqbcfg::AppConfig cfg(s_allocator_p); // empty default config + mqbcfg::AppConfig cfg( + bmqtst::TestHelperUtil::allocator()); // empty default config mqbcfg::BrokerConfig::set(cfg); - bdlbb::PooledBlobBufferFactory bufferFactory(1024, s_allocator_p); + bdlbb::PooledBlobBufferFactory bufferFactory( + 1024, + bmqtst::TestHelperUtil::allocator()); bdlmt::EventScheduler scheduler(bsls::SystemClockType::e_MONOTONIC, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); mqbplug::PluginManager pluginManager; scheduler.start(); @@ -95,9 +98,9 @@ static void test1_breathingTest() &bufferFactory, 0, // no allocatorsStatContext &scheduler, - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); - bmqu::MemOutStream errStream(s_allocator_p); + bmqu::MemOutStream errStream(bmqtst::TestHelperUtil::allocator()); int rc = obj.start(errStream); ASSERT_EQ(rc, 0); obj.stop(); @@ -119,7 +122,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbu/mqbu_capacitymeter.t.cpp b/src/groups/mqb/mqbu/mqbu_capacitymeter.t.cpp index 6ef20499b..9a05407f5 100644 --- a/src/groups/mqb/mqbu/mqbu_capacitymeter.t.cpp +++ b/src/groups/mqb/mqbu/mqbu_capacitymeter.t.cpp @@ -63,7 +63,8 @@ static void test1_breathingTest() const char* k_NAME = "dummy"; - mqbu::CapacityMeter capacityMeter(k_NAME, s_allocator_p); + mqbu::CapacityMeter capacityMeter(k_NAME, + bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(capacityMeter.name(), k_NAME); ASSERT_EQ(capacityMeter.messages(), 0); @@ -95,7 +96,7 @@ static void test2_logStateChange() { bmqtst::TestHelper::printTestName("LOG STATE CHANGE"); - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -112,9 +113,11 @@ static void test2_logStateChange() { PV("STATE - NORMAL"); - bmqtst::ScopedLogObserver observer(ball::Severity::WARN, - s_allocator_p); - mqbu::CapacityMeter capacityMeter("dummy", s_allocator_p); + bmqtst::ScopedLogObserver observer( + ball::Severity::WARN, + bmqtst::TestHelperUtil::allocator()); + mqbu::CapacityMeter capacityMeter("dummy", + bmqtst::TestHelperUtil::allocator()); capacityMeter.setLimits(k_MSGS_LIMIT, k_BYTES_LIMIT); capacityMeter.setWatermarkThresholds(k_MSGS_THRESHOLD, k_BYTES_THRESHOLD); @@ -129,9 +132,11 @@ static void test2_logStateChange() { PV("STATE - HIGH WATERMARK"); - bmqtst::ScopedLogObserver observer(ball::Severity::WARN, - s_allocator_p); - mqbu::CapacityMeter capacityMeter("dummy", s_allocator_p); + bmqtst::ScopedLogObserver observer( + ball::Severity::WARN, + bmqtst::TestHelperUtil::allocator()); + mqbu::CapacityMeter capacityMeter("dummy", + bmqtst::TestHelperUtil::allocator()); capacityMeter.setLimits(k_MSGS_LIMIT, k_BYTES_LIMIT); capacityMeter.setWatermarkThresholds(k_MSGS_THRESHOLD, k_BYTES_THRESHOLD); @@ -157,21 +162,23 @@ static void test2_logStateChange() ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( record, "ALARM \\[CAPACITY_STATE_HIGH_WATERMARK\\]", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); // This pattern is looked for to generate an alarm ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( record, "dummy.*Messages.*HIGH_WATERMARK", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); } // Set resource to 100%, the full capacity, it should log one { PV("STATE - FULL"); - bmqtst::ScopedLogObserver observer(ball::Severity::WARN, - s_allocator_p); - mqbu::CapacityMeter capacityMeter("dummy", s_allocator_p); + bmqtst::ScopedLogObserver observer( + ball::Severity::WARN, + bmqtst::TestHelperUtil::allocator()); + mqbu::CapacityMeter capacityMeter("dummy", + bmqtst::TestHelperUtil::allocator()); capacityMeter.setLimits(k_MSGS_LIMIT, k_BYTES_LIMIT); capacityMeter.setWatermarkThresholds(k_MSGS_THRESHOLD, k_BYTES_THRESHOLD); @@ -185,12 +192,12 @@ static void test2_logStateChange() ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( observer.records()[0], "ALARM \\[CAPACITY_STATE_FULL\\]", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); // This pattern is looked for to generate an alarm ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( observer.records()[0], "dummy.*Messages.*FULL", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); } // Set resource to the high watermark, and then to 100%, the full capacity, @@ -198,9 +205,11 @@ static void test2_logStateChange() { PV("STATE - HIGH WATERMARK TO FULL"); - bmqtst::ScopedLogObserver observer(ball::Severity::WARN, - s_allocator_p); - mqbu::CapacityMeter capacityMeter("dummy", s_allocator_p); + bmqtst::ScopedLogObserver observer( + ball::Severity::WARN, + bmqtst::TestHelperUtil::allocator()); + mqbu::CapacityMeter capacityMeter("dummy", + bmqtst::TestHelperUtil::allocator()); capacityMeter.setLimits(k_MSGS_LIMIT, k_BYTES_LIMIT); capacityMeter.setWatermarkThresholds(k_MSGS_THRESHOLD, k_BYTES_THRESHOLD); @@ -213,12 +222,12 @@ static void test2_logStateChange() ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( observer.records()[0], "ALARM \\[CAPACITY_STATE_HIGH_WATERMARK\\]", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); // This pattern is looked for to generate an alarm ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( observer.records()[0], "dummy.*Messages.*HIGH_WATERMARK", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); ASSERT_EQ(observer.records()[0].fixedFields().severity(), ball::Severity::ERROR); @@ -230,12 +239,12 @@ static void test2_logStateChange() ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( observer.records()[1], "ALARM \\[CAPACITY_STATE_FULL\\]", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); // This pattern is looked for to generate an alarm ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( observer.records()[1], "dummy.*Messages.*FULL", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); } } @@ -260,7 +269,7 @@ static void test3_enhancedLog() // Set resource to the high watermark, it should log one PV("STATE - HIGH WATERMARK"); - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Logging infrastructure allocates using the default allocator, and // that logging is beyond the control of this function. @@ -273,10 +282,11 @@ static void test3_enhancedLog() const bsls::Types::Int64 k_BYTES_HIGH_WATERMARK_VALUE = k_BYTES_LIMIT * k_BYTES_THRESHOLD; - bmqtst::ScopedLogObserver observer(ball::Severity::WARN, s_allocator_p); + bmqtst::ScopedLogObserver observer(ball::Severity::WARN, + bmqtst::TestHelperUtil::allocator()); mqbu::CapacityMeter capacityMeter( "dummy", - s_allocator_p, + bmqtst::TestHelperUtil::allocator(), bdlf::BindUtil::bind(&logEnhancedStorageInfoCb, bdlf::PlaceHolders::_1) // stream ); @@ -304,12 +314,12 @@ static void test3_enhancedLog() ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( record, "ALARM \\[CAPACITY_STATE_HIGH_WATERMARK\\]", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); // Check log from callback ASSERT(bmqtst::ScopedLogObserverUtil::recordMessageMatch( record, "Test enhanced storage Info", - s_allocator_p)); + bmqtst::TestHelperUtil::allocator())); } // ============================================================================ @@ -327,7 +337,7 @@ int main(int argc, char* argv[]) case 3: test3_enhancedLog(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbu/mqbu_exit.t.cpp b/src/groups/mqb/mqbu/mqbu_exit.t.cpp index 6029195ba..c21592c5c 100644 --- a/src/groups/mqb/mqbu/mqbu_exit.t.cpp +++ b/src/groups/mqb/mqbu/mqbu_exit.t.cpp @@ -131,7 +131,7 @@ static void test1_exitCode_toAscii() PVV(test.d_line << ": Testing: toAscii(" << test.d_value << ") == " << test.d_expected); - bsl::string ascii(s_allocator_p); + bsl::string ascii(bmqtst::TestHelperUtil::allocator()); ascii = mqbu::ExitCode::toAscii(mqbu::ExitCode::Enum(test.d_value)); ASSERT_EQ_D(test.d_line, ascii, test.d_expected); @@ -245,7 +245,7 @@ static void test3_exitCode_print() << ") == " << test.d_expected); // 1. - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); mqbu::ExitCode::Enum obj( static_cast(test.d_value)); @@ -254,7 +254,7 @@ static void test3_exitCode_print() PVV(test.d_line << ": '" << out.str()); - bsl::string expected(s_allocator_p); + bsl::string expected(bmqtst::TestHelperUtil::allocator()); expected.assign(test.d_expected); expected.append("\n"); ASSERT_EQ_D(test.d_line, out.str(), expected); @@ -385,8 +385,8 @@ static void test5_exit_shutdown() // 'ExitUtil::shutdown' // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; - s_ignoreCheckGblAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; + bmqtst::TestHelperUtil::ignoreCheckGblAlloc() = true; // For an unknown reason, this test case fails the default allocator // check, and whenever main sets '_da.setAllocationLimit(0)', it // suddenly passes the default allocator check. @@ -480,7 +480,7 @@ int main(int argc, char* argv[]) case 1: test1_exitCode_toAscii(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbu/mqbu_loadbalancer.t.cpp b/src/groups/mqb/mqbu/mqbu_loadbalancer.t.cpp index b5b01d730..f1282c29f 100644 --- a/src/groups/mqb/mqbu/mqbu_loadbalancer.t.cpp +++ b/src/groups/mqb/mqbu/mqbu_loadbalancer.t.cpp @@ -62,7 +62,8 @@ static void test1_breathingTest() const int k_NUM_PROCESSORS = 3; const int k_NUM_CLIENTS = 13; - mqbu::LoadBalancer obj(k_NUM_PROCESSORS, s_allocator_p); + mqbu::LoadBalancer obj(k_NUM_PROCESSORS, + bmqtst::TestHelperUtil::allocator()); // Ensure that 'numProcessors()' accessor returns the number of processors // set at construction; and that there are no clients. @@ -122,7 +123,8 @@ static void test2_singleProcessorLoadBalancer() const int k_NUM_PROCESSORS = 1; const int k_NUM_CLIENTS = 10; - mqbu::LoadBalancer obj(k_NUM_PROCESSORS, s_allocator_p); + mqbu::LoadBalancer obj(k_NUM_PROCESSORS, + bmqtst::TestHelperUtil::allocator()); // Ensure that 'numProcessors()' accessor returns the number of processors // set at construction; and that there are no clients. @@ -150,7 +152,8 @@ static void test3_loadBalancing() bmqtst::TestHelper::printTestName("LOAD BALANCING"); const int k_INITIAL_CLIENTS_COUNT = 137; - mqbu::LoadBalancer obj(5, s_allocator_p); + mqbu::LoadBalancer obj(5, + bmqtst::TestHelperUtil::allocator()); PV(":: Registering " << k_INITIAL_CLIENTS_COUNT << " clients"); for (int i = 0; i < k_INITIAL_CLIENTS_COUNT; ++i) { @@ -194,7 +197,8 @@ static void test4_forceAssociate() bmqtst::TestHelper::printTestName("FORCE_ASSOCIATE"); const int k_NUM_PROCESSORS = 3; - mqbu::LoadBalancer obj(k_NUM_PROCESSORS, s_allocator_p); + mqbu::LoadBalancer obj(k_NUM_PROCESSORS, + bmqtst::TestHelperUtil::allocator()); PV(":: Assign client '0' to processor '0'"); obj.setProcessorForClient(reinterpret_cast(0), 0); @@ -243,7 +247,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbu/mqbu_messageguidutil.t.cpp b/src/groups/mqb/mqbu/mqbu_messageguidutil.t.cpp index 86c575187..de2a2f621 100644 --- a/src/groups/mqb/mqbu/mqbu_messageguidutil.t.cpp +++ b/src/groups/mqb/mqbu/mqbu_messageguidutil.t.cpp @@ -145,7 +145,7 @@ static void test1_breathingTest() bsl::unordered_map > - myMap(s_allocator_p); + myMap(bmqtst::TestHelperUtil::allocator()); bmqt::MessageGUID guid; mqbu::MessageGUIDUtil::generateGUID(&guid); myMap.insert(bsl::make_pair(guid, 1)); @@ -172,7 +172,7 @@ static void test2_multithread() // Unicity of the generated GUID in a multithreaded environment. // ------------------------------------------------------------------------ { - s_ignoreCheckGblAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckGblAlloc() = true; // Can't ensure no global memory is allocated because // 'bslmt::ThreadUtil::create()' uses the global allocator to allocate // memory. @@ -196,13 +196,14 @@ static void test2_multithread() const int k_NUM_GUIDS = 1000000; // 1M #endif - bslmt::ThreadGroup threadGroup(s_allocator_p); + bslmt::ThreadGroup threadGroup(bmqtst::TestHelperUtil::allocator()); // Barrier to get each thread to start at the same time; `+1` for this // (main) thread. bslmt::Barrier barrier(k_NUM_THREADS + 1); - bsl::vector > threadsData(s_allocator_p); + bsl::vector > threadsData( + bmqtst::TestHelperUtil::allocator()); threadsData.resize(k_NUM_THREADS); for (int i = 0; i < k_NUM_THREADS; ++i) { @@ -217,7 +218,7 @@ static void test2_multithread() threadGroup.joinAll(); // Check uniqueness across all threads - bsl::set allGUIDs(s_allocator_p); + bsl::set allGUIDs(bmqtst::TestHelperUtil::allocator()); for (int tIt = 0; tIt < k_NUM_THREADS; ++tIt) { const bsl::vector& guids = threadsData[tIt]; for (int gIt = 0; gIt < k_NUM_GUIDS; ++gIt) { @@ -243,7 +244,7 @@ static void test3_print() // Printing of the various parts of a GUID. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; bmqtst::TestHelper::printTestName("PRINT"); @@ -252,7 +253,7 @@ static void test3_print() bmqt::MessageGUID guid; ASSERT_EQ(guid.isUnset(), true); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); mqbu::MessageGUIDUtil::print(out, guid); ASSERT_EQ(out.str(), "** UNSET **"); } @@ -273,7 +274,7 @@ static void test3_print() // Print and compare const char k_EXPECTED[] = "[version: 1, counter: 5, timerTick: " "297593876864458, brokerId: CE04742D2E]"; - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); mqbu::MessageGUIDUtil::print(out, guid); ASSERT_EQ(out.str(), k_EXPECTED); } @@ -283,7 +284,7 @@ static void test3_print() bmqt::MessageGUID guid; mqbu::MessageGUIDUtil::generateGUID(&guid); - bmqu::MemOutStream out(s_allocator_p); + bmqu::MemOutStream out(bmqtst::TestHelperUtil::allocator()); mqbu::MessageGUIDUtil::print(out, guid); // Extract the BrokerId from the printed string, that is the 10 @@ -310,7 +311,7 @@ static void test4_defaultHashUniqueness() // Hash uniqueness of the generated GUIDs. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Because there is no emplace on unordered_map, the temporary list // created upon insertion of objects in the map uses the default // allocator. @@ -332,7 +333,8 @@ static void test4_defaultHashUniqueness() typedef bsl::vector Guids; // hash -> vector of corresponding GUIDs - bsl::unordered_map hashes(s_allocator_p); + bsl::unordered_map hashes( + bmqtst::TestHelperUtil::allocator()); hashes.reserve(k_NUM_GUIDS); bsl::hash hasher; @@ -396,7 +398,7 @@ static void test5_customHashUniqueness() // Hash uniqueness of the generated GUIDs. // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Because there is no emplace on unordered_map, the temporary list // created upon insertion of objects in the map uses the default // allocator. @@ -418,7 +420,8 @@ static void test5_customHashUniqueness() typedef bsl::vector Guids; // hash -> vector of corresponding GUIDs - bsl::unordered_map hashes(s_allocator_p); + bsl::unordered_map hashes( + bmqtst::TestHelperUtil::allocator()); hashes.reserve(k_NUM_GUIDS); @@ -491,7 +494,8 @@ static void testN1_decode() // - // ------------------------------------------------------------------------ { - s_ignoreCheckDefAlloc = true; // istringstream allocates + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = + true; // istringstream allocates bmqtst::TestHelper::printTestName("DECODE"); @@ -507,7 +511,7 @@ static void testN1_decode() bsl::istringstream is(buffer); - bsl::string hexGuid(s_allocator_p); + bsl::string hexGuid(bmqtst::TestHelperUtil::allocator()); bsls::Types::Int64 startTimerTick = 0; bsls::Types::Int64 startSecondsFromEpoch = 0; @@ -761,7 +765,8 @@ BSLA_MAYBE_UNUSED static void testN5_hashTableWithDefaultHashBenchmark() const size_t k_NUM_ELEMS = 10000000; // 10M bmqt::MessageGUID guid; - bsl::unordered_map ht(s_allocator_p); + bsl::unordered_map ht( + bmqtst::TestHelperUtil::allocator()); ht.reserve(k_NUM_ELEMS); // Warmup @@ -808,7 +813,7 @@ BSLA_MAYBE_UNUSED static void testN6_hashTableWithCustomHashBenchmark() bsl::unordered_map > - ht(s_allocator_p); + ht(bmqtst::TestHelperUtil::allocator()); ht.reserve(k_NUM_ELEMS); // Warmup @@ -852,8 +857,9 @@ BSLA_MAYBE_UNUSED static void testN7_orderedMapWithDefaultHashBenchmark() const size_t k_NUM_ELEMS = 10000000; // 10M bmqt::MessageGUID guid; - bmqc::OrderedHashMap ht(k_NUM_ELEMS, - s_allocator_p); + bmqc::OrderedHashMap ht( + k_NUM_ELEMS, + bmqtst::TestHelperUtil::allocator()); // Warmup for (size_t i = 1; i <= 1000; ++i) { mqbu::MessageGUIDUtil::generateGUID(&guid); @@ -898,7 +904,7 @@ BSLA_MAYBE_UNUSED static void testN8_orderedMapWithCustomHashBenchmark() bmqc::OrderedHashMap > - ht(k_NUM_ELEMS, s_allocator_p); + ht(k_NUM_ELEMS, bmqtst::TestHelperUtil::allocator()); // Warmup for (size_t i = 1; i <= 1000; ++i) { @@ -949,7 +955,8 @@ static void testN1_decode_GoogleBenchmark(benchmark::State& state) { for (auto _ : state) { state.PauseTiming(); - s_ignoreCheckDefAlloc = true; // istringstream allocates + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = + true; // istringstream allocates bmqtst::TestHelper::printTestName("GOOGLE BENCHMARK DECODE"); @@ -966,7 +973,7 @@ static void testN1_decode_GoogleBenchmark(benchmark::State& state) bsl::istringstream is(buffer); - bsl::string hexGuid(s_allocator_p); + bsl::string hexGuid(bmqtst::TestHelperUtil::allocator()); bsls::Types::Int64 startTimerTick = 0; bsls::Types::Int64 startSecondsFromEpoch = 0; @@ -1174,7 +1181,8 @@ static void testN5_hashTableWithDefaultHashBenchmark_GoogleBenchmark( "w/ DEFAULT HASH BENCHMARK"); bmqt::MessageGUID guid; - bsl::unordered_map ht(s_allocator_p); + bsl::unordered_map ht( + bmqtst::TestHelperUtil::allocator()); ht.reserve(state.range(0)); // Warmup @@ -1211,7 +1219,7 @@ static void testN6_hashTableWithCustomHashBenchmark_GoogleBenchmark( bsl::unordered_map > - ht(s_allocator_p); + ht(bmqtst::TestHelperUtil::allocator()); ht.reserve(state.range(0)); // Warmup @@ -1246,8 +1254,9 @@ static void testN7_orderedMapWithDefaultHashBenchmark_GoogleBenchmark( bmqt::MessageGUID guid; - bmqc::OrderedHashMap ht(state.range(0), - s_allocator_p); + bmqc::OrderedHashMap ht( + state.range(0), + bmqtst::TestHelperUtil::allocator()); // Warmup for (size_t i = 1; i <= 1000; ++i) { mqbu::MessageGUIDUtil::generateGUID(&guid); @@ -1283,7 +1292,7 @@ static void testN8_orderedMapWithCustomHashBenchmark_GoogleBenchmark( bmqc::OrderedHashMap > - ht(state.range(0), s_allocator_p); + ht(state.range(0), bmqtst::TestHelperUtil::allocator()); // Warmup for (size_t i = 1; i <= 1000; ++i) { @@ -1372,7 +1381,7 @@ int main(int argc, char* argv[]) break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } #ifdef BSLS_PLATFORM_OS_LINUX diff --git a/src/groups/mqb/mqbu/mqbu_resourceusagemonitor.t.cpp b/src/groups/mqb/mqbu/mqbu_resourceusagemonitor.t.cpp index a9c67dfd3..4fabaecd8 100644 --- a/src/groups/mqb/mqbu/mqbu_resourceusagemonitor.t.cpp +++ b/src/groups/mqb/mqbu/mqbu_resourceusagemonitor.t.cpp @@ -2398,7 +2398,7 @@ static void test9_print() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bsl::string ascii(s_allocator_p); + bsl::string ascii(bmqtst::TestHelperUtil::allocator()); PVV(test.d_line << ": checking 'RUMState::toAscii(" << "RUMState::e_" << test.d_expected << ")';"); @@ -2433,7 +2433,7 @@ static void test9_print() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bsl::string ascii(s_allocator_p); + bsl::string ascii(bmqtst::TestHelperUtil::allocator()); PVV(test.d_line << ": checking 'RUMStateTransition::toAscii(" << "RUMStateTransition::e_" << test.d_expected @@ -2467,8 +2467,8 @@ static void test9_print() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bsl::string ascii(s_allocator_p); - bmqu::MemOutStream ss(s_allocator_p); + bsl::string ascii(bmqtst::TestHelperUtil::allocator()); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); PVV(test.d_line << ": checking 'RUMState::print(ostream, " << "RUMState::e_" << test.d_expected @@ -2517,7 +2517,7 @@ static void test9_print() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqu::MemOutStream ss(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); PVV(test.d_line << ": checking 'RUMStateTransition::print(ostream" << ", RUMStateTransition::e_" << test.d_expected @@ -2638,7 +2638,7 @@ static void test9_print() for (size_t idx = 0; idx < k_NUM_DATA; ++idx) { const Test& test = k_DATA[idx]; - bmqu::MemOutStream ss(s_allocator_p); + bmqu::MemOutStream ss(bmqtst::TestHelperUtil::allocator()); PVV(test.d_line << ": checking 'monitor.print(ostream)'"); @@ -2807,7 +2807,7 @@ int main(int argc, char* argv[]) case 1: test1_breathingTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } diff --git a/src/groups/mqb/mqbu/mqbu_storagekey.t.cpp b/src/groups/mqb/mqbu/mqbu_storagekey.t.cpp index 67c6ccb39..a1b1319c1 100644 --- a/src/groups/mqb/mqbu/mqbu_storagekey.t.cpp +++ b/src/groups/mqb/mqbu/mqbu_storagekey.t.cpp @@ -185,7 +185,7 @@ void test1_breathingTest() s5.loadHex(s); ASSERT_EQ(0, memcmp(k_VALID_HEX, s, mqbu::StorageKey::e_KEY_LENGTH_HEX)); - bsl::vector binBuf(s_allocator_p); + bsl::vector binBuf(bmqtst::TestHelperUtil::allocator()); s5.loadBinary(&binBuf); ASSERT_EQ(0, memcmp(k_VALID_BIN, @@ -199,7 +199,8 @@ void test1_breathingTest() ASSERT_EQ(true, s4 != s6); PV("Checking default hashing and less than operator"); - bsl::map storageMap(s_allocator_p); + bsl::map storageMap( + bmqtst::TestHelperUtil::allocator()); storageMap.insert(bsl::make_pair(s2, 1)); storageMap.insert(bsl::make_pair(s4, 2)); storageMap.insert(bsl::make_pair(s6, 3)); @@ -210,7 +211,7 @@ void test1_breathingTest() ASSERT_EQ(2, it->second); bsl::unordered_map unorderedStorageMap( - s_allocator_p); + bmqtst::TestHelperUtil::allocator()); unorderedStorageMap.insert(bsl::make_pair(s2, 1)); unorderedStorageMap.insert(bsl::make_pair(s4, 2)); unorderedStorageMap.insert(bsl::make_pair(s6, 3)); @@ -228,7 +229,7 @@ void test1_breathingTest() bsl::unordered_map > - myMap(s_allocator_p); + myMap(bmqtst::TestHelperUtil::allocator()); myMap.insert(bsl::make_pair(s6, 2)); @@ -244,10 +245,10 @@ void test2_streamout() mqbu::StorageKey s1(mqbu::StorageKey::HexRepresentation(), k_HEX); - bmqu::MemOutStream osstr(s_allocator_p); + bmqu::MemOutStream osstr(bmqtst::TestHelperUtil::allocator()); osstr << s1; - bsl::string storageKeyStr(k_HEX, s_allocator_p); + bsl::string storageKeyStr(k_HEX, bmqtst::TestHelperUtil::allocator()); ASSERT_EQ(storageKeyStr, osstr.str()); @@ -272,7 +273,7 @@ void test3_defaultHashUniqueness() { bmqtst::TestHelper::printTestName("DEFAULT HASH UNIQUENESS"); - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Because there is no emplace on unordered_map, the temporary list // created upon insertion of objects in the map uses the default // allocator. @@ -285,8 +286,10 @@ void test3_defaultHashUniqueness() typedef bsl::vector StorageKeys; // hash -> vector of corresponding StorageKeys - bsl::unordered_map hashes(s_allocator_p); - bsl::unordered_set keySet(s_allocator_p); + bsl::unordered_map hashes( + bmqtst::TestHelperUtil::allocator()); + bsl::unordered_set keySet( + bmqtst::TestHelperUtil::allocator()); hashes.reserve(k_NUM_ELEMS); generateStorageKeys(&keySet, k_NUM_ELEMS); // k_NUM_ELEMS in keySet @@ -357,7 +360,7 @@ void test4_customHashUniqueness() { bmqtst::TestHelper::printTestName("CUSTOM HASH UNIQUENESS"); - s_ignoreCheckDefAlloc = true; + bmqtst::TestHelperUtil::ignoreCheckDefAlloc() = true; // Because there is no emplace on unordered_map, the temporary list // created upon insertion of objects in the map uses the default // allocator. @@ -368,8 +371,10 @@ void test4_customHashUniqueness() typedef bsl::vector StorageKeys; // hash -> vector of corresponding StorageKeys - bsl::unordered_map hashes(s_allocator_p); - bsl::unordered_set keySet(s_allocator_p); + bsl::unordered_map hashes( + bmqtst::TestHelperUtil::allocator()); + bsl::unordered_set keySet( + bmqtst::TestHelperUtil::allocator()); hashes.reserve(k_NUM_ELEMS); generateStorageKeys(&keySet, k_NUM_ELEMS); // k_NUM_ELEMS in keySet @@ -531,8 +536,11 @@ void testN3_hashTableWithDefaultHashBenchmark() typedef bsl::unordered_set::const_iterator CITER; const size_t k_NUM_ELEMS = 10000; // 10K - bsl::unordered_set keySet(s_allocator_p); - bsl::unordered_map ht(16843, s_allocator_p); + bsl::unordered_set keySet( + bmqtst::TestHelperUtil::allocator()); + bsl::unordered_map ht( + 16843, + bmqtst::TestHelperUtil::allocator()); ht.reserve(k_NUM_ELEMS); generateStorageKeys(&keySet, k_NUM_ELEMS); // k_NUM_ELEMS in keySet @@ -574,11 +582,12 @@ void testN4_hashTableWithCustomHashBenchmark() typedef bsl::unordered_set::const_iterator CITER; const size_t k_NUM_ELEMS = 10000; // 10K - bsl::unordered_set keySet(s_allocator_p); + bsl::unordered_set keySet( + bmqtst::TestHelperUtil::allocator()); bsl::unordered_map > - ht(16843, s_allocator_p); + ht(16843, bmqtst::TestHelperUtil::allocator()); ht.reserve(k_NUM_ELEMS); generateStorageKeys(&keySet, k_NUM_ELEMS); @@ -620,11 +629,14 @@ void testN5_orderedMapWithDefaultHashBenchmark() typedef bsl::unordered_set::const_iterator CITER; const size_t k_NUM_ELEMS = 10000; // 10K - bsl::unordered_set keySet(s_allocator_p); + bsl::unordered_set keySet( + bmqtst::TestHelperUtil::allocator()); generateStorageKeys(&keySet, k_NUM_ELEMS); - bmqc::OrderedHashMap ht(16843, s_allocator_p); + bmqc::OrderedHashMap ht( + 16843, + bmqtst::TestHelperUtil::allocator()); int i = 1; // Warmup @@ -671,14 +683,15 @@ void testN6_orderedMapWithCustomHashBenchmark() typedef bsl::unordered_set::const_iterator CITER; const size_t k_NUM_ELEMS = 10000; // 10K - bsl::unordered_set keySet(s_allocator_p); + bsl::unordered_set keySet( + bmqtst::TestHelperUtil::allocator()); generateStorageKeys(&keySet, k_NUM_ELEMS); bmqc::OrderedHashMap > - ht(16843, s_allocator_p); + ht(16843, bmqtst::TestHelperUtil::allocator()); int i = 1; // Warmup @@ -792,8 +805,11 @@ static void testN3_hashTableWithDefaultHashBenchmark_GoogleBenchmark( typedef bsl::unordered_set::const_iterator CITER; const size_t k_NUM_ELEMS = state.range(0); - bsl::unordered_set keySet(s_allocator_p); - bsl::unordered_map ht(16843, s_allocator_p); + bsl::unordered_set keySet( + bmqtst::TestHelperUtil::allocator()); + bsl::unordered_map ht( + 16843, + bmqtst::TestHelperUtil::allocator()); ht.reserve(k_NUM_ELEMS); generateStorageKeys(&keySet, k_NUM_ELEMS); // k_NUM_ELEMS in keySet @@ -825,11 +841,12 @@ static void testN4_hashTableWithCustomHashBenchmark_GoogleBenchmark( typedef bsl::unordered_set::const_iterator CITER; const size_t k_NUM_ELEMS = state.range(0); - bsl::unordered_set keySet(s_allocator_p); + bsl::unordered_set keySet( + bmqtst::TestHelperUtil::allocator()); bsl::unordered_map > - ht(16843, s_allocator_p); + ht(16843, bmqtst::TestHelperUtil::allocator()); ht.reserve(k_NUM_ELEMS); generateStorageKeys(&keySet, k_NUM_ELEMS); @@ -860,11 +877,14 @@ static void testN5_orderedMapWithDefaultHashBenchmark_GoogleBenchmark( typedef bsl::unordered_set::const_iterator CITER; const size_t k_NUM_ELEMS = state.range(0); - bsl::unordered_set keySet(s_allocator_p); + bsl::unordered_set keySet( + bmqtst::TestHelperUtil::allocator()); generateStorageKeys(&keySet, k_NUM_ELEMS); - bmqc::OrderedHashMap ht(16843, s_allocator_p); + bmqc::OrderedHashMap ht( + 16843, + bmqtst::TestHelperUtil::allocator()); int i = 1; // Warmup @@ -900,14 +920,15 @@ static void testN6_orderedMapWithCustomHashBenchmark_GoogleBenchmark( typedef bsl::unordered_set::const_iterator CITER; const size_t k_NUM_ELEMS = state.range(0); - bsl::unordered_set keySet(s_allocator_p); + bsl::unordered_set keySet( + bmqtst::TestHelperUtil::allocator()); generateStorageKeys(&keySet, k_NUM_ELEMS); bmqc::OrderedHashMap > - ht(16843, s_allocator_p); + ht(16843, bmqtst::TestHelperUtil::allocator()); int i = 1; // Warmup @@ -982,7 +1003,7 @@ int main(int argc, char* argv[]) break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; - s_testStatus = -1; + bmqtst::TestHelperUtil::testStatus() = -1; } break; } #ifdef BSLS_PLATFORM_OS_LINUX diff --git a/src/integration-tests/test_strong_consistency.py b/src/integration-tests/test_strong_consistency.py index f31b98506..6df40abb1 100644 --- a/src/integration-tests/test_strong_consistency.py +++ b/src/integration-tests/test_strong_consistency.py @@ -256,7 +256,7 @@ def test_change_consistency(self, multi_node: Cluster): wait_ack=False, ) # Cannot wait for too long because resumed nodes may disconnect - # because of missed hearbeats and fail to send the receipt. + # because of missed heartbeats and fail to send the receipt. assert not self.consumer.wait_push_event(timeout=3) # Verify that message is now delivered. diff --git a/src/python/bin/schemagen b/src/python/bin/schemagen index 1d7facc70..a6fbddc03 100755 --- a/src/python/bin/schemagen +++ b/src/python/bin/schemagen @@ -46,13 +46,13 @@ cd "${python_root}" function copyright_black { echo "$copyright -$(cat $1)" > $1 - black -q $1 +$(cat "$1")" > "$1" + black -q "$1" } function generate { xsdata generate --package blazingmq.schemas "$1" - copyright_black $2 + copyright_black "$2" } generate "${blazingmq_root}/src/groups/mqb/mqbcfg/mqbcfg.xsd" blazingmq/schemas/mqbcfg.py diff --git a/src/python/requirements.txt b/src/python/requirements.txt index aaa395a90..2b60e3663 100644 --- a/src/python/requirements.txt +++ b/src/python/requirements.txt @@ -1,3 +1,4 @@ +black @ git+https://github.com/psf/black boofuzz crc32c docker