[BACK]Return to tests.sh CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / external / mpl / bind / dist / bin / tests / system / masterformat

Annotation of src/external/mpl/bind/dist/bin/tests/system/masterformat/tests.sh, Revision 1.1.1.1.2.2

1.1.1.1.2.2! pgoyette    1: #!/bin/sh
        !             2: #
        !             3: # Copyright (C) Internet Systems Consortium, Inc. ("ISC")
        !             4: #
        !             5: # This Source Code Form is subject to the terms of the Mozilla Public
        !             6: # License, v. 2.0. If a copy of the MPL was not distributed with this
        !             7: # file, You can obtain one at http://mozilla.org/MPL/2.0/.
        !             8: #
        !             9: # See the COPYRIGHT file distributed with this work for additional
        !            10: # information regarding copyright ownership.
        !            11:
        !            12: SYSTEMTESTTOP=..
        !            13: . $SYSTEMTESTTOP/conf.sh
        !            14:
        !            15: ismap () {
        !            16:     $PERL -e 'binmode STDIN;
        !            17:             read(STDIN, $input, 8);
        !            18:              ($style, $version) = unpack("NN", $input);
        !            19:              exit 1 if ($style != 3 || $version > 1);' < $1
        !            20:     return $?
        !            21: }
        !            22:
        !            23: israw () {
        !            24:     $PERL -e 'binmode STDIN;
        !            25:              read(STDIN, $input, 8);
        !            26:              ($style, $version) = unpack("NN", $input);
        !            27:              exit 1 if ($style != 2 || $version > 1);' < $1
        !            28:     return $?
        !            29: }
        !            30:
        !            31: isfull () {
        !            32:     # there should be no whitespace at the beginning of a line
        !            33:     if grep '^[        ][      ]*' $1 > /dev/null 2>&1; then
        !            34:        return 1
        !            35:     else
        !            36:        return 0
        !            37:     fi
        !            38: }
        !            39:
        !            40: rawversion () {
        !            41:     $PERL -e 'binmode STDIN;
        !            42:              read(STDIN, $input, 8);
        !            43:              if (length($input) < 8) { print "not raw\n"; exit 0; };
        !            44:              ($style, $version) = unpack("NN", $input);
        !            45:              print ($style == 2 || $style == 3 ? "$version\n" :
        !            46:                "not raw or map\n");' < $1
        !            47: }
        !            48:
        !            49: sourceserial () {
        !            50:     $PERL -e 'binmode STDIN;
        !            51:              read(STDIN, $input, 20);
        !            52:              if (length($input) < 20) { print "UNSET\n"; exit; };
        !            53:              ($format, $version, $dumptime, $flags, $sourceserial) =
        !            54:                      unpack("NNNNN", $input);
        !            55:              if ($format != 2 || $version <  1) { print "UNSET\n"; exit; };
        !            56:              if ($flags & 02) {
        !            57:                      print $sourceserial . "\n";
        !            58:              } else {
        !            59:                      print "UNSET\n";
        !            60:              }' < $1
        !            61: }
        !            62:
        !            63: stomp () {
        !            64:         $PERL -e 'open(my $file, "+<", $ARGV[0]);
        !            65:                  binmode $file;
        !            66:                  seek($file, $ARGV[1], 0);
        !            67:                  for (my $i = 0; $i < $ARGV[2]; $i++) {
        !            68:                          print $file pack('C', $ARGV[3]);
        !            69:                  }
        !            70:                  close($file);' $1 $2 $3 $4
        !            71: }
        !            72:
        !            73: restart () {
        !            74:     sleep 1
        !            75:     (cd ..; $PERL start.pl --noclean --restart --port ${PORT} masterformat ns3)
        !            76: }
        !            77:
        !            78: DIGOPTS="+tcp +noauth +noadd +nosea +nostat +noquest +nocomm +nocmd -p ${PORT}"
        !            79: RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p ${CONTROLPORT} -s"
        !            80:
        !            81: status=0
        !            82:
        !            83: echo_i "checking that master files in raw format loaded"
        !            84: ret=0
        !            85: set -- 1 2 3
        !            86: for zone in example example-explicit example-compat; do
        !            87:     for server in $*; do
        !            88:        for name in ns mx a aaaa cname dname txt rrsig nsec \
        !            89:                    dnskey ds cdnskey cds; do
        !            90:                $DIG $DIGOPTS $name.$zone. $name @10.53.0.$server
        !            91:                echo
        !            92:        done > dig.out.$zone.$server
        !            93:     done
        !            94:     digcomp dig.out.$zone.1 dig.out.$zone.2 || ret=1
        !            95:     if [ $zone = "example" ]; then
        !            96:         set -- 1 2
        !            97:         digcomp dig.out.$zone.1 dig.out.$zone.3 || ret=1
        !            98:     fi
        !            99: done
        !           100: [ $ret -eq 0 ] || echo_i "failed"
        !           101: status=`expr $status + $ret`
        !           102:
        !           103: echo_i "checking raw format versions"
        !           104: ret=0
        !           105: israw ns1/example.db.raw || ret=1
        !           106: israw ns1/example.db.raw1 || ret=1
        !           107: israw ns1/example.db.compat || ret=1
        !           108: ismap ns1/example.db.map || ret=1
        !           109: [ "`rawversion ns1/example.db.raw`" = 1 ] || ret=1
        !           110: [ "`rawversion ns1/example.db.raw1`" = 1 ] || ret=1
        !           111: [ "`rawversion ns1/example.db.compat`" = 0 ] || ret=1
        !           112: [ "`rawversion ns1/example.db.map`" = 1 ] || ret=1
        !           113: [ $ret -eq 0 ] || echo_i "failed"
        !           114: status=`expr $status + $ret`
        !           115:
        !           116: echo_i "checking source serial numbers"
        !           117: ret=0
        !           118: [ "`sourceserial ns1/example.db.raw`" = "UNSET" ] || ret=1
        !           119: [ "`sourceserial ns1/example.db.serial.raw`" = "3333" ] || ret=1
        !           120: [ $ret -eq 0 ] || echo_i "failed"
        !           121: status=`expr $status + $ret`
        !           122:
        !           123: echo_i "waiting for transfers to complete"
        !           124: for i in 0 1 2 3 4 5 6 7 8 9
        !           125: do
        !           126:        test -f ns2/transfer.db.raw -a -f ns2/transfer.db.txt && break
        !           127:        sleep 1
        !           128: done
        !           129:
        !           130: echo_i "checking that slave was saved in raw format by default"
        !           131: ret=0
        !           132: israw ns2/transfer.db.raw || ret=1
        !           133: [ $ret -eq 0 ] || echo_i "failed"
        !           134: status=`expr $status + $ret`
        !           135:
        !           136: echo_i "checking that slave was saved in text format when configured"
        !           137: ret=0
        !           138: israw ns2/transfer.db.txt && ret=1
        !           139: isfull ns2/transfer.db.txt && ret=1
        !           140: [ $ret -eq 0 ] || echo_i "failed"
        !           141: status=`expr $status + $ret`
        !           142:
        !           143: echo_i "checking that slave was saved in 'full' style when configured"
        !           144: ret=0
        !           145: isfull ns2/transfer.db.full > /dev/null 2>&1 || ret=1
        !           146: [ $ret -eq 0 ] || echo_i "failed"
        !           147: status=`expr $status + $ret`
        !           148:
        !           149: echo_i "checking that slave formerly in text format is now raw"
        !           150: for i in 0 1 2 3 4 5 6 7 8 9
        !           151: do
        !           152:     ret=0
        !           153:     israw ns2/formerly-text.db > /dev/null 2>&1 || ret=1
        !           154:     [ "`rawversion ns2/formerly-text.db`" = 1 ] || ret=1
        !           155:     [ $ret -eq 0 ] && break
        !           156:     sleep 1
        !           157: done
        !           158: [ $ret -eq 0 ] || echo_i "failed"
        !           159: status=`expr $status + $ret`
        !           160:
        !           161: echo_i "checking that large rdatasets loaded"
        !           162: for i in 0 1 2 3 4 5 6 7 8 9
        !           163: do
        !           164: ret=0
        !           165: for a in a b c
        !           166: do
        !           167:        $DIG +tcp txt ${a}.large @10.53.0.2 -p ${PORT} > dig.out
        !           168:        grep "status: NOERROR" dig.out > /dev/null || ret=1
        !           169: done
        !           170: [ $ret -eq 0 ] && break
        !           171: sleep 1
        !           172: done
        !           173:
        !           174: echo_i "checking format transitions: text->raw->map->text"
        !           175: ret=0
        !           176: ./named-compilezone -D -f text -F text -o baseline.txt example.nil ns1/example.db > /dev/null
        !           177: ./named-compilezone -D -f text -F raw -o raw.1 example.nil baseline.txt > /dev/null
        !           178: ./named-compilezone -D -f raw -F map -o map.1 example.nil raw.1 > /dev/null
        !           179: ./named-compilezone -D -f map -F text -o text.1 example.nil map.1 > /dev/null
        !           180: cmp -s baseline.txt text.1 || ret=0
        !           181: [ $ret -eq 0 ] || echo_i "failed"
        !           182: status=`expr $status + $ret`
        !           183:
        !           184: echo_i "checking format transitions: text->map->raw->text"
        !           185: ret=0
        !           186: ./named-compilezone -D -f text -F map -o map.2 example.nil baseline.txt > /dev/null
        !           187: ./named-compilezone -D -f map -F raw -o raw.2 example.nil map.2 > /dev/null
        !           188: ./named-compilezone -D -f raw -F text -o text.2 example.nil raw.2 > /dev/null
        !           189: cmp -s baseline.txt text.2 || ret=0
        !           190: [ $ret -eq 0 ] || echo_i "failed"
        !           191: status=`expr $status + $ret`
        !           192:
        !           193: echo_i "checking map format loading with journal file rollforward"
        !           194: ret=0
        !           195: $NSUPDATE <<END > /dev/null || status=1
        !           196: server 10.53.0.3 ${PORT}
        !           197: ttl 600
        !           198: update add newtext.dynamic IN TXT "added text"
        !           199: update delete aaaa.dynamic
        !           200: send
        !           201: END
        !           202: $DIG $DIGOPTS @10.53.0.3 newtext.dynamic txt > dig.out.dynamic.3.1
        !           203: grep "added text" dig.out.dynamic.3.1 > /dev/null 2>&1 || ret=1
        !           204: $DIG $DIGOPTS +comm @10.53.0.3 added.dynamic txt > dig.out.dynamic.3.2
        !           205: grep "NXDOMAIN"  dig.out.dynamic.3.2 > /dev/null 2>&1 || ret=1
        !           206: # using "rndc halt" ensures that we don't dump the zone file
        !           207: $RNDCCMD 10.53.0.3 halt 2>&1 | sed 's/^/ns3 /' | cat_i
        !           208: restart
        !           209: for i in 0 1 2 3 4 5 6 7 8 9; do
        !           210:     lret=0
        !           211:     $DIG $DIGOPTS @10.53.0.3 newtext.dynamic txt > dig.out.dynamic.3.3
        !           212:     grep "added text" dig.out.dynamic.3.3 > /dev/null 2>&1 || lret=1
        !           213:     [ $lret -eq 0 ] && break;
        !           214: done
        !           215: [ $lret -eq 1 ] && ret=1
        !           216: $DIG $DIGOPTS +comm @10.53.0.3 added.dynamic txt > dig.out.dynamic.3.4
        !           217: grep "NXDOMAIN"  dig.out.dynamic.3.4 > /dev/null 2>&1 || ret=1
        !           218: [ $ret -eq 0 ] || echo_i "failed"
        !           219: status=`expr $status + $ret`
        !           220:
        !           221: echo_i "checking map format file dumps correctly"
        !           222: ret=0
        !           223: $NSUPDATE <<END > /dev/null || status=1
        !           224: server 10.53.0.3 ${PORT}
        !           225: ttl 600
        !           226: update add moretext.dynamic IN TXT "more text"
        !           227: send
        !           228: END
        !           229: $DIG $DIGOPTS @10.53.0.3 moretext.dynamic txt > dig.out.dynamic.3.5
        !           230: grep "more text" dig.out.dynamic.3.5 > /dev/null 2>&1 || ret=1
        !           231: # using "rndc stop" will cause the zone file to flush before shutdown
        !           232: $RNDCCMD 10.53.0.3 stop 2>&1 | sed 's/^/ns3 /' | cat_i
        !           233: rm ns3/*.jnl
        !           234: restart
        !           235: for i in 0 1 2 3 4 5 6 7 8 9; do
        !           236:     lret=0
        !           237:     $DIG $DIGOPTS +comm @10.53.0.3 moretext.dynamic txt > dig.out.dynamic.3.6
        !           238:     grep "more text" dig.out.dynamic.3.6 > /dev/null 2>&1 || lret=1
        !           239:     [ $lret -eq 0 ] && break;
        !           240: done
        !           241: [ $lret -eq 1 ] && ret=1
        !           242: [ $ret -eq 0 ] || echo_i "failed"
        !           243: status=`expr $status + $ret`
        !           244:
        !           245: # stomp on the file header
        !           246: echo_i "checking corrupt map files fail to load (bad file header)"
        !           247: ret=0
        !           248: ./named-compilezone -D -f text -F map -o map.5 example.nil baseline.txt > /dev/null
        !           249: cp map.5 badmap
        !           250: stomp badmap 0 32 99
        !           251: ./named-compilezone -D -f map -F text -o text.5 example.nil badmap > /dev/null
        !           252: [ $? = 1 ] || ret=1
        !           253: [ $ret -eq 0 ] || echo_i "failed"
        !           254: status=`expr $status + $ret`
        !           255: # stomp on the file data so it hashes differently.
        !           256: # these are small and subtle changes, so that the resulting file
        !           257: # would appear to be a legitimate map file and would not trigger an
        !           258: # assertion failure if loaded into memory, but should still fail to
        !           259: # load because of a SHA1 hash mismatch.
        !           260: echo_i "checking corrupt map files fail to load (bad node header)"
        !           261: ret=0
        !           262: cp map.5 badmap
        !           263: stomp badmap 2754 2 99
        !           264: ./named-compilezone -D -f map -F text -o text.5 example.nil badmap > /dev/null
        !           265: [ $? = 1 ] || ret=1
        !           266: [ $ret -eq 0 ] || echo_i "failed"
        !           267: status=`expr $status + $ret`
        !           268:
        !           269: echo_i "checking corrupt map files fail to load (bad node data)"
        !           270: ret=0
        !           271: cp map.5 badmap
        !           272: stomp badmap 2897 5 127
        !           273: ./named-compilezone -D -f map -F text -o text.5 example.nil badmap > /dev/null
        !           274: [ $? = 1 ] || ret=1
        !           275: [ $ret -eq 0 ] || echo_i "failed"
        !           276: status=`expr $status + $ret`
        !           277:
        !           278: echo_i "checking map format zone is scheduled for resigning (compilezone)"
        !           279: ret=0
        !           280: $RNDCCMD 10.53.0.1 zonestatus signed > rndc.out 2>&1 || ret=1
        !           281: grep 'next resign' rndc.out > /dev/null 2>&1 || ret=1
        !           282: [ $ret -eq 0 ] || echo_i "failed"
        !           283: status=`expr $status + $ret`
        !           284:
        !           285: echo_i "checking map format zone is scheduled for resigning (signzone)"
        !           286: ret=0
        !           287: $RNDCCMD 10.53.0.1 freeze signed > rndc.out 2>&1 || ret=1
        !           288: cd ns1
        !           289: $SIGNER -S -O map -f signed.db.map -o signed signed.db > /dev/null 2>&1
        !           290: cd ..
        !           291: $RNDCCMD 10.53.0.1 reload signed > rndc.out 2>&1 || ret=1
        !           292: $RNDCCMD 10.53.0.1 zonestatus signed > rndc.out 2>&1 || ret=1
        !           293: grep 'next resign' rndc.out > /dev/null 2>&1 || ret=1
        !           294: [ $ret -eq 0 ] || echo_i "failed"
        !           295: status=`expr $status + $ret`
        !           296:
        !           297: echo_i "exit status: $status"
        !           298: [ $status -eq 0 ] || exit 1

CVSweb <webmaster@jp.NetBSD.org>