diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-04-12 00:24:53 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-04-12 00:24:53 +0000 |
commit | 77ea0461c9cf437a3527c12086d02c3febf52bd3 (patch) | |
tree | 8f2170eec9a239ec907c5d01796c60ad2275ab46 /test/ruby | |
parent | f7dca1d7cd5ca9e84ae33f9a8f7217ae9ae085a1 (diff) |
* test/ruby/test_file_exhaustive.rb: Test a file not owned.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_file_exhaustive.rb | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index 20bc37990a..c2e41e32ba 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -57,6 +57,16 @@ class TestFileExhaustive < Test::Unit::TestCase @file end + def notownedfile + return @notownedfile if defined? @notownedfile + if Process.euid != 0 + @notownedfile = '/' + else + @notownedfile = nil + end + @notownedfile + end + def suidfile return @suidfile if defined? @suidfile if /mswin|mingw|bccwin/ !~ RUBY_PLATFORM @@ -381,9 +391,14 @@ class TestFileExhaustive < Test::Unit::TestCase assert_file.not_size?(nofile) end - def test_owned_p ## xxx + def test_owned_p return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM assert_file.owned?(regular_file) + assert_file.not_owned?(notownedfile) + end + + def test_grpowned_p ## xxx + return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM assert_file.grpowned?(regular_file) end @@ -1097,6 +1112,7 @@ class TestFileExhaustive < Test::Unit::TestCase @dir, fn1, zerofile, + notownedfile, suidfile, sgidfile, stickyfile, @@ -1329,9 +1345,14 @@ class TestFileExhaustive < Test::Unit::TestCase assert(!(File::Stat.new(zerofile).size?)) end - def test_stat_owned_p ## xxx + def test_stat_owned_p return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM assert(File::Stat.new(regular_file).owned?) + assert(!File::Stat.new(notownedfile).owned?) + end + + def test_stat_grpowned_p ## xxx + return if /cygwin|mswin|bccwin|mingw|emx/ =~ RUBY_PLATFORM assert(File::Stat.new(regular_file).grpowned?) end |