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

Unified Diff: sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc

Issue 10833044: Refactored ErrorCode into it's own class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Made changes requested by reviewer (jln) Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
diff --git a/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc b/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
index ce54f875cc5d8a0dd96c13dca898c421d7bd5397..904e0ce9ee5f33d902c73ef107fd174de38074bb 100644
--- a/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
+++ b/sandbox/linux/seccomp-bpf/sandbox_bpf_unittest.cc
@@ -66,7 +66,7 @@ void StartSandboxOrDie(Sandbox::EvaluateSyscall evaluator) {
void RunInSandbox(Sandbox::EvaluateSyscall evaluator,
void (*SandboxedCode)()) {
// TODO(jln): Implement IsEqual for ErrorCode
- // IsEqual(evaluator(__NR_exit_group), Sandbox::SB_ALLOWED) <<
+ // IsEqual(evaluator(__NR_exit_group), ErrorCode::ERR_ALLOWED) <<
// "You need to always allow exit_group() in your test policy";
StartSandboxOrDie(evaluator);
// TODO(jln): find a way to use the testing framework inside
@@ -92,17 +92,17 @@ void TryPolicyInProcess(Sandbox::EvaluateSyscall evaluator,
// A simple blacklist test
-Sandbox::ErrorCode BlacklistNanosleepPolicy(int sysno) {
+ErrorCode BlacklistNanosleepPolicy(int sysno) {
if (sysno < static_cast<int>(MIN_SYSCALL) ||
sysno > static_cast<int>(MAX_SYSCALL)) {
// FIXME: we should really not have to do that in a trivial policy
- return ENOSYS;
+ return ErrorCode(ENOSYS);
}
switch (sysno) {
case __NR_nanosleep:
- return EACCES;
+ return ErrorCode(EACCES);
default:
- return Sandbox::SB_ALLOWED;
+ return ErrorCode(ErrorCode::ERR_ALLOWED);
}
}
@@ -121,13 +121,13 @@ TEST(SandboxBpf, ApplyBasicBlacklistPolicy) {
// Now do a simple whitelist test
-Sandbox::ErrorCode WhitelistGetpidPolicy(int sysno) {
+ErrorCode WhitelistGetpidPolicy(int sysno) {
switch (sysno) {
case __NR_getpid:
case __NR_exit_group:
- return Sandbox::SB_ALLOWED;
+ return ErrorCode(ErrorCode::ERR_ALLOWED);
default:
- return ENOMEM;
+ return ErrorCode(ENOMEM);
}
}
@@ -161,18 +161,18 @@ intptr_t EnomemHandler(const struct arch_seccomp_data& args, void *aux) {
return -ENOMEM;
}
-Sandbox::ErrorCode BlacklistNanosleepPolicySigsys(int sysno) {
+ErrorCode BlacklistNanosleepPolicySigsys(int sysno) {
if (sysno < static_cast<int>(MIN_SYSCALL) ||
sysno > static_cast<int>(MAX_SYSCALL)) {
// FIXME: we should really not have to do that in a trivial policy
- return ENOSYS;
+ return ErrorCode(ENOSYS);
}
switch (sysno) {
case __NR_nanosleep:
- return Sandbox::ErrorCode(EnomemHandler,
+ return Sandbox::Trap(EnomemHandler,
static_cast<void *>(&BlacklistNanosleepPolicySigsysAuxData));
default:
- return Sandbox::SB_ALLOWED;
+ return ErrorCode(ErrorCode::ERR_ALLOWED);
}
}
@@ -213,17 +213,17 @@ int SysnoToRandomErrno(int sysno) {
return ((sysno & ~3) >> 2) % 29 + 1;
}
-Sandbox::ErrorCode SyntheticPolicy(int sysno) {
+ErrorCode SyntheticPolicy(int sysno) {
if (sysno < static_cast<int>(MIN_SYSCALL) ||
sysno > static_cast<int>(MAX_SYSCALL)) {
// FIXME: we should really not have to do that in a trivial policy.
- return ENOSYS;
+ return ErrorCode(ENOSYS);
}
if (sysno == __NR_exit_group) {
// exit_group() is special, we really need it to work.
- return Sandbox::SB_ALLOWED;
+ return ErrorCode(ErrorCode::ERR_ALLOWED);
} else {
- return SysnoToRandomErrno(sysno);
+ return ErrorCode(SysnoToRandomErrno(sysno));
}
}

Powered by Google App Engine
This is Rietveld 408576698