Chromium Code Reviews| Index: src/trusted/validator_mips/validator_tests.cc |
| diff --git a/src/trusted/validator_mips/validator_tests.cc b/src/trusted/validator_mips/validator_tests.cc |
| index a1dbc4f9d2522e41ae3b0348ea9d75bf544785be..502cce6c47f547fc90c255523237dee76666b8cb 100644 |
| --- a/src/trusted/validator_mips/validator_tests.cc |
| +++ b/src/trusted/validator_mips/validator_tests.cc |
| @@ -43,6 +43,8 @@ using nacl_mips_dec::Instruction; |
| using nacl_mips_val::SfiValidator; |
| using nacl_mips_val::ProblemSink; |
| using nacl_mips_val::CodeSegment; |
| +using nacl_mips_dec::kInstrSize; |
| +using nacl_mips_dec::kNop; |
| namespace { |
| @@ -250,10 +252,6 @@ static const AnnotatedInstruction examples_of_safe_jumps[] = { |
| { (10<<21|8), "simple jump jr t2" }, |
| }; |
| -static const AnnotatedInstruction nop_instruction[] = { |
| - { 0, "nop"}, |
| -}; |
| - |
| TEST_F(ValidatorTests, SafeMaskedJumps) { |
| /* |
| * Produces examples of masked jumps using the safe jump table |
| @@ -266,7 +264,7 @@ TEST_F(ValidatorTests, SafeMaskedJumps) { |
| << ", " |
| << examples_of_safe_jumps[s].about; |
| mips_inst program[] = { |
| - nop_instruction[0].inst, |
| + kNop, |
| examples_of_safe_jump_masks[m].inst, |
| examples_of_safe_jumps[s].inst, |
| }; |
| @@ -357,7 +355,7 @@ TEST_F(ValidatorTests, IncorrectStackOps) { |
| mips_inst bad_program[] = { |
| examples_of_safe_stack_masks[m].inst, |
| examples_of_safe_stack_ops[s].inst, |
| - nop_instruction[0].inst |
| + kNop |
| }; |
| ValidationShouldFail(bad_program, |
| @@ -368,6 +366,16 @@ TEST_F(ValidatorTests, IncorrectStackOps) { |
| } |
| } |
| +TEST_F(ValidatorTests, UnmaskedSpUpdate) { |
|
JF
2012/11/16 21:03:27
Please also add a test for nop (as in the ARM chan
petarj
2012/11/19 18:46:10
Done.
|
| + vector<mips_inst> code(_validator.bytes_per_bundle()/kInstrSize, kNop); |
|
Mark Seaborn
2012/11/16 20:08:08
Nit: please put spaces around '/'
petarj
2012/11/19 18:46:10
Done.
|
| + for (vector<mips_inst>::size_type i = 0; i < code.size(); ++i) { |
| + std::fill(code.begin(), code.end(), kNop); |
| + code[i] = 0x8fbd0000; // lw $sp, 0($sp) |
| + ValidationShouldFail(&code[0], code.size(), kDefaultBaseAddr, |
| + "unmasked SP update"); |
| + } |
| +} |
| + |
| /* |
| * Implementation of the ValidatorTests utility methods. These are documented |
| * toward the top of this file. |