| 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..6f800a5a361970d28ee0ef5440760434d307f79b
|
| --- /dev/null
|
| +++ b/sandbox/linux/seccomp-bpf/kernel_return_value_helpers_unittest.cc
|
| @@ -0,0 +1,34 @@
|
| +// 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) {
|
| +#if defined(__mips__)
|
| + int err_status, test_val = -1;
|
| + const intptr_t* arg_val = &test_val;
|
| + int expected_kernel_ret = SandboxSyscallRaw(__NR_dup, arg_val, &err_status);
|
| + // On error, syscall returns non zero value as error status on MIPS.
|
| + ASSERT_NE(err_status, 0);
|
| +#else
|
| + int expected_kernel_ret = SandboxSyscall(__NR_dup, -1);
|
| +#endif // defined(__mips__)
|
| +
|
| + ASSERT_EQ(expected_kernel_ret, ErrnoToKernelRet(EBADF));
|
| +}
|
| +
|
| +}
|
| +} // namespace sandbox
|
|
|