[rubygem-snmp] Update to snmp 1.1.1.

Vít Ondruch vondruch at fedoraproject.org
Mon Jul 14 15:47:45 UTC 2014


commit 62b15052bb99938a09a15de0f32a067cc63046a8
Author: Vít Ondruch <vondruch at redhat.com>
Date:   Mon Jul 14 17:47:56 2014 +0200

    Update to snmp 1.1.1.

 .gitignore                                |    1 +
 rubygem-snmp-1.1.0-Enforce-encoding.patch |   38 ------
 rubygem-snmp-1.1.1-fix-test-suite.patch   |  176 +++++++++++++++++++++++++++++
 rubygem-snmp.spec                         |   41 +++++--
 sources                                   |    2 +-
 5 files changed, 210 insertions(+), 48 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 9ed4cd9..14454c1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
 snmp-1.0.3.gem
 /snmp-1.1.0.gem
+/snmp-1.1.1.gem
diff --git a/rubygem-snmp-1.1.1-fix-test-suite.patch b/rubygem-snmp-1.1.1-fix-test-suite.patch
new file mode 100644
index 0000000..047869f
--- /dev/null
+++ b/rubygem-snmp-1.1.1-fix-test-suite.patch
@@ -0,0 +1,176 @@
+diff --git a/test/test_manager.rb b/test/test_manager.rb
+index 59aed99..390092d 100644
+--- a/test/test_manager.rb
++++ b/test/test_manager.rb
+@@ -177,7 +177,7 @@ class TestManager < Test::Unit::TestCase
+       :enterpriseSpecific,
+       42,
+       12345,
+-      [VarBind.new("1.3.6.1.2.3.4", Integer.new(1))]
++      [VarBind.new("1.3.6.1.2.3.4", SNMP::Integer.new(1))]
+     )
+     pdu = Message.decode(sent_data).pdu
+     assert_equal(ObjectId.new("1.3.6.1.4.1.9"), pdu.enterprise)
+diff --git a/test/test_pdu.rb b/test/test_pdu.rb
+index c4eaf51..a423f3d 100644
+--- a/test/test_pdu.rb
++++ b/test/test_pdu.rb
+@@ -6,7 +6,7 @@ class TestProtocol < Test::Unit::TestCase
+   include SNMP
+ 
+   def test_message_decode_v1
+-    message = SNMP::Message.decode("0'\002\001\000\004\006public\240\032\002\002\003\350\002\001\000\002\001\0000\0160\f\006\010+\006\001\002\001\001\001\000\005\000")
++    message = SNMP::Message.decode("0'\002\001\000\004\006public\240\032\002\002\003\350\002\001\000\002\001\0000\0160\f\006\010+\006\001\002\001\001\001\000\005\000".force_encoding('ASCII-8BIT'))
+     assert_equal(:SNMPv1, message.version)
+     assert_equal("public", message.community)
+     assert_equal(SNMP::GetRequest, message.pdu.class)
+@@ -17,7 +17,7 @@ class TestProtocol < Test::Unit::TestCase
+   end
+ 
+   def test_message_decode_v2c
+-    message = SNMP::Message.decode("0)\002\001\001\004\006public\240\034\002\0040\265\020\202\002\001\000\002\001\0000\0160\f\006\010+\006\001\002\001\001\001\000\005\000")
++    message = SNMP::Message.decode("0)\002\001\001\004\006public\240\034\002\0040\265\020\202\002\001\000\002\001\0000\0160\f\006\010+\006\001\002\001\001\001\000\005\000".force_encoding('ASCII-8BIT'))
+     assert_equal(:SNMPv2c, message.version)
+     assert_equal("public", message.community)
+     varbind_list = message.pdu.vb_list;
+@@ -38,7 +38,7 @@ class TestProtocol < Test::Unit::TestCase
+     list << varbind << varbind;
+     pdu = SNMP::Response.new(12345, list)
+     message = SNMP::Message.new(:SNMPv2c, "public", pdu)
+-    assert_equal("07\002\001\001\004\006public\242*\002\00209\002\001\000\002\001\0000\0360\r\006\004+\006\211R\004\005value0\r\006\004+\006\211R\004\005value", message.encode)
++    assert_equal("07\002\001\001\004\006public\242*\002\00209\002\001\000\002\001\0000\0360\r\006\004+\006\211R\004\005value0\r\006\004+\006\211R\004\005value".force_encoding('ASCII-8BIT'), message.encode)
+   end
+ 
+   def test_get_request_from_single_string
+@@ -102,7 +102,7 @@ class TestProtocol < Test::Unit::TestCase
+ 
+   def test_get_bulk_encode
+     request = SNMP::GetBulkRequest.new(1234, VarBindList.new, 0, 10)
+-    assert_equal("\245\f\002\002\004\322\002\001\000\002\001\n0\000", request.encode)
++    assert_equal("\245\f\002\002\004\322\002\001\000\002\001\n0\000".force_encoding('ASCII-8BIT'), request.encode)
+   end
+ 
+   def test_error_status
+@@ -124,7 +124,7 @@ class TestProtocol < Test::Unit::TestCase
+     trap_oid_varbind = VarBind.new(ObjectId.new("1.3.6.1.6.3.1.1.4.1.0"),
+                                    ObjectId.new("1.2.3"))
+     trap = SNMPv2_Trap.new(42, VarBindList.new([sys_up_varbind, trap_oid_varbind]))
+-    assert_equal("\247-\002\001*\002\001\000\002\001\0000\"0\016\006\010+\006\001\002\001\001\003\000C\002\004\3220\020\006\n+\006\001\006\003\001\001\004\001\000\006\002*\003", trap.encode)
++    assert_equal("\247-\002\001*\002\001\000\002\001\0000\"0\016\006\010+\006\001\002\001\001\003\000C\002\004\3220\020\006\n+\006\001\006\003\001\001\004\001\000\006\002*\003".force_encoding('ASCII-8BIT'), trap.encode)
+     assert_equal(1234, trap.sys_up_time.to_i)
+     assert_equal("1.2.3", trap.trap_oid.to_s)
+   end
+@@ -155,9 +155,9 @@ class TestProtocol < Test::Unit::TestCase
+     generic_trap = :linkDown
+     specific_trap = 0
+     timestamp = TimeTicks.new(2176117721)
+-    varbinds = VarBindList.new([VarBind.new("1.3.6.2", Integer.new(1))])
++    varbinds = VarBindList.new([VarBind.new("1.3.6.2", SNMP::Integer.new(1))])
+     trap = SNMPv1_Trap.new(enterprise, agent_addr, generic_trap, specific_trap, timestamp, varbinds)
+-    assert_equal("\244%\006\004+\006\001{@\004\001\002\003\004\002\001\002\002\001\000C\005\000\201\264\353\3310\n0\010\006\003+\006\002\002\001\001", trap.encode)
++    assert_equal("\244%\006\004+\006\001{@\004\001\002\003\004\002\001\002\002\001\000C\005\000\201\264\353\3310\n0\010\006\003+\006\002\002\001\001".force_encoding('ASCII-8BIT'), trap.encode)
+ 
+     encoded = Message.new(:SNMPv1, "public", trap).encode
+     trap = Message.decode(encoded).pdu
+@@ -172,7 +172,7 @@ class TestProtocol < Test::Unit::TestCase
+ 
+   def test_response_pdu
+     pdu = Response.new(2147483647, VarBindList.new, :noError, 0)
+-    assert_equal("\242\016\002\004\177\377\377\377\002\001\000\002\001\0000\000", pdu.encode)
++    assert_equal("\242\016\002\004\177\377\377\377\002\001\000\002\001\0000\000".force_encoding('ASCII-8BIT'), pdu.encode)
+ 
+     encoded = Message.new(:SNMPv2c, "public", pdu).encode
+     pdu = Message.decode(encoded).pdu
+diff --git a/test/test_varbind.rb b/test/test_varbind.rb
+index d94cb7e..c24f0ce 100644
+--- a/test/test_varbind.rb
++++ b/test/test_varbind.rb
+@@ -57,11 +57,11 @@ class TestVarBind < Test::Unit::TestCase
+ 
+     check_varbind_list_create(VarBindList.new(
+                                 [VarBind.new("1.2.3.4.5", Null),
+-                                 VarBind.new("1.2.3.4.6", Integer.new(123)),
++                                 VarBind.new("1.2.3.4.6", SNMP::Integer.new(123)),
+                                  ObjectId.new("1.2.3.4.7")]
+     ), 3)
+ 
+-    list = VarBindList.new([VarBind.new("1.3.6.2", Integer.new(1))])
++    list = VarBindList.new([VarBind.new("1.3.6.2", SNMP::Integer.new(1))])
+     assert_equal(1, list.length)
+     assert_equal("1.3.6.2", list.first.name.to_s)
+     assert_equal(1, list.first.value.to_i)
+@@ -204,7 +204,7 @@ class TestVarBind < Test::Unit::TestCase
+   end
+ 
+   def test_integer_create
+-    i = Integer.new(12345)
++    i = SNMP::Integer.new(12345)
+     assert_equal("12345", i.to_s)
+     assert_equal(12345, i.to_i)
+     assert_equal("\002\00209", i.encode)
+@@ -212,13 +212,13 @@ class TestVarBind < Test::Unit::TestCase
+   end
+ 
+   def test_integer_decode
+-    i = Integer.decode("09")
++    i = SNMP::Integer.decode("09")
+     assert_equal(12345, i.to_i)
+   end
+ 
+   def test_integer_equal
+-    i1 = Integer.new(12345)
+-    i2 = Integer.new(12345)
++    i1 = SNMP::Integer.new(12345)
++    i2 = SNMP::Integer.new(12345)
+     i3 = 12345.2
+     i4 = 12345
+     assert_not_same(i1, i2)
+@@ -229,8 +229,8 @@ class TestVarBind < Test::Unit::TestCase
+   end
+ 
+   def test_integer_comparable
+-    i1 = Integer.new(12345)
+-    i2 = Integer.new(54321.0)
++    i1 = SNMP::Integer.new(12345)
++    i2 = SNMP::Integer.new(54321.0)
+     assert(i1 < i2)
+     assert(i2 > i1)
+     assert(123 < i1)
+@@ -239,10 +239,10 @@ class TestVarBind < Test::Unit::TestCase
+   end
+ 
+   def test_integer_to_oid
+-    assert_equal(ObjectId.new("123"), Integer.new(123).to_oid)
+-    assert_equal(ObjectId.new("0"), Integer.new(0).to_oid)
++    assert_equal(ObjectId.new("123"), SNMP::Integer.new(123).to_oid)
++    assert_equal(ObjectId.new("0"), SNMP::Integer.new(0).to_oid)
+ 
+-    i = Integer.new(-1)
++    i = SNMP::Integer.new(-1)
+     assert_raise(RangeError) { i.to_oid }
+   end
+ 
+@@ -318,10 +318,10 @@ class TestVarBind < Test::Unit::TestCase
+   # Decode as a positive number even though high bit is set.
+   # Not strict ASN.1, but implemented in some agents.
+   def test_unsigned_decode
+-    i = Counter32.decode("\201\264\353\331")
++    i = Counter32.decode("\201\264\353\331".force_encoding('ASCII-8BIT'))
+     assert_equal(2176117721, i.to_i)
+ 
+-    i = TimeTicks.decode("\201\264\353\331")
++    i = TimeTicks.decode("\201\264\353\331".force_encoding('ASCII-8BIT'))
+     assert_equal(2176117721, i.to_i)
+   end
+ 
+@@ -329,8 +329,8 @@ class TestVarBind < Test::Unit::TestCase
+     i = Counter64.new(18446744073709551615)
+     assert_equal(18446744073709551615, i.to_i)
+     assert_equal("18446744073709551615", i.to_s)
+-    assert_equal("F\t\000\377\377\377\377\377\377\377\377", i.encode)
+-    assert_equal(i, Counter64.decode("\000\377\377\377\377\377\377\377\377"))
++    assert_equal("F\t\000\377\377\377\377\377\377\377\377".force_encoding('ASCII-8BIT'), i.encode)
++    assert_equal(i, Counter64.decode("\000\377\377\377\377\377\377\377\377".force_encoding('ASCII-8BIT')))
+     assert_not_nil(i.asn1_type)
+   end
+ 
diff --git a/rubygem-snmp.spec b/rubygem-snmp.spec
index 78fdcf5..f1b3328 100644
--- a/rubygem-snmp.spec
+++ b/rubygem-snmp.spec
@@ -2,20 +2,19 @@
 
 Summary: A Ruby implementation of SNMP (the Simple Network Management Protocol)
 Name: rubygem-%{gem_name}
