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); |