summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorDentomologist <dentomologist@gmail.com>2022-05-19 12:17:46 -0700
committerDentomologist <dentomologist@gmail.com>2022-05-19 12:26:41 -0700
commit6ffd938f98781b6bd2ddec0af4a514abc6d2cab7 (patch)
tree509d9cb966545f2851e5a5ea2725eac21655c497 /Source
parent62601663e578bcd0b981e134c84fbc9d37850a15 (diff)
UnitTests: Skip PageFaultTest if exception handlers are not supported
Page faults should only occur on architectures that support exception handlers, so skip the test on other architectures to avoid spurious test failures.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/MemTools.cpp22
-rw-r--r--Source/Core/Core/MemTools.h1
-rw-r--r--Source/UnitTests/Core/PageFaultTest.cpp5
3 files changed, 28 insertions, 0 deletions
diff --git a/Source/Core/Core/MemTools.cpp b/Source/Core/Core/MemTools.cpp
index c427c8ba7e..c9109bfd1f 100644
--- a/Source/Core/Core/MemTools.cpp
+++ b/Source/Core/Core/MemTools.cpp
@@ -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)
@@ -245,6 +250,11 @@ void UninstallExceptionHandler()
{
}
+bool IsExceptionHandlerSupported()
+{
+ return true;
+}
+
#elif defined(_POSIX_VERSION) && !defined(_M_GENERIC)
static struct sigaction old_sa_segv;
@@ -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
diff --git a/Source/Core/Core/MemTools.h b/Source/Core/Core/MemTools.h
index 65c06e7023..e71f2bb2f9 100644
--- a/Source/Core/Core/MemTools.h
+++ b/Source/Core/Core/MemTools.h
@@ -7,4 +7,5 @@ namespace EMM
{
void InstallExceptionHandler();
void UninstallExceptionHandler();
+bool IsExceptionHandlerSupported();
} // namespace EMM
diff --git a/Source/UnitTests/Core/PageFaultTest.cpp b/Source/UnitTests/Core/PageFaultTest.cpp
index 841ba54609..e340ca7646 100644
--- a/Source/UnitTests/Core/PageFaultTest.cpp
+++ b/Source/UnitTests/Core/PageFaultTest.cpp
@@ -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);