[m-rev.] diff: fix tabling for the oota test case

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Mar 15 16:16:08 AEDT 2004


runtime/mercury_minimal_model.c:
	Fix a bug in the code that resets the redoip slots of saved nondet
	stack frames. The idea is that just after we save the state of an
	SLD branch, we will explore all the branches to its right, so we
	don't want to explore those branches again when we restore the saved
	state.

	The bug manifested itself in situations where p calls q, q returns,
	and p calls r. The nondet stack in such cases contains p, q and r.
	When saving the state of the consumer r, we used to clobber the redoip
	of the stack frame belonging to q, even though it is not on the saved
	SLD branch.

	The fix includes clobbering redoips only on the main SLD branch.

	To make the fix easier, the new version of this file factors out
	some previously mostly-duplicated code, and add facilities for 
	converting addresses between the real stack and saved stack segments
	that do sanity checking at runtime.

tests/tabling/test_tabling:
	A new shell script to make it convenient to execute the test cases
	in this directory without a bootcheck, if you have a workspace compiled
	with minimal model tabling.

tests/tabling/Mmakefile:
	Record that we now pass the oota test case.

	Add support for the new shell script.

Zoltan.

cvs diff: Diffing .
cvs diff: Diffing analysis
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing java
cvs diff: Diffing java/library
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
Index: runtime/mercury_minimal_model.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_minimal_model.c,v
retrieving revision 1.9
diff -u -b -r1.9 mercury_minimal_model.c
--- runtime/mercury_minimal_model.c	15 Mar 2004 02:17:18 -0000	1.9
+++ runtime/mercury_minimal_model.c	15 Mar 2004 04:39:49 -0000
@@ -27,6 +27,12 @@
                     const MR_Label_Layout *top_layout);
 static  void    restore_state(MR_SavedState *saved_state, const char *who,
                     const char *what);
+static  MR_Word *saved_to_real_nondet_stack(MR_SavedState *saved_state,
+                    MR_Word *saved_ptr);
+static  MR_Word *real_to_saved_nondet_stack(MR_SavedState *saved_state,
+                    MR_Word *real_ptr);
+static  void    pickle_stack_segment(MR_SavedState *saved_state,
+                    MR_Integer already_pickled, MR_Subgoal *subgoal);
 static  void    extend_consumer_stacks(MR_Subgoal *leader,
                     MR_Consumer *consumer);
 static  void    make_subgoal_follow_leader(MR_Subgoal *this_follower,
@@ -697,10 +703,6 @@
     MR_Word         extension_size;
     MR_Word         *old_common_ancestor_fr;
     MR_Word         *new_common_ancestor_fr;
-    MR_Word         *saved_fr;
-    MR_Word         *real_fr;
-    MR_Word         frame_size;
-    MR_Word         offset;
     MR_SavedState   *cons_saved_state;
 
     cons_saved_state = &consumer->MR_cns_saved_state;
@@ -821,58 +823,286 @@
         cons_saved_state->MR_ss_non_stack_saved_block = arena_block;
         cons_saved_state->MR_ss_non_stack_block_size = arena_size;
         cons_saved_state->MR_ss_non_stack_real_start = arena_start;
+
+        pickle_stack_segment(cons_saved_state, arena_size - extension_size,
+            NULL);
     }
 
 #ifdef  MR_TABLE_DEBUG
     if (MR_tablestackdebug) {
-        printf("\nbefore pickling nondet stack\n");
+        printf("\nfinished extending saved consumer stacks\n");
         print_saved_state(stdout, cons_saved_state);
     }
 #endif  /* MR_TABLE_DEBUG */
+}
 
