mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/resolv/test_dns.rb: Use assert_join_threads.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48381 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1fca7620dc
commit
08bb9482a0
2 changed files with 68 additions and 64 deletions
|
@ -1,3 +1,7 @@
|
|||
Tue Nov 11 22:51:14 2014 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* test/resolv/test_dns.rb: Use assert_join_threads.
|
||||
|
||||
Tue Nov 11 22:33:08 2014 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* test/net/pop/test_pop.rb: Use assert_join_threads.
|
||||
|
|
|
@ -33,11 +33,12 @@ class TestResolvDNS < Test::Unit::TestCase
|
|||
with_udp('127.0.0.1', 0) {|u|
|
||||
_, server_port, _, server_address = u.addr
|
||||
begin
|
||||
th = Thread.new {
|
||||
client_thread = Thread.new {
|
||||
Resolv::DNS.open(:nameserver_port => [[server_address, server_port]]) {|dns|
|
||||
dns.getresources("foo.example.org", Resolv::DNS::Resource::IN::A)
|
||||
}
|
||||
}
|
||||
server_thread = Thread.new {
|
||||
msg, (_, client_port, _, client_address) = u.recvfrom(4096)
|
||||
id, word2, qdcount, ancount, nscount, arcount = msg.unpack("nnnnnn")
|
||||
qr = (word2 & 0x8000) >> 15
|
||||
|
@ -98,7 +99,8 @@ class TestResolvDNS < Test::Unit::TestCase
|
|||
rr = [name, type, klass, ttl, rdlength, rdata].pack("a*nnNna*")
|
||||
msg << rr
|
||||
u.send(msg, 0, client_address, client_port)
|
||||
result = th.value
|
||||
}
|
||||
result, _ = assert_join_threads([client_thread, server_thread])
|
||||
assert_instance_of(Array, result)
|
||||
assert_equal(1, result.length)
|
||||
rr = result[0]
|
||||
|
@ -106,8 +108,6 @@ class TestResolvDNS < Test::Unit::TestCase
|
|||
assert_instance_of(Resolv::IPv4, rr.address)
|
||||
assert_equal("192.0.2.1", rr.address.to_s)
|
||||
assert_equal(3600, rr.ttl)
|
||||
ensure
|
||||
th.join
|
||||
end
|
||||
}
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue