mirror of
https://git.freebsd.org/ports.git
synced 2025-06-08 22:30:38 -04:00
196 lines
6.1 KiB
Text
196 lines
6.1 KiB
Text
o Add DragonFly and GNU/kFreeBSD support
|
|
o Implement GetThreadCount() for BSDs
|
|
o Work around StreamingListenerTest with GCC 4.2
|
|
|
|
--- include/gtest/internal/gtest-port-arch.h.orig 2017-09-23 23:21:02 UTC
|
|
+++ include/gtest/internal/gtest-port-arch.h
|
|
@@ -67,6 +67,10 @@
|
|
# if TARGET_OS_IPHONE
|
|
# define GTEST_OS_IOS 1
|
|
# endif
|
|
+#elif defined __DragonFly__
|
|
+# define GTEST_OS_DRAGONFLY 1
|
|
+#elif defined(__GLIBC__) && defined(__FreeBSD_kernel__)
|
|
+# define GTEST_OS_GNU_KFREEBSD 1
|
|
#elif defined __FreeBSD__
|
|
# define GTEST_OS_FREEBSD 1
|
|
#elif defined __Fuchsia__
|
|
--- include/gtest/internal/gtest-port.h.orig 2017-09-23 23:21:02 UTC
|
|
+++ include/gtest/internal/gtest-port.h
|
|
@@ -121,7 +121,9 @@
|
|
//
|
|
// GTEST_OS_AIX - IBM AIX
|
|
// GTEST_OS_CYGWIN - Cygwin
|
|
+// GTEST_OS_DRAGONFLY - DragonFly
|
|
// GTEST_OS_FREEBSD - FreeBSD
|
|
+// GTEST_OS_GNU_KFREEBSD - GNU/kFreeBSD
|
|
// GTEST_OS_FUCHSIA - Fuchsia
|
|
// GTEST_OS_HPUX - HP-UX
|
|
// GTEST_OS_LINUX - Linux
|
|
@@ -623,6 +625,7 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SE
|
|
// to your compiler flags.
|
|
#define GTEST_HAS_PTHREAD \
|
|
(GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX || GTEST_OS_QNX || \
|
|
+ GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || GTEST_OS_OPENBSD || \
|
|
GTEST_OS_FREEBSD || GTEST_OS_NACL || GTEST_OS_NETBSD || GTEST_OS_FUCHSIA)
|
|
#endif // GTEST_HAS_PTHREAD
|
|
|
|
@@ -803,7 +806,8 @@ using ::std::tuple_size;
|
|
(GTEST_OS_MAC && !GTEST_OS_IOS) || \
|
|
(GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
|
|
GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
|
|
- GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD || GTEST_OS_NETBSD)
|
|
+ GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || GTEST_OS_NETBSD || \
|
|
+ GTEST_OS_OPENBSD || GTEST_OS_QNX || GTEST_OS_FREEBSD)
|
|
# define GTEST_HAS_DEATH_TEST 1
|
|
#endif
|
|
|
|
@@ -835,7 +839,8 @@ using ::std::tuple_size;
|
|
(GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)
|
|
|
|
// Determines whether test results can be streamed to a socket.
|
|
-#if GTEST_OS_LINUX
|
|
+#if GTEST_OS_LINUX || GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || \
|
|
+ GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_OPENBSD
|
|
# define GTEST_CAN_STREAM_RESULTS_ 1
|
|
#endif
|
|
|
|
--- src/gtest-port.cc.orig 2017-09-23 23:21:02 UTC
|
|
+++ src/gtest-port.cc
|
|
@@ -52,6 +52,14 @@
|
|
# include <mach/vm_map.h>
|
|
#endif // GTEST_OS_MAC
|
|
|
|
+#if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
|
|
+ GTEST_OS_NETBSD || GTEST_OS_OPENBSD
|
|
+# include <sys/sysctl.h>
|
|
+# if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD
|
|
+# include <sys/user.h>
|
|
+# endif
|
|
+#endif
|
|
+
|
|
#if GTEST_OS_QNX
|
|
# include <devctl.h>
|
|
# include <fcntl.h>
|
|
@@ -131,6 +139,80 @@ size_t GetThreadCount() {
|
|
}
|
|
}
|
|
|
|
+#elif GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
|
|
+ GTEST_OS_NETBSD
|
|
+
|
|
+#if GTEST_OS_NETBSD
|
|
+#undef KERN_PROC
|
|
+#define KERN_PROC KERN_PROC2
|
|
+#define kinfo_proc kinfo_proc2
|
|
+#endif
|
|
+
|
|
+#if GTEST_OS_DRAGONFLY
|
|
+#define KP_NLWP(kp) (kp.kp_nthreads)
|
|
+#elif GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD
|
|
+#define KP_NLWP(kp) (kp.ki_numthreads)
|
|
+#elif GTEST_OS_NETBSD
|
|
+#define KP_NLWP(kp) (kp.p_nlwps)
|
|
+#endif
|
|
+
|
|
+// Returns the number of threads running in the process, or 0 to indicate that
|
|
+// we cannot detect it.
|
|
+size_t GetThreadCount() {
|
|
+ int mib[] = {
|
|
+ CTL_KERN,
|
|
+ KERN_PROC,
|
|
+ KERN_PROC_PID,
|
|
+ getpid(),
|
|
+#if GTEST_OS_NETBSD
|
|
+ sizeof(struct kinfo_proc),
|
|
+ 1,
|
|
+#endif
|
|
+ };
|
|
+ u_int miblen = sizeof(mib) / sizeof(mib[0]);
|
|
+ struct kinfo_proc info;
|
|
+ size_t size = sizeof(info);
|
|
+ if (sysctl(mib, miblen, &info, &size, NULL, 0)) {
|
|
+ return 0;
|
|
+ }
|
|
+ return KP_NLWP(info);
|
|
+}
|
|
+#elif GTEST_OS_OPENBSD
|
|
+
|
|
+// Returns the number of threads running in the process, or 0 to indicate that
|
|
+// we cannot detect it.
|
|
+size_t GetThreadCount() {
|
|
+ int mib[] = {
|
|
+ CTL_KERN,
|
|
+ KERN_PROC,
|
|
+ KERN_PROC_PID | KERN_PROC_SHOW_THREADS,
|
|
+ getpid(),
|
|
+ sizeof(struct kinfo_proc),
|
|
+ 0,
|
|
+ };
|
|
+ u_int miblen = sizeof(mib) / sizeof(mib[0]);
|
|
+
|
|
+ // get number of structs
|
|
+ size_t size;
|
|
+ if (sysctl(mib, miblen, NULL, &size, NULL, 0)) {
|
|
+ return 0;
|
|
+ }
|
|
+ mib[5] = size / mib[4];
|
|
+
|
|
+ // populate array of structs
|
|
+ struct kinfo_proc info[mib[5]];
|
|
+ if (sysctl(mib, miblen, &info, &size, NULL, 0)) {
|
|
+ return 0;
|
|
+ }
|
|
+
|
|
+ // exclude empty members
|
|
+ int nthreads = 0;
|
|
+ for (int i = 0; i < size / mib[4]; i++) {
|
|
+ if (info[i].p_tid != -1)
|
|
+ nthreads++;
|
|
+ }
|
|
+ return nthreads;
|
|
+}
|
|
#elif GTEST_OS_QNX
|
|
|
|
// Returns the number of threads running in the process, or 0 to indicate that
|
|
--- src/gtest.cc.orig 2017-09-23 23:21:02 UTC
|
|
+++ src/gtest.cc
|
|
@@ -127,7 +127,7 @@
|
|
#endif
|
|
|
|
#if GTEST_CAN_STREAM_RESULTS_
|
|
-# include <arpa/inet.h> // NOLINT
|
|
+# include <sys/socket.h> // NOLINT
|
|
# include <netdb.h> // NOLINT
|
|
# include <sys/socket.h> // NOLINT
|
|
# include <sys/types.h> // NOLINT
|
|
--- test/gtest-port_test.cc.orig 2017-09-23 23:21:02 UTC
|
|
+++ test/gtest-port_test.cc
|
|
@@ -304,7 +304,8 @@ TEST(FormatCompilerIndependentFileLocationTest, Format
|
|
EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(NULL, -1));
|
|
}
|
|
|
|
-#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX
|
|
+#if GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_DRAGONFLY || \
|
|
+ GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || GTEST_OS_NETBSD || GTEST_OS_OPENBSD
|
|
void* ThreadFunc(void* data) {
|
|
internal::Mutex* mutex = static_cast<internal::Mutex*>(data);
|
|
mutex->Lock();
|
|
--- test/gtest_unittest.cc.orig 2017-09-23 23:21:02 UTC
|
|
+++ test/gtest_unittest.cc
|
|
@@ -118,6 +118,7 @@ TEST_F(StreamingListenerTest, OnTestIterationEnd) {
|
|
EXPECT_EQ("event=TestIterationEnd&passed=1&elapsed_time=0ms\n", *output());
|
|
}
|
|
|
|
+#if GTEST_LANG_CXX11 // workaround breakage with GCC 4.2
|
|
TEST_F(StreamingListenerTest, OnTestCaseStart) {
|
|
*output() = "";
|
|
streamer_.OnTestCaseStart(TestCase("FooTest", "Bar", NULL, NULL));
|
|
@@ -129,6 +130,7 @@ TEST_F(StreamingListenerTest, OnTestCaseEnd) {
|
|
streamer_.OnTestCaseEnd(TestCase("FooTest", "Bar", NULL, NULL));
|
|
EXPECT_EQ("event=TestCaseEnd&passed=1&elapsed_time=0ms\n", *output());
|
|
}
|
|
+#endif
|
|
|
|
TEST_F(StreamingListenerTest, OnTestStart) {
|
|
*output() = "";
|