233
def test_cp_preserve_permissions
234
bug4507 = '[ruby-core:35518]'
236
chmod 0755, 'tmp/cptmp'
237
cp 'tmp/cptmp', 'tmp/cptmp2'
238
assert_equal(File.stat('tmp/cptmp').mode,
239
File.stat('tmp/cptmp2').mode,
232
243
def test_cp_symlink
233
244
touch 'tmp/cptmp'
234
245
# src==dest (2) symlink and its target
882
893
assert_equal 0500, File.stat('tmp/a').mode & 0777
883
894
end if have_file_perm?
896
def test_chmod_symbol_mode
897
check_singleton :chmod
900
chmod "u=wrx,g=,o=", 'tmp/a'
901
assert_equal 0700, File.stat('tmp/a').mode & 0777
902
chmod "u=rx,go=", 'tmp/a'
903
assert_equal 0500, File.stat('tmp/a').mode & 0777
904
chmod "+wrx", 'tmp/a'
905
assert_equal 0777, File.stat('tmp/a').mode & 0777
906
chmod "u+s,o=s", 'tmp/a'
907
assert_equal 04770, File.stat('tmp/a').mode & 07777
908
chmod "u-w,go-wrx", 'tmp/a'
909
assert_equal 04500, File.stat('tmp/a').mode & 07777
911
assert_equal 06500, File.stat('tmp/a').mode & 07777
913
# FreeBSD ufs and tmpfs don't allow to change sticky bit against
914
# regular file. It's slightly strange. Anyway it's no effect bit.
915
# see /usr/src/sys/ufs/ufs/ufs_chmod()
916
# NetBSD and OpenBSD also denies it.
917
if /freebsd|netbsd|openbsd/ !~ RUBY_PLATFORM
918
chmod "u+t,o+t", 'tmp/a'
919
assert_equal 07500, File.stat('tmp/a').mode & 07777
920
chmod "a-t,a-s", 'tmp/a'
921
assert_equal 0500, File.stat('tmp/a').mode & 07777
924
end if have_file_perm?
886
928
check_singleton :chmod_R
900
942
chmod_R 0700, 'tmp/dir' # to remove
901
943
end if have_file_perm?
945
def test_chmod_symbol_mode_R
946
check_singleton :chmod_R
948
mkdir_p 'tmp/dir/dir'
949
touch %w( tmp/dir/file tmp/dir/dir/file )
950
chmod_R "u=wrx,g=,o=", 'tmp/dir'
951
assert_equal 0700, File.stat('tmp/dir').mode & 0777
952
assert_equal 0700, File.stat('tmp/dir/file').mode & 0777
953
assert_equal 0700, File.stat('tmp/dir/dir').mode & 0777
954
assert_equal 0700, File.stat('tmp/dir/dir/file').mode & 0777
955
chmod_R "u=xr,g+X,o=", 'tmp/dir'
956
assert_equal 0510, File.stat('tmp/dir').mode & 0777
957
assert_equal 0500, File.stat('tmp/dir/file').mode & 0777
958
assert_equal 0510, File.stat('tmp/dir/dir').mode & 0777
959
assert_equal 0500, File.stat('tmp/dir/dir/file').mode & 0777
960
chmod_R 0700, 'tmp/dir' # to remove
961
end if have_file_perm?
903
963
# FIXME: How can I test this method?
905
965
check_singleton :chown