Skip to content

Commit b918322

Browse files
committed
working before add permission
1 parent 6323773 commit b918322

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/sys/stm_tests.ml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ struct
1414

1515
module Map_names = Map.Make (String)
1616

17+
type permission = {
18+
owner: int;
19+
group: int;
20+
other: int;
21+
}
22+
1723
type filesys =
1824
| Directory of {perm: int; fs_map: filesys Map_names.t}
1925
| File of {perm: int}
@@ -147,24 +153,24 @@ struct
147153
then fs
148154
else touch fs path new_file_name perm
149155

150-
(* let init_sut () = try Sys.mkdir (static_path / "sandbox_root") 0o777 with Sys_error _ -> () *)
151-
let init_sut () = ignore(Sys.command ("rm -rf " ^ (static_path / "sandbox_root") ^ " && mkdir " ^ (static_path / "sandbox_root")))
156+
let init_sut () = ignore(Sys.command ("rm -rf " ^ (static_path / "sandbox_root") ^ " && mkdir " ^ (static_path / "sandbox_root")))
152157

153-
(* let cleanup _ = ignore (Sys.command ("tree " ^ static_path ^ "/sandbox_root && rm -r -d -f " ^ static_path ^ "/sandbox_root")) *)
154158
let cleanup _ = ignore (Sys.command ("rm -r -d -f " ^ static_path ^ "/sandbox_root"))
155159

156160
let precond _c _s = true
157161

158-
let run c _file_name = match c with
159-
| File_exists (path) -> Res (bool, Sys.file_exists (static_path / "sandbox_root" / (List.fold_left (/) "" path)))
162+
let run c _file_name =
163+
let p path = static_path / "sandbox_root" / (List.fold_left (/) "" path) in
164+
match c with
165+
| File_exists (path) -> Res (bool, Sys.file_exists (p path))
160166
| Mkdir (path, new_dir_name, perm) ->
161-
Res (result unit exn, protect (Sys.mkdir (static_path / "sandbox_root" / (List.fold_left (/) "" path) / new_dir_name))perm)
167+
Res (result unit exn, protect (Sys.mkdir ((p path) / new_dir_name))perm)
162168
| Rmdir (path, delete_dir_name) ->
163-
Res (result unit exn, protect (Sys.rmdir) (static_path / "sandbox_root" / (List.fold_left (/) "" path) / delete_dir_name))
169+
Res (result unit exn, protect (Sys.rmdir) ((p path) / delete_dir_name))
164170
| Readdir (path) ->
165-
Res (result (array string) exn, protect (Sys.readdir) (static_path / "sandbox_root" / (List.fold_left (/) "" path)))
171+
Res (result (array string) exn, protect (Sys.readdir) (p path))
166172
| Touch (path, new_file_name, _perm) ->
167-
Res (unit, ignore(Sys.command ("touch " ^ static_path / "sandbox_root" / (List.fold_left (/) "" path) / new_file_name ^ " 2>/dev/null")))
173+
Res (unit, ignore(Sys.command ("touch " ^ (p path) / new_file_name ^ " 2>/dev/null")))
168174

169175
let is_a_dir fs = match fs with | Directory _ -> true | File _ -> false
170176

0 commit comments

Comments
 (0)