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

Unified Diff: src/platform/minijail/minijail_unittest.cc

Issue 466049: Baseline minijail with a commandline switch driven main. (Closed)
Patch Set: fix overly long lines Created 11 years 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 | « src/platform/minijail/minijail_testrunner.cc ('k') | src/platform/minijail/options.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/minijail/minijail_unittest.cc
diff --git a/src/platform/minijail/minijail_unittest.cc b/src/platform/minijail/minijail_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..85013c9df4ea40d7d01e25412b40af1926dbafd7
--- /dev/null
+++ b/src/platform/minijail/minijail_unittest.cc
@@ -0,0 +1,45 @@
+// Copyright (c) 2009 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.
+// Some portions Copyright (c) 2009 The Chromium Authors.
+//
+// Tests for MiniJail
+#include "env.h"
+#include "minijail.h"
+#include <gtest/gtest.h>
+
+namespace chromeos {
+
+// TODO: pull in gmock to make this non-crazy for testing.
+class TrueEnv : public minijail::Env {
+ public:
+ TrueEnv() { }
+ ~TrueEnv() { }
+ bool DisableTracing() const { return true; }
+ bool KeepRootCapabilities() const { return true; }
+ bool DisableDefaultRootPrivileges() const { return true; }
+ bool ChangeUser(uid_t uid, gid_t gid) const { return true; }
+ bool SanitizeBoundingSet(uint64 capmask) const { return true; }
+ bool EnterNamespace(int namespaces) const { return true; }
+ bool FilterSyscallsBySource() const { return true; }
+ bool Mount() const { return true; }
+ bool SanitizeCapabilities(uint64 eff_capmask) const { return true; }
+ bool Run(const char *path,
+ char * const *argv,
+ char * const *envp) const { return true; }
+};
+
+class MiniJailTest : public ::testing::Test { };
+
+TEST(MiniJailTest, TrueJail) {
+ TrueEnv *env = new TrueEnv;
+ MiniJailOptions options;
+ options.set_env(env);
+ MiniJail jail;
+ // This does basically nothing since the options default to false.
+ // Only ChangeUser is actually called.
+ EXPECT_TRUE(jail.Jail());
+ EXPECT_TRUE(jail.Run());
+}
+
+} // namespace chromeos
« no previous file with comments | « src/platform/minijail/minijail_testrunner.cc ('k') | src/platform/minijail/options.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698