Skip functionality test if seccomp_load returns -EINVAL
[linux-seccomp.git] / t / Linux-Seccomp.t
index 771d41e4851f9b92e87d98b8bb3975360cfa1c91..ee1737f939dfc0c28de96c33933e6caf6834f081 100644 (file)
@@ -2,8 +2,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 2;
-BEGIN { use_ok('Linux::Seccomp') };
+use Errno qw/EINVAL/;
+use Test::More tests => 4;
+BEGIN { use_ok('Linux::Seccomp', ':all') };
 
 
 my $fail = 0;
@@ -122,3 +123,20 @@ foreach my $constname (qw(
 }
 
 ok( $fail == 0 , 'Constants' );
+
+is_deeply version, [2, 3, 1], 'library version is 2.3.1';
+
+my $got_sigsys = 0;
+$SIG{SYS} = sub { $got_sigsys = 1 };
+
+my $ctx = Linux::Seccomp->new(SCMP_ACT_ALLOW);
+$ctx->rule_add(SCMP_ACT_TRAP, syscall_resolve_name('mkdir'));
+my $result = $ctx->load;
+
+SKIP: {
+       skip 'loading filter fails with EINVAL -- does your kernel have CONFIG_SECCOMP_FILTER=y?'
+         if $result == -EINVAL;
+
+       mkdir 'testdir';
+       ok $got_sigsys, 'filter with SCMP_ACT_TRAP on mkdir() works';
+}
This page took 0.009657 seconds and 4 git commands to generate.