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

Unified Diff: src/trusted/validator_arm/decoder_tester.h

Issue 10381030: Clean up testing of instructions. Allow testing to quit if test pattern tests (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/trusted/validator_arm/baseline_classes.cc ('k') | src/trusted/validator_arm/decoder_tester.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/trusted/validator_arm/decoder_tester.h
===================================================================
--- src/trusted/validator_arm/decoder_tester.h (revision 8517)
+++ src/trusted/validator_arm/decoder_tester.h (working copy)
@@ -50,9 +50,12 @@
// Once an instruction is decoded, this method is called to apply
// sanity checks on the matched decoder. The default checks that the
- // expected class name matches the name of the decoder, and that
- // the safety level MAY_BE_SAFE.
- virtual void ApplySanityChecks(
+ // expected class name matches the name of the decoder, and that the
+ // safety level is MAY_BE_SAFE. Returns whether further checking of
+ // the instruction should be performed. In particular, false is returned
+ // if there is some unencoded assumption that isn't put into the
+ // test patterns, and hence, should not be checked.
+ virtual bool ApplySanityChecks(
nacl_arm_dec::Instruction inst,
const NamedClassDecoder& decoder);
@@ -113,6 +116,21 @@
void FillBitRange(int index, int length, bool value);
};
+// Helper macro for testing if preconditions are met within the
+// ApplySanityChecks method of a DecoderTester. That is, if the
+// precondition is not met, exit the routine and return false.
+// Otherwise, the precondition of the remaining code has been met,
+// and execution continues.
+#define NC_PRECOND(test) \
+ { if (!(test)) return false; }
+
+// Helper macro for testing if an (error) precondition a != b is met
+// within the ApplySanityChecks method of a DecoderTester. That is,
+// if a == b, generate a gtest error and then stop the application
+// from doing further checks for the given instruction.
+#define NC_EXPECT_NE_PRECOND(a, b) \
+ { EXPECT_NE(a, b) << InstContents(); NC_PRECOND((a) == (b)); }
+
// Defines a decoder tester that enumerates an Arm32 instruction pattern,
// and tests that all of the decoded patterns match the expected class
// decoder, and that any additional sanity checks, specific to the
« no previous file with comments | « src/trusted/validator_arm/baseline_classes.cc ('k') | src/trusted/validator_arm/decoder_tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698