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 #include <versionhelpers.h> | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/process/launch.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 | |
11 namespace { | |
12 const wchar_t* kExeFilename = L"cfi_unittest_exe.exe"; | |
13 const wchar_t* kSysDllTest = L"1"; | |
14 | |
15 // CFG security check failure (STATUS_STACK_BUFFER_OVERRUN). | |
16 const DWORD kCfgExceptionId = 0xc0000409; | |
Will Harris
2017/02/06 22:33:36
This appears to be declared (in winnt.h) can it be
penny
2017/02/07 23:12:56
Done.
| |
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 (::IsWindows8Point1OrGreater()) { | |
Will Harris
2017/02/06 22:33:36
we would normally use base::win::GetVersion and VE
penny
2017/02/07 23:12:56
Yes. If one only has to check version, and nothin
| |
30 base::CommandLine cmd_line = base::CommandLine::FromString(kExeFilename); | |
31 cmd_line.AppendArgNative(kSysDllTest); | |
32 | |
33 base::Process proc = | |
34 base::LaunchProcess(cmd_line, base::LaunchOptionsForTest()); | |
35 ASSERT_TRUE(proc.IsValid()); | |
36 | |
37 int exit_code = 0; | |
38 if (!proc.WaitForExitWithTimeout(base::TimeDelta::FromSeconds(5), | |
Will Harris
2017/02/06 22:33:36
consider using TestTimeouts::tiny_timeout() or act
penny
2017/02/07 23:12:56
Done. action_timeout().
I wasn't 100% certain th
| |
39 &exit_code)) { | |
40 // Timeout while waiting. Try to cleanup. | |
41 proc.Terminate(1, false); | |
42 ADD_FAILURE(); | |
43 return; | |
44 } | |
45 | |
46 // CFG exception. | |
47 ASSERT_EQ(kCfgExceptionId, static_cast<DWORD>(exit_code)); | |
48 } | |
49 } | |
50 | |
51 } // namespace sandbox | |
OLD | NEW |