Initialise Glib threading system in test_PipeCapture (#777973)
On CentOS 6, with glib/glibmm 2.28, running the tests fails thus: $ ./test_PipeCapture Running main() from gtest_main.cc [==========] Running 4 tests from 1 test case. [----------] Global test environment set-up. [----------] 4 tests from PipeCaptureTest [ RUN ] PipeCaptureTest.EmptyPipe GLib-ERROR **: The thread system is not yet initialized. aborting... Aborted (core dumped) For glib before version 2.32, the threading system must be explicitly initialised with a call to g_thread_init(), or the Glibmm Glib::thread_init() equivalent to prevent this error. Deprecated thread API, g_thread_init() https://developer.gnome.org/glib/stable/glib-Deprecated-Thread-APIs.html#g-thread-init Do this by providing our own main() which also initialises the Glib threading system, rather using and linking in the Google Test provided main(). Bug 777973 - Segmentation fault on bad disk
This commit is contained in:
parent
b21ee06230
commit
d90702d526
|
@ -21,3 +21,4 @@ TESTS = $(check_PROGRAMS)
|
|||
test_dummy_SOURCES = test_dummy.cc
|
||||
test_BlockSpecial_SOURCES = test_BlockSpecial.cc ../src/BlockSpecial.cc
|
||||
test_PipeCapture_SOURCES = test_PipeCapture.cc ../src/PipeCapture.cc
|
||||
test_PipeCapture_LDADD = $(GTEST_LIBS) $(top_builddir)/lib/gtest/lib/libgtest.la
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "gtest/gtest.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
@ -159,3 +160,19 @@ TEST_F( PipeCaptureTest, ShortASCIIText )
|
|||
}
|
||||
|
||||
} // namespace GParted
|
||||
|
||||
// Custom Google Test main() which also initialises the Glib threading system for
|
||||
// distributions with glib/glibmm before version 2.32.
|
||||
// References:
|
||||
// * Google Test, Primer, Writing the main() Function
|
||||
// * Deprecated thread API, g_thread_init()
|
||||
// https://developer.gnome.org/glib/stable/glib-Deprecated-Thread-APIs.html#g-thread-init
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
printf("Running main() from %s\n", __FILE__ );
|
||||
testing::InitGoogleTest( &argc, argv );
|
||||
|
||||
Glib::thread_init();
|
||||
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue