about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik Agaram <vc@akkartik.com>2018-10-05 13:31:53 -0700
committerKartik Agaram <vc@akkartik.com>2018-10-05 13:33:14 -0700
commit15ae0717ba51649dd8042cd5ef0be3bc296b8a26 (patch)
treec26ea2b0ba15152e0746bfbb7c5c11a9a0027c20
parent9f1d0ef3fb2044f7f9cdb51f72cc9822b023eea0 (diff)
downloadmu-15ae0717ba51649dd8042cd5ef0be3bc296b8a26.tar.gz
4664 - subx: reflect test failures in exit status
-rw-r--r--subx/036global_variables.cc2
-rw-r--r--subx/051test.subx5
-rw-r--r--subx/052kernel_string_equal.subx4
-rw-r--r--subx/054string_equal.subx4
-rwxr-xr-xsubx/apps/crenshaw2-1bin1905 -> 1923 bytes
-rwxr-xr-xsubx/apps/factorialbin1903 -> 1921 bytes
-rwxr-xr-xsubx/test_apps18
7 files changed, 16 insertions, 17 deletions
diff --git a/subx/036global_variables.cc b/subx/036global_variables.cc
index b29207bf..e7c139ae 100644
--- a/subx/036global_variables.cc
+++ b/subx/036global_variables.cc
@@ -47,6 +47,8 @@ void compute_addresses_for_global_variables(const segment& s, map<string, uint32
         if (trace_contains_errors()) return;
         if (j > 0)
           raise << "'" << to_string(inst) << "': global variable names can only be the first word in a line.\n" << end();
+        if (Dump_map)
+          cerr << "0x" << HEXWORD << current_address << ' ' << variable << '\n';
         put(address, variable, current_address);
         trace(99, "transform") << "global variable '" << variable << "' is at address 0x" << HEXWORD << current_address << end();
         // no modifying current_address; global variable definitions won't be in the final binary
diff --git a/subx/051test.subx b/subx/051test.subx
index 0ec4c451..faa5257c 100644
--- a/subx/051test.subx
+++ b/subx/051test.subx
@@ -45,6 +45,8 @@ $check_ints_equal:else:
   e8/call  write_stderr/disp32
       # discard arg
   81          0/subop/add         3/mod/direct    4/rm32/ESP    .           .             .           .           .               4/imm32           # add to ESP
+    # increment Num_test_failures
+  ff          0/subop/increment   0/mod/indirect  5/rm32/.disp32            .             .           .           Num_test_failures/disp32          # increment *Num_test_failures
 $check_ints_equal:end:
   # restore registers
   5b/pop-to-EBX
@@ -62,4 +64,7 @@ Newline:
   # data
   0a/newline
 
+Num_test_failures:
+  00 00 00 00
+
 # vim:nowrap:textwidth=0
diff --git a/subx/052kernel_string_equal.subx b/subx/052kernel_string_equal.subx
index e07d2157..21bd9a09 100644
--- a/subx/052kernel_string_equal.subx
+++ b/subx/052kernel_string_equal.subx
@@ -22,8 +22,8 @@
 
 # main:  (manual test if this is the last file loaded)
   e8/call  run_tests/disp32  # 'run_tests' is a function created automatically by SubX. It calls all functions that start with 'test_'.
-  # exit(EAX)
-  89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                 # copy EAX to EBX
+  # exit(Num_test_failures)
+  8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           3/r32/EBX   Num_test_failures/disp32          # copy *Num_test_failures to EBX
   b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EAX
   cd/syscall  0x80/imm8
 
diff --git a/subx/054string_equal.subx b/subx/054string_equal.subx
index 0548fee3..5af6bce8 100644
--- a/subx/054string_equal.subx
+++ b/subx/054string_equal.subx
@@ -8,8 +8,8 @@
 
 # main:  (manual test if this is the last file loaded)
   e8/call  run_tests/disp32  # 'run_tests' is a function created automatically by SubX. It calls all functions that start with 'test_'.
-  # exit(EAX)
-  89/copy                         3/mod/direct    3/rm32/EBX    .           .             .           0/r32/EAX   .               .                 # copy EAX to EBX
+  # exit(Num_test_failures)
+  8b/copy                         0/mod/indirect  5/rm32/.disp32            .             .           3/r32/EBX   Num_test_failures/disp32          # copy *Num_test_failures to EBX
   b8/copy                         .               .             .           .             .           .           .               1/imm32           # copy to EAX
   cd/syscall  0x80/imm8
 
diff --git a/subx/apps/crenshaw2-1 b/subx/apps/crenshaw2-1
index 7ea3fe58..82b37e65 100755
--- a/subx/apps/crenshaw2-1
+++ b/subx/apps/crenshaw2-1
Binary files differdiff --git a/subx/apps/factorial b/subx/apps/factorial
index b15f8fc7..ea130f06 100755
--- a/subx/apps/factorial
+++ b/subx/apps/factorial
Binary files differdiff --git a/subx/test_apps b/subx/test_apps
index 988e81ae..8f00e538 100755
--- a/subx/test_apps
+++ b/subx/test_apps
@@ -114,33 +114,25 @@ test `uname` = 'Linux'  &&  {
 echo ex11
 CFLAGS=-g ./subx translate examples/ex11.subx  -o examples/ex11
 test `uname -m` = 'i686'  &&  git diff --quiet examples/ex11
-CFLAGS=-g ./subx run examples/ex11 2>ex11.out  ||  true  # exit status for run_tests not yet well-defined
-grep -vq 'F' ex11.out  # no test failures
-test `uname` = 'Linux'  &&  {
-  examples/ex11 2>ex11.out  ||  true  # exit status for run_tests not yet well-defined
-  grep -vq 'F' ex11.out  # no test failures
-}
+CFLAGS=-g ./subx run examples/ex11
+test `uname` = 'Linux'  &&  examples/ex11
 
 echo ex12
 CFLAGS=-g ./subx translate examples/ex12.subx  -o examples/ex12
 test `uname -m` = 'i686'  &&  git diff --quiet examples/ex12
 CFLAGS=-g ./subx run examples/ex12  # final byte of mmap'd address is well-nigh guaranteed to be 0
-test `uname` = 'Linux'  &&  {
-  examples/ex12  # final byte of mmap'd address is well-nigh guaranteed to be 0
-}
+test `uname` = 'Linux'  &&  examples/ex12
 
 echo factorial
 CFLAGS=-g ./subx translate *.subx apps/factorial.subx  -o apps/factorial
 test `uname -m` = 'i686'  &&  git diff --quiet apps/factorial
 CFLAGS=-g ./subx run apps/factorial  ||  ret=$?
 test $ret -eq 120  # factorial(5)
-CFLAGS=-g ./subx run apps/factorial test 2>factorial.out  ||  true  # exit status for run_tests not yet well-defined
-grep -vq 'F' factorial.out  # no test failures
+CFLAGS=-g ./subx run apps/factorial test
 test `uname` = 'Linux'  &&  {
   apps/factorial  ||  ret=$?
   test $ret -eq 120  # factorial(5)
-  apps/factorial test 2>factorial.out  ||  true  # exit status for run_tests not yet well-defined
-  grep -vq 'F' factorial.out  # no test failures
+  apps/factorial test
 }
 
 echo crenshaw2-1