int runDbTests(int argc, char** argv) { frameworkGlobalParams.perfHist = 1; frameworkGlobalParams.seed = time(0); frameworkGlobalParams.runsPerTest = 1; registerShutdownTask([] { // We drop the scope cache because leak sanitizer can't see across the // thread we use for proxying MozJS requests. Dropping the cache cleans up // the memory and makes leak sanitizer happy. ScriptEngine::dropScopeCache(); // We may be shut down before we have a global storage // engine. if (!getGlobalServiceContext()->getGlobalStorageEngine()) return; getGlobalServiceContext()->shutdownGlobalStorageEngineCleanly(); }); Client::initThread("testsuite"); auto globalServiceContext = getGlobalServiceContext(); // DBTests run as if in the database, so allow them to create direct clients. DBDirectClientFactory::get(globalServiceContext) .registerImplementation([](OperationContext* opCtx) { return std::unique_ptr<DBClientBase>(new DBDirectClient(opCtx)); }); srand((unsigned)frameworkGlobalParams.seed); checked_cast<ServiceContextMongoD*>(globalServiceContext)->createLockFile(); globalServiceContext->initializeGlobalStorageEngine(); auto registry = stdx::make_unique<OpObserverRegistry>(); registry->addObserver(stdx::make_unique<UUIDCatalogObserver>()); globalServiceContext->setOpObserver(std::move(registry)); int ret = unittest::Suite::run(frameworkGlobalParams.suites, frameworkGlobalParams.filter, frameworkGlobalParams.runsPerTest); // So everything shuts down cleanly exitCleanly((ExitCode)ret); return ret; }
int bridgeMain(int argc, char** argv, char** envp) { static StaticObserver staticObserver; registerShutdownTask([&] { // NOTE: This function may be called at any time. It must not // depend on the prior execution of mongo initializers or the // existence of threads. ListeningSockets::get()->closeAll(); listener->shutdownAll(); }); setupSignalHandlers(); runGlobalInitializersOrDie(argc, argv, envp); startSignalProcessingThread(LogFileStatus::kNoLogFileToRotate); listener = stdx::make_unique<BridgeListener>(); listener->setupSockets(); listener->initAndListen(); return EXIT_CLEAN; }