diff --git a/acceptance/tests/resource/file/symbolic_modes.rb b/acceptance/tests/resource/file/symbolic_modes.rb new file mode 100644 index 000000000..138fe44e3 --- /dev/null +++ b/acceptance/tests/resource/file/symbolic_modes.rb @@ -0,0 +1,111 @@ +test_name "file resource: symbolic modes" + +def validate(path, mode) + "ruby -e 'exit (File::Stat.new(#{path.inspect}).mode & 0777 == #{mode})'" +end + +def tmpfile(what) + "/tmp/symbolic-mode-#{what}-" + + "#{Time.now.strftime("%Y%m%d")}-#{$$}-" + + "#{rand(0x100000000).to_s(36)}.test" +end + +# Generate some standard, remote-safe names for our scratch content, and make +# sure that they exist already. Don't need to care about modes or owners, as +# we reset anything that matters inside the test loop. +file = tmpfile('file') +dir = tmpfile('dir') + +on agents, "touch #{file} ; mkdir #{dir}" + +# Infrastructure for a nice, table driven test. Yum. +# +# For your reference: +# 4000 the set-user-ID-on-execution bit +# 2000 the set-group-ID-on-execution bit +# 1000 the sticky bit +# 0400 Allow read by owner. +# 0200 Allow write by owner. +# 0100 For files, allow execution by owner. For directories, allow the +# owner to search in the directory. +# 0040 Allow read by group members. +# 0020 Allow write by group members. +# 0010 For files, allow execution by group members. For directories, allow +# group members to search in the directory. +# 0004 Allow read by others. +# 0002 Allow write by others. +# 0001 For files, allow execution by others. For directories allow others +# to search in the directory. +# +# fields are: start_mode, symbolic_mode, file_mode, dir_mode +# start_mode is passed to chmod on the target platform +# symbolic_mode is the mode set in our test +# the file and dir mode values are the numeric resultant values we should get +tests = <