[前][次][番号順一覧][スレッド一覧]

ruby-changes:38159

From: akr <ko1@a...>
Date: Sun, 12 Apr 2015 08:52:41 +0900 (JST)
Subject: [ruby-changes:38159] akr:r50240 (trunk): * test/ruby/test_file_exhaustive.rb: Test suid, sgid and sticky file.

akr	2015-04-12 08:52:34 +0900 (Sun, 12 Apr 2015)

  New Revision: 50240

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50240

  Log:
    * test/ruby/test_file_exhaustive.rb: Test suid, sgid and sticky file.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_file_exhaustive.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50239)
+++ ChangeLog	(revision 50240)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Apr 12 08:52:01 2015  Tanaka Akira  <akr@f...>
+
+	* test/ruby/test_file_exhaustive.rb: Test suid, sgid and sticky file.
+
 Sat Apr 11 23:48:30 2015  SHIBATA Hiroshi  <shibata.hiroshi@g...>
 
 	* template/fake.rb.in: Don't assign baseruby, Because it's affect to
Index: test/ruby/test_file_exhaustive.rb
===================================================================
--- test/ruby/test_file_exhaustive.rb	(revision 50239)
+++ test/ruby/test_file_exhaustive.rb	(revision 50240)
@@ -57,6 +57,30 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L57
     @file
   end
 
+  def suidfile
+    return @suidfile if defined? @suidfile
+    @suidfile = make_tmp_filename("suidfile")
+    make_file("", @suidfile)
+    File.chmod 04500, @suidfile
+    @suidfile
+  end
+
+  def sgidfile
+    return @sgidfile if defined? @sgidfile
+    @sgidfile = make_tmp_filename("sgidfile")
+    make_file("", @sgidfile)
+    File.chmod 02500, @sgidfile
+    @sgidfile
+  end
+
+  def stickyfile
+    return @stickyfile if defined? @stickyfile
+    @stickyfile = make_tmp_filename("stickyfile")
+    Dir.mkdir(@stickyfile)
+    File.chmod 01500, @stickyfile
+    @stickyfile
+  end
+
   def symlinkfile
     return @symlinkfile if @symlinkfile
     @symlinkfile = make_tmp_filename("symlinkfile")
@@ -351,10 +375,19 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L375
     assert_file.grpowned?(regular_file)
   end
 
-  def test_suid_sgid_sticky ## xxx
+  def test_suid
     assert_file.not_setuid?(regular_file)
+    assert_file.setuid?(suidfile) if suidfile
+  end
+
+  def test_sgid
     assert_file.not_setgid?(regular_file)
+    assert_file.setgid?(sgidfile) if sgidfile
+  end
+
+  def test_sticky
     assert_file.not_sticky?(regular_file)
+    assert_file.sticky?(stickyfile) if stickyfile
   end
 
   def test_path_identical_p
@@ -1048,7 +1081,19 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1081
     sleep(1.1)
     fn2 = fn1 + "2"
     make_file("foo", fn2)
-    [@dir, fn1, zerofile, symlinkfile, hardlinkfile, chardev, fifo, socket].compact.each do |f|
+    [
+      @dir,
+      fn1,
+      zerofile,
+      suidfile,
+      sgidfile,
+      stickyfile,
+      symlinkfile,
+      hardlinkfile,
+      chardev,
+      fifo,
+      socket
+    ].compact.each do |f|
       assert_equal(File.atime(f), test(?A, f))
       assert_equal(File.ctime(f), test(?C, f))
       assert_equal(File.mtime(f), test(?M, f))
@@ -1177,7 +1222,7 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1222
     assert(!(File::Stat.new(regular_file).blockdev?))
   end
 
-  def test_stat_chardev_p ## xxx
+  def test_stat_chardev_p
     assert(!(File::Stat.new(@dir).chardev?))
     assert(!(File::Stat.new(regular_file).chardev?))
     assert(File::Stat.new(chardev).chardev?) if chardev
@@ -1278,10 +1323,19 @@ class TestFileExhaustive < Test::Unit::T https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file_exhaustive.rb#L1323
     assert(File::Stat.new(regular_file).grpowned?)
   end
 
-  def test_stat_suid_sgid_sticky ## xxx
+  def test_stat_suid
     assert(!(File::Stat.new(regular_file).setuid?))
+    assert(File::Stat.new(suidfile).setuid?) if suidfile
+  end
+
+  def test_stat_sgid
     assert(!(File::Stat.new(regular_file).setgid?))
+    assert(File::Stat.new(sgidfile).setgid?) if sgidfile
+  end
+
+  def test_stat_sticky
     assert(!(File::Stat.new(regular_file).sticky?))
+    assert(File::Stat.new(stickyfile).sticky?) if stickyfile
   end
 
   def test_stat_size

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]