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

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/gen/arm32_decode_named.h"
11 14
12 using nacl_arm_dec::kRegisterFlags; 15 using nacl_arm_dec::kRegisterFlags;
13 using nacl_arm_dec::kRegisterNone; 16 using nacl_arm_dec::kRegisterNone;
14 using nacl_arm_dec::kRegisterPc; 17 using nacl_arm_dec::kRegisterPc;
15 using nacl_arm_dec::ClassDecoder;
16 using nacl_arm_dec::Instruction; 18 using nacl_arm_dec::Instruction;
17 using nacl_arm_dec::NamedBinary4RegisterShiftedOp;
18 19
19 namespace nacl_arm_test { 20 namespace nacl_arm_test {
20 21
21 Binary4RegisterShiftedOpTester::Binary4RegisterShiftedOpTester() 22 Binary4RegisterShiftedOpTesterRegsNotPc::
22 : Arm32DecoderTester(state_.Binary4RegisterShiftedOp_instance_) {} 23 Binary4RegisterShiftedOpTesterRegsNotPc(const NamedClassDecoder& decoder)
24 : Arm32DecoderTester(decoder) {}
23 25
24 void Binary4RegisterShiftedOpTester:: 26 void Binary4RegisterShiftedOpTesterRegsNotPc::
25 ApplySanityChecks(Instruction inst, const ClassDecoder& decoder) { 27 ApplySanityChecks(Instruction inst,
26 NamedBinary4RegisterShiftedOp &expected_decoder = 28 const NamedClassDecoder& decoder) {
27 state_.Binary4RegisterShiftedOp_instance_; 29 nacl_arm_dec::Binary4RegisterShiftedOp expected_decoder;
28 30
29 // Check that condition is defined correctly. 31 // Check that condition is defined correctly.
30 EXPECT_EQ(expected_decoder.cond_.value(inst), inst.bits(31, 28)); 32 EXPECT_EQ(expected_decoder.cond_.value(inst), inst.bits(31, 28));
31 33
32 // Didn't parse undefined conditional. 34 // Didn't parse undefined conditional.
33 if (expected_decoder.cond_.undefined(inst) && 35 if (expected_decoder.cond_.undefined(inst) &&
34 (&expected_decoder != &decoder)) return; 36 (&state_.Binary4RegisterShiftedOp_instance_ != &decoder)) return;
35 37
36 // Check if expected class name found. 38 // Check if expected class name found.
37 Arm32DecoderTester::ApplySanityChecks(inst, decoder); 39 Arm32DecoderTester::ApplySanityChecks(inst, decoder);
38 40
39 // Check Registers and flags used in DataProc. 41 // Check Registers and flags used in DataProc.
40 EXPECT_EQ(expected_decoder.n_.number(inst), inst.bits(19, 16)); 42 EXPECT_EQ(expected_decoder.n_.number(inst), inst.bits(19, 16));
41 EXPECT_EQ(expected_decoder.d_.number(inst), inst.bits(15, 12)); 43 EXPECT_EQ(expected_decoder.d_.number(inst), inst.bits(15, 12));
42 EXPECT_EQ(expected_decoder.s_.number(inst), inst.bits(11, 8)); 44 EXPECT_EQ(expected_decoder.s_.number(inst), inst.bits(11, 8));
43 EXPECT_EQ(expected_decoder.m_.number(inst), inst.bits(3, 0)); 45 EXPECT_EQ(expected_decoder.m_.number(inst), inst.bits(3, 0));
44 EXPECT_EQ(expected_decoder.flags_.is_updated(inst), inst.bit(20)); 46 EXPECT_EQ(expected_decoder.flags_.is_updated(inst), inst.bit(20));
45 if (expected_decoder.flags_.is_updated(inst)) { 47 if (expected_decoder.flags_.is_updated(inst)) {
46 EXPECT_EQ(expected_decoder.flags_.reg_if_updated(inst), kRegisterFlags); 48 EXPECT_EQ(expected_decoder.flags_.reg_if_updated(inst), kRegisterFlags);
47 } else { 49 } else {
48 EXPECT_EQ(expected_decoder.flags_.reg_if_updated(inst), kRegisterNone); 50 EXPECT_EQ(expected_decoder.flags_.reg_if_updated(inst), kRegisterNone);
49 } 51 }
50 52
51 // Other ARM constraints about this instruction. 53 // Other ARM constraints about this instruction.
52 EXPECT_NE(expected_decoder.n_.reg(inst), kRegisterPc) 54 EXPECT_NE(expected_decoder.n_.reg(inst), kRegisterPc)
53 << "Expected Unpredictable for " << InstContents(); 55 << "Expected Unpredictable for " << InstContents();
54 EXPECT_NE(expected_decoder.d_.reg(inst), kRegisterPc) 56 EXPECT_NE(expected_decoder.d_.reg(inst), kRegisterPc)
55 << "Expected Unpredictable for " << InstContents(); 57 << "Expected Unpredictable for " << InstContents();
56 EXPECT_NE(expected_decoder.s_.reg(inst), kRegisterPc) 58 EXPECT_NE(expected_decoder.s_.reg(inst), kRegisterPc)
57 << "Expected Unpredictable for " << InstContents(); 59 << "Expected Unpredictable for " << InstContents();
58 EXPECT_NE(expected_decoder.m_.reg(inst), kRegisterPc) 60 EXPECT_NE(expected_decoder.m_.reg(inst), kRegisterPc)
59 << "Expected Unpredictable for " << InstContents(); 61 << "Expected Unpredictable for " << InstContents();
60 } 62 }
61 63
62 } // namespace 64 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698