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