No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / bind / dist / bin / tests / system / dnssec / dnssec_update_test.pl
blob4dc20db0c41eea63fecf06f9eee0b47f16b916f6
1 #!/usr/bin/perl
3 # Copyright (C) 2004, 2007 Internet Systems Consortium, Inc. ("ISC")
4 # Copyright (C) 2002 Internet Software Consortium.
6 # Permission to use, copy, modify, and/or distribute this software for any
7 # purpose with or without fee is hereby granted, provided that the above
8 # copyright notice and this permission notice appear in all copies.
10 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 # PERFORMANCE OF THIS SOFTWARE.
19 # DNSSEC Dynamic update test suite.
21 # Usage:
23 # perl update_test.pl [-s server] [-p port] zone
25 # The server defaults to 127.0.0.1.
26 # The port defaults to 53.
28 # Installation notes:
30 # This program uses the Net::DNS::Resolver module.
31 # You can install it by saying
33 # perl -MCPAN -e "install Net::DNS"
35 # Id: dnssec_update_test.pl,v 1.5 2007/06/19 23:47:02 tbox Exp
38 use Getopt::Std;
39 use Net::DNS;
40 use Net::DNS::Update;
41 use Net::DNS::Resolver;
43 $opt_s = "127.0.0.1";
44 $opt_p = 53;
46 getopt('s:p:');
48 $res = new Net::DNS::Resolver;
49 $res->nameservers($opt_s);
50 $res->port($opt_p);
51 $res->defnames(0); # Do not append default domain.
53 @ARGV == 1 or die
54 "usage: perl update_test.pl [-s server] [-p port] zone\n";
56 $zone = shift @ARGV;
58 my $failures = 0;
60 sub assert {
61 my ($cond, $explanation) = @_;
62 if (!$cond) {
63 print "I:Test Failed: $explanation ***\n";
64 $failures++
68 sub test {
69 my ($expected, @records) = @_;
71 my $update = new Net::DNS::Update("$zone");
73 foreach $rec (@records) {
74 $update->push(@$rec);
77 $reply = $res->send($update);
79 # Did it work?
80 if (defined $reply) {
81 my $rcode = $reply->header->rcode;
82 assert($rcode eq $expected, "expected $expected, got $rcode");
83 } else {
84 print "I:Update failed: ", $res->errorstring, "\n";
88 sub section {
89 my ($msg) = @_;
90 print "I:$msg\n";
93 section("Add a name");
94 test("NOERROR", ["update", rr_add("a.$zone 300 A 73.80.65.49")]);
96 section("Delete the name");
97 test("NOERROR", ["update", rr_del("a.$zone")]);
99 if ($failures) {
100 print "I:$failures tests failed.\n";
101 } else {
102 print "I:All tests successful.\n";
105 exit $failures;