Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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 #include <windows.h> | |
| 5 | |
| 6 #include "base/command_line.h" | |
| 7 #include "base/files/file_util.h" | |
| 8 #include "base/process/launch.h" | |
| 9 #include "base/test/test_timeouts.h" | |
| 10 #include "base/win/windows_version.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | |
| 12 | |
| 13 namespace { | |
| 14 const wchar_t* kExeFilename = L"cfi_unittest_exe.exe"; | |
|
Will Harris
2017/02/10 22:38:47
Declare variables as close to them being used as p
penny
2017/02/13 18:47:00
Done.
| |
| 15 const wchar_t* kSysDllTest = L"1"; | |
| 16 | |
| 17 } // namespace | |
| 18 | |
| 19 namespace sandbox { | |
| 20 | |
| 21 // Make sure Microsoft binaries, that are compiled with CFG enabled, catch | |
| 22 // a hook and throw an exception. | |
| 23 // - If this test fails, the expected CFG exception did NOT happen. This | |
| 24 // indicates a build system change that has disabled Chrome process-wide CFG. | |
| 25 TEST(CFGSupportTests, MsIndirectFailure) { | |
| 26 // CFG is only supported on >= Win8.1 Update 3. | |
| 27 // Not checking for update, since test infra is updated and it would add | |
| 28 // a lot of complexity. | |
| 29 if (base::win::GetVersion() < base::win::VERSION_WIN8_1) | |
| 30 return; | |
| 31 | |
| 32 // ASLR must be enabled for CFG to be enabled. As ASLR is disabled in debug | |
| 33 // builds, so must be CFG. | |
| 34 #if !defined(NDEBUG) | |
|
Will Harris
2017/02/10 22:38:47
Consider just commenting out the entire test, inst
penny
2017/02/13 18:47:00
Done. I'm fine either way.
| |
| 35 return; | |
| 36 #endif // !defined(NDEBUG) | |
| 37 | |
| 38 base::CommandLine cmd_line = base::CommandLine::FromString(kExeFilename); | |
| 39 cmd_line.AppendArgNative(kSysDllTest); | |
| 40 | |
| 41 base::Process proc = | |
| 42 base::LaunchProcess(cmd_line, base::LaunchOptionsForTest()); | |
| 43 ASSERT_TRUE(proc.IsValid()); | |
| 44 | |
| 45 int exit_code = 0; | |
| 46 if (!proc.WaitForExitWithTimeout(TestTimeouts::action_timeout(), | |
| 47 &exit_code)) { | |
| 48 // Timeout while waiting. Try to cleanup. | |
| 49 proc.Terminate(1, false); | |
| 50 ADD_FAILURE(); | |
| 51 return; | |
| 52 } | |
| 53 | |
| 54 // CFG security check failure. | |
| 55 ASSERT_EQ(STATUS_STACK_BUFFER_OVERRUN, static_cast<DWORD>(exit_code)); | |
| 56 } | |
| 57 | |
| 58 } // namespace sandbox | |
| OLD | NEW |