aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gtest-internal-inl.h11
-rw-r--r--src/gtest-port.cc21
-rw-r--r--src/gtest.cc18
3 files changed, 49 insertions, 1 deletions
diff --git a/src/gtest-internal-inl.h b/src/gtest-internal-inl.h
index dfc1e958..2a90edac 100644
--- a/src/gtest-internal-inl.h
+++ b/src/gtest-internal-inl.h
@@ -548,6 +548,9 @@ class TestResult {
// Returns true iff the test fatally failed.
bool HasFatalFailure() const;
+ // Returns true iff the test has a non-fatal failure.
+ bool HasNonfatalFailure() const;
+
// Returns the elapsed time, in milliseconds.
TimeInMillis elapsed_time() const { return elapsed_time_; }
@@ -575,6 +578,9 @@ class TestResult {
// Increments the death test count, returning the new count.
int increment_death_test_count() { return ++death_test_count_; }
+ // Clears the test part results.
+ void ClearTestPartResults() { test_part_results_.Clear(); }
+
// Clears the object.
void Clear();
private:
@@ -1300,6 +1306,11 @@ inline UnitTestImpl* GetUnitTestImpl() {
return UnitTest::GetInstance()->impl();
}
+// Clears all test part results of the current test.
+inline void ClearCurrentTestPartResults() {
+ GetUnitTestImpl()->current_test_result()->ClearTestPartResults();
+}
+
// Internal helper functions for implementing the simple regular
// expression matcher.
bool IsInSet(char ch, const char* str);
diff --git a/src/gtest-port.cc b/src/gtest-port.cc
index 166ff414..193f5323 100644
--- a/src/gtest-port.cc
+++ b/src/gtest-port.cc
@@ -42,6 +42,11 @@
#include <unistd.h>
#endif // GTEST_OS_WINDOWS
+#if GTEST_OS_MAC
+#include <mach/mach_init.h>
+#include <mach/task.h>
+#endif // GTEST_OS_MAC
+
#ifdef _WIN32_WCE
#include <windows.h> // For TerminateProcess()
#endif // _WIN32_WCE
@@ -69,6 +74,22 @@ const int kStdErrFileno = 2;
const int kStdErrFileno = STDERR_FILENO;
#endif // _MSC_VER
+// Returns the number of threads running in the process, or 0 to indicate that
+// we cannot detect it.
+size_t GetThreadCount() {
+#if GTEST_OS_MAC
+ mach_msg_type_number_t thread_count;
+ thread_act_port_array_t thread_list;
+ kern_return_t status = task_threads(mach_task_self(),
+ &thread_list, &thread_count);
+ return status == KERN_SUCCESS ? static_cast<size_t>(thread_count) : 0;
+#else
+ // There's no portable way to detect the number of threads, so we just
+ // return 0 to indicate that we cannot detect it.
+ return 0;
+#endif // GTEST_OS_MAC
+}
+
#if GTEST_USES_POSIX_RE
// Implements RE. Currently only needed for death tests.
diff --git a/src/gtest.cc b/src/gtest.cc
index ac5ed9d5..5903f2ae 100644
--- a/src/gtest.cc
+++ b/src/gtest.cc
@@ -1852,7 +1852,7 @@ int TestResult::failed_part_count() const {
}
// Returns true iff the test part fatally failed.
-static bool TestPartFatallyFailed(const TestPartResult & result) {
+static bool TestPartFatallyFailed(const TestPartResult& result) {
return result.fatally_failed();
}
@@ -1861,6 +1861,16 @@ bool TestResult::HasFatalFailure() const {
return test_part_results_.CountIf(TestPartFatallyFailed) > 0;
}
+// Returns true iff the test part non-fatally failed.
+static bool TestPartNonfatallyFailed(const TestPartResult& result) {
+ return result.nonfatally_failed();
+}
+
+// Returns true iff the test has a non-fatal failure.
+bool TestResult::HasNonfatalFailure() const {
+ return test_part_results_.CountIf(TestPartNonfatallyFailed) > 0;
+}
+
// Gets the number of all test parts. This is the sum of the number
// of successful test parts and the number of failed test parts.
int TestResult::total_part_count() const {
@@ -2059,6 +2069,12 @@ bool Test::HasFatalFailure() {
return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure();
}
+// Returns true iff the current test has a non-fatal failure.
+bool Test::HasNonfatalFailure() {
+ return internal::GetUnitTestImpl()->current_test_result()->
+ HasNonfatalFailure();
+}
+
// class TestInfo
// Constructs a TestInfo object. It assumes ownership of the test factory