| OLD | NEW |
| 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 /* | 7 /* |
| 8 * Tests the decoder. | 8 * Tests the decoder. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef NACL_TRUSTED_BUT_NOT_TCB | 11 #ifndef NACL_TRUSTED_BUT_NOT_TCB |
| 12 #error This file is not meant for use in the TCB | 12 #error This file is not meant for use in the TCB |
| 13 #endif | 13 #endif |
| 14 | 14 |
| 15 #include "native_client/src/trusted/validator_arm/decoder_tester.h" | 15 #include "native_client/src/trusted/validator_arm/decoder_tester.h" |
| 16 | 16 |
| 17 #include <string> | 17 #include <string> |
| 18 #include "gtest/gtest.h" | 18 #include "gtest/gtest.h" |
| 19 | 19 |
| 20 using nacl_arm_dec::kArm32InstSize; | 20 using nacl_arm_dec::kArm32InstSize; |
| 21 using nacl_arm_dec::kThumbWordSize; | 21 using nacl_arm_dec::kThumbWordSize; |
| 22 using nacl_arm_dec::Instruction; | 22 using nacl_arm_dec::Instruction; |
| 23 using nacl_arm_dec::MAY_BE_SAFE; | 23 using nacl_arm_dec::MAY_BE_SAFE; |
| 24 | 24 |
| 25 namespace nacl_arm_test { | 25 namespace nacl_arm_test { |
| 26 | 26 |
| 27 DecoderTester::DecoderTester() | 27 DecoderTester::DecoderTester() |
| 28 {} | 28 {} |
| 29 | 29 |
| 30 void DecoderTester::ApplySanityChecks(Instruction inst, | 30 bool DecoderTester::ApplySanityChecks(Instruction inst, |
| 31 const NamedClassDecoder& decoder) { | 31 const NamedClassDecoder& decoder) { |
| 32 UNREFERENCED_PARAMETER(inst); | 32 UNREFERENCED_PARAMETER(inst); |
| 33 EXPECT_EQ(&decoder, &ExpectedDecoder()) | 33 bool test = (&decoder == &ExpectedDecoder()); |
| 34 EXPECT_TRUE(test) |
| 34 << "Expected " << ExpectedDecoder().name() << " but found " | 35 << "Expected " << ExpectedDecoder().name() << " but found " |
| 35 << decoder.name() << " for " << InstContents(); | 36 << decoder.name() << " for " << InstContents(); |
| 37 NC_PRECOND(test); |
| 38 return true; |
| 36 } | 39 } |
| 37 | 40 |
| 38 void DecoderTester::TestAtIndex(int index) { | 41 void DecoderTester::TestAtIndex(int index) { |
| 39 while (true) { | 42 while (true) { |
| 40 // First see if we have completed generating test. | 43 // First see if we have completed generating test. |
| 41 if (index < 0) { | 44 if (index < 0) { |
| 42 ProcessMatch(); | 45 ProcessMatch(); |
| 43 return; | 46 return; |
| 44 } | 47 } |
| 45 | 48 |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 } | 408 } |
| 406 | 409 |
| 407 void ThumbDecoderTester::SetBitRange(int index, int length, uint32_t value) { | 410 void ThumbDecoderTester::SetBitRange(int index, int length, uint32_t value) { |
| 408 // This should never be called. The decoders word1_tester_ | 411 // This should never be called. The decoders word1_tester_ |
| 409 // and word2_tester_ should be doing all of the bit setting. | 412 // and word2_tester_ should be doing all of the bit setting. |
| 410 GTEST_FAIL() << "ThumbDecoderTester::SetBitRange(" << index << | 413 GTEST_FAIL() << "ThumbDecoderTester::SetBitRange(" << index << |
| 411 ", " << length << ", " << value << ")"; | 414 ", " << length << ", " << value << ")"; |
| 412 } | 415 } |
| 413 | 416 |
| 414 } // namespace | 417 } // namespace |
| OLD | NEW |