File: 35-bgread.t

package info (click to toggle)
libnet-dns-resolver-unbound-perl 1.32-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 180 kB
  • sloc: perl: 586; makefile: 5
file content (43 lines) | stat: -rw-r--r-- 1,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/perl
#

use strict;
use warnings;
use Test::More;

use Net::DNS::Resolver::Unbound;

my $resolver = Net::DNS::Resolver::Unbound->new();

plan skip_all => 'resolver not loaded' unless $resolver;
plan tests    => 12;


for ( my $handle = undef ) {
	ok( !$resolver->bgbusy($handle), 'not bgbusy' );
	is( $resolver->bgread($handle), undef, 'undefined bgread' );
}

my $id	= 123;
my $err = -99;

for ( my $handle = Net::DNS::Resolver::libunbound::emulate_wait($id) ) {
	ok( $handle->waiting(),		'handle->waiting' );
	ok( $resolver->bgbusy($handle), 'bgbusy' );
	ok( !$handle->err(),		'no handle->err' );
	ok( !$handle->result(),		'no handle->result' );
}


for ( my $handle = Net::DNS::Resolver::libunbound::emulate_callback( $id, $err ) ) {
	ok( !$handle->waiting(),	 'not handle->waiting' );
	ok( !$resolver->bgbusy($handle), 'not bgbusy' );
	ok( $handle->err(),		 'handle->err' );
	ok( !$handle->result(),		 'no handle->result' );
	is( $resolver->bgread($handle), undef, 'undefined bgread' );
	my $errorstring = $resolver->errorstring;
	like( $errorstring, "/$err/", "errorstring: [$errorstring]" );
}


exit;