Files
FairMQ/test/helper/runTestDevice.cxx
Dennis Klein 2bd9a072a9 test: pre-fill libstdc++ ctype caches before threads exist
- std::ctype<char> caches narrow()/widen() results per character in
  plain char arrays of the global classic-locale facet, written without
  synchronization from header-inlined code (locale_facets.h); two
  threads exercising an uncached character concurrently (e.g. compiling
  a std::regex in Channel::Validate) constitute a true data race that
  ThreadSanitizer rightfully reports
- the stores are real and unsynchronized, so a tsan-instrumented
  libstdc++ cannot help here; instead fill the caches before any thread
  is spawned, which turns every later access into a pure read
- warm the lazily-installed num_put/num_get caches used by stream
  insertion/extraction as well, via a small format/parse round-trip
- wire the warm-up into the gtest runner main() and, via a static
  initializer, into the test device runner
2026-06-10 19:31:19 +02:00

86 lines
3.1 KiB
C++

/********************************************************************************
* Copyright (C) 2015-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include "LocaleWarmup.h"
#include "devices/TestPairLeft.h"
#include "devices/TestPairRight.h"
#include "devices/TestPollIn.h"
#include "devices/TestPollOut.h"
#include "devices/TestPub.h"
#include "devices/TestPull.h"
#include "devices/TestPush.h"
#include "devices/TestRep.h"
#include "devices/TestReq.h"
#include "devices/TestSub.h"
#include "devices/TestTransferTimeout.h"
#include "devices/TestWaitFor.h"
#include "devices/TestExceptions.h"
#include "devices/TestErrorState.h"
#include "devices/TestSignals.h"
#include <fairmq/runDevice.h>
#include <boost/program_options.hpp>
#include <iostream>
#include <string>
namespace bpo = boost::program_options;
namespace {
[[maybe_unused]] fair::mq::test::LocaleWarmup const gLocaleWarmup{};
}
auto addCustomOptions(bpo::options_description& options) -> void
{
options.add_options()
("poll-type", bpo::value<int>()->default_value(0), "Poll type switch(0 - vector of (sub-)channels, 1 - vector of channel names)");
}
auto getDevice(fair::mq::ProgOptions& config) -> std::unique_ptr<fair::mq::Device>
{
using namespace std;
using namespace fair::mq::test;
auto id = config.GetProperty<std::string>("id");
if (0 == id.find("pull_")) {
return std::make_unique<Pull>();
} else if (0 == id.find("push_")) {
return std::make_unique<Push>();
} else if (0 == id.find("sub_")) {
return std::make_unique<Sub>();
} else if (0 == id.find("pub_")) {
return std::make_unique<Pub>();
} else if (0 == id.find("req_")) {
return std::make_unique<Req>();
} else if (0 == id.find("rep_")) {
return std::make_unique<Rep>();
} else if (0 == id.find("transfer_timeout_")) {
return std::make_unique<TransferTimeout>();
} else if (0 == id.find("pollout_")) {
return std::make_unique<PollOut>();
} else if (0 == id.find("pollin_")) {
return std::make_unique<PollIn>();
} else if (0 == id.find("pairleft_")) {
return std::make_unique<PairLeft>();
} else if (0 == id.find("pairright_")) {
return std::make_unique<PairRight>();
} else if (0 == id.find("waitfor_")) {
return std::make_unique<TestWaitFor>();
} else if (0 == id.find("exceptions_")) {
return std::make_unique<Exceptions>();
} else if (0 == id.find("error_state_")) {
return std::make_unique<ErrorState>();
} else if (0 == id.find("signals_")) {
return std::make_unique<Signals>();
} else {
cerr << "Don't know id '" << id << "'" << endl;
return nullptr;
}
}