Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: sandbox/linux/bpf_dsl/bpf_dsl_unittest.cc

Issue 511993005: sandbox: style cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sandbox/linux/bpf_dsl/bpf_dsl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" 5 #include "sandbox/linux/bpf_dsl/bpf_dsl.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <netinet/in.h> 8 #include <netinet/in.h>
9 #include <sys/socket.h> 9 #include <sys/socket.h>
10 #include <sys/utsname.h> 10 #include <sys/utsname.h>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "sandbox/linux/seccomp-bpf/bpf_tests.h" 14 #include "sandbox/linux/seccomp-bpf/bpf_tests.h"
15 #include "sandbox/linux/seccomp-bpf/errorcode.h" 15 #include "sandbox/linux/seccomp-bpf/errorcode.h"
16 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy.h" 16 #include "sandbox/linux/seccomp-bpf/sandbox_bpf_policy.h"
17 #include "sandbox/linux/seccomp-bpf/syscall.h" 17 #include "sandbox/linux/seccomp-bpf/syscall.h"
18 18
19 using namespace sandbox::bpf_dsl;
20
21 // Helper macro to assert that invoking system call |sys| directly via 19 // Helper macro to assert that invoking system call |sys| directly via
22 // Syscall::Call with arguments |...| returns |res|. 20 // Syscall::Call with arguments |...| returns |res|.
23 // Errors can be asserted by specifying a value like "-EINVAL". 21 // Errors can be asserted by specifying a value like "-EINVAL".
24 #define ASSERT_SYSCALL_RESULT(res, sys, ...) \ 22 #define ASSERT_SYSCALL_RESULT(res, sys, ...) \
25 BPF_ASSERT_EQ(res, Stubs::sys(__VA_ARGS__)) 23 BPF_ASSERT_EQ(res, Stubs::sys(__VA_ARGS__))
26 24
27 namespace sandbox { 25 namespace sandbox {
26 namespace bpf_dsl {
28 namespace { 27 namespace {
29 28
30 // Type safe stubs for tested system calls. 29 // Type safe stubs for tested system calls.
31 class Stubs { 30 class Stubs {
32 public: 31 public:
33 static int getpgid(pid_t pid) { return Syscall::Call(__NR_getpgid, pid); } 32 static int getpgid(pid_t pid) { return Syscall::Call(__NR_getpgid, pid); }
34 static int setuid(uid_t uid) { return Syscall::Call(__NR_setuid, uid); } 33 static int setuid(uid_t uid) { return Syscall::Call(__NR_setuid, uid); }
35 static int setgid(gid_t gid) { return Syscall::Call(__NR_setgid, gid); } 34 static int setgid(gid_t gid) { return Syscall::Call(__NR_setgid, gid); }
36 35
37 static int uname(struct utsname* buf) { 36 static int uname(struct utsname* buf) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 ASSERT_SYSCALL_RESULT(-EINVAL, setuid, 0x0002); 257 ASSERT_SYSCALL_RESULT(-EINVAL, setuid, 0x0002);
259 258
260 ASSERT_SYSCALL_RESULT(-EEXIST, setuid, 0x0011); 259 ASSERT_SYSCALL_RESULT(-EEXIST, setuid, 0x0011);
261 ASSERT_SYSCALL_RESULT(-EEXIST, setuid, 0x0022); 260 ASSERT_SYSCALL_RESULT(-EEXIST, setuid, 0x0022);
262 261
263 ASSERT_SYSCALL_RESULT(-EACCES, setuid, 0x0111); 262 ASSERT_SYSCALL_RESULT(-EACCES, setuid, 0x0111);
264 ASSERT_SYSCALL_RESULT(-EACCES, setuid, 0x0222); 263 ASSERT_SYSCALL_RESULT(-EACCES, setuid, 0x0222);
265 } 264 }
266 265
267 } // namespace 266 } // namespace
267 } // namespace bpf_dsl
268 } // namespace sandbox 268 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/bpf_dsl/bpf_dsl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698