@@ -506,30 +506,33 @@ let check f =
506
506
507
507
let error_count = ref 0
508
508
509
- let rec explore_all func trie =
509
+ let explore_one func trie =
510
510
let empty_schedule = [{ proc_id = [] ; op = Start ; obj_ptr = None }] in
511
511
setup_run func empty_schedule trie ;
512
512
let empty_state = do_run empty_schedule :: [] in
513
513
let empty_last_access = IdMap. empty, IdMap. empty in
514
- let has_error, trie =
515
- explore func 1 empty_state trie empty_schedule empty_last_access
516
- in
517
- match T. min_depth trie with
518
- | None ->
519
- assert (T. nb_todos trie = 0 ) ;
520
- T. graphviz ~filename: " /tmp/dscheck.dot" trie ;
521
- trie
522
- | _ when has_error ->
523
- error_count := ! error_count + 1 ;
524
- T. graphviz ~filename: " /tmp/dscheck.dot" trie ;
525
- if ! error_count > = 5
526
- then trie
527
- else explore_all func trie
528
- | Some _ -> explore_all func trie
529
-
530
- let trace func =
514
+ explore func 1 empty_state trie empty_schedule empty_last_access
515
+
516
+ let rec explore_all ~count ~errors func trie =
517
+ if ! error_count > = errors
518
+ || ! num_runs > = count
519
+ || T. nb_todos trie = 0
520
+ then trie (* graphviz_output ?graphviz trie *)
521
+ else begin
522
+ let has_error, trie = explore_one func trie in
523
+ if has_error then error_count := ! error_count + 1 ;
524
+ explore_all ~count ~errors func trie
525
+ end
526
+
527
+ let graphviz_output ?graphviz trie =
528
+ match graphviz with
529
+ | None -> ()
530
+ | Some filename -> T. graphviz ~filename trie
531
+
532
+ let trace ?(count = max_int) ?(errors = 1 ) ?graphviz func =
531
533
print_header () ;
532
534
num_runs := 0 ;
533
- let _ = explore_all func T. todo in
535
+ let trie = explore_all ~count ~errors func T. todo in
536
+ graphviz_output ?graphviz trie ;
534
537
Format. printf " @.Found %#i errors after %#i runs.@." ! error_count ! num_runs ;
535
538
()
0 commit comments