-    /* XXX we should be doing this only for the newly added segment */
-    saved_fr = cons_saved_state->MR_ss_non_stack_saved_block +
-        cons_saved_state->MR_ss_non_stack_block_size - 1;
-    real_fr = cons_saved_state->MR_ss_non_stack_real_start +
-        cons_saved_state->MR_ss_non_stack_block_size - 1;
-    while (saved_fr > cons_saved_state->MR_ss_non_stack_saved_block) {
-        frame_size = real_fr - MR_prevfr_slot(saved_fr);
+static MR_Word *
+saved_to_real_nondet_stack(MR_SavedState *saved_state, MR_Word *saved_ptr)
+{
+    MR_Word *real_ptr;
 
-        if (saved_fr - frame_size >
-            cons_saved_state->MR_ss_non_stack_saved_block)
+    if (saved_state->MR_ss_non_stack_saved_block <= saved_ptr
+        && saved_ptr < saved_state->MR_ss_non_stack_saved_block +
+            saved_state->MR_ss_non_stack_block_size)
         {
-            *MR_redoip_addr(saved_fr) = (MR_Word) MR_ENTRY(MR_do_fail);
+        MR_Integer  offset;
+
+        offset = saved_ptr - saved_state->MR_ss_non_stack_saved_block;
+        real_ptr = saved_state->MR_ss_non_stack_real_start + offset;
+#if 0
+        printf("real start %p, saved block %p, real ptr %p, saved ptr %p\n",
+            saved_state->MR_ss_non_stack_real_start,
+            saved_state->MR_ss_non_stack_saved_block,
+            real_ptr,
+            saved_ptr);
+#endif
+        return real_ptr;
+    } else {
+        MR_fatal_error("saved_to_real_nondet_stack: out of bounds");
+    }
+}
+
+static MR_Word *
+real_to_saved_nondet_stack(MR_SavedState *saved_state, MR_Word *real_ptr)
+{
+    MR_Word *saved_ptr;
+
+    if (saved_state->MR_ss_non_stack_real_start <= real_ptr
+        && real_ptr < saved_state->MR_ss_non_stack_real_start +
+            saved_state->MR_ss_non_stack_block_size)
+    {
+        MR_Integer  offset;
+
+        offset = real_ptr - saved_state->MR_ss_non_stack_real_start;
+#if 0
+        saved_ptr = saved_state->MR_ss_non_stack_saved_block + offset;
+        printf("real start %p, saved block %p, real ptr %p, saved ptr %p\n",
+            saved_state->MR_ss_non_stack_real_start,
+            saved_state->MR_ss_non_stack_saved_block,
+            real_ptr,
+            saved_ptr);
+#endif
+        return saved_ptr;
+    } else {
+        MR_fatal_error("real_to_saved_nondet_stack: out of bounds");
+    }
+}
+
+MR_declare_entry(MR_table_nondet_commit);
+
+static void
+pickle_stack_segment(MR_SavedState *saved_state, MR_Integer already_pickled,
+    MR_Subgoal *subgoal)
+{
+    MR_Word         *saved_fr;
+    MR_Word         *saved_stop_fr;
+    MR_Word         *saved_top_fr;
+    MR_Word         *saved_next_fr;
+    MR_Word         *real_fr;
+    MR_Word         *saved_redoip_addr;
+    MR_Word         *real_redoip_addr;
+    MR_Word         frame_size;
+    MR_Word         *real_main_branch_fr;
+    MR_Integer      cur_gen;
+    MR_Integer      cur_cut;
+    MR_Integer      cur_pneg;
+    MR_bool         ordinary;
+    MR_bool         generator_is_at_bottom;
+
+    if (already_pickled > 0) {
+        generator_is_at_bottom = MR_TRUE;
+    } else {
+        generator_is_at_bottom = MR_FALSE;
+    }
 
 #ifdef  MR_TABLE_DEBUG
-            if (MR_tabledebug) {
-                printf("do_fail to redoip at %p (%d)\n",
-                    MR_redoip_addr(saved_fr),
-                    MR_redoip_addr(saved_fr) -
-                        cons_saved_state->MR_ss_non_stack_saved_block);
+    if (MR_tablestackdebug) {
+        printf("\nbefore pickling nondet stack, already pickled %d\n",
+            already_pickled);
+        print_saved_state(stdout, saved_state);
             }
 #endif  /* MR_TABLE_DEBUG */
+
+    saved_stop_fr = saved_state->MR_ss_non_stack_saved_block - 1;
+    saved_top_fr = saved_state->MR_ss_non_stack_saved_block +
+        saved_state->MR_ss_non_stack_block_size - 1;
+    saved_fr = saved_top_fr;
+
+    /*
+    real_stop_fr = saved_state->MR_ss_non_stack_real_start - 1;
+    real_top_fr = saved_state->MR_ss_non_stack_real_start +
+        saved_state->MR_ss_non_stack_block_size - 1;
+    real_fr = real_top_fr;
+    */
+
+    real_main_branch_fr =
+        saved_to_real_nondet_stack(saved_state, saved_top_fr);
+
+    cur_gen = MR_gen_next - 1;
+    cur_cut = MR_cut_next - 1;
+    cur_pneg = MR_pneg_next - 1;
+
+    while (saved_fr > saved_stop_fr) {
+        real_fr = saved_to_real_nondet_stack(saved_state, saved_fr);
+        frame_size = real_fr - MR_prevfr_slot(saved_fr);
+        saved_next_fr = saved_fr - frame_size;
+
+        if (frame_size >= MR_NONDET_FIXED_SIZE) {
+            ordinary = MR_TRUE;
         } else {
-            *MR_redoip_addr(saved_fr) = (MR_Word) MR_ENTRY(MR_RESUME_ENTRY);
+            ordinary = MR_FALSE;
+        }
+
+        /*
+        redoip_offset_from_stop = MR_redoip_addr(saved_fr) - real_stop_fr;
+        saved_redoip_addr = saved_stop_fr + redoip_offset_from_stop;
+        real_redoip_addr = saved_stop_fr + redoip_offset_from_stop;
+        */
+
+#if MR_TABLE_DEBUG
+        if (MR_tablestackdebug) {
+            printf("considering %s frame ",
+                (ordinary? "ordinary" : "temp"));
+            MR_print_nondstackptr(stdout,
+                saved_to_real_nondet_stack(saved_state, saved_fr));
+            printf(" with redoip slot at ");
+            MR_print_nondstackptr(stdout, MR_redoip_addr(saved_fr));
+            printf("\n");
+        }
+#endif
+
+        if (already_pickled > 0) {
 #ifdef  MR_TABLE_DEBUG
             if (MR_tabledebug) {
-                printf("resume to redoip at %p (%d)\n",
-                    MR_redoip_addr(saved_fr),
-                    MR_redoip_addr(saved_fr) -
-                        cons_saved_state->MR_ss_non_stack_saved_block);
+                printf("already pickled %d -> %d\n",
+                    already_pickled, already_pickled - frame_size);
             }
 #endif  /* MR_TABLE_DEBUG */
-        } /*** else cut_stack XXX */
 
-        saved_fr -= frame_size;
-        real_fr -= frame_size;
+            already_pickled -= frame_size;
+
+            if (real_fr == real_main_branch_fr && ordinary) {
+#ifdef  MR_TABLE_DEBUG
+                if (MR_tabledebug) {
+                    printf("next main sequence frame ");
+                    MR_printnondstackptr(MR_succfr_slot(saved_fr));
     }
+#endif  /* MR_TABLE_DEBUG */
 
+                real_main_branch_fr = MR_succfr_slot(saved_fr);
+            }
+        } else if (MR_redofr_slot(saved_fr) != real_main_branch_fr) {
 #ifdef  MR_TABLE_DEBUG
+            if (MR_tabledebug) {
+                printf("skipping over non-main-branch frame\n");
+            }
+#endif  /* MR_TABLE_DEBUG */
+            /* do nothing */;
+        } else if (generator_is_at_bottom && saved_next_fr == saved_stop_fr) {
+#ifdef  MR_TABLE_DEBUG
+            if (MR_tabledebug) {
+                printf("completing redoip of bottom frame at ");
+                MR_print_nondstackptr(stdout,
+                    saved_to_real_nondet_stack(saved_state, saved_fr));
+                printf(" (in saved copy)\n");
+            }
+#endif  /* MR_TABLE_DEBUG */
+
+            *MR_redoip_addr(saved_fr) = (MR_Word) MR_ENTRY(MR_RESUME_ENTRY);
+        } else if (!generator_is_at_bottom &&
+            real_fr == MR_gen_stack[cur_gen].MR_gen_frame)
+        {
+            assert(subgoal != NULL);
+            assert(ordinary);
+
+            if (MR_gen_stack[cur_gen].MR_gen_subgoal == subgoal) {
+                /*
+                ** This is the nondet stack frame of the generator
+                ** corresponding to the consumer whose saved state
+                ** we are pickling.
+                */
+
+#ifdef  MR_TABLE_DEBUG
+                if (MR_tabledebug) {
+                    printf("completing redoip of frame at ");
+                    MR_print_nondstackptr(stdout,
+                        saved_to_real_nondet_stack(saved_state, saved_fr));
+                    printf(" (in saved copy)\n");
+                }
+#endif  /* MR_TABLE_DEBUG */
+
+                *MR_redoip_addr(saved_fr) = (MR_Word) MR_ENTRY(MR_RESUME_ENTRY);
+
+  #ifdef  MR_TABLE_DEBUG
+                if (MR_tabledebug) {
+                    printf("saved gen_next set to %d from %d\n",
+                        cur_gen + 1, saved_state->MR_ss_gen_next);
+                    if (saved_state->MR_ss_gen_next != cur_gen + 1) {
+                        printf("XXX saved gen_next := not idempotent\n");
+                        MR_print_gen_stack(stdout);
+                        MR_print_cut_stack(stdout);
+                    }
+                }
+  #endif    /* MR_TABLE_DEBUG */
+
+                saved_state->MR_ss_gen_next = cur_gen + 1;
+            } else {
+                /*
+                ** This is the nondet stack frame of some other generator.
+                */
+
+                /* reenable XXX */
+                assert(MR_prevfr_slot(saved_fr) !=
+                    saved_to_real_nondet_stack(saved_state, saved_stop_fr));
+
+  #ifdef  MR_TABLE_DEBUG
     if (MR_tablestackdebug) {
-        printf("\nfinished extending saved consumer stacks\n");
-        print_saved_state(stdout, cons_saved_state);
+                    printf("clobbering redoip of follower frame at ");
+                    MR_printnondstackptr(real_fr);
+                    printf(" (in saved copy)\n");
+                }
+  #endif    /* MR_TABLE_DEBUG */
+
+                *MR_redoip_addr(saved_fr) = (MR_Word) MR_ENTRY(MR_do_fail);
+
+                MR_save_transient_registers();
+                make_subgoal_follow_leader(
+                    MR_gen_stack[cur_gen].MR_gen_subgoal, subgoal);
+                MR_restore_transient_registers();
+            }
+
+            cur_gen--;
+        } else if (generator_is_at_bottom && cur_cut > 0
+            && real_fr == MR_cut_stack[cur_cut].MR_cut_frame)
+        {
+            assert(! ordinary);
+
+  #ifdef  MR_TABLE_DEBUG
+            if (MR_tablestackdebug) {
+                printf("committing redoip of frame at ");
+                MR_printnondstackptr(real_fr);
+                printf(" (in saved copy)\n");
+            }
+  #endif    /* MR_TABLE_DEBUG */
+
+            *MR_redoip_addr(saved_fr) = (MR_Word)
+                MR_ENTRY(MR_table_nondet_commit);
+            cur_cut--;
+        } else {
+#ifdef  MR_TABLE_DEBUG
+            if (MR_tabledebug) {
+                printf("clobbering redoip of frame at ");
+                MR_printnondstackptr(real_fr);
+                printf(" (in saved copy)\n");
     }
+
+            *MR_redoip_addr(saved_fr) = (MR_Word) MR_ENTRY(MR_do_fail);
 #endif  /* MR_TABLE_DEBUG */
+        }
+
+        saved_fr -= frame_size;
+        real_fr -= frame_size;
+    }
 }
 
 /*
@@ -1213,107 +1443,7 @@
         subgoal->MR_sg_deepest_nca_fr = common_ancestor;
     }
 
-    cur_gen = MR_gen_next - 1;
-    cur_cut = MR_cut_next - 1;
-    cur_pneg = MR_pneg_next - 1;
-    stop_addr = consumer->MR_cns_saved_state.MR_ss_non_stack_real_start;
-
-    for (fr = MR_maxfr; fr > stop_addr; fr = MR_prevfr_slot(fr)) {
-        offset = MR_redoip_addr(fr) -
-            consumer->MR_cns_saved_state.MR_ss_non_stack_real_start;
-        clobber_addr = consumer->MR_cns_saved_state.MR_ss_non_stack_saved_block
-            + offset;
-#if 0
-        if (MR_tablestackdebug) {
-            printf("redoip addr ");
-            MR_printnondstackptr(MR_redoip_addr(fr));
-            printf(", offset %d from start, ", offset);
-            printf("saved copy at %p\n", clobber_addr);
-        }
-#endif
-
-        if (fr == MR_gen_stack[cur_gen].MR_gen_frame) {
-            if (MR_gen_stack[cur_gen].MR_gen_subgoal == subgoal) {
-                /*
-                ** This is the nondet stack frame of the
-                ** generator corresponding to this consumer.
-                */
-
-  #ifdef  MR_TABLE_DEBUG
-                if (MR_tablestackdebug) {
-                    printf("completing redoip of frame at ");
-                    MR_printnondstackptr(fr);
-                    printf(" (in saved copy)\n");
-                    printf("  old contents was %p\n",
-                        (MR_Word *) *clobber_addr);
-                }
-  #endif    /* MR_TABLE_DEBUG */
-                *clobber_addr = (MR_Word) MR_ENTRY(MR_RESUME_ENTRY);
-
-  #ifdef  MR_TABLE_DEBUG
-                if (MR_tabledebug) {
-                    printf("saved gen_next set to %d from %d\n",
-                        cur_gen + 1,
-                        consumer->MR_cns_saved_state.MR_ss_gen_next);
-                    /* XXX if next assignment is not idempotent */
-                    if (consumer->MR_cns_saved_state.MR_ss_gen_next
-                        != cur_gen + 1)
-                    {
-                        MR_print_gen_stack(stdout);
-                        MR_print_cut_stack(stdout);
-                    }
-                }
-  #endif    /* MR_TABLE_DEBUG */
-                consumer->MR_cns_saved_state.MR_ss_gen_next = cur_gen + 1;
-            } else {
-                /*
-                ** This is the nondet stack frame of some other generator.
-                */
-
-  #if 0
-                /* reenable XXX */
-                assert(MR_prevfr_slot(fr) != (stop_addr - 1));
-  #endif
-
-                *clobber_addr = (MR_Word) MR_ENTRY(MR_do_fail);
-  #ifdef  MR_TABLE_DEBUG
-                if (MR_tablestackdebug) {
-                    printf("clobbering redoip of frame at ");
-                    MR_printnondstackptr(fr);
-                    printf(" (in saved copy)\n");
-                }
-  #endif    /* MR_TABLE_DEBUG */
-
-                MR_save_transient_registers();
-                make_subgoal_follow_leader(MR_gen_stack[cur_gen].
-                    MR_gen_subgoal, subgoal);
-                MR_restore_transient_registers();
-            }
-
-            cur_gen--;
-            /* XXX can we be at a generator AND a cut? */
-        } else if (cur_cut > 0 && fr == MR_cut_stack[cur_cut].MR_cut_frame) {
-            *clobber_addr = (MR_Word) MR_ENTRY(MR_table_nondet_commit);
-  #ifdef  MR_TABLE_DEBUG
-            if (MR_tablestackdebug) {
-                printf("committing redoip of frame at ");
-                MR_printnondstackptr(fr);
-                printf(" (in saved copy)\n");
-            }
-  #endif    /* MR_TABLE_DEBUG */
-
-            cur_cut--;
-        } else {
-            *clobber_addr = (MR_Word) MR_ENTRY(MR_do_fail);
-  #ifdef  MR_TABLE_DEBUG
-            if (MR_tablestackdebug) {
-                printf("clobbering redoip of frame at ");
-                MR_printnondstackptr(fr);
-                printf(" (in saved copy)\n");
-            }
-  #endif    /* MR_TABLE_DEBUG */
-        }
-    }
+    pickle_stack_segment(&consumer->MR_cns_saved_state, 0, subgoal);
 
   #ifdef  MR_TABLE_DEBUG
     if (MR_tabledebug) {
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
cvs diff: Diffing tests/tabling
Index: tests/tabling/Mmakefile
===================================================================
RCS file: /home/mercury/mercury1/repository/tests/tabling/Mmakefile,v
retrieving revision 1.27
diff -u -b -r1.27 Mmakefile
--- tests/tabling/Mmakefile	15 Mar 2004 01:33:33 -0000	1.27
+++ tests/tabling/Mmakefile	15 Mar 2004 05:12:37 -0000
@@ -4,7 +4,7 @@
 
 #-----------------------------------------------------------------------------#
 
-SIMPLE_PROGS = \
+SIMPLE_NONLOOP_PROGS = \
 	boyer \
 	expand \
 	expand_float \
@@ -14,11 +14,13 @@
 	fib_float \
 	fib_list \
 	fib_string \
-	loopcheck \
 	loopcheck_no_loop \
 	unused_args
 
-NONDET_PROGS = \
+SIMPLE_LOOP_PROGS = \
+	loopcheck
+
+NONDET_NONLOOP_PROGS = \
 	combine \
 	completed_consumer_in_solutions \
 	consumer_in_commit \
@@ -31,32 +33,41 @@
 	coup_non_tabled_frame \
 	generator_in_commit \
 	mday \
+	oota \
 	repeat \
 	seq \
 	seq2 \
 	seq3 \
 	seq4 \
 	sg \
-	tc_loop \
 	tc_minimal \
 	tc_minimal2
 
-# We don't yet pass the following minimal model tests. The reason is that
-# they contain interactions between tabling and constructs that function
-# as committed or negated contexts.
+NONDET_LOOP_PROGS = \
+	tc_loop
+
+# We don't yet pass the following minimal model tests.
 #
-#	consumer_in_solutions
-#	oota
+#	consumer_in_solutions 	it contains interactions between tabling
+#				and constructs that function as committed
+#				or negated contexts.
+
+ALL_SIMPLE_PROGS = $(SIMPLE_NONLOOP_PROGS) $(SIMPLE_LOOP_PROGS)
+ALL_NONDET_PROGS = $(NONDET_NONLOOP_PROGS) $(NONDET_LOOP_PROGS)
 
 # Tabling does not yet work in .rt grades
 ifneq "$(findstring .gc,$(GRADE))" ""
 	ifneq "$(findstring .rt,$(GRADE))" ""
 		PROGS=
+		NONLOOP_PROGS=
 	else
 		ifneq "$(findstring .mm,$(GRADE))" ""
-			PROGS=$(SIMPLE_PROGS) $(NONDET_PROGS)
+			PROGS=$(ALL_SIMPLE_PROGS) $(ALL_NONDET_PROGS)
+			NONLOOP_PROGS=$(SIMPLE_NONLOOP_PROGS) \
+				$(NONDET_NONLOOP_PROGS)
 		else
-			PROGS=$(SIMPLE_PROGS)
+			PROGS=$(ALL_SIMPLE_PROGS)
+			NONLOOP_PROGS=$(SIMPLE_NONLOOP_PROGS)
 		endif
 	endif
 else
@@ -103,5 +114,21 @@
 			< $@.tmp > $@; \
 		rm -f $@.tmp; \
 	fi
+
+.PHONY: echo_progs
+echo_progs:
+	@echo $(PROGS)
+
+.PHONY: echo_nonloop_progs
+echo_nonloop_progs:
+	@echo $(NONLOOP_PROGS)
+
+.PHONY: echo_nondet_nonloop_progs
+echo_nondet_nonloop_progs:
+	@echo $(NONDET_NONLOOP_PROGS)
+
+.PHONY: echo_simple_nonloop_progs
+echo_simple_nonloop_progs:
+	@echo $(SIMPLE_NONLOOP_PROGS)
 
 #-----------------------------------------------------------------------------#
Index: tests/tabling/test_tabling
===================================================================
RCS file: tests/tabling/test_tabling
diff -N tests/tabling/test_tabling
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ tests/tabling/test_tabling	15 Mar 2004 05:14:15 -0000
@@ -0,0 +1,60 @@
+#!/bin/sh
+#
+# A script to test all the test cases in this directory using the setup
+# (runtime, library, compiler etc) from a given workspace. The workspace
+# is specified via the mmc command to execute to create the test case
+# executables; it is intended that this command be a wrapper around tools/lmc.
+
+case $# in
+	1)	mmc_cmd=$1
+		;;
+	*)	echo "usage: test_tabling mmc_cmd"
+		exit 1
+		;;
+esac
+
+set -x
+
+status=0
+failed=""
+testcases=`mmake echo_nondet_nonloop_progs echo_simple_nonloop_progs`
+for testcase in $testcases
+do
+	echo "testing $testcase"
+
+	if $mmc_cmd --grade asm_fast.gc.mm $testcase.m
+	then
+		if test -f $testcase.inp
+		then
+			inputfile=$testcase.inp
+		else
+			inputfile="/dev/null"
+		fi
+
+		if ./$testcase < $inputfile > $testcase.out
+		then
+			diff -u $testcase.exp $testcase.out > $testcase.res
+			if test -s $testcase.res
+			then
+				echo "$testcase generated unexpected output"
+				failed="$failed $testcase"
+				status=1
+			fi
+		else
+			echo "execution of $testcase failed"
+			failed="$failed $testcase"
+			status=1
+		fi
+	else
+		echo "compilation of $testcase failed"
+		status=1
+		failed="$failed $testcase"
+	fi
+done
+
+if test "$failed" != ""
+then
+	echo "failed test cases: $failed"
+fi
+
+exit $status
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list