-Version: 1.1.0
-Release: 9%{?dist}
+Version: 1.1.1
+Release: 1%{?dist}
 Group: Development/Languages
+# https://github.com/hallidave/ruby-snmp/issues/11
 License: GPLv2 or Ruby
 URL: http://snmplib.rubyforge.org
-Source0: http://gems.rubyforge.org/gems/%{gem_name}-%{version}.gem
-Patch0: rubygem-snmp-1.1.0-Enforce-encoding.patch
-Requires: ruby(rubygems)
-Requires: ruby(release)
+Source0: https://rubygems.org/gems/%{gem_name}-%{version}.gem
+# https://github.com/hallidave/ruby-snmp/pull/32
+Patch0: rubygem-snmp-1.1.1-fix-test-suite.patch
 BuildRequires: rubygems-devel
 BuildRequires: ruby-devel
-BuildRequires: rubygem(minitest)
+BuildRequires: rubygem(minitest) > 5
 BuildArch: noarch
-Provides: rubygem(%{gem_name}) = %{version}
 
 %description
 A Ruby implementation of SNMP (the Simple Network Management Protocol).
@@ -37,7 +36,28 @@ cp -pa .%{gem_dir}/* \
 
 %check
 pushd .%{gem_instdir}
-ruby -Ilib test/*.rb
+
+# Run the tests using minitest 5.
+ruby -Ilib -rminitest/autorun - << \EOF
+  module Kernel
+    alias orig_require require
+    remove_method :require
+
+    def require path
+      orig_require path unless path == 'test/unit'
+    end
+  end
+
+  module Minitest::Assertions
+    alias :assert_raise :assert_raises
+    alias :assert_not_same :refute_same
+    alias :assert_not_nil :refute_nil
+  end
+
+  Test = Minitest
+
+  Dir.glob "./test/**/test_*.rb", &method(:require)
+EOF
 popd
 
 %files
@@ -54,6 +74,9 @@ popd
 
 
 %changelog
+* Mon Jul 14 2014 Vít Ondruch <vondruch at redhat.com> - 1.1.1-1
+- Update to snmp 1.1.1.
+
 * Sun Jun 08 2014 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 1.1.0-9
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
 
diff --git a/sources b/sources
index 3f6a180..3c2ba92 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-38d4de268ccfa25f1d0e234e4bb8f448  snmp-1.1.0.gem
+da49f018da8f4b4117776ca78f454160  snmp-1.1.1.gem


More information about the scm-commits mailing list