Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10678 from Dentomologist/skip_pagefault_test_if_n…
…o_exception_handler

UnitTests: Skip PageFaultTest if exception handlers aren't supported
  • Loading branch information
Pokechu22 committed Jun 2, 2022
2 parents a58bb2a + 6ffd938 commit 0fc1fb0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Source/Core/Core/MemTools.cpp
Expand Up @@ -113,6 +113,11 @@ void UninstallExceptionHandler()
s_veh_handle = nullptr;
}

bool IsExceptionHandlerSupported()
{
return true;
}

#elif defined(__APPLE__) && !defined(USE_SIGACTION_ON_APPLE)

static void CheckKR(const char* name, kern_return_t kr)
Expand Down Expand Up @@ -245,6 +250,11 @@ void UninstallExceptionHandler()
{
}

bool IsExceptionHandlerSupported()
{
return true;
}

#elif defined(_POSIX_VERSION) && !defined(_M_GENERIC)

static struct sigaction old_sa_segv;
Expand Down Expand Up @@ -353,15 +363,27 @@ void UninstallExceptionHandler()
sigaction(SIGBUS, &old_sa_bus, nullptr);
#endif
}

bool IsExceptionHandlerSupported()
{
return true;
}

#else // _M_GENERIC or unsupported platform

void InstallExceptionHandler()
{
}

void UninstallExceptionHandler()
{
}

bool IsExceptionHandlerSupported()
{
return false;
}

#endif

} // namespace EMM
1 change: 1 addition & 0 deletions Source/Core/Core/MemTools.h
Expand Up @@ -7,4 +7,5 @@ namespace EMM
{
void InstallExceptionHandler();
void UninstallExceptionHandler();
bool IsExceptionHandlerSupported();
} // namespace EMM
5 changes: 5 additions & 0 deletions Source/UnitTests/Core/PageFaultTest.cpp
Expand Up @@ -61,6 +61,11 @@ static void ASAN_DISABLE perform_invalid_access(void* data)

TEST(PageFault, PageFault)
{
if (!EMM::IsExceptionHandlerSupported())
{
// TODO: Use GTEST_SKIP() instead when GTest is updated to 1.10+
return;
}
EMM::InstallExceptionHandler();
void* data = Common::AllocateMemoryPages(PAGE_GRAN);
EXPECT_NE(data, nullptr);
Expand Down

0 comments on commit 0fc1fb0

Please sign in to comment.