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

Side by Side Diff: src/trusted/validator_arm/inst_classes_testers.cc

Issue 9960043: Finish separation of testing from sel_ldr validation. Also, automate (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 #ifndef NACL_TRUSTED_BUT_NOT_TCB
7 #error This file is not meant for use in the TCB
8 #endif
6 9
7 #include "native_client/src/trusted/validator_arm/inst_classes_testers.h" 10 #include "native_client/src/trusted/validator_arm/inst_classes_testers.h"
8 11
9 #include "gtest/gtest.h" 12 #include "gtest/gtest.h"
10 #include "native_client/src/trusted/validator_arm/gen/arm32_decode_named.h" 13 #include "native_client/src/trusted/validator_arm/decoder_tester.h"
14
11 15
12 using nacl_arm_dec::kRegisterFlags; 16 using nacl_arm_dec::kRegisterFlags;
13 using nacl_arm_dec::kRegisterNone; 17 using nacl_arm_dec::kRegisterNone;
14 using nacl_arm_dec::kRegisterPc; 18 using nacl_arm_dec::kRegisterPc;
15 using nacl_arm_dec::ClassDecoder;
16 using nacl_arm_dec::Instruction; 19 using nacl_arm_dec::Instruction;
17 using nacl_arm_dec::NamedBinary4RegisterShiftedOp;
18 20
19 namespace nacl_arm_test { 21 namespace nacl_arm_test {
20 22
21 Binary4RegisterShiftedOpTester::Binary4RegisterShiftedOpTester() 23 Binary4RegisterShiftedOpTester::Binary4RegisterShiftedOpTester()
22 : Arm32DecoderTester(state_.Binary4RegisterShiftedOp_instance_) {} 24 : Arm32DecoderTester(state_.Binary4RegisterShiftedOp_instance_)
25 {}
26
27 Binary4RegisterShiftedOpTester::Binary4RegisterShiftedOpTester(
28 const NamedBinary4RegisterShiftedOp& decoder)
29 : Arm32DecoderTester(decoder) {}
23 30
24 void Binary4RegisterShiftedOpTester:: 31 void Binary4RegisterShiftedOpTester::
25 ApplySanityChecks(Instruction inst, const ClassDecoder& decoder) { 32 ApplySanityChecks(Instruction inst,
26 NamedBinary4RegisterShiftedOp &expected_decoder = 33 const NamedClassDecoder& decoder) {
27 state_.Binary4RegisterShiftedOp_instance_; 34 nacl_arm_dec::Binary4RegisterShiftedOp expected_decoder;
28 35
29 // Check that condition is defined correctly. 36 // Check that condition is defined correctly.
30 EXPECT_EQ(expected_decoder.cond_.value(inst), inst.bits(31, 28)); 37 EXPECT_EQ(expected_decoder.cond_.value(inst), inst.bits(31, 28));
31 38
32 // Didn't parse undefined conditional. 39 // Didn't parse undefined conditional.
33 if (expected_decoder.cond_.undefined(inst) && 40 if (expected_decoder.cond_.undefined(inst) &&
34 (&expected_decoder != &decoder)) return; 41 (&state_.Binary4RegisterShiftedOp_instance_ != &decoder)) return;
35 42
36 // Check if expected class name found. 43 // Check if expected class name found.
37 Arm32DecoderTester::ApplySanityChecks(inst, decoder); 44 Arm32DecoderTester::ApplySanityChecks(inst, decoder);
38 45
39 // Check Registers and flags used in DataProc. 46 // Check Registers and flags used in DataProc.
40 EXPECT_EQ(expected_decoder.n_.number(inst), inst.bits(19, 16)); 47 EXPECT_EQ(expected_decoder.n_.number(inst), inst.bits(19, 16));
41 EXPECT_EQ(expected_decoder.d_.number(inst), inst.bits(15, 12)); 48 EXPECT_EQ(expected_decoder.d_.number(inst), inst.bits(15, 12));
42 EXPECT_EQ(expected_decoder.s_.number(inst), inst.bits(11, 8)); 49 EXPECT_EQ(expected_decoder.s_.number(inst), inst.bits(11, 8));
43 EXPECT_EQ(expected_decoder.m_.number(inst), inst.bits(3, 0)); 50 EXPECT_EQ(expected_decoder.m_.number(inst), inst.bits(3, 0));
44 EXPECT_EQ(expected_decoder.flags_.is_updated(inst), inst.bit(20)); 51 EXPECT_EQ(expected_decoder.flags_.is_updated(inst), inst.bit(20));
45 if (expected_decoder.flags_.is_updated(inst)) { 52 if (expected_decoder.flags_.is_updated(inst)) {
46 EXPECT_EQ(expected_decoder.flags_.reg_if_updated(inst), kRegisterFlags); 53 EXPECT_EQ(expected_decoder.flags_.reg_if_updated(inst), kRegisterFlags);
47 } else { 54 } else {
48 EXPECT_EQ(expected_decoder.flags_.reg_if_updated(inst), kRegisterNone); 55 EXPECT_EQ(expected_decoder.flags_.reg_if_updated(inst), kRegisterNone);
49 } 56 }
57 }
58
59 Binary4RegisterShiftedOpTesterRegsNotPc::
60 Binary4RegisterShiftedOpTesterRegsNotPc()
61 : Binary4RegisterShiftedOpTester() {}
62
63 Binary4RegisterShiftedOpTesterRegsNotPc::
64 Binary4RegisterShiftedOpTesterRegsNotPc(
65 const NamedBinary4RegisterShiftedOp& decoder)
66 : Binary4RegisterShiftedOpTester(decoder) {}
67
68 void Binary4RegisterShiftedOpTesterRegsNotPc::
69 ApplySanityChecks(Instruction inst,
70 const NamedClassDecoder& decoder) {
71 nacl_arm_dec::Binary4RegisterShiftedOp expected_decoder;
72
73 Binary4RegisterShiftedOpTester::ApplySanityChecks(inst, decoder);
50 74
51 // Other ARM constraints about this instruction. 75 // Other ARM constraints about this instruction.
52 EXPECT_NE(expected_decoder.n_.reg(inst), kRegisterPc) 76 EXPECT_NE(expected_decoder.n_.reg(inst), kRegisterPc)
53 << "Expected Unpredictable for " << InstContents(); 77 << "Expected Unpredictable for " << InstContents();
54 EXPECT_NE(expected_decoder.d_.reg(inst), kRegisterPc) 78 EXPECT_NE(expected_decoder.d_.reg(inst), kRegisterPc)
55 << "Expected Unpredictable for " << InstContents(); 79 << "Expected Unpredictable for " << InstContents();
56 EXPECT_NE(expected_decoder.s_.reg(inst), kRegisterPc) 80 EXPECT_NE(expected_decoder.s_.reg(inst), kRegisterPc)
57 << "Expected Unpredictable for " << InstContents(); 81 << "Expected Unpredictable for " << InstContents();
58 EXPECT_NE(expected_decoder.m_.reg(inst), kRegisterPc) 82 EXPECT_NE(expected_decoder.m_.reg(inst), kRegisterPc)
59 << "Expected Unpredictable for " << InstContents(); 83 << "Expected Unpredictable for " << InstContents();
60 } 84 }
61 85
62 } // namespace 86 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698