View | Details | Raw Unified | Return to bug 192736 | Differences between
and this patch

Collapse All | Expand All

(-)include/gtest/internal/gtest-port.h (-2 / +18 lines)
Lines 128-133 Link Here
128
//     GTEST_OS_IOS    - iOS
128
//     GTEST_OS_IOS    - iOS
129
//       GTEST_OS_IOS_SIMULATOR - iOS simulator
129
//       GTEST_OS_IOS_SIMULATOR - iOS simulator
130
//   GTEST_OS_NACL     - Google Native Client (NaCl)
130
//   GTEST_OS_NACL     - Google Native Client (NaCl)
131
//   GTEST_OS_GNU_KFREEBSD - GNU/kFreeBSD
132
//   GTEST_OS_DRAGONFLY - DragonFly
133
//   GTEST_OS_FREEBSD  - FreeBSD
134
//   GTEST_OS_NETBSD   - NetBSD
131
//   GTEST_OS_OPENBSD  - OpenBSD
135
//   GTEST_OS_OPENBSD  - OpenBSD
132
//   GTEST_OS_QNX      - QNX
136
//   GTEST_OS_QNX      - QNX
133
//   GTEST_OS_SOLARIS  - Sun Solaris
137
//   GTEST_OS_SOLARIS  - Sun Solaris
Lines 341-346 Link Here
341
# define GTEST_OS_HPUX 1
345
# define GTEST_OS_HPUX 1
342
#elif defined __native_client__
346
#elif defined __native_client__
343
# define GTEST_OS_NACL 1
347
# define GTEST_OS_NACL 1
348
#elif defined(__GLIBC__) && defined(__FreeBSD_kernel__)
349
# define GTEST_OS_GNU_KFREEBSD 1
350
#elif defined __DragonFly__
351
# define GTEST_OS_DRAGONFLY 1
352
#elif defined __FreeBSD__
353
# define GTEST_OS_FREEBSD 1
354
#elif defined __NetBSD__
355
# define GTEST_OS_NETBSD 1
344
#elif defined __OpenBSD__
356
#elif defined __OpenBSD__
345
# define GTEST_OS_OPENBSD 1
357
# define GTEST_OS_OPENBSD 1
346
#elif defined __QNX__
358
#elif defined __QNX__
Lines 611-616 struct _RTL_CRITICAL_SECTION; Link Here
611
// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
623
// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0
612
// to your compiler flags.
624
// to your compiler flags.
613
# define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX \
625
# define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX \
626
    || GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD \
627
    || GTEST_OS_NETBSD || GTEST_OS_OPENBSD \
614
    || GTEST_OS_QNX)
628
    || GTEST_OS_QNX)
615
#endif  // GTEST_HAS_PTHREAD
629
#endif  // GTEST_HAS_PTHREAD
616
630
Lines 791-797 using ::std::tuple_size; Link Here
791
     (GTEST_OS_MAC && !GTEST_OS_IOS) || GTEST_OS_IOS_SIMULATOR || \
805
     (GTEST_OS_MAC && !GTEST_OS_IOS) || GTEST_OS_IOS_SIMULATOR || \
792
     (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
806
     (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \
793
     GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
807
     GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \
794
     GTEST_OS_OPENBSD || GTEST_OS_QNX)
808
     GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || \
809
     GTEST_OS_NETBSD || GTEST_OS_OPENBSD || GTEST_OS_QNX)
795
# define GTEST_HAS_DEATH_TEST 1
810
# define GTEST_HAS_DEATH_TEST 1
796
# include <vector>  // NOLINT
811
# include <vector>  // NOLINT
797
#endif
812
#endif
Lines 824-830 using ::std::tuple_size; Link Here
824
    (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)
839
    (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX)
825
840
826
// Determines whether test results can be streamed to a socket.
841
// Determines whether test results can be streamed to a socket.
827
#if GTEST_OS_LINUX
842
#if GTEST_OS_LINUX || GTEST_OS_GNU_KFREEBSD || GTEST_OS_DRAGONFLY || \
843
    GTEST_OS_FREEBSD || GTEST_OS_NETBSD || GTEST_OS_OPENBSD
