OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2010 The Native Client Authors. All rights reserved. | 2 * Copyright 2010 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can | 3 * Use of this source code is governed by a BSD-style license that can |
4 * be found in the LICENSE file. | 4 * be found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /* | 7 /* |
8 * Unit tests for the ARM validator | 8 * Unit tests for the ARM validator |
9 * | 9 * |
10 * These tests use the google-test framework (gtest for short) to exercise the | 10 * These tests use the google-test framework (gtest for short) to exercise the |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 | 184 |
185 TEST_F(ValidatorTests, GeneratesCorrectMasksFromSizes) { | 185 TEST_F(ValidatorTests, GeneratesCorrectMasksFromSizes) { |
186 EXPECT_EQ(0xC0000000, _validator.data_address_mask()); | 186 EXPECT_EQ(0xC0000000, _validator.data_address_mask()); |
187 EXPECT_EQ(0xE000000F, _validator.code_address_mask()); | 187 EXPECT_EQ(0xE000000F, _validator.code_address_mask()); |
188 | 188 |
189 // Reinitialize the validator to test a different bundle size. | 189 // Reinitialize the validator to test a different bundle size. |
190 _validator = SfiValidator(32, | 190 _validator = SfiValidator(32, |
191 kCodeRegionSize, | 191 kCodeRegionSize, |
192 kDataRegionSize, | 192 kDataRegionSize, |
193 kAbiReadOnlyRegisters, | 193 kAbiReadOnlyRegisters, |
194 kAbiDataAddrRegisters); | 194 kAbiDataAddrRegisters, |
195 0); // ARM mode | |
bsy
2011/09/16 18:35:52
comment like this is a good indication that an enu
| |
195 EXPECT_EQ(0xC0000000, _validator.data_address_mask()) | 196 EXPECT_EQ(0xC0000000, _validator.data_address_mask()) |
196 << "Changes in bundle size should not affect the data mask."; | 197 << "Changes in bundle size should not affect the data mask."; |
197 EXPECT_EQ(0xE000001F, _validator.code_address_mask()) | 198 EXPECT_EQ(0xE000001F, _validator.code_address_mask()) |
198 << "Changes in bundle size must affect the code mask."; | 199 << "Changes in bundle size must affect the code mask."; |
199 } | 200 } |
200 | 201 |
201 /* | 202 /* |
202 * Code validation tests | 203 * Code validation tests |
203 */ | 204 */ |
204 | 205 |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
601 | 602 |
602 /* | 603 /* |
603 * Implementation of the ValidatorTests utility methods. These are documented | 604 * Implementation of the ValidatorTests utility methods. These are documented |
604 * toward the top of this file. | 605 * toward the top of this file. |
605 */ | 606 */ |
606 ValidatorTests::ValidatorTests() | 607 ValidatorTests::ValidatorTests() |
607 : _validator(kBytesPerBundle, | 608 : _validator(kBytesPerBundle, |
608 kCodeRegionSize, | 609 kCodeRegionSize, |
609 kDataRegionSize, | 610 kDataRegionSize, |
610 kAbiReadOnlyRegisters, | 611 kAbiReadOnlyRegisters, |
611 kAbiDataAddrRegisters) {} | 612 kAbiDataAddrRegisters, |
613 0) {} | |
612 | 614 |
613 bool ValidatorTests::validate(const arm_inst *pattern, | 615 bool ValidatorTests::validate(const arm_inst *pattern, |
614 size_t inst_count, | 616 size_t inst_count, |
615 uint32_t start_addr, | 617 uint32_t start_addr, |
616 ProblemSink *sink) { | 618 ProblemSink *sink) { |
617 // We think in instructions; CodeSegment thinks in bytes. | 619 // We think in instructions; CodeSegment thinks in bytes. |
618 const uint8_t *bytes = reinterpret_cast<const uint8_t *>(pattern); | 620 const uint8_t *bytes = reinterpret_cast<const uint8_t *>(pattern); |
619 CodeSegment segment(bytes, start_addr, inst_count * sizeof(arm_inst)); | 621 CodeSegment segment(bytes, start_addr, inst_count * sizeof(arm_inst)); |
620 | 622 |
621 vector<CodeSegment> segments; | 623 vector<CodeSegment> segments; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
699 return problems; | 701 return problems; |
700 } | 702 } |
701 | 703 |
702 }; // anonymous namespace | 704 }; // anonymous namespace |
703 | 705 |
704 // Test driver function. | 706 // Test driver function. |
705 int main(int argc, char *argv[]) { | 707 int main(int argc, char *argv[]) { |
706 testing::InitGoogleTest(&argc, argv); | 708 testing::InitGoogleTest(&argc, argv); |
707 return RUN_ALL_TESTS(); | 709 return RUN_ALL_TESTS(); |
708 } | 710 } |
OLD | NEW |