From 77ea0461c9cf437a3527c12086d02c3febf52bd3 Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 12 Apr 2015 00:24:53 +0000 Subject: * 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 --- ChangeLog | 4 ++++ test/ruby/test_file_exhaustive.rb | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index df99a3312e..c5b7494345 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Apr 12 09:24:03 2015 Tanaka Akira + + * test/ruby/test_file_exhaustive.rb: Test a file not owned. + Sun Apr 12 09:05:44 2015 Tanaka Akira * ext/fiddle/depend: Fix "Wrong mix of special targets" error with 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 -- cgit v1.2.3