Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command-line options to force googletest to run in single thread

I have a suite of unit tests that is managed by googletest. These tests are run in multiple threads by default, even when I use --gtest_filter=foo.test so that it only runs a single test. This is causing ambiguity about the cause of a bug I'm trying to hammer out.

How can multithreaded testing be turned off in googletest?

like image 608
user14717 Avatar asked Mar 29 '15 22:03

user14717


People also ask

What is single threaded execution?

A single-threaded process is the execution of programmed instructions in a single sequence. Having said that, if an application has the following set of instructions: Instruction A. Instruction B.

What is GMock?

gMock is a library (sometimes we also call it a “framework” to make it sound cool) for creating mock classes and using them. It does to C++ what jMock/EasyMock does to Java (well, more or less).


1 Answers

There's no commandline switch for single/multi-threading. libgtest is built either single-threading or multi-threading.

To make it single-threading, build gtest with ./configure --with-pthreads=no, then link your unit test app without -pthread

If you only want single threading sometimes, then make a no-pthreads build of libgtest, call it something else, and link it when you want.

like image 117
Mike Kinghan Avatar answered Oct 18 '22 09:10

Mike Kinghan