OLD | NEW |
| (Empty) |
1 // Copyright (c) 2010 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 | |
6 #include "chrome/test/nacl_security_tests/nacl_security_tests_posix.h" | |
7 #include <string> | |
8 #include "testing/gtest/include/gtest/gtest.h" | |
9 #include "chrome/test/nacl_security_tests/commands_posix.h" | |
10 | |
11 __attribute__((constructor)) | |
12 static void initializer(void) { | |
13 } | |
14 | |
15 __attribute__((destructor)) | |
16 static void finalizer(void) { | |
17 } | |
18 | |
19 namespace { | |
20 void CheckDenied(sandbox::SboxTestResult x) { | |
21 EXPECT_EQ(sandbox::SBOX_TEST_DENIED, x); | |
22 } | |
23 } // anon namespace | |
24 | |
25 extern "C" | |
26 __attribute__((visibility("default"))) | |
27 bool RunNaClLoaderTests(void) { | |
28 CheckDenied(sandbox::TestOpenReadFile("/etc")); | |
29 CheckDenied(sandbox::TestOpenReadFile("/tmp")); | |
30 CheckDenied(sandbox::TestOpenReadFile("$HOME")); | |
31 CheckDenied(sandbox::TestOpenWriteFile("/etc")); | |
32 CheckDenied(sandbox::TestOpenWriteFile("/etc/passwd")); | |
33 CheckDenied(sandbox::TestOpenWriteFile("/bin")); | |
34 CheckDenied(sandbox::TestOpenWriteFile("/usr/bin")); | |
35 CheckDenied(sandbox::TestOpenWriteFile("/usr/bin/bash")); | |
36 CheckDenied(sandbox::TestOpenWriteFile("/usr/bin/login")); | |
37 CheckDenied(sandbox::TestOpenWriteFile("/usr/sbin")); | |
38 CheckDenied(sandbox::TestOpenWriteFile("$HOME")); | |
39 | |
40 CheckDenied(sandbox::TestCreateProcess("/usr/bin/env")); | |
41 CheckDenied(sandbox::TestConnect("www.archive.org")); | |
42 | |
43 return !(testing::Test::HasFatalFailure() || | |
44 testing::Test::HasNonfatalFailure()); | |
45 } | |
46 | |
OLD | NEW |