[m-rev.] for review: mdprof_test --verify-profile
Julien Fischer
juliensf at cs.mu.OZ.AU
Wed Aug 10 14:08:21 AEST 2005
For review by anyone.
Estimated hours taken: 0.5
Branches: main
Add a new mode of operation, '--verify-profile', to mdprof_test.
When run in this mode, mdprof_test reads in a deep profile and
tests that it is well-formed by running the usual startup
procedure on it. It does not create a server process.
The intention is to use this in the test suite when testing
the .profdeep grades, e.g to prevent the situation where a
test case is passing but the Deep.data file it generates
is invalid.
deep_profiler/mdprof_test.m:
Add an option '--verify-profile' that causes to
mdprof_test to run in verification mode.
Julien.
Index: mdprof_test.m
===================================================================
RCS file: /home/mercury1/repository/mercury/deep_profiler/mdprof_test.m,v
retrieving revision 1.8
diff -u -r1.8 mdprof_test.m
--- mdprof_test.m 23 Jun 2005 08:21:29 -0000 1.8
+++ mdprof_test.m 10 Aug 2005 04:01:10 -0000
@@ -58,6 +58,7 @@
MaybeOptions = ok(Options),
lookup_bool_option(Options, help, Help),
lookup_bool_option(Options, version, Version),
+ lookup_bool_option(Options, verify_profile, Verify),
(
Help = yes,
write_help_message(ProgName, !IO)
@@ -74,7 +75,13 @@
Help = no,
Version = no
->
- main2(ProgName, Args, Options, !IO)
+ (
+ Verify = no,
+ main2(ProgName, Args, Options, !IO)
+ ;
+ Verify = yes,
+ verify_profile(ProgName, Options, !IO)
+ )
;
true
)
@@ -85,6 +92,8 @@
[s(ProgName), s(Msg)], !IO)
).
+%-----------------------------------------------------------------------------%
+
:- pred main2(string::in, list(string)::in, option_table::in,
io::di, io::uo) is cc_multi.
@@ -125,6 +134,35 @@
write_help_message(ProgName, !IO)
).
+
+%-----------------------------------------------------------------------------%
+%
+% Verification mode
+%
+
+% In this mode of operation mdprof_test just checks to see if the deep
+% profiler can read and process a Deep.data file, i.e do everything
+% it needs to up to the point where we normally start querying a profile.
+% This mode does not cause a server to be started.
+
+:- pred verify_profile(string::in, option_table::in, io::di, io::uo) is det.
+
+verify_profile(ProgName, Options, !IO) :-
+ lookup_bool_option(Options, canonical_clique, Canonical),
+ Machine = "dummy", % For verification this doesn't matter.
+ FileName = "Deep.data",
+ read_and_startup(Machine, [FileName], Canonical, no, [], Res, !IO),
+ (
+ Res = ok(_Deep)
+ ;
+ Res = error(Error),
+ io.set_exit_status(1, !IO),
+ io.format("%s: error reading data file: %s\n",
+ [s(ProgName), s(Error)], !IO)
+ ).
+
+%-----------------------------------------------------------------------------%
+
:- pred write_version_message(string::in, io::di, io::uo) is det.
write_version_message(ProgName, !IO) :-
@@ -146,6 +184,14 @@
io__format("--verbose Generate progress messages during startup.\n", []),
io__format("--test Test the deep profiler, generating all\n", []),
io__format(" possible web pages of the popular types.\n", []),
+ io__format("--verify-profile\n", []),
+ io__format(" Verify that any file named Deep.data in the\n",
+ []),
+ io__format(" current directory is a well-formed deep\n", []),
+ io__format(" profiling data file. The <filename> argument\n",
+ []),
+ io__format(" is ignored.\n", []),
+ io.nl,
io__format("You may also specify the following options:.\n", []),
io__format("--test-dir <dirname>\n", []),
io__format(" Put the generated web pages into <dirname>.\n",
@@ -234,7 +280,8 @@
; test
; test_dir
; verbose
- ; version.
+ ; version
+ ; verify_profile.
:- type options ---> options.
:- type option_table == (option_table(option)).
@@ -256,6 +303,7 @@
long("test-dir", test_dir).
long("verbose", verbose).
long("version", version).
+long("verify-profile", verify_profile).
:- pred defaults(option::out, option_data::out) is multi.
@@ -266,6 +314,7 @@
defaults(test_dir, string("deep_test")).
defaults(verbose, bool(no)).
defaults(version, bool(no)).
+defaults(verify_profile, bool(no)).
%-----------------------------------------------------------------------------%
:- end_module mdprof_test.
--------------------------------------------------------------------------
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