Add more grpowned? tests

This commit is contained in:
Nobuyoshi Nakada 2021-10-11 23:17:05 +09:00
parent 058cd3a6df
commit 9a3333986f
Notes: git 2021-10-14 00:20:41 +09:00

View File

@ -78,6 +78,19 @@ class TestFileExhaustive < Test::Unit::TestCase
@notownedfile @notownedfile
end end
def grpownedfile
return nil unless POSIX
return @grpownedfile if defined? @grpownedfile
if group = (Process.groups - [Process.egid]).last
grpownedfile = make_tmp_filename("grpownedfile")
make_file("grpowned", grpownedfile)
File.chown(nil, group, grpownedfile)
return @grpownedfile = grpownedfile
end
rescue
@grpownedfile = nil
end
def suidfile def suidfile
return @suidfile if defined? @suidfile return @suidfile if defined? @suidfile
if POSIX if POSIX
@ -493,6 +506,9 @@ class TestFileExhaustive < Test::Unit::TestCase
def test_grpowned_p ## xxx def test_grpowned_p ## xxx
assert_file.grpowned?(regular_file) assert_file.grpowned?(regular_file)
assert_file.grpowned?(utf8_file) assert_file.grpowned?(utf8_file)
if file = grpownedfile
assert_file.grpowned?(file)
end
end if POSIX end if POSIX
def io_open(file_name) def io_open(file_name)
@ -1454,6 +1470,7 @@ class TestFileExhaustive < Test::Unit::TestCase
fn1, fn1,
zerofile, zerofile,
notownedfile, notownedfile,
grpownedfile,
suidfile, suidfile,
sgidfile, sgidfile,
stickyfile, stickyfile,
@ -1689,6 +1706,9 @@ class TestFileExhaustive < Test::Unit::TestCase
def test_stat_grpowned_p ## xxx def test_stat_grpowned_p ## xxx
assert_predicate(File::Stat.new(regular_file), :grpowned?) assert_predicate(File::Stat.new(regular_file), :grpowned?)
if file = grpownedfile
assert_predicate(File::Stat.new(file), :grpowned?)
end
end if POSIX end if POSIX
def test_stat_suid def test_stat_suid