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

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

Issue 12095039: Add testing of generated (ARM) baseline decoders using hand-written decoders. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 7 years, 10 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
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 6
7 #ifndef NACL_TRUSTED_BUT_NOT_TCB 7 #ifndef NACL_TRUSTED_BUT_NOT_TCB
8 #error This file is not meant for use in the TCB 8 #error This file is not meant for use in the TCB
9 #endif 9 #endif
10 10
11 #include "native_client/src/trusted/validator_arm/actual_vs_baseline.h" 11 #include "native_client/src/trusted/validator_arm/actual_vs_baseline.h"
12 12
13 #include "gtest/gtest.h" 13 #include "gtest/gtest.h"
14 14
15 namespace nacl_arm_test { 15 namespace nacl_arm_test {
16 16
17 ActualVsBaselineTester::ActualVsBaselineTester( 17 ActualVsBaselineTester::ActualVsBaselineTester(
18 const NamedClassDecoder& actual, 18 const NamedClassDecoder& actual,
19 DecoderTester& baseline_tester) 19 DecoderTester& baseline_tester)
20 : Arm32DecoderTester(baseline_tester.ExpectedDecoder()), 20 : Arm32DecoderTester(baseline_tester.ExpectedDecoder()),
21 actual_(actual), 21 actual_(actual),
22 baseline_(baseline_tester.ExpectedDecoder()), 22 baseline_(baseline_tester.ExpectedDecoder()),
23 baseline_tester_(baseline_tester), 23 baseline_tester_(baseline_tester),
24 actual_decoder_(actual_.named_decoder()), 24 actual_decoder_(actual_.named_decoder()),
25 baseline_decoder_(baseline_.named_decoder()) {} 25 baseline_decoder_(baseline_.named_decoder()) {}
26 26
27 bool ActualVsBaselineTester::DoApplySanityChecks() {
28 return baseline_tester_.ApplySanityChecks(
29 inst_, baseline_tester_.GetInstDecoder());
30 }
31
27 void ActualVsBaselineTester::ProcessMatch() { 32 void ActualVsBaselineTester::ProcessMatch() {
28 baseline_tester_.InjectInstruction(inst_); 33 baseline_tester_.InjectInstruction(inst_);
29 const NamedClassDecoder& decoder = baseline_tester_.GetInstDecoder(); 34 const NamedClassDecoder& decoder = baseline_tester_.GetInstDecoder();
30 if (!baseline_tester_.PassesParsePreconditions(inst_, decoder)) { 35 if (!baseline_tester_.PassesParsePreconditions(inst_, decoder)) {
31 // Parse precondition implies that this pattern is NOT supposed to 36 // Parse precondition implies that this pattern is NOT supposed to
32 // be handled by the baseline tester (because another decoder 37 // be handled by the baseline tester (because another decoder
33 // handles it). Hence, don't do any further processing. 38 // handles it). Hence, don't do any further processing.
34 return; 39 return;
35 } 40 }
36 if (nacl_arm_dec::MAY_BE_SAFE == decoder.safety(inst_)) { 41 if (nacl_arm_dec::MAY_BE_SAFE == decoder.safety(inst_)) {
37 // Run sanity baseline checks, to see that the baseline is 42 // Run sanity baseline checks, to see that the baseline is
38 // correct. 43 // correct.
39 if (!baseline_tester_.ApplySanityChecks(inst_, decoder)) { 44 if (!DoApplySanityChecks()) {
40 // The sanity checks found a serious issue and already reported 45 // The sanity checks found a serious issue and already reported
41 // it. don't bother to report additional problems. 46 // it. don't bother to report additional problems.
42 return; 47 return;
43 } 48 }
44 // Check virtuals. Start with check if safe. If unsafe, no further 49 // Check virtuals. Start with check if safe. If unsafe, no further
45 // checking need be applied, since the validator will stop 50 // checking need be applied, since the validator will stop
46 // processing such instructions after the safe test. 51 // processing such instructions after the safe test.
47 if (!MayBeSafe()) return; 52 if (!MayBeSafe()) return;
48 } else { 53 } else {
49 // Not safe in baseline, only compare safety, testing if not safe 54 // Not safe in baseline, only compare safety, testing if not safe
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // Note: We don't actually test all combinations of masks. We just 190 // Note: We don't actually test all combinations of masks. We just
186 // try a few. 191 // try a few.
187 for (uint32_t i = 0; i < 15; ++i) { 192 for (uint32_t i = 0; i < 15; ++i) {
188 nacl_arm_dec::Register r(i); 193 nacl_arm_dec::Register r(i);
189 EXPECT_EQ(baseline_decoder_.sets_Z_if_bits_clear(inst_, r, data24_mask), 194 EXPECT_EQ(baseline_decoder_.sets_Z_if_bits_clear(inst_, r, data24_mask),
190 actual_decoder_.sets_Z_if_bits_clear(inst_, r, data24_mask)); 195 actual_decoder_.sets_Z_if_bits_clear(inst_, r, data24_mask));
191 } 196 }
192 } 197 }
193 198
194 } // namespace nacl_arm_test 199 } // namespace nacl_arm_test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698