@@ -3117,9 +3117,8 @@ fn test_cp_archive_on_nonexistent_file() {
31173117 . arg ( TEST_NONEXISTENT_FILE )
31183118 . arg ( TEST_EXISTING_FILE )
31193119 . fails ( )
3120- . stderr_only (
3121- "cp: cannot stat 'nonexistent_file.txt': No such file or directory (os error 2)\n " ,
3122- ) ;
3120+ . stderr_contains ( "cannot stat 'nonexistent_file.txt'" )
3121+ . stderr_contains ( "No such file or directory" ) ;
31233122}
31243123
31253124#[ test]
@@ -7479,32 +7478,53 @@ fn test_cp_xattr_enotsup_handling() {
74797478 let at = & scene. fixtures ;
74807479 at. write ( "src" , "x" ) ;
74817480
7482- if Command :: new ( "setfattr" )
7481+ // Check if setfattr is available and source fs supports xattrs
7482+ if !Command :: new ( "setfattr" )
74837483 . args ( [ "-n" , "user.t" , "-v" , "v" , & at. plus_as_string ( "src" ) ] )
74847484 . status ( )
7485- . map_or ( false , |s| s. success ( ) )
7485+ . is_ok_and ( |s| s. success ( ) )
74867486 {
7487- // -a: silent success
7488- scene
7489- . ucmd ( )
7490- . args ( & [ "-a" , & at. plus_as_string ( "src" ) , "/dev/shm/t1" ] )
7491- . succeeds ( )
7492- . no_stderr ( ) ;
7493- // --preserve=all: silent success
7494- scene
7495- . ucmd ( )
7496- . args ( & [ "--preserve=all" , & at. plus_as_string ( "src" ) , "/dev/shm/t2" ] )
7497- . succeeds ( )
7498- . no_stderr ( ) ;
7499- // --preserve=xattr: must fail with proper message
7500- scene
7501- . ucmd ( )
7502- . args ( & [ "--preserve=xattr" , & at. plus_as_string ( "src" ) , "/dev/shm/t3" ] )
7503- . fails ( )
7504- . stderr_contains ( "setting attributes" )
7505- . stderr_contains ( "Operation not supported" ) ;
7506- for f in [ "/dev/shm/t1" , "/dev/shm/t2" , "/dev/shm/t3" ] {
7507- std:: fs:: remove_file ( f) . ok ( ) ;
7508- }
7487+ return ; // Skip: setfattr not available or source doesn't support xattrs
7488+ }
7489+
7490+ // Check if /dev/shm exists
7491+ if !std:: path:: Path :: new ( "/dev/shm" ) . exists ( ) {
7492+ return ; // Skip: /dev/shm not available
7493+ }
7494+
7495+ // Check if /dev/shm actually doesn't support xattrs by trying to set one
7496+ let shm_test_file = "/dev/shm/xattr_test_probe" ;
7497+ std:: fs:: write ( shm_test_file, "test" ) . ok ( ) ;
7498+ let shm_supports_xattr = Command :: new ( "setfattr" )
7499+ . args ( [ "-n" , "user.t" , "-v" , "v" , shm_test_file] )
7500+ . status ( )
7501+ . is_ok_and ( |s| s. success ( ) ) ;
7502+ std:: fs:: remove_file ( shm_test_file) . ok ( ) ;
7503+
7504+ if shm_supports_xattr {
7505+ return ; // Skip: /dev/shm supports xattrs on this system
7506+ }
7507+
7508+ // -a: silent success
7509+ scene
7510+ . ucmd ( )
7511+ . args ( & [ "-a" , & at. plus_as_string ( "src" ) , "/dev/shm/t1" ] )
7512+ . succeeds ( )
7513+ . no_stderr ( ) ;
7514+ // --preserve=all: silent success
7515+ scene
7516+ . ucmd ( )
7517+ . args ( & [ "--preserve=all" , & at. plus_as_string ( "src" ) , "/dev/shm/t2" ] )
7518+ . succeeds ( )
7519+ . no_stderr ( ) ;
7520+ // --preserve=xattr: must fail with proper message
7521+ scene
7522+ . ucmd ( )
7523+ . args ( & [ "--preserve=xattr" , & at. plus_as_string ( "src" ) , "/dev/shm/t3" ] )
7524+ . fails ( )
7525+ . stderr_contains ( "setting attributes" )
7526+ . stderr_contains ( "Operation not supported" ) ;
7527+ for f in [ "/dev/shm/t1" , "/dev/shm/t2" , "/dev/shm/t3" ] {
7528+ std:: fs:: remove_file ( f) . ok ( ) ;
75097529 }
75107530}
0 commit comments