Skip to content

Commit bf90b9e

Browse files
committed
cleaner version
1 parent 1a61ee5 commit bf90b9e

File tree

1 file changed

+4
-60
lines changed

1 file changed

+4
-60
lines changed

src/sys/stm_tests.ml

Lines changed: 4 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -60,25 +60,6 @@ struct
6060
else is_perm_ok tl path
6161
)
6262

63-
(* let rec find (fsl: filesys list) path name =
64-
match fsl with
65-
| [] -> None
66-
| Directory d :: tl ->
67-
(match path with
68-
| [] -> if d.dir_name = name
69-
then Some (Directory d)
70-
else find tl path name
71-
| hd_path :: tl_path -> if d.dir_name = hd_path
72-
then if d.perm > 447
73-
then find d.fs_list tl_path name
74-
else None
75-
else find tl path name)
76-
| File f :: _tl -> if path = [] && f.file_name = name
77-
then Some (File f)
78-
else None *)
79-
80-
81-
8263
let rec find fs path name =
8364
match fs with
8465
| File f -> path = [] && f.file_name = name
@@ -90,23 +71,6 @@ struct
9071
then List.exists (fun f -> find f tl name) d.fs_list
9172
else false
9273

93-
(* let rec mkdir (fsl: filesys list) path dir_name perm =
94-
match fsl with
95-
| [] -> []
96-
| Directory d :: tl -> (match path with
97-
| hd_path :: tl_path ->
98-
if (hd_path = d.dir_name) && (List.length path = 1)
99-
then (
100-
if perm > 447
101-
then (let update = Directory {d with fs_list =
102-
(Directory {perm; dir_name; fs_list = []} :: d.fs_list)} in
103-
update :: tl)
104-
else ( Directory d :: []))
105-
else if hd_path = d.dir_name
106-
then Directory {d with fs_list = (mkdir d.fs_list tl_path dir_name perm)} :: []
107-
else Directory d :: (mkdir tl path dir_name perm)
108-
| _ -> [])
109-
| File f :: tl -> File f :: (mkdir tl path dir_name perm) *)
11074
let get_name fs =
11175
match fs with
11276
| File f -> f.file_name
@@ -126,35 +90,21 @@ struct
12690
then Directory {d with fs_list = List.map (fun f -> mkdir f tl dir_name perm) d.fs_list}
12791
else fs
12892

129-
13093
let next_state c fs =
13194
match c with
13295
| File_exists (_path, _name) -> fs
13396
| Mkdir (path, dir_name, perm) ->
13497
if find fs path dir_name
13598
then fs
13699
else mkdir fs path dir_name perm
137-
(* | Mkdir (path, dir_name, perm) -> (match find fs path dir_name with
138-
| Some _ -> fs
139-
| None -> (match path with
140-
| _hd :: _tl -> let rev = List.rev path in
141-
(match find [fs] (List.rev (List.tl rev)) (List.hd rev) with
142-
| Some _ -> mkdir fs path dir_name perm
143-
| None -> fs)
144-
| _ -> Format.printf "Bonjour\n"; fs)) *)
145100

146101
let reset_root path = Sys.command ("rm -r -d -f " ^ path ^ " && sync")
147102

148-
let init_sut () = let content = Array.to_list (Sys.readdir (static_path)) in
149-
Format.printf "[initsut] content : %s\n%!" (String.concat " " content);
103+
let init_sut () =
150104
try Sys.mkdir (static_path ^ "/" ^ "root") 0o777 with Sys_error _ -> ()
151105

152106
let cleanup _ =
153-
Format.printf "___cleanup___\n";
154-
ignore (reset_root (static_path ^ "/" ^ "root"));
155-
let content = Array.to_list (Sys.readdir (static_path)) in
156-
Format.printf "[cleanup] content : %s\n%!" (String.concat " " content)
157-
107+
ignore (reset_root (static_path ^ "/" ^ "root"))
158108

159109
let precond _c _s = true
160110

@@ -167,7 +117,7 @@ struct
167117

168118
let postcond c (fs: filesys) res =
169119
let p path dir_name = static_path ^ "/" ^ (String.concat "/" path) ^ "/" ^ dir_name in
170-
Format.printf "\n\ncmd : %s \t\tfs : %s\n" (show_cmd c) (show_filesys fs);
120+
(* Format.printf "\n\ncmd : %s \t\tfs : %s\n" (show_cmd c) (show_filesys fs); *)
171121
match c, res with
172122
| File_exists (path, name), Res ((Bool,_),b) ->
173123
b = file_exists fs path name
@@ -180,13 +130,7 @@ struct
180130

181131
| Mkdir (path, dir_name, _perm), Res ((Result (Unit,Exn),_), Error (Sys_error (s) ))
182132
when s = (p path dir_name) ^ ": File exists" ->
183-
Format.printf "---- %s existe deja\t\t\n\n 1\t fs = %s\n\n" dir_name (show_filesys fs);
184133
let b = file_exists fs path dir_name in
185-
(* Format.printf "taille de fsstr : %d \t\test ce que le dossier est deja dans state ? %b\n" (String.length) b; *)
186-
if not b then
187-
(
188-
Format.printf "\n AAAAAAAAAAAAAAAAAAAAAAAAAH c = %s\n\n" (show_cmd c)
189-
);
190134
assert (b);
191135
b
192136

@@ -218,7 +162,7 @@ module SysSTM = STM.Make(SConf)
218162
Util.set_ci_printing ()
219163
;;
220164
QCheck_base_runner.run_tests_main
221-
(let count = 10 in
165+
(let count = 1000 in
222166
[SysSTM.agree_test ~count ~name:"STM Sys test sequential";
223167
(* SysSTM.neg_agree_test_par ~count ~name:"STM Sys test parallel" *)
224168
])

0 commit comments

Comments
 (0)