summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/exceptions.cc
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-12-06 13:06:37 -0800
committergVisor bot <gvisor-bot@google.com>2020-12-06 13:06:37 -0800
commita97ceec01bc464c9efa5d8140906c46f637e9002 (patch)
tree1c5e1dff5e48ed608db97c7b688359bf4947a563 /test/syscalls/linux/exceptions.cc
parent3075ede86edf04117f120b3cf110e699034b759c (diff)
parentbe71d3569cacc9da7e260895914272e3f5b81764 (diff)
Merge pull request #4932 from lubinszARM:pr_test_exceptions
PiperOrigin-RevId: 345976554
Diffstat (limited to 'test/syscalls/linux/exceptions.cc')
-rw-r--r--test/syscalls/linux/exceptions.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/syscalls/linux/exceptions.cc b/test/syscalls/linux/exceptions.cc
index 420b9543f..11dc1c651 100644
--- a/test/syscalls/linux/exceptions.cc
+++ b/test/syscalls/linux/exceptions.cc
@@ -23,6 +23,7 @@
namespace gvisor {
namespace testing {
+#if defined(__x86_64__)
// Default value for the x87 FPU control word. See Intel SDM Vol 1, Ch 8.1.5
// "x87 FPU Control Word".
constexpr uint16_t kX87ControlWordDefault = 0x37f;
@@ -93,6 +94,9 @@ void InIOHelper(int width, int value) {
},
::testing::KilledBySignal(SIGSEGV), "");
}
+#elif defined(__aarch64__)
+void inline Halt() { asm("hlt #0\r\n"); }
+#endif
TEST(ExceptionTest, Halt) {
// In order to prevent the regular handler from messing with things (and
@@ -102,9 +106,14 @@ TEST(ExceptionTest, Halt) {
sa.sa_handler = SIG_DFL;
auto const cleanup = ASSERT_NO_ERRNO_AND_VALUE(ScopedSigaction(SIGSEGV, sa));
+#if defined(__x86_64__)
EXPECT_EXIT(Halt(), ::testing::KilledBySignal(SIGSEGV), "");
+#elif defined(__aarch64__)
+ EXPECT_EXIT(Halt(), ::testing::KilledBySignal(SIGILL), "");
+#endif
}
+#if defined(__x86_64__)
TEST(ExceptionTest, DivideByZero) {
// See above.
struct sigaction sa = {};
@@ -362,6 +371,7 @@ TEST(ExceptionTest, Int3Compact) {
EXPECT_EXIT(Int3Compact(), ::testing::KilledBySignal(SIGTRAP), "");
}
+#endif
} // namespace testing
} // namespace gvisor