Skip to content

Commit

Permalink
[tests] Run the tests as the current user, without needing root.
Browse files Browse the repository at this point in the history
The sockets are placed in the _build directory rather than global
directories.
  • Loading branch information
avsm authored and andrenth committed Dec 2, 2013
1 parent 990232a commit d1ec148
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib_test/helper.ml
Expand Up @@ -35,4 +35,4 @@ let main fd =
let () =
ignore (Lwt_unix.on_signal Sys.sigterm handle_sigterm);
Random.self_init ();
Release.me ~syslog:false ~user:"andre" ~main:main ()
Release.me ~syslog:false ~main:main ()
5 changes: 3 additions & 2 deletions lib_test/master.ml
Expand Up @@ -44,10 +44,11 @@ let () =
let slave_cmd = (slave_exec, [||]) in
let helper_cmd = (helper_exec, [||]) in
Release.master_slaves
~privileged:false
~background:false
~syslog:false
~lock_file:(sprintf "/var/run/%s.pid" (Filename.basename Sys.argv.(0)))
~control:("/tmp/master.socket", control_connection_handler)
~lock_file:(sprintf "./_build/release%s.pid" (Filename.basename Sys.executable_name))
~control:("./_build/master.socket", control_connection_handler)
~main:store_slave_connections
~slaves:[ slave_cmd, ipc_handler, 1
; helper_cmd, lwt_ignore, 1 ]
Expand Down
6 changes: 1 addition & 5 deletions lib_test/masterctl.ml
Expand Up @@ -9,13 +9,9 @@ let response_handler res =
| _ -> Lwt_io.printl "! bad response"

let () =
if Unix.geteuid () <> 0 then begin
prerr_endline "masterctl must be run as root";
exit 1
end;
let request_t =
let sock = Lwt_unix.socket Unix.PF_UNIX Unix.SOCK_STREAM 0 in
let sock_addr = Lwt_unix.ADDR_UNIX "/tmp/master.socket" in
let sock_addr = Lwt_unix.ADDR_UNIX "_build/master.socket" in
lwt () = Lwt_unix.connect sock sock_addr in
let str = "example" in
lwt () = Lwt_io.printlf "> %s" str in
Expand Down
2 changes: 1 addition & 1 deletion lib_test/slave.ml
Expand Up @@ -52,4 +52,4 @@ let sleep _ =

let () =
Random.self_init ();
Release.me ~syslog:false ~user:"andre" ~main:main ()
Release.me ~syslog:false ~main ()

0 comments on commit d1ec148

Please sign in to comment.