Fix more stuff and get tests to pass

This commit is contained in:
Fabrice de Gans-Riberi 2018-05-03 12:06:45 -07:00
parent 96c3c422ad
commit 13af91faff
6 changed files with 35 additions and 14 deletions

View File

@ -198,7 +198,7 @@ class GTEST_API_ ExitedWithCode {
const int exit_code_;
};
# if !GTEST_OS_WINDOWS
# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
// Tests that an exit code describes an exit due to termination by a
// given signal.
class GTEST_API_ KilledBySignal {

View File

@ -156,7 +156,7 @@ ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) {
// ExitedWithCode function-call operator.
bool ExitedWithCode::operator()(int exit_status) const {
# if GTEST_OS_WINDOWS
# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
return exit_status == exit_code_;
@ -167,7 +167,7 @@ bool ExitedWithCode::operator()(int exit_status) const {
# endif // GTEST_OS_WINDOWS
}
# if !GTEST_OS_WINDOWS
# if !GTEST_OS_WINDOWS && !GTEST_OS_FUCHSIA
// KilledBySignal constructor.
KilledBySignal::KilledBySignal(int signum) : signum_(signum) {
}
@ -195,7 +195,7 @@ namespace internal {
static std::string ExitSummary(int exit_code) {
Message m;
# if GTEST_OS_WINDOWS
# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
m << "Exited with exit status " << exit_code;
@ -866,10 +866,10 @@ int FuchsiaDeathTest::Wait() {
zx_status_t status_zx;
zx_signals_t signals;
status_zx = zx_object_wait_one(
child_process_,
ZX_PROCESS_TERMINATED,
ZX_TIME_INFINITE,
&signals);
child_process_,
ZX_PROCESS_TERMINATED,
ZX_TIME_INFINITE,
&signals);
GTEST_DEATH_TEST_CHECK_(status_zx == ZX_OK);
ReadAndInterpretStatusByte();

View File

@ -64,6 +64,7 @@
#endif // GTEST_OS_AIX
#if GTEST_OS_FUCHSIA
# include <zircon/process.h>
# include <zircon/syscalls.h>
#endif
@ -163,7 +164,20 @@ size_t GetThreadCount() {
#elif GTEST_OS_FUCHSIA
size_t GetThreadCount() {
return static_cast<size_t>(zx_system_get_num_cpus());
int dummy_buffer;
size_t avail;
zx_status_t status = zx_object_get_info(
zx_process_self(),
ZX_INFO_PROCESS_THREADS,
&dummy_buffer,
0,
nullptr,
&avail);
if(status == ZX_OK) {
return avail;
} else {
return 0;
}
}
#else

View File

@ -200,7 +200,7 @@ int DieInDebugElse12(int* sideeffect) {
return 12;
}
# if GTEST_OS_WINDOWS
# if GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
// Tests the ExitedWithCode predicate.
TEST(ExitStatusPredicateTest, ExitedWithCode) {
@ -272,7 +272,7 @@ TEST(ExitStatusPredicateTest, KilledBySignal) {
EXPECT_FALSE(pred_kill(status_segv));
}
# endif // GTEST_OS_WINDOWS
# endif // GTEST_OS_WINDOWS || GTEST_OS_FUCHSIA
// Tests that the death test macros expand to code which may or may not
// be followed by operator<<, and that in either case the complete text
@ -787,8 +787,9 @@ static void TestExitMacros() {
// See http://msdn.microsoft.com/en-us/library/dwwzkt4c(VS.71).aspx.
EXPECT_EXIT(raise(SIGABRT), testing::ExitedWithCode(3), "") << "b_ar";
# else
# elif !GTEST_OS_FUCHSIA
// Fuchsia has no unix signals.
EXPECT_EXIT(raise(SIGKILL), testing::KilledBySignal(SIGKILL), "") << "foo";
ASSERT_EXIT(raise(SIGUSR2), testing::KilledBySignal(SIGUSR2), "") << "bar";

View File

@ -103,6 +103,8 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
_strcmpi("gtest-options-ex_test", exe_str.c_str()) == 0 ||
_strcmpi("gtest_all_test", exe_str.c_str()) == 0 ||
_strcmpi("gtest_dll_test", exe_str.c_str()) == 0;
#elif GTEST_OS_FUCHSIA
const bool success = exe_str == "app";
#else
// TODO(wan@google.com): remove the hard-coded "lt-" prefix when
// Chandler Carruth's libtool replacement is ready.
@ -116,6 +118,8 @@ TEST(OutputFileHelpersTest, GetCurrentExecutableName) {
FAIL() << "GetCurrentExecutableName() returns " << exe_str;
}
#if !GTEST_OS_FUCHSIA
class XmlOutputChangeDirTest : public Test {
protected:
virtual void SetUp() {
@ -202,6 +206,8 @@ TEST_F(XmlOutputChangeDirTest, PreserveOriginalWorkingDirWithAbsolutePath) {
#endif
}
#endif // !GTEST_OS_FUCHSIA
} // namespace
} // namespace internal
} // namespace testing

View File

@ -296,7 +296,7 @@ TEST(FormatCompilerIndependentFileLocationTest, FormatsUknownFileAndLine) {
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_FUCHSIA
void* ThreadFunc(void* data) {
internal::Mutex* mutex = static_cast<internal::Mutex*>(data);
mutex->Lock();
@ -340,7 +340,7 @@ TEST(GetThreadCountTest, ReturnsCorrectValue) {
TEST(GetThreadCountTest, ReturnsZeroWhenUnableToCountThreads) {
EXPECT_EQ(0U, GetThreadCount());
}
#endif // GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX
#endif // GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_QNX || GTEST_OS_FUCHSIA
TEST(GtestCheckDeathTest, DiesWithCorrectOutputOnFailure) {
const bool a_false_condition = false;