Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / bin / tests / system / stress / update.pl
blob2eec6d0e3fabdf5fc43f08e931e87bf243ebe615
1 #!/usr/bin/perl
3 # Copyright (C) 2004, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
4 # Copyright (C) 2000, 2001 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 # 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 # The "Special NS rules" tests will only work correctly if the
29 # has no NS records to begin with, or alternatively has a
30 # single NS record pointing at the name "ns1" (relative to
31 # the zone name).
33 # Installation notes:
35 # This program uses the Net::DNS::Resolver module.
36 # You can install it by saying
38 # perl -MCPAN -e "install Net::DNS"
40 # Id: update.pl,v 1.5 2007/06/19 23:47:05 tbox Exp
43 use Getopt::Std;
44 use Net::DNS;
45 use Net::DNS::Update;
46 use Net::DNS::Resolver;
48 $opt_s = "127.0.0.1";
49 $opt_p = 53;
51 getopt('s:p:');
53 $res = new Net::DNS::Resolver;
54 $res->nameservers($opt_s);
55 $res->port($opt_p);
56 $res->defnames(0); # Do not append default domain.
58 @ARGV == 1 or die
59 "usage: perl update_test.pl [-s server] [-p port] zone\n";
61 $zone = shift @ARGV;
63 my $failures = 0;
65 sub assert {
66 my ($cond, $explanation) = @_;
67 if (!$cond) {
68 print "I:Test Failed: $explanation ***\n";
69 $failures++
73 sub test {
74 my ($expected, @records) = @_;
76 my $update = new Net::DNS::Update("$zone");
78 foreach $rec (@records) {
79 $update->push(@$rec);
82 $reply = $res->send($update);
84 # Did it work?
85 if (defined $reply) {
86 my $rcode = $reply->header->rcode;
87 assert($rcode eq $expected, "expected $expected, got $rcode");
88 } else {
89 print "I:Update failed: ", $res->errorstring, "\n";
93 sub section {
94 my ($msg) = @_;
95 print "I:$msg\n";
98 for ($i = 0; $i < 1000; $i++) {
99 test("NOERROR", ["update", rr_add("dynamic-$i.$zone 300 TXT txt-$i" )]);
102 if ($failures) {
103 print "I:$failures tests failed.\n";
104 } else {
105 print "I:Update of $opt_s zone $zone successful.\n";
107 exit $failures;