Sha256: 6aaf5c620de89d7fb661fdc9bd4b50d1b718916be1582f0410b9ca64b2f6d8a5
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
require 'minitest/autorun' require 'dnssd' require 'socket' class TestDNSSD < MiniTest::Unit::TestCase def setup @abort = Thread.abort_on_exception Thread.abort_on_exception = true @port = Socket.getservbyname 'blackjack' end def teardown Thread.abort_on_exception = @abort end def test_class_announce_tcp_server t = Thread.current DNSSD.browse '_blackjack._tcp' do |reply| next unless 'blackjack tcp server' == reply.name t[:reply] = reply break end s = TCPServer.new 'localhost', @port DNSSD.announce s, 'blackjack tcp server' sleep 1 assert_equal 'blackjack tcp server', t[:reply].name ensure s.close end def test_class_announce_tcp_server_service t = Thread.current resolver = DNSSD.resolve 'blackjack resolve', '_blackjack._tcp', 'local.' do |reply| t[:reply] = reply break end s = TCPServer.new 'localhost', @port + 1 DNSSD.announce s, 'blackjack resolve', 'blackjack' sleep 1 assert_equal 'blackjack resolve', t[:reply].name assert_equal @port + 1, t[:reply].port ensure s.close end def test_class_getservbyport assert_equal 'blackjack', DNSSD.getservbyport(1025), "Your /etc/services is out of date, sorry!" end def test_class_interface_index index = DNSSD.interface_index('lo0') refute_equal 0, index, 'what? no lo0?' end def test_class_interface_name index = DNSSD.interface_index('lo0') assert_equal 'lo0', DNSSD.interface_name(index) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dnssd-1.2 | test/test_dnssd.rb |