OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 <windows.h> | |
6 | |
7 #include "base/win/scoped_handle.h" | |
8 #include "base/win/scoped_process_information.h" | |
9 #include "sandbox/win/src/policy_broker.h" | |
10 #include "sandbox/win/src/sandbox_nt_util.h" | |
11 #include "testing/gtest/include/gtest/gtest.h" | |
12 | |
13 namespace sandbox { | |
14 namespace { | |
15 | |
16 TEST(SandboxNtUtil, IsSameProcess) { | |
17 InitGlobalNt(); | |
18 | |
19 HANDLE current_process_pseudo = GetCurrentProcess(); | |
20 EXPECT_TRUE(IsSameProcess(current_process_pseudo)); | |
21 | |
22 base::win::ScopedHandle current_process( | |
23 OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, GetCurrentProcessId())); | |
24 ASSERT_TRUE(current_process.IsValid()); | |
Will Harris
2015/09/04 02:18:12
some are EXPECT_TRUE and some ASSERT_TRUE - normal
rickyz (no longer on Chrome)
2015/09/08 21:51:39
Discussed in person - I split the test up into sma
| |
25 EXPECT_TRUE(IsSameProcess(current_process.Get())); | |
26 | |
27 STARTUPINFO si = {sizeof(si)}; | |
28 PROCESS_INFORMATION pi = {}; | |
29 wchar_t notepad[] = L"notepad"; | |
30 ASSERT_TRUE(CreateProcessW(nullptr, notepad, nullptr, nullptr, FALSE, 0, | |
31 nullptr, nullptr, &si, &pi)); | |
32 base::win::ScopedProcessInformation process_info(pi); | |
33 | |
34 EXPECT_FALSE(IsSameProcess(process_info.process_handle())); | |
35 | |
36 EXPECT_TRUE(TerminateProcess(process_info.process_handle(), 0)); | |
37 } | |
38 | |
39 } // namespace | |
40 } // namespace sandbox | |
OLD | NEW |