OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 |
| 6 #include <errno.h> |
| 7 #include <asm/unistd.h> |
| 8 |
| 9 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" |
| 10 #include "sandbox/linux/seccomp-bpf/kernel_return_value_helpers.h" |
| 11 #include "sandbox/linux/seccomp-bpf/syscall.h" |
| 12 #include "sandbox/linux/tests/unit_tests.h" |
| 13 |
| 14 namespace sandbox { |
| 15 |
| 16 namespace { |
| 17 |
| 18 // Check that ErrnoToKernelRet works. |
| 19 TEST(KernelReturnValueHelpers, ErrnoToKernelRet) { |
| 20 #if defined(__mips__) |
| 21 int err_status, test_val = -1; |
| 22 const intptr_t* arg_val = &test_val; |
| 23 int expected_kernel_ret = SandboxSyscallRaw(__NR_dup, arg_val, &err_status); |
| 24 // On error, syscall returns non zero value as error status on MIPS. |
| 25 ASSERT_NE(err_status, 0); |
| 26 #else |
| 27 int expected_kernel_ret = SandboxSyscall(__NR_dup, -1); |
| 28 #endif // defined(__mips__) |
| 29 |
| 30 ASSERT_EQ(expected_kernel_ret, ErrnoToKernelRet(EBADF)); |
| 31 } |
| 32 |
| 33 } |
| 34 } // namespace sandbox |
OLD | NEW |