OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * TestFixture for SUID Sandbox testing. | 6 * TestFixture for SUID Sandbox testing. |
7 * @extends {testing.Test} | 7 * @extends {testing.Test} |
8 * @constructor | 8 * @constructor |
9 */ | 9 */ |
10 function SandboxStatusUITest() {} | 10 function SandboxStatusUITest() {} |
(...skipping 10 matching lines...) Expand all Loading... |
21 // This test is for Linux only. | 21 // This test is for Linux only. |
22 // PLEASE READ: | 22 // PLEASE READ: |
23 // - If failures of this test are a problem on a bot under your care, | 23 // - If failures of this test are a problem on a bot under your care, |
24 // the proper way to address such failures is to install the SUID | 24 // the proper way to address such failures is to install the SUID |
25 // sandbox. See: | 25 // sandbox. See: |
26 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment | 26 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment |
27 // - PLEASE DO NOT GLOBALLY DISABLE THIS TEST. | 27 // - PLEASE DO NOT GLOBALLY DISABLE THIS TEST. |
28 // SUID sandbox is currently incompatible with AddressSanitizer, | 28 // SUID sandbox is currently incompatible with AddressSanitizer, |
29 // see http://crbug.com/137653. | 29 // see http://crbug.com/137653. |
30 GEN('#if defined(OS_LINUX) && !defined(ADDRESS_SANITIZER)'); | 30 GEN('#if defined(OS_LINUX) && !defined(ADDRESS_SANITIZER)'); |
31 GEN('# define MAYBE_testSUIDSandboxEnabled \\'); | 31 GEN('# define MAYBE_testSUIDorNamespaceSandboxEnabled \\'); |
32 GEN(' testSUIDSandboxEnabled'); | 32 GEN(' testSUIDorNamespaceSandboxEnabled'); |
33 GEN('#else'); | 33 GEN('#else'); |
34 GEN('# define MAYBE_testSUIDSandboxEnabled \\'); | 34 GEN('# define MAYBE_testSUIDorNamespaceSandboxEnabled \\'); |
35 GEN(' DISABLED_testSUIDSandboxEnabled'); | 35 GEN(' DISABLED_testSUIDorNamespaceSandboxEnabled'); |
36 GEN('#endif'); | 36 GEN('#endif'); |
37 | 37 |
38 /** | 38 /** |
39 * Test if the SUID sandbox is enabled. | 39 * Test if the SUID sandbox is enabled. |
40 */ | 40 */ |
41 TEST_F('SandboxStatusUITest', 'MAYBE_testSUIDSandboxEnabled', function() { | 41 TEST_F('SandboxStatusUITest', |
| 42 'MAYBE_testSUIDorNamespaceSandboxEnabled', function() { |
| 43 var namespaceyesstring = 'Namespace Sandbox\tYes'; |
| 44 var namespacenostring = 'Namespace Sandbox\tNo'; |
42 var suidyesstring = 'SUID Sandbox\tYes'; | 45 var suidyesstring = 'SUID Sandbox\tYes'; |
43 var suidnostring = 'SUID Sandbox\tNo'; | 46 var suidnostring = 'SUID Sandbox\tNo'; |
| 47 |
44 var suidyes = document.body.innerText.match(suidyesstring); | 48 var suidyes = document.body.innerText.match(suidyesstring); |
45 var suidno = document.body.innerText.match(suidnostring); | 49 var suidno = document.body.innerText.match(suidnostring); |
| 50 var namespaceyes = document.body.innerText.match(namespaceyesstring); |
| 51 var namespaceno = document.body.innerText.match(namespacenostring); |
46 | 52 |
47 expectEquals(null, suidno); | 53 // Exactly one of the namespace or suid sandbox should be enabled. |
48 assertFalse(suidyes === null); | 54 expectTrue(suidyes !== null || namespaceyes !== null); |
49 expectEquals(suidyesstring, suidyes[0]); | 55 expectFalse(suidyes !== null && namespaceyes !== null); |
| 56 |
| 57 if (namespaceyes !== null) { |
| 58 expectEquals(null, namespaceno); |
| 59 expectEquals(namespaceyesstring, namespaceyes[0]); |
| 60 } |
| 61 |
| 62 if (suidyes !== null) { |
| 63 expectEquals(null, suidno); |
| 64 expectEquals(suidyesstring, suidyes[0]); |
| 65 } |
50 }); | 66 }); |
51 | 67 |
52 // The seccomp-bpf sandbox is also not compatible with ASAN. | 68 // The seccomp-bpf sandbox is also not compatible with ASAN. |
53 GEN('#if !defined(OS_LINUX) || defined(ADDRESS_SANITIZER)'); | 69 GEN('#if !defined(OS_LINUX) || defined(ADDRESS_SANITIZER)'); |
54 GEN('# define MAYBE_testBPFSandboxEnabled \\'); | 70 GEN('# define MAYBE_testBPFSandboxEnabled \\'); |
55 GEN(' DISABLED_testBPFSandboxEnabled'); | 71 GEN(' DISABLED_testBPFSandboxEnabled'); |
56 GEN('#else'); | 72 GEN('#else'); |
57 GEN('# define MAYBE_testBPFSandboxEnabled \\'); | 73 GEN('# define MAYBE_testBPFSandboxEnabled \\'); |
58 GEN(' testBPFSandboxEnabled'); | 74 GEN(' testBPFSandboxEnabled'); |
59 GEN('#endif'); | 75 GEN('#endif'); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 if (gpuyes || gpuno) { | 130 if (gpuyes || gpuno) { |
115 expectEquals(null, gpuno); | 131 expectEquals(null, gpuno); |
116 expectTrue(gpuyes && (gpuyes[0] == gpuyesstring)); | 132 expectTrue(gpuyes && (gpuyes[0] == gpuyesstring)); |
117 testDone(); | 133 testDone(); |
118 } | 134 } |
119 } | 135 } |
120 }) | 136 }) |
121 }); | 137 }); |
122 observer.observe(document.getElementById('basic-info'), {childList: true}); | 138 observer.observe(document.getElementById('basic-info'), {childList: true}); |
123 }); | 139 }); |
OLD | NEW |