Index: sandbox/linux/seccomp-bpf/syscall_iterator_unittest.cc |
diff --git a/sandbox/linux/seccomp-bpf/syscall_iterator_unittest.cc b/sandbox/linux/seccomp-bpf/syscall_iterator_unittest.cc |
index 08a857a2e2933ad03eb29406874f0e48bb99d5ef..6ae1789dd48f2bd85f3c92a00004d888dbcd00f3 100644 |
--- a/sandbox/linux/seccomp-bpf/syscall_iterator_unittest.cc |
+++ b/sandbox/linux/seccomp-bpf/syscall_iterator_unittest.cc |
@@ -35,10 +35,18 @@ SANDBOX_TEST(SyscallIterator, PublicSyscallRange) { |
// The iterator should cover the public syscall range |
// MIN_SYSCALL..MAX_PUBLIC_SYSCALL, without skipping syscalls. |
- // We're assuming MIN_SYSCALL == 0 for all architectures, |
- // this is currently valid for Intel and ARM EABI. |
- SANDBOX_ASSERT(MIN_SYSCALL == 0); |
- SANDBOX_ASSERT(next == MIN_SYSCALL); |
+ if (MIN_SYSCALL) { |
jln (very slow on Chromium)
2014/05/16 19:30:17
Let's just create Two Tests: SyscallIteratorIntelA
nedeljko
2014/05/19 17:37:23
Should I create just two tests (that would be Publ
jln (very slow on Chromium)
2014/05/20 01:57:47
No, just two tests.
The problem is that the Sysca
nedeljko
2014/05/22 17:38:55
Done.
|
+ // When MIN_SYSCALL != 0 we need to move iterator to valid range |
+ while (next < MIN_SYSCALL - 1) { |
+ next = iter.Next(); |
+ } |
+ SANDBOX_ASSERT(next == MIN_SYSCALL -1); |
+ } else { |
+ // We're assuming MIN_SYSCALL == 0 for Intel and ARM EABI |
+ SANDBOX_ASSERT(MIN_SYSCALL == 0); |
+ SANDBOX_ASSERT(next == MIN_SYSCALL); |
+ } |
+ |
for (uint32_t last = next; next < MAX_PUBLIC_SYSCALL + 1; last = next) { |
SANDBOX_ASSERT((next = iter.Next()) == last + 1); |
} |
@@ -107,10 +115,26 @@ SANDBOX_TEST(SyscallIterator, InvalidOnly) { |
bool invalid_only = true; |
SyscallIterator iter(invalid_only); |
uint32_t next = iter.Next(); |
- // We're assuming MIN_SYSCALL == 0 for all architectures, |
- // this is currently valid for Intel and ARM EABI. |
+ // We're assuming MIN_SYSCALL == 0 for all architectures |
+ // (this is currently valid for Intel and ARM EABI), except |
jln (very slow on Chromium)
2014/05/16 19:30:17
Again, let's split this into two tests, one for MI
nedeljko
2014/05/22 17:38:55
Done.
|
+ // for Mips O32 ABI for which MIN_SYSCALL == 4000. |
// First invalid syscall should then be |MAX_PUBLIC_SYSCALL + 1|. |
+#if defined(__mips__) && (_MIPS_SIM == _MIPS_SIM_ABI32) |
+ SANDBOX_ASSERT(MIN_SYSCALL == 4000); |
+#else |
SANDBOX_ASSERT(MIN_SYSCALL == 0); |
+#endif |
+ |
+ // If MIN_SYSCALL != 0, we need to move iterator to valid range |
+ if (MIN_SYSCALL) { |
+ next = iter.Next(); |
+ // The iterator should skip until the last invalid syscall in this range. |
+ SANDBOX_ASSERT(next == MIN_SYSCALL - 1); |
+ while (next <= MAX_PUBLIC_SYSCALL) { |
+ next = iter.Next(); |
+ } |
+ } |
+ |
SANDBOX_ASSERT(next == MAX_PUBLIC_SYSCALL + 1); |
#if defined(__arm__) |