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

Side by Side Diff: sandbox/linux/seccomp-bpf-helpers/baseline_policy_unittest.cc

Issue 296703007: Linux Sandbox: run all BaselinePolicy tests with sanitizers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
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/seccomp-bpf-helpers/baseline_policy.h" 5 #include "sandbox/linux/seccomp-bpf-helpers/baseline_policy.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sched.h> 8 #include <sched.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 BPF_ASSERT_LE(0, getuid()); 87 BPF_ASSERT_LE(0, getuid());
88 } 88 }
89 89
90 BPF_TEST_C(BaselinePolicy, FchmodErrno, BaselinePolicy) { 90 BPF_TEST_C(BaselinePolicy, FchmodErrno, BaselinePolicy) {
91 int ret = fchmod(-1, 07777); 91 int ret = fchmod(-1, 07777);
92 BPF_ASSERT_EQ(-1, ret); 92 BPF_ASSERT_EQ(-1, ret);
93 // Without the sandbox, this would EBADF instead. 93 // Without the sandbox, this would EBADF instead.
94 BPF_ASSERT_EQ(EPERM, errno); 94 BPF_ASSERT_EQ(EPERM, errno);
95 } 95 }
96 96
97 // TODO(jln): make this work with the sanitizers.
98 #if !defined(ADDRESS_SANITIZER) && !defined(THREAD_SANITIZER) && \
99 !defined(MEMORY_SANITIZER)
100
101 BPF_TEST_C(BaselinePolicy, ForkErrno, BaselinePolicy) { 97 BPF_TEST_C(BaselinePolicy, ForkErrno, BaselinePolicy) {
102 errno = 0; 98 errno = 0;
103 pid_t pid = fork(); 99 pid_t pid = fork();
104 const int fork_errno = errno; 100 const int fork_errno = errno;
105 HandlePostForkReturn(pid); 101 HandlePostForkReturn(pid);
106 102
107 BPF_ASSERT_EQ(-1, pid); 103 BPF_ASSERT_EQ(-1, pid);
108 BPF_ASSERT_EQ(EPERM, fork_errno); 104 BPF_ASSERT_EQ(EPERM, fork_errno);
109 } 105 }
110 106
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 TEST_BASELINE_SIGSYS(__NR_sysinfo); 234 TEST_BASELINE_SIGSYS(__NR_sysinfo);
239 TEST_BASELINE_SIGSYS(__NR_inotify_init); 235 TEST_BASELINE_SIGSYS(__NR_inotify_init);
240 TEST_BASELINE_SIGSYS(__NR_init_module); 236 TEST_BASELINE_SIGSYS(__NR_init_module);
241 TEST_BASELINE_SIGSYS(__NR_keyctl); 237 TEST_BASELINE_SIGSYS(__NR_keyctl);
242 TEST_BASELINE_SIGSYS(__NR_mq_open); 238 TEST_BASELINE_SIGSYS(__NR_mq_open);
243 TEST_BASELINE_SIGSYS(__NR_vserver); 239 TEST_BASELINE_SIGSYS(__NR_vserver);
244 TEST_BASELINE_SIGSYS(__NR_getcpu); 240 TEST_BASELINE_SIGSYS(__NR_getcpu);
245 TEST_BASELINE_SIGSYS(__NR_setpgid); 241 TEST_BASELINE_SIGSYS(__NR_setpgid);
246 TEST_BASELINE_SIGSYS(__NR_getitimer); 242 TEST_BASELINE_SIGSYS(__NR_getitimer);
247 243
248 #endif // !defined(ADDRESS_SANITIZER) && !defined(THREAD_SANITIZER) &&
249 // !defined(MEMORY_SANITIZER)
250
251 } // namespace 244 } // namespace
252 245
253 } // namespace sandbox 246 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698