(*
- * Copyright 2010, INRIA, University of Copenhagen
+ * Copyright 2012, INRIA
+ * Julia Lawall, Gilles Muller
+ * Copyright 2010-2011, INRIA, University of Copenhagen
* Julia Lawall, Rene Rydhof Hansen, Gilles Muller, Nicolas Palix
* Copyright 2005-2009, Ecole des Mines de Nantes, University of Copenhagen
* Yoann Padioleau, Julia Lawall, Rene Rydhof Hansen, Henrik Stuart, Gilles Muller, Nicolas Palix
*)
+# 0 "./testing.ml"
open Common
open Sexplib
| Some (Some outfile) ->
if List.length res > 1
then pr2 ("note that not just " ^ cfile ^ " was involved");
-
- let tmpfile = "/tmp/"^Common.basename cfile in
+ let tmpfile = sprintf "%s/%s" Filename.temp_dir_name (Common.basename cfile) in
pr2 (sprintf "One file modified. Result is here: %s" tmpfile);
Common.command2 ("mv "^outfile^" "^tmpfile);
tmpfile
* (via -testall). Fortunately such bugs are rare.
*
*)
-let testall ?(expected_score_file="tests/SCORE_expected.sexp") () =
+let testall expected_score_file update_score_file =
let score = empty_score () in
let cocci_file = "tests/" ^ base ^ ".cocci" in
let expected = "tests/" ^ res in
- let timeout_testall = 30 in
+ let timeout_testall = 60 in
try (
Common.timeout_function timeout_testall (fun () ->
else begin
pr2 "Current score is greater than expected :)";
pr2 (spf "(was expecting %d but got %d)" expected_good good);
- pr2 "Generating new expected score file and saving old one";
- Common.command2_y_or_no_exit_if_no
- (spf "mv %s %s" expected_score_file (expected_score_file ^ ".save"));
- Common.command2_y_or_no_exit_if_no
- (spf "mv %s %s" best_of_both_file expected_score_file);
+ if update_score_file then
+ begin
+ pr2 "Generating new expected score file and saving old one";
+ Common.command2_y_or_no_exit_if_no
+ (spf "mv %s %s" expected_score_file (expected_score_file ^ ".save"));
+ Common.command2_y_or_no_exit_if_no
+ (spf "mv %s %s" best_of_both_file expected_score_file);
+ end;
+
+ (* when there are sufficient number of tests, abort if a substantial
+ * amount of tests fail, which would indicate a broken build.
+ *)
+ if total > 40 && good < (total * 3) / 4
+ then begin
+ pr2 "Still, less 75% the tests passed. Returning a nonzero exist status.";
+ raise (UnixExit 1);
+ end;
+
raise (UnixExit 0);
end
let delete_previous_result_files infile =
[Ok;SpatchOK;Failed] +> List.iter (fun kind ->
- Common.command2 ("rm -f " ^ infile ^ t_to_s kind)
+ Common.remove_file (infile ^ t_to_s kind)
)
(* quite similar to compare_with_expected below *)
let newscore = Common.empty_score () in
let oks =
- Common.cmd_to_list ("find -name \"*.ok\"")
+ Common.cmd_to_list ("find . -name \"*.ok\"")
++
- Common.cmd_to_list ("find -name \"*.spatch_ok\"")
+ Common.cmd_to_list ("find . -name \"*.spatch_ok\"")
in
- let failed = Common.cmd_to_list ("find -name \"*.failed\"") in
+ let failed = Common.cmd_to_list ("find . -name \"*.failed\"") in
if null (oks ++ failed)
then failwith "no ok/failed file, you certainly did a make clean"
(if !Flag.scanner = Flag.Glimpse then "glimpse" else "google");
(match query with
None -> pr "No query"
- | Some x -> pr (String.concat " ||\n" x))
+ | Some x -> pr (String.concat "\nor on glimpse failure\n" x))