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

Unified Diff: options_unittest.cc

Issue 6881066: [minijail] Add the ability to set capabilities from the command line (Closed) Base URL: http://git.chromium.org/git/minijail.git@master
Patch Set: Created 9 years, 8 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
« no previous file with comments | « options.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: options_unittest.cc
diff --git a/options_unittest.cc b/options_unittest.cc
index f57adefda69aeddb6f7e7d57c45e435a0821e057..54ded5e8d643070d6319b279b2196fcf5469a08a 100644
--- a/options_unittest.cc
+++ b/options_unittest.cc
@@ -1,8 +1,10 @@
-// Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Tests for minijail::Options
+#include "options.h"
+
#include "mock_env.h"
#include "mock_options.h"
#include <gmock/gmock.h>
@@ -31,16 +33,19 @@ class OptionsDepsTest : public ::testing::Test {
TEST_F(OptionsDepsTest, NothingToCorrect) {
// Since all options default to false, this should just work.
- EXPECT_TRUE(options_->FixUpDependencies());
+ minijail::Options options;
+ EXPECT_TRUE(options.FixUpDependencies());
}
TEST_F(OptionsDepsTest, MountsWithoutVfs) {
+ EXPECT_CALL(*(options_.get()), FixUpDependencies())
+ .Times(1);
+ EXPECT_CALL(*options_, enforce_syscalls_benchmark())
+ .WillOnce(Return(false));
// Set up the case in need of correction
EXPECT_CALL(*options_, add_readonly_mounts())
- .Times(1)
.WillOnce(Return(true));
EXPECT_CALL(*options_, namespace_vfs())
- .Times(1)
.WillOnce(Return(false));
EXPECT_CALL(*options_, set_namespace_vfs(true)) // Proof of correction
.Times(1);
@@ -48,12 +53,14 @@ TEST_F(OptionsDepsTest, MountsWithoutVfs) {
}
TEST_F(OptionsDepsTest, MountsWithVfs) {
+ EXPECT_CALL(*(options_.get()), FixUpDependencies())
+ .Times(1);
+ EXPECT_CALL(*options_, enforce_syscalls_benchmark())
+ .WillOnce(Return(false));
// Setup case which should be untouched
EXPECT_CALL(*options_, add_readonly_mounts())
- .Times(1)
.WillOnce(Return(true));
EXPECT_CALL(*options_, namespace_vfs())
- .Times(1)
.WillOnce(Return(true));
EXPECT_CALL(*options_, set_namespace_vfs(_)) // Proof of correction
.Times(0);
@@ -61,9 +68,12 @@ TEST_F(OptionsDepsTest, MountsWithVfs) {
}
TEST_F(OptionsDepsTest, NoMounts) {
+ EXPECT_CALL(*(options_.get()), FixUpDependencies())
+ .Times(1);
+ EXPECT_CALL(*options_, enforce_syscalls_benchmark())
+ .WillOnce(Return(false));
// Setup case which should be untouched
EXPECT_CALL(*options_, add_readonly_mounts())
- .Times(1)
.WillOnce(Return(false));
// VFS check should never be run since the conditional short circuits
EXPECT_CALL(*options_, namespace_vfs())
@@ -74,29 +84,36 @@ TEST_F(OptionsDepsTest, NoMounts) {
}
TEST_F(OptionsDepsTest, BothSyscallEnforcements) {
+ EXPECT_CALL(*(options_.get()), FixUpDependencies())
+ .Times(1);
// Case which fails
+ EXPECT_CALL(*options_, add_readonly_mounts())
+ .WillOnce(Return(false));
EXPECT_CALL(*options_, enforce_syscalls_benchmark())
- .Times(1)
.WillOnce(Return(true));
EXPECT_CALL(*options_, enforce_syscalls_by_source())
- .Times(1)
.WillOnce(Return(true));
EXPECT_FALSE(options_->FixUpDependencies());
}
TEST_F(OptionsDepsTest, SyscallBenchmarkOnly) {
+ EXPECT_CALL(*(options_.get()), FixUpDependencies())
+ .Times(1);
+ EXPECT_CALL(*options_, add_readonly_mounts())
+ .WillOnce(Return(false));
EXPECT_CALL(*options_, enforce_syscalls_benchmark())
- .Times(1)
.WillOnce(Return(true));
EXPECT_CALL(*options_, enforce_syscalls_by_source())
- .Times(1)
.WillOnce(Return(false));
EXPECT_TRUE(options_->FixUpDependencies());
}
TEST_F(OptionsDepsTest, SyscallNoBenchmark) {
+ EXPECT_CALL(*(options_.get()), FixUpDependencies())
+ .Times(1);
+ EXPECT_CALL(*options_, add_readonly_mounts())
+ .WillOnce(Return(false));
EXPECT_CALL(*options_, enforce_syscalls_benchmark())
- .Times(1)
.WillOnce(Return(false));
EXPECT_CALL(*options_, enforce_syscalls_by_source())
.Times(0);
« no previous file with comments | « options.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698