Index: sandbox/linux/seccomp-bpf/kernel_return_value_helpers_unittest.cc |
diff --git a/sandbox/linux/seccomp-bpf/kernel_return_value_helpers_unittest.cc b/sandbox/linux/seccomp-bpf/kernel_return_value_helpers_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..16d00c93cf3c5387196d05336e898dbf24fbd5ca |
--- /dev/null |
+++ b/sandbox/linux/seccomp-bpf/kernel_return_value_helpers_unittest.cc |
@@ -0,0 +1,32 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+ |
+#include <errno.h> |
+#include <asm/unistd.h> |
+ |
+#include "sandbox/linux/seccomp-bpf/bpf_tests.h" |
+#include "sandbox/linux/seccomp-bpf/kernel_return_value_helpers.h" |
+#include "sandbox/linux/seccomp-bpf/syscall.h" |
+#include "sandbox/linux/tests/unit_tests.h" |
+ |
+namespace sandbox { |
+ |
+namespace { |
+ |
+// Check that ErrnoToKernelRet works. |
+TEST(KernelReturnValueHelpers, ErrnoToKernelRet) { |
+ int expected_kernel_ret = SandboxSyscall(__NR_dup, -1); |
+#if defined(__mips__) |
+ // SandboxSyscall() for MIPS was written so it returns negation of the value |
+ // returned by kernel on error. This was done in order for this function to |
+ // behave like other architectures on places where return value from |
+ // SandboxSyscall() is used directly (like in the most tests), but for this |
+ // test to pass we need to cancel this negation. |
+ expected_kernel_ret = - expected_kernel_ret; |
jln (very slow on Chromium)
2014/05/28 00:06:57
This looks very strange as it doesn't really like
nedeljko
2014/05/28 09:33:43
I could use SandboxSyscallRaw() as you suggested i
nedeljko
2014/05/29 14:06:45
Done.
|
+#endif |
+ ASSERT_EQ(expected_kernel_ret, ErrnoToKernelRet(EBADF));} |
+ |
+} |
+} // namespace sandbox |