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

Unified Diff: src/trusted/validator_mips/validator_tests.cc

Issue 11415031: [MIPS] Forbid $sp update at the end of the last bundle. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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.
« src/trusted/validator_mips/validator.cc ('K') | « src/trusted/validator_mips/validator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698