Fix sys_ptrace_test feature check on arm64
The code was checking PTRACE_GETREGSET output even in case of error.
This seems not correct. Though ptrace can still write some output in
case of EINVAL, implementation should still check updated iov_len before
reading it.
Change the code to avoid checking output in case of error at all.
Test: bionic-unit-tests --gtest_filter=sys_ptrace.watchpoint_stress
Change-Id: I7b1ca18ac64f81055ff89f56b453aff0ce8e1057
diff --git a/tests/sys_ptrace_test.cpp b/tests/sys_ptrace_test.cpp
index 15e9a24..f17f80c 100644
--- a/tests/sys_ptrace_test.cpp
+++ b/tests/sys_ptrace_test.cpp
@@ -92,8 +92,14 @@
feature == HwFeature::Watchpoint ? NT_ARM_HW_WATCH : NT_ARM_HW_BREAK, &iov);
if (result == -1) {
ASSERT_EQ(EINVAL, errno);
+ GTEST_SKIP() << "Hardware support missing";
+ } else if ((dreg_state.dbg_info & 0xff) == 0) {
+ if (feature == HwFeature::Watchpoint) {
+ GTEST_SKIP() << "Kernel reports zero hardware watchpoints";
+ } else {
+ GTEST_SKIP() << "Kernel reports zero hardware breakpoints";
+ }
}
- if ((dreg_state.dbg_info & 0xff) == 0) GTEST_SKIP() << "hardware support missing";
#else
// We assume watchpoints and breakpoints are always supported on x86.
UNUSED(child);