about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-02 00:42:43 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-02 00:42:43 -0700
commit60c566eaacbae981c425d4a12abafb56506bacfa (patch)
tree46a23d059389cc12e6cfb6853c1075e899b84d3b
parent36d74808d9d8fdb9c38c8164d34de24dd7968b1b (diff)
downloadmu-60c566eaacbae981c425d4a12abafb56506bacfa.tar.gz
3291
Stop double-counting failing tests in some situations.
-rw-r--r--002test.cc4
-rw-r--r--003trace.cc5
2 files changed, 5 insertions, 4 deletions
diff --git a/002test.cc b/002test.cc
index b9cb0e15..a07d5d9f 100644
--- a/002test.cc
+++ b/002test.cc
@@ -23,7 +23,7 @@ long Num_failures = 0;
 
 :(before "End Includes")
 #define CHECK(X) \
-  if (!(X)) { \
+  if (Passed && !(X)) { \
     ++Num_failures; \
     cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): " << #X << '\n'; \
     Passed = false; \
@@ -31,7 +31,7 @@ long Num_failures = 0;
   }
 
 #define CHECK_EQ(X, Y) \
-  if ((X) != (Y)) { \
+  if (Passed && (X) != (Y)) { \
     ++Num_failures; \
     cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): " << #X << " == " << #Y << '\n'; \
     cerr << "  got " << (X) << '\n';  /* BEWARE: multiple eval */ \
diff --git a/003trace.cc b/003trace.cc
index 3f08aa40..7522fc90 100644
--- a/003trace.cc
+++ b/003trace.cc
@@ -216,7 +216,7 @@ START_TRACING_UNTIL_END_OF_SCOPE
 
 #define CHECK_TRACE_CONTAINS_ERROR()  CHECK(trace_count("error") > 0)
 #define CHECK_TRACE_DOESNT_CONTAIN_ERROR() \
-  if (trace_count("error") > 0) { \
+  if (Passed && trace_count("error") > 0) { \
     ++Num_failures; \
     cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): unexpected errors\n"; \
     DUMP("error"); \
@@ -225,7 +225,7 @@ START_TRACING_UNTIL_END_OF_SCOPE
   }
 
 #define CHECK_TRACE_COUNT(label, count) \
-  if (trace_count(label) != (count)) { \
+  if (Passed && trace_count(label) != (count)) { \
     ++Num_failures; \
     cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): trace_count of " << label << " should be " << count << '\n'; \
     cerr << "  got " << trace_count(label) << '\n';  /* multiple eval */ \
@@ -238,6 +238,7 @@ START_TRACING_UNTIL_END_OF_SCOPE
 
 :(code)
 bool check_trace_contents(string FUNCTION, string FILE, int LINE, string expected) {
+  if (!Passed) return false;
   if (!Trace_stream) return false;
   vector<string> expected_lines = split(expected, "");
   int curr_expected_line = 0;
nt */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
//: helper for division operations: sign-extend EAX into EDX

:(before "End Initialize Op Names")
put_new(Name, "99", "sign-extend EAX into EDX (cdq)");

:(code)
void test_cdq() {
  Reg[EAX].i = 10;
  run(
      "== code 0x1\n"
      "99\n"
  );
  CHECK_TRACE_CONTENTS(
      "run: sign-extend EAX into EDX\n"
      "run: EDX is now 0x00000000\n"
  );
}

:(before "End Single-Byte Opcodes")
case 0x99: {  // sign-extend EAX into EDX
  trace(Callstack_depth+1, "run") << "sign-extend EAX into EDX" << end();
  Reg[EDX].i = (Reg[EAX].i < 0) ? -1 : 0;
  trace(Callstack_depth+1, "run") << "EDX is now 0x" << HEXWORD << Reg[EDX].u << end();
  break;
}

:(code)
void test_cdq_negative() {
  Reg[EAX].i = -10;
  run(
      "== code 0x1\n"
      "99\n"
  );
  CHECK_TRACE_CONTENTS(
      "run: sign-extend EAX into EDX\n"
      "run: EDX is now 0xffffffff\n"
  );
}