Add some tests
This commit is contained in:
parent
0e381fbcc4
commit
13b8f0e253
3 changed files with 38 additions and 2 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,5 +1,5 @@
|
|||
jail_root/*
|
||||
test.log
|
||||
.build
|
||||
App-EvalServerAdvanced-*
|
||||
Sys-Linux-Syscall-*
|
||||
testsandbox
|
||||
|
|
|
@ -2,12 +2,14 @@ package Sys::Linux::Syscall::Execve;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Data::Dumper;
|
||||
use Linux::Seccomp qw/syscall_resolve_name/;
|
||||
use Encode qw/decode/;
|
||||
use Exporter qw/import/;
|
||||
|
||||
our $VERSION = "0.10";
|
||||
|
||||
our @EXPORT_OK = qw/execve execve_env execve_byref/;
|
||||
|
||||
my $ptr_int_type;
|
||||
my $ptr_int_size;
|
||||
my $execve_syscall = syscall_resolve_name('execve');
|
||||
|
|
34
t/execve.t
Normal file
34
t/execve.t
Normal file
|
@ -0,0 +1,34 @@
|
|||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Test::More;
|
||||
use Sys::Linux::Syscall::Execve qw/execve/;
|
||||
use POSIX qw/_exit/;
|
||||
|
||||
sub test_exec {
|
||||
my $cmd = shift;
|
||||
|
||||
if (!-x $cmd) {
|
||||
return 42;
|
||||
}
|
||||
|
||||
my $pid = fork();
|
||||
|
||||
die "Couldn't fork: $!" unless defined $pid;
|
||||
|
||||
if ($pid) {
|
||||
waitpid $pid;
|
||||
return $?>>8;
|
||||
} else {
|
||||
execve($cmd);
|
||||
_exit 42; # shibboleet;
|
||||
}
|
||||
}
|
||||
|
||||
my $ret = test_exec("/bin/true");
|
||||
is($ret, 0, "Executed /bin/true");
|
||||
|
||||
$ret = test_exec("/bin/false");
|
||||
is($ret, 1, "Executed /bin/false");
|
||||
|
||||
done_testing;
|
Loading…
Add table
Reference in a new issue