@@ -4153,8 +4153,7 @@ fn test_ls_dangling_symlinks() {
41534153#[ test]
41544154#[ cfg( feature = "feat_selinux" ) ]
41554155fn test_ls_context1 ( ) {
4156- use selinux:: { self , KernelSupport } ;
4157- if selinux:: kernel_support ( ) == KernelSupport :: Unsupported {
4156+ if !uucore:: selinux:: is_selinux_enabled ( ) {
41584157 println ! ( "test skipped: Kernel has no support for SElinux context" ) ;
41594158 return ;
41604159 }
@@ -4169,8 +4168,7 @@ fn test_ls_context1() {
41694168#[ test]
41704169#[ cfg( feature = "feat_selinux" ) ]
41714170fn test_ls_context2 ( ) {
4172- use selinux:: { self , KernelSupport } ;
4173- if selinux:: kernel_support ( ) == KernelSupport :: Unsupported {
4171+ if !uucore:: selinux:: is_selinux_enabled ( ) {
41744172 println ! ( "test skipped: Kernel has no support for SElinux context" ) ;
41754173 return ;
41764174 }
@@ -4183,11 +4181,30 @@ fn test_ls_context2() {
41834181 }
41844182}
41854183
4184+ #[ test]
4185+ #[ cfg( feature = "feat_selinux" ) ]
4186+ fn test_ls_context_long ( ) {
4187+ if !uucore:: selinux:: is_selinux_enabled ( ) {
4188+ return ;
4189+ }
4190+ let scene = TestScenario :: new ( util_name ! ( ) ) ;
4191+ let at = & scene. fixtures ;
4192+ at. touch ( "foo" ) ;
4193+ for c_flag in [ "-Zl" , "-Zal" ] {
4194+ let result = scene. ucmd ( ) . args ( & [ c_flag, "foo" ] ) . succeeds ( ) ;
4195+
4196+ let line: Vec < _ > = result. stdout_str ( ) . split ( " " ) . collect ( ) ;
4197+ assert ! ( line[ 0 ] . ends_with( "." ) ) ;
4198+ assert ! ( line[ 4 ] . starts_with( "unconfined_u" ) ) ;
4199+ let s: Vec < _ > = line[ 4 ] . split ( ":" ) . collect ( ) ;
4200+ assert ! ( s. len( ) == 4 ) ;
4201+ }
4202+ }
4203+
41864204#[ test]
41874205#[ cfg( feature = "feat_selinux" ) ]
41884206fn test_ls_context_format ( ) {
4189- use selinux:: { self , KernelSupport } ;
4190- if selinux:: kernel_support ( ) == KernelSupport :: Unsupported {
4207+ if !uucore:: selinux:: is_selinux_enabled ( ) {
41914208 println ! ( "test skipped: Kernel has no support for SElinux context" ) ;
41924209 return ;
41934210 }
0 commit comments