[m-rev.] diff: fix bug in MERCURY_OPTIONS handling
Mark Brown
mark at csse.unimelb.edu.au
Mon Aug 28 20:12:35 AEST 2006
Estimated hours taken: 3
Branches: main, release
Fix a bug in the handling of unrecognised runtime flags.
runtime/mercury_wrapper.c:
Add the required sentinel at the end of MR_long_opts.
Allow "det-stack-*" and "nondet-stack-*" as synonyms for
"detstack-*" and "nondetstack-*" respectively.
tests/hard_coded/Mmakefile:
tests/hard_coded/runtime_opt.exp:
tests/hard_coded/runtime_opt.inp:
tests/hard_coded/runtime_opt.m:
Test case for both recognised and unrecognised options. The options
to attempt are listed one per line in runtime_opt.inp.
Index: runtime/mercury_wrapper.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_wrapper.c,v
retrieving revision 1.164
diff -u -r1.164 mercury_wrapper.c
--- runtime/mercury_wrapper.c 15 Aug 2006 04:19:39 -0000 1.164
+++ runtime/mercury_wrapper.c 28 Aug 2006 08:00:09 -0000
@@ -1049,9 +1049,13 @@
{ "heap-size", 1, 0, MR_HEAP_SIZE },
{ "heap-size-kwords", 1, 0, MR_HEAP_SIZE_KWORDS },
{ "detstack-size", 1, 0, MR_DETSTACK_SIZE },
+ { "det-stack-size", 1, 0, MR_DETSTACK_SIZE },
{ "detstack-size-kwords", 1, 0, MR_DETSTACK_SIZE_KWORDS },
+ { "det-stack-size-kwords", 1, 0, MR_DETSTACK_SIZE_KWORDS },
{ "nondetstack-size", 1, 0, MR_NONDETSTACK_SIZE },
+ { "nondet-stack-size", 1, 0, MR_NONDETSTACK_SIZE },
{ "nondetstack-size-kwords", 1, 0, MR_NONDETSTACK_SIZE_KWORDS },
+ { "nondet-stack-size-kwords", 1, 0, MR_NONDETSTACK_SIZE_KWORDS },
{ "solutions-heap-size", 1, 0, MR_SOLUTIONS_HEAP_SIZE },
{ "solutions-heap-size-kwords", 1, 0, MR_SOLUTIONS_HEAP_SIZE_KWORDS },
{ "trail-size", 1, 0, MR_TRAIL_SIZE },
@@ -1059,11 +1063,17 @@
{ "heap-redzone-size", 1, 0, MR_HEAP_REDZONE_SIZE },
{ "heap-redzone-size-kwords", 1, 0, MR_HEAP_REDZONE_SIZE_KWORDS },
{ "detstack-redzone-size", 1, 0, MR_DETSTACK_REDZONE_SIZE },
+ { "det-stack-redzone-size", 1, 0, MR_DETSTACK_REDZONE_SIZE },
{ "detstack-redzone-size-kwords",
1, 0, MR_DETSTACK_REDZONE_SIZE_KWORDS },
+ { "det-stack-redzone-size-kwords",
+ 1, 0, MR_DETSTACK_REDZONE_SIZE_KWORDS },
{ "nondetstack-redzone-size", 1, 0, MR_NONDETSTACK_REDZONE_SIZE },
+ { "nondet-stack-redzone-size", 1, 0, MR_NONDETSTACK_REDZONE_SIZE },
{ "nondetstack-redzone-size-kwords",
1, 0, MR_NONDETSTACK_REDZONE_SIZE_KWORDS },
+ { "nondet-stack-redzone-size-kwords",
+ 1, 0, MR_NONDETSTACK_REDZONE_SIZE_KWORDS },
{ "solutions-heap-redzone-size",1, 0, MR_SOLUTIONS_HEAP_REDZONE_SIZE },
{ "solutions-heap-redzone-size-kwords",
1, 0, MR_SOLUTIONS_HEAP_REDZONE_SIZE_KWORDS },
@@ -1102,7 +1112,10 @@
{ "tabling-statistics", 0, 0, MR_TABLING_STATISTICS_OPT },
{ "trace-count", 0, 0, MR_TRACE_COUNT_OPT },
{ "coverage-test", 0, 0, MR_COVERAGE_TEST_OPT },
- { "mem-usage-report", 0, 0, MR_MEM_USAGE_REPORT }
+ { "mem-usage-report", 0, 0, MR_MEM_USAGE_REPORT },
+
+ /* This needs to be kept at the end. */
+ { NULL, 0, 0, 0 }
};
static void
Index: tests/hard_coded/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/Mmakefile,v
retrieving revision 1.292
diff -u -r1.292 Mmakefile
--- tests/hard_coded/Mmakefile 9 Aug 2006 01:49:41 -0000 1.292
+++ tests/hard_coded/Mmakefile 28 Aug 2006 08:57:44 -0000
@@ -174,6 +174,7 @@
rtc_bug \
rtree_test \
rtti_strings \
+ runtime_opt \
setjmp_test \
shift_test \
solve_quadratic \
@@ -621,6 +622,19 @@
# intermod_unused_args.m.
intermod_unused_args.c: intermod_unused_args2.c
+# The runtime_opt test needs to be run a number of different times with the
+# MERCURY_OPTIONS environment variable set to a different value each time.
+# The options to try are in runtime_opt.inp, one per line. The .out file
+# is created by concatenating all of the outputs from each run.
+runtime_opt.out: runtime_opt runtime_opt.inp
+ ( \
+ for option in `cat runtime_opt.inp`; do \
+ echo "Option \`$$option':"; \
+ MERCURY_OPTIONS="$$option" ./runtime_opt 2>&1 || true; \
+ echo ""; \
+ done \
+ ) > runtime_opt.out 2>&1
+
#-----------------------------------------------------------------------------#
dir_test.out: prepare_for_dir_test
Index: tests/hard_coded/runtime_opt.exp
===================================================================
RCS file: tests/hard_coded/runtime_opt.exp
diff -N tests/hard_coded/runtime_opt.exp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/runtime_opt.exp 28 Aug 2006 08:59:30 -0000
@@ -0,0 +1,15 @@
+Option `--nondetstack-size-kwords=256':
+Hello world (with non-standard options).
+
+Option `--nondet-stack-size-kwords=256':
+Hello world (with non-standard options).
+
+Option `--detstack-size=128':
+Hello world (with non-standard options).
+
+Option `--this-is-not-a-real-option':
+mercury_runtime: unrecognized option `--this-is-not-a-real-option'
+The MERCURY_OPTIONS environment variable contains an invalid option.
+Please refer to the Environment Variables section of the Mercury
+User's Guide for details.
+
Index: tests/hard_coded/runtime_opt.inp
===================================================================
RCS file: tests/hard_coded/runtime_opt.inp
diff -N tests/hard_coded/runtime_opt.inp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/runtime_opt.inp 28 Aug 2006 08:26:31 -0000
@@ -0,0 +1,4 @@
+--nondetstack-size-kwords=256
+--nondet-stack-size-kwords=256
+--detstack-size=128
+--this-is-not-a-real-option
Index: tests/hard_coded/runtime_opt.m
===================================================================
RCS file: tests/hard_coded/runtime_opt.m
diff -N tests/hard_coded/runtime_opt.m
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/hard_coded/runtime_opt.m 28 Aug 2006 08:20:19 -0000
@@ -0,0 +1,9 @@
+:- module runtime_opt.
+:- interface.
+:- import_module io.
+:- pred main(io::di, io::uo) is det.
+:- implementation.
+
+main(!IO) :-
+ io.write_string("Hello world (with non-standard options).\n", !IO).
+
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list