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

Unified Diff: sandbox/linux/services/yama_unittests.cc

Issue 188193002: Linux sandbox: add basic Yama support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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
« sandbox/linux/services/yama.cc ('K') | « sandbox/linux/services/yama.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/services/yama_unittests.cc
diff --git a/sandbox/linux/services/yama_unittests.cc b/sandbox/linux/services/yama_unittests.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9c5da992a29f720853580ba7f01819a0eb08fc95
--- /dev/null
+++ b/sandbox/linux/services/yama_unittests.cc
@@ -0,0 +1,49 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "sandbox/linux/services/yama.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include "base/compiler_specific.h"
+#include "sandbox/linux/tests/unit_tests.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace sandbox {
+
+namespace {
+
+TEST(Yama, GetStatus) {
+ int status1 = Yama::GetStatus();
+ int status2 = Yama::GetStatus();
+
+ // In theory someone could change the status while this runs, accept
+ // this risk.
+ EXPECT_EQ(status1, status2);
+ ASSERT_LE(Yama::STATUS_DONT_KNOW, status1);
+ ASSERT_GE(Yama::STATUS_ENFORCING, status1);
+
+ // This test is not running sandboxed, there is no reason to not know the
+ // status.
+ EXPECT_NE(Yama::STATUS_DONT_KNOW, status1);
+
+ const bool yama_available = (status1 == Yama::STATUS_ENFORCING ||
+ status1 == Yama::STATUS_NOT_ENFORCING);
+
+ // Again, this could be racy if someone touches Yama while this test runs.
+ EXPECT_EQ(yama_available, Yama::IsAvailable());
+
+ fprintf(stdout,
+ "Yama present: %s - enforcing: %s\n",
+ yama_available ? "Y" : "N",
+ Yama::STATUS_ENFORCING == status1 ? "Y" : "N");
+}
+
+} // namespace
+
+} // namespace sandbox
« sandbox/linux/services/yama.cc ('K') | « sandbox/linux/services/yama.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698