OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "sandbox/linux/services/yama.h" |
| 6 |
| 7 #include <errno.h> |
| 8 #include <fcntl.h> |
| 9 #include <sys/stat.h> |
| 10 #include <sys/types.h> |
| 11 #include <unistd.h> |
| 12 |
| 13 #include "base/compiler_specific.h" |
| 14 #include "sandbox/linux/tests/unit_tests.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 |
| 17 namespace sandbox { |
| 18 |
| 19 namespace { |
| 20 |
| 21 TEST(Yama, GetStatus) { |
| 22 int status1 = Yama::GetStatus(); |
| 23 int status2 = Yama::GetStatus(); |
| 24 |
| 25 // In theory someone could change the status while this runs, accept |
| 26 // this risk. |
| 27 EXPECT_EQ(status1, status2); |
| 28 ASSERT_LE(Yama::STATUS_DONT_KNOW, status1); |
| 29 ASSERT_GE(Yama::STATUS_ENFORCING, status1); |
| 30 |
| 31 // This test is not running sandboxed, there is no reason to not know the |
| 32 // status. |
| 33 EXPECT_NE(Yama::STATUS_DONT_KNOW, status1); |
| 34 |
| 35 const bool yama_available = (status1 == Yama::STATUS_ENFORCING || |
| 36 status1 == Yama::STATUS_NOT_ENFORCING); |
| 37 |
| 38 // Again, this could be racy if someone touches Yama while this test runs. |
| 39 EXPECT_EQ(yama_available, Yama::IsAvailable()); |
| 40 |
| 41 fprintf(stdout, |
| 42 "Yama present: %s - enforcing: %s\n", |
| 43 yama_available ? "Y" : "N", |
| 44 Yama::STATUS_ENFORCING == status1 ? "Y" : "N"); |
| 45 } |
| 46 |
| 47 } // namespace |
| 48 |
| 49 } // namespace sandbox |
OLD | NEW |