828
# define GTEST_CAN_STREAM_RESULTS_ 1
844
# define GTEST_CAN_STREAM_RESULTS_ 1
829
#endif
845
#endif
830
846
(-)src/gtest-port.cc (+82 lines)
Lines 51-56 Link Here
51
# include <mach/vm_map.h>
51
# include <mach/vm_map.h>
52
#endif  // GTEST_OS_MAC
52
#endif  // GTEST_OS_MAC
53
53
54
#if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
55
    GTEST_OS_NETBSD || GTEST_OS_OPENBSD
56
# include <sys/sysctl.h>
57
# if GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD
58
#  include <sys/user.h>
59
# endif
60
#endif
61
54
#if GTEST_OS_QNX
62
#if GTEST_OS_QNX
55
# include <devctl.h>
63
# include <devctl.h>
56
# include <fcntl.h>
64
# include <fcntl.h>
Lines 104-109 size_t GetThreadCount() { Link Here
104
  }
112
  }
105
}
113
}
106
114
115
#elif GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD || \
116
      GTEST_OS_NETBSD
117
118
#if GTEST_OS_NETBSD
119
#undef KERN_PROC
120
#define KERN_PROC KERN_PROC2
121
#define kinfo_proc kinfo_proc2
122
#endif
123
124
#if GTEST_OS_DRAGONFLY
125
#define KP_NLWP(kp) (kp.kp_nthreads)
126
#elif GTEST_OS_FREEBSD || GTEST_OS_GNU_KFREEBSD
127
#define KP_NLWP(kp) (kp.ki_numthreads)
128
#elif GTEST_OS_NETBSD
129
#define KP_NLWP(kp) (kp.p_nlwps)
130
#endif
131
132
// Returns the number of threads running in the process, or 0 to indicate that
133
// we cannot detect it.
134
size_t GetThreadCount() {
135
  int mib[] = {
136
    CTL_KERN,
137
    KERN_PROC,
138
    KERN_PROC_PID,
139
    getpid(),
140
#if GTEST_OS_NETBSD
141
    sizeof(struct kinfo_proc),
142
    1,
143
#endif
144
  };
145
  u_int miblen = sizeof(mib) / sizeof(mib[0]);
146
  struct kinfo_proc info;
147
  size_t size = sizeof(info);
148
  if (sysctl(mib, miblen, &info, &size, NULL, 0)) {
149
    return 0;
150
  }
151
  return KP_NLWP(info);
152
}
153
#elif GTEST_OS_OPENBSD
154
155
// Returns the number of threads running in the process, or 0 to indicate that
156
// we cannot detect it.
157
size_t GetThreadCount() {
158
  int mib[] = {
159
    CTL_KERN,
160
    KERN_PROC,
161
    KERN_PROC_PID | KERN_PROC_SHOW_THREADS,
162
    getpid(),
163
    sizeof(struct kinfo_proc),
164
    0,
165
  };
166
  u_int miblen = sizeof(mib) / sizeof(mib[0]);
167
168
  // get number of structs
169
  size_t size;
170
  if (sysctl(mib, miblen, NULL, &size, NULL, 0)) {
171
    return 0;
172
  }
173
  mib[5] = size / mib[4];
174
175
  // populate array of structs
176
  struct kinfo_proc info[mib[5]];
177
  if (sysctl(mib, miblen, &info, &size, NULL, 0)) {
178
    return 0;
179
  }
180
181
  // exclude empty members
182
  int nthreads = 0;
183
  for (int i = 0; i < size / mib[4]; i++) {
184
    if (info[i].p_tid != -1)
185
      nthreads++;
186
  }
187
  return nthreads;
188
}
107
#elif GTEST_OS_QNX
189
#elif GTEST_OS_QNX
108
190
109
// Returns the number of threads running in the process, or 0 to indicate that
191
// Returns the number of threads running in the process, or 0 to indicate that
(-)src/gtest.cc (-1 / +1 lines)
Lines 126-132 Link Here
126
#endif
126
#endif
127
127
128
#if GTEST_CAN_STREAM_RESULTS_
128
#if GTEST_CAN_STREAM_RESULTS_
129
# include <arpa/inet.h>  // NOLINT
129
# include <sys/socket.h>
130
# include <netdb.h>  // NOLINT
130
# include <netdb.h>  // NOLINT
131
#endif
131
#endif
132
132
(-)test/gtest-port_test.cc (-2 / +3 lines)
Lines 304-310 TEST(FormatCompilerIndependentFileLocationTest, Fo Link Here
304
  EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(NULL, -1));
304
  EXPECT_EQ("unknown file", FormatCompilerIndependentFileLocation(NULL, -1));
305
}
305
}
306
306
307
#if GTEST_OS_MAC || GTEST_OS_QNX
307
#if GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_DRAGONFLY || GTEST_OS_FREEBSD || \
308
    GTEST_OS_GNU_KFREEBSD || GTEST_OS_NETBSD || GTEST_OS_OPENBSD
308
void* ThreadFunc(void* data) {
309
void* ThreadFunc(void* data) {
309
  pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data);
310
  pthread_mutex_t* mutex = static_cast<pthread_mutex_t*>(data);
310
  pthread_mutex_lock(mutex);
311
  pthread_mutex_lock(mutex);
Lines 355-361 TEST(GetThreadCountTest, ReturnsCorrectValue) { Link Here
355
TEST(GetThreadCountTest, ReturnsZeroWhenUnableToCountThreads) {
356
TEST(GetThreadCountTest, ReturnsZeroWhenUnableToCountThreads) {
356
  EXPECT_EQ(0U, GetThreadCount());
357
  EXPECT_EQ(0U, GetThreadCount());
357
}
358
}
358
#endif  // GTEST_OS_MAC || GTEST_OS_QNX
359
#endif  // GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_*BSD
359
360
360
TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {
361
TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {
361
  const bool a_false_condition = false;
362
  const bool a_false_condition = false;
(-)test/gtest_unittest.cc (+2 lines)
Lines 117-122 TEST_F(StreamingListenerTest, OnTestIterationEnd) Link Here
117
  EXPECT_EQ("event=TestIterationEnd&passed=1&elapsed_time=0ms\n", *output());
117
  EXPECT_EQ("event=TestIterationEnd&passed=1&elapsed_time=0ms\n", *output());
118
}
118
}
119
119
120
#if GTEST_LANG_CXX11 // workaround breakage with GCC 4.2
120
TEST_F(StreamingListenerTest, OnTestCaseStart) {
121
TEST_F(StreamingListenerTest, OnTestCaseStart) {
121
  *output() = "";
122
  *output() = "";
122
  streamer_.OnTestCaseStart(TestCase("FooTest", "Bar", NULL, NULL));
123
  streamer_.OnTestCaseStart(TestCase("FooTest", "Bar", NULL, NULL));
Lines 128-133 TEST_F(StreamingListenerTest, OnTestCaseEnd) { Link Here
128
  streamer_.OnTestCaseEnd(TestCase("FooTest", "Bar", NULL, NULL));
129
  streamer_.OnTestCaseEnd(TestCase("FooTest", "Bar", NULL, NULL));
129
  EXPECT_EQ("event=TestCaseEnd&passed=1&elapsed_time=0ms\n", *output());
130
  EXPECT_EQ("event=TestCaseEnd&passed=1&elapsed_time=0ms\n", *output());
130
}
131
}
132
#endif
131
133
132
TEST_F(StreamingListenerTest, OnTestStart) {
134
TEST_F(StreamingListenerTest, OnTestStart) {
133
  *output() = "";
135
  *output() = "";

Return to bug 192736