[gparted] Initialise Glib threading system in test_PipeCapture (#777973)
- From: Curtis Gedak <gedakc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] Initialise Glib threading system in test_PipeCapture (#777973)
- Date: Sat, 3 Jun 2017 15:42:12 +0000 (UTC)
commit d90702d52608d84ef5c68d66d0c92a3438253ab7
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date: Sat May 20 18:51:50 2017 +0100
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
tests/Makefile.am | 1 +
tests/test_PipeCapture.cc | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8fb91f3..84d3744 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
diff --git a/tests/test_PipeCapture.cc b/tests/test_PipeCapture.cc
index b77369c..05ede91 100644
--- a/tests/test_PipeCapture.cc
+++ b/tests/test_PipeCapture.cc
@@ -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();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]