Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: snapshot/win/cpu_context_win_test.cc

Issue 1336823002: win x86: Grab bag of restructuring to get tests working on x86-on-x86 (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: fixes2 Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "snapshot/win/cpu_context_win.h" 15 #include "snapshot/win/cpu_context_win.h"
16 16
17 #include <windows.h> 17 #include <windows.h>
18 18
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "gtest/gtest.h" 20 #include "gtest/gtest.h"
21 #include "snapshot/cpu_context.h" 21 #include "snapshot/cpu_context.h"
22 22
23 namespace crashpad { 23 namespace crashpad {
24 namespace test { 24 namespace test {
25 namespace { 25 namespace {
26 26
27 #if defined(ARCH_CPU_X86_64) 27 #if defined(ARCH_CPU_X86_64)
28 28
29 TEST(CPUContextWin, InitializeX64Context) { 29 TEST(CPUContextWin, InitializeX64Context) {
30 CONTEXT context; 30 CONTEXT context = {0};
31 context.Rax = 10; 31 context.Rax = 10;
32 context.FltSave.TagWord = 11; 32 context.FltSave.TagWord = 11;
33 context.Dr0 = 12; 33 context.Dr0 = 12;
34 context.ContextFlags =
35 CONTEXT_INTEGER | CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS;
34 36
35 // Test the simple case, where everything in the CPUContextX86_64 argument is 37 // Test the simple case, where everything in the CPUContextX86_64 argument is
36 // set directly from the supplied thread, float, and debug state parameters. 38 // set directly from the supplied thread, float, and debug state parameters.
37 { 39 {
38 CPUContextX86_64 cpu_context_x86_64 = {}; 40 CPUContextX86_64 cpu_context_x86_64 = {};
39 InitializeX64Context(context, &cpu_context_x86_64); 41 InitializeX64Context(context, &cpu_context_x86_64);
40 EXPECT_EQ(10u, cpu_context_x86_64.rax); 42 EXPECT_EQ(10u, cpu_context_x86_64.rax);
41 EXPECT_EQ(11u, cpu_context_x86_64.fxsave.ftw); 43 EXPECT_EQ(11u, cpu_context_x86_64.fxsave.ftw);
42 EXPECT_EQ(12u, cpu_context_x86_64.dr0); 44 EXPECT_EQ(12u, cpu_context_x86_64.dr0);
43 } 45 }
44 } 46 }
45 47
46 #else // ARCH_CPU_X86_64 48 #else
47 49
48 #error ARCH_CPU_X86 50 TEST(CPUContextWin, InitializeX86Context) {
51 CONTEXT context = {0};
52 context.ContextFlags =
53 CONTEXT_INTEGER | CONTEXT_EXTENDED_REGISTERS | CONTEXT_DEBUG_REGISTERS;
54 context.Eax = 1;
55 context.ExtendedRegisters[4] = 2; // FTW.
56 context.Dr0 = 3;
57
58 // Test the simple case, where everything in the CPUContextX86 argument is
59 // set directly from the supplied thread, float, and debug state parameters.
60 {
61 CPUContextX86 cpu_context_x86 = {};
62 InitializeX86Context(context, &cpu_context_x86);
63 EXPECT_EQ(1u, cpu_context_x86.eax);
64 EXPECT_EQ(2u, cpu_context_x86.fxsave.ftw);
65 EXPECT_EQ(3u, cpu_context_x86.dr0);
66 }
67 }
49 68
50 #endif // ARCH_CPU_X86_64 69 #endif // ARCH_CPU_X86_64
51 70
52 } // namespace 71 } // namespace
53 } // namespace test 72 } // namespace test
54 } // namespace crashpad 73 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698