~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to test/gdbm/test_gdbm.rb

  • Committer: Package Import Robot
  • Author(s): Antonio Terceiro, Lucas Nussbaum, Daigo Moriwaki, James Healy, Antonio Terceiro
  • Date: 2012-06-02 07:42:28 UTC
  • mfrom: (21.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20120602074228-09t2jgg1ozrsnnfo
Tags: 1.9.3.194-1
[ Lucas Nussbaum ]
* Add hurd-path-max.diff. Fixes FTBFS on Hurd. (Closes: #648055)

[ Daigo Moriwaki ]
* Removed debian/patches/debian/patches/sparc-continuations.diff,
  which the upstream has applied.
* debian/rules:
  - Bumped up tcltk_ver to 8.5.
  - Used chrpath for tcltklib.so to fix a lintian error,
    binary-or-shlib-defines-rpath.
* debian/control:
  - Suggests ruby-switch. (Closes: #654312)
  - Build-Depends: chrpath.
* debian/libruby1.9.1.symbols: Added a new symbol for
  rb_str_modify_expand@Base.
* debian/run-test-suites.bash:
  - Corrected options for test-all.
  - Enabled timeout to allow hang tests to be aborted.

[ James Healy ]
* New upstream release: 1.9.3p194 (Closes: #669582)
  + This release includes a fix for CVE-2011-0188 (Closes: #628451)
  + This release also does not segfault when running the test suite under
    amd64 (Closes: #674347)
* Enable hardened build flags (Closes: #667964)
* debian/control:
  - depend on specific version on coreutils
  - update policy version (no changes)

[ Antonio Terceiro ]
* debian/ruby1.9.1.postinst:
  + bump alternatives priority for `ruby` to 51 so that Ruby 1.9 has a
    higher priority than Ruby 1.8 (50).
  + bump alternatives priority for `gem` to 181 so that the Rubygems
    provided by Ruby 1.9 has priority over the one provided by the rubygems
    package.
* debian/control: added myself to Uploaders:
* debian/libruby1.9.1.symbols: update with new symbols added in 1.9.3p194
  upstream release.
* debian/manpages/*: fix references to command names with s/1.9/1.9.1/
* debian/rules: skip running DRB tests, since they seem to make the build
  hang. This should close #647296, but let's way and see. Also, with this do
  not need to timeout the test suite anymore.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
  require 'tmpdir'
11
11
  require 'fileutils'
12
12
 
13
 
  class TestGDBM < Test::Unit::TestCase
14
 
    def TestGDBM.uname_s
 
13
  class TestGDBM_RDONLY < Test::Unit::TestCase
 
14
    def TestGDBM_RDONLY.uname_s
15
15
      require 'rbconfig'
16
16
      case RbConfig::CONFIG['target_os']
17
17
      when 'cygwin'
31
31
      @tmpdir = Dir.mktmpdir("tmptest_gdbm")
32
32
      @prefix = "tmptest_gdbm_#{$$}"
33
33
      @path = "#{@tmpdir}/#{@prefix}_"
34
 
      assert_instance_of(GDBM, @gdbm = GDBM.new(@path))
35
34
 
36
35
      # prepare to make readonly GDBM file
37
36
      GDBM.open("#{@tmpdir}/#{@prefix}_rdonly", 0400) {|gdbm|
40
39
      assert_instance_of(GDBM, @gdbm_rdonly = GDBM.new("#{@tmpdir}/#{@prefix}_rdonly", nil))
41
40
    end
42
41
    def teardown
 
42
      assert_nil(@gdbm_rdonly.close)
 
43
      ObjectSpace.each_object(GDBM) do |obj|
 
44
        obj.close unless obj.closed?
 
45
      end
 
46
      FileUtils.remove_entry_secure @tmpdir
 
47
    end
 
48
 
 
49
    def test_delete_rdonly
 
50
      if /^CYGWIN_9/ !~ SYSTEM and Process.euid != 0
 
51
        assert_raise(GDBMError) {
 
52
          @gdbm_rdonly.delete("foo")
 
53
        }
 
54
 
 
55
        assert_nil(@gdbm_rdonly.delete("bar"))
 
56
      end
 
57
    end
 
58
  end
 
59
 
 
60
  class TestGDBM < Test::Unit::TestCase
 
61
    SYSTEM = TestGDBM_RDONLY::SYSTEM
 
62
 
 
63
    def setup
 
64
      @tmpdir = Dir.mktmpdir("tmptest_gdbm")
 
65
      @prefix = "tmptest_gdbm_#{$$}"
 
66
      @path = "#{@tmpdir}/#{@prefix}_"
 
67
      assert_instance_of(GDBM, @gdbm = GDBM.new(@path))
 
68
    end
 
69
    def teardown
43
70
      assert_nil(@gdbm.close)
44
 
      assert_nil(@gdbm_rdonly.close)
45
71
      ObjectSpace.each_object(GDBM) do |obj|
46
72
        obj.close unless obj.closed?
47
73
      end
83
109
      begin
84
110
        assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}"))
85
111
        gdbm.close
86
 
        assert_equal(File.stat("#{@tmpdir}/#{@prefix}").mode & 0777, 0666) unless /mswin|mignw/ =~ RUBY_PLATFORM
 
112
        assert_equal(File.stat("#{@tmpdir}/#{@prefix}").mode & 0777, 0666) unless /mswin|mingw/ =~ RUBY_PLATFORM
87
113
        assert_instance_of(GDBM, gdbm = GDBM.open("#{@tmpdir}/#{@prefix}2", 0644))
88
114
        gdbm.close
89
115
        assert_equal(File.stat("#{@tmpdir}/#{@prefix}2").mode & 0777, 0644)
438
464
      assert_equal(2, @gdbm.size)
439
465
 
440
466
      assert_nil(@gdbm.delete(key))
441
 
 
442
 
      if /^CYGWIN_9/ !~ SYSTEM and Process.euid != 0
443
 
        assert_raise(GDBMError) {
444
 
          @gdbm_rdonly.delete("foo")
445
 
        }
446
 
 
447
 
        assert_nil(@gdbm_rdonly.delete("bar"))
448
 
      end
449
467
    end
 
468
 
450
469
    def test_delete_with_block
451
470
      key = 'no called block'
452
471
      @gdbm[key] = 'foo'