You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I built GoogleTest without pthread on Linux and successful compile tests with it using mocks. When running these tests all of them crash with a final message "Segmentation fault". They should pass.
Steps to reproduce the bug
I cloned GoogleTest and stay in its root directory. Here I use this simple test program:
~$ cat test_simple.cpp
#include "gmock/gmock.h"
#include "gtest/gtest.h"
// simple mocked class
// -------------------
class Foo {
virtual int GetInt() const = 0;
};
class MockFoo : public Foo {
public:
MOCK_METHOD(int, GetInt, (), (const, override));
};
// simple testsuite
//-----------------
TEST(simpleTestSuite, simpleMockTest) {
MockFoo mockedFoo;
EXPECT_CALL(mockedFoo, GetInt()).Times(1);
EXPECT_EQ(mockedFoo.GetInt(), 0);
}
// main entry
// ----------
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
Now verify that it runs successful with default configure/build of GoogleTest:
~$ ./test_simple
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from simpleTestSuite
[ RUN ] simpleTestSuite.simpleMockTest
[ OK ] simpleTestSuite.simpleMockTest (0 ms)
[----------] 1 test from simpleTestSuite (0 ms total)
[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (0 ms total)
[ PASSED ] 1 test.
So far so good. Now build GoogleTest with option -D gtest_disable_pthreads=ON and compile the simple test:
On compiling the simple test I do not need option -lpthread of course.
~$ g++ -std=c++11 -otest_simple -I./googletest/include/ -I./googlemock/include/ ./test_simple.cpp ./build/lib/libgtest.a ./build/lib/libgmock.a
/usr/bin/ld: /tmp/ccGIohZm.o: in function `testing::internal::ThreadLocal<testing::Sequence*>::GetOrCreateValue() const':
test_simple.cpp:(.text._ZNK7testing8internal11ThreadLocalIPNS_8SequenceEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalIPNS_8SequenceEE16GetOrCreateValueEv]+0x16): undefined reference to `pthread_getspecific'
/usr/bin/ld: test_simple.cpp:(.text._ZNK7testing8internal11ThreadLocalIPNS_8SequenceEE16GetOrCreateValueEv[_ZNK7testing8internal11ThreadLocalIPNS_8SequenceEE16GetOrCreateValueEv]+0x79): undefined reference to `pthread_setspecific'
collect2: error: ld returned 1 exit status
Huh? Why that? Ok, appended -lpthread again, compile and run the test:
~$ ./test_simple
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from simpleTestSuite
[ RUN ] simpleTestSuite.simpleMockTest
Segmentation fault
Describe the bug
I built GoogleTest without pthread on Linux and successful compile tests with it using mocks. When running these tests all of them crash with a final message "Segmentation fault". They should pass.
Steps to reproduce the bug
I cloned GoogleTest and stay in its root directory. Here I use this simple test program:
Now verify that it runs successful with default configure/build of GoogleTest:
and compile the simple test:
run it:
So far so good. Now build GoogleTest with option
-D gtest_disable_pthreads=ON
and compile the simple test:On compiling the simple test I do not need option
-lpthread
of course.Huh? Why that? Ok, appended
-lpthread
again, compile and run the test:Does the bug persist in the most recent commit?
Yes.
What operating system and version are you using?
What compiler and version are you using?
What build system are you using?
Additional context
This should be seen in context with #3577
The text was updated successfully, but these errors were encountered: