mirror of
https://github.com/uselessd/alcove.git
synced 2026-04-15 01:04:41 +00:00
Tests for execvp
Write data to and from the child process. Requires having busybox installed. Update the typespecs.
This commit is contained in:
@@ -153,7 +153,7 @@ static() ->
|
||||
static({stdin,2}) ->
|
||||
"
|
||||
stdin(Port, Data) ->
|
||||
alcove_drv:cast(Port, <<?UINT16(?ALCOVE_MSG_CHILDIN), Data/binary>>).
|
||||
alcove_drv:cast(Port, [<<?UINT16(?ALCOVE_MSG_CHILDIN)>>, Data]).
|
||||
";
|
||||
|
||||
static({stdout,1}) ->
|
||||
@@ -265,10 +265,10 @@ specs() ->
|
||||
-spec setrlimit(port(),non_neg_integer(),non_neg_integer(),non_neg_integer()) -> 'ok' | {'error', file:posix()}.
|
||||
-spec setrlimit(port(),non_neg_integer(),#rlimit{}) -> 'ok' | {'error', file:posix()}.
|
||||
-spec setuid(port(),non_neg_integer()) -> 'ok' | {'error', file:posix()}.
|
||||
-spec stderr(port()) -> any().
|
||||
-spec stderr(port(),'infinity' | non_neg_integer()) -> any().
|
||||
-spec stdin(port(),binary()) -> 'true'.
|
||||
-spec stdout(port()) -> any().
|
||||
-spec stdout(port(),'infinity' | non_neg_integer()) -> any().
|
||||
-spec stderr(port()) -> 'false' | binary().
|
||||
-spec stderr(port(),'infinity' | non_neg_integer()) -> 'false' | binary().
|
||||
-spec stdin(port(),iodata()) -> 'true'.
|
||||
-spec stdout(port()) -> 'false' | binary().
|
||||
-spec stdout(port(),'infinity' | non_neg_integer()) -> 'false' | binary().
|
||||
-spec version(port()) -> binary().
|
||||
".
|
||||
|
||||
@@ -27,13 +27,16 @@ erlxc_test_() ->
|
||||
}.
|
||||
|
||||
run(Port) ->
|
||||
% Test order must be maintained
|
||||
[
|
||||
version(Port),
|
||||
chroot(Port),
|
||||
chdir(Port),
|
||||
setrlimit(Port),
|
||||
setgid(Port),
|
||||
setuid(Port)
|
||||
setuid(Port),
|
||||
execvp(Port),
|
||||
stdin(Port)
|
||||
].
|
||||
|
||||
start() ->
|
||||
@@ -81,3 +84,20 @@ setuid(Port) ->
|
||||
?_assertEqual(ok, Reply),
|
||||
?_assertEqual(65534, UID)
|
||||
].
|
||||
|
||||
execvp(Port) ->
|
||||
% cwd = /, chroot'ed in /bin
|
||||
Reply = alcove:execvp(Port, "/busybox", ["/busybox", "sh", "-i"]),
|
||||
Stderr = alcove:stderr(Port, 5000),
|
||||
[
|
||||
?_assertEqual(ok, Reply),
|
||||
?_assertNotEqual(false, Stderr)
|
||||
].
|
||||
|
||||
stdin(Port) ->
|
||||
Reply = alcove:stdin(Port, "help\n"),
|
||||
Stdout = alcove:stdout(Port, 5000),
|
||||
[
|
||||
?_assertEqual(true, Reply),
|
||||
?_assertNotEqual(false, Stdout)
|
||||
].
|
||||
|
||||
Reference in New Issue
Block a user