@@ -7,25 +7,25 @@ fn arch_nonnative() -> Arch {
77 }
88}
99
10- #[ cfg( feature = "libseccomp-2-4" ) ]
11- static ACTIONS : & [ Action ] = & [
12- Action :: Allow ,
13- Action :: KillProcess ,
14- Action :: KillThread ,
15- Action :: Log ,
16- Action :: Errno ( libc:: EPERM ) ,
17- ] ;
18-
19- #[ cfg( not( feature = "libseccomp-2-4" ) ) ]
20- static ACTIONS : & [ Action ] = & [
21- Action :: Allow ,
22- Action :: KillThread ,
23- Action :: Errno ( libc:: EPERM ) ,
24- ] ;
25-
2610#[ test]
2711fn test_default_action ( ) {
28- for action in ACTIONS . iter ( ) . copied ( ) {
12+ let actions = if libscmp:: libseccomp_version ( ) >= ( 2 , 4 , 0 ) {
13+ & [
14+ Action :: Allow ,
15+ Action :: KillProcess ,
16+ Action :: KillThread ,
17+ Action :: Log ,
18+ Action :: Errno ( libc:: EPERM ) ,
19+ ] [ ..]
20+ } else {
21+ & [
22+ Action :: Allow ,
23+ Action :: KillThread ,
24+ Action :: Errno ( libc:: EPERM ) ,
25+ ] [ ..]
26+ } ;
27+
28+ for action in actions. iter ( ) . copied ( ) {
2929 assert_eq ! (
3030 Filter :: new( action) . unwrap( ) . get_default_action( ) . unwrap( ) ,
3131 action
@@ -52,20 +52,21 @@ fn test_badarch_action() {
5252 }
5353}
5454
55- #[ cfg( feature = "libseccomp-2-5" ) ]
56- static FLAGS : & [ Flag ] = & [ Flag :: NoNewPrivs , Flag :: Log , Flag :: SysRawRC ] ;
57-
58- #[ cfg( all( feature = "libseccomp-2-4" , not( feature = "libseccomp-2-5" ) ) ) ]
59- static FLAGS : & [ Flag ] = & [ Flag :: NoNewPrivs , Flag :: Log ] ;
60-
61- #[ cfg( not( feature = "libseccomp-2-4" ) ) ]
62- static FLAGS : & [ Flag ] = & [ Flag :: NoNewPrivs ] ;
63-
6455#[ test]
6556fn test_get_set_flags ( ) {
6657 let mut filter = Filter :: new ( Action :: Allow ) . unwrap ( ) ;
6758
68- for flag in FLAGS . iter ( ) . copied ( ) {
59+ let version = libscmp:: libseccomp_version ( ) ;
60+
61+ let flags = if version >= ( 2 , 5 , 0 ) {
62+ & [ Flag :: NoNewPrivs , Flag :: Log , Flag :: SysRawRC ] [ ..]
63+ } else if version >= ( 2 , 4 , 0 ) {
64+ & [ Flag :: NoNewPrivs , Flag :: Log ] [ ..]
65+ } else {
66+ & [ Flag :: NoNewPrivs ] [ ..]
67+ } ;
68+
69+ for flag in flags. iter ( ) . copied ( ) {
6970 let orig_val = filter. get_flag ( flag) . unwrap ( ) ;
7071
7172 for val in [ true , false , orig_val] . iter ( ) . copied ( ) {
0 commit comments