mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-29 05:28:00 +00:00
Rewrite rrchecker system test to pytest
This commit is contained in:
parent
4be1db6e82
commit
6a301c1d35
@ -1,3 +0,0 @@
|
||||
IN
|
||||
CH
|
||||
HS
|
@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
#
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# See the COPYRIGHT file distributed with this work for additional
|
||||
# information regarding copyright ownership.
|
||||
|
||||
rm -f classlist.out privatelist.out typelist.out tempzone checkzone.out* checker.out
|
@ -1,98 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
#
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# See the COPYRIGHT file distributed with this work for additional
|
||||
# information regarding copyright ownership.
|
||||
|
||||
set -e
|
||||
|
||||
. ../conf.sh
|
||||
|
||||
status=0
|
||||
n=0
|
||||
|
||||
n=$((n + 1))
|
||||
echo_i "class list ($n)"
|
||||
$RRCHECKER -C >classlist.out
|
||||
diff classlist.out classlist.good || {
|
||||
echo_i "failed"
|
||||
status=$((status + 1))
|
||||
}
|
||||
|
||||
n=$((n + 1))
|
||||
echo_i "type list ($n)"
|
||||
$RRCHECKER -T >typelist.out
|
||||
diff typelist.out typelist.good || {
|
||||
echo_i "failed"
|
||||
status=$((status + 1))
|
||||
}
|
||||
|
||||
n=$((n + 1))
|
||||
echo_i "private type list ($n)"
|
||||
$RRCHECKER -P >privatelist.out
|
||||
diff privatelist.out privatelist.good || {
|
||||
echo_i "failed"
|
||||
status=$((status + 1))
|
||||
}
|
||||
|
||||
myecho() {
|
||||
cat <<EOF
|
||||
$*
|
||||
EOF
|
||||
}
|
||||
|
||||
n=$((n + 1))
|
||||
echo_i "check conversions to canonical format ($n)"
|
||||
ret=0
|
||||
$SHELL ${TOP_SRCDIR}/bin/tests/system/genzone.sh 0 >tempzone
|
||||
$CHECKZONE -Dq . tempzone | sed '/^;/d' >checkzone.out$n
|
||||
while read -r name tt cl ty rest; do
|
||||
myecho "$cl $ty $rest" | $RRCHECKER -p >checker.out || {
|
||||
ret=1
|
||||
echo_i "'$cl $ty $rest' not handled."
|
||||
}
|
||||
read -r cl0 ty0 rest0 <checker.out
|
||||
test "$cl $ty $rest" = "$cl0 $ty0 $rest0" || {
|
||||
ret=1
|
||||
echo_i "'$cl $ty $rest' != '$cl0 $ty0 $rest0'"
|
||||
}
|
||||
done <checkzone.out$n
|
||||
test $ret -eq 0 || {
|
||||
echo_i "failed"
|
||||
status=$((status + 1))
|
||||
}
|
||||
|
||||
n=$((n + 1))
|
||||
echo_i "check conversions to and from unknown record format ($n)"
|
||||
ret=0
|
||||
$CHECKZONE -Dq . tempzone | sed '/^;/d' >checkzone.out$n
|
||||
while read -r name tt cl ty rest; do
|
||||
myecho "$cl $ty $rest" | $RRCHECKER -u >checker.out || {
|
||||
ret=1
|
||||
echo_i "'$cl $ty $rest' not converted to unknown record format"
|
||||
}
|
||||
read -r clu tyu restu <checker.out
|
||||
myecho "$clu $tyu $restu" | $RRCHECKER -p >checker.out || {
|
||||
ret=1
|
||||
echo_i "'$cl $ty $rest' not converted back to canonical format"
|
||||
}
|
||||
read -r cl0 ty0 rest0 <checker.out
|
||||
test "$cl $ty $rest" = "$cl0 $ty0 $rest0" || {
|
||||
ret=1
|
||||
echo_i "'$cl $ty $rest' != '$cl0 $ty0 $rest0'"
|
||||
}
|
||||
done <checkzone.out$n
|
||||
test $ret -eq 0 || {
|
||||
echo_i "failed"
|
||||
status=$((status + 1))
|
||||
}
|
||||
|
||||
echo_i "exit status: $status"
|
||||
[ $status -eq 0 ] || exit 1
|
188
bin/tests/system/rrchecker/tests_rrchecker.py
Normal file
188
bin/tests/system/rrchecker/tests_rrchecker.py
Normal file
@ -0,0 +1,188 @@
|
||||
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
#
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# See the COPYRIGHT file distributed with this work for additional
|
||||
# information regarding copyright ownership.
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"option,expected_result",
|
||||
[
|
||||
("-C", ["HS", "CH", "IN"]),
|
||||
(
|
||||
"-T",
|
||||
[
|
||||
"A",
|
||||
"A6",
|
||||
"AAAA",
|
||||
"AFSDB",
|
||||
"AMTRELAY",
|
||||
"APL",
|
||||
"ATMA",
|
||||
"AVC",
|
||||
"CAA",
|
||||
"CDNSKEY",
|
||||
"CDS",
|
||||
"CERT",
|
||||
"CNAME",
|
||||
"CSYNC",
|
||||
"DHCID",
|
||||
"DLV",
|
||||
"DNAME",
|
||||
"DNSKEY",
|
||||
"DOA",
|
||||
"DS",
|
||||
"EID",
|
||||
"EUI48",
|
||||
"EUI64",
|
||||
"GID",
|
||||
"GPOS",
|
||||
"HINFO",
|
||||
"HIP",
|
||||
"HTTPS",
|
||||
"IPSECKEY",
|
||||
"ISDN",
|
||||
"KEY",
|
||||
"KX",
|
||||
"L32",
|
||||
"L64",
|
||||
"LOC",
|
||||
"LP",
|
||||
"MB",
|
||||
"MD",
|
||||
"MF",
|
||||
"MG",
|
||||
"MINFO",
|
||||
"MR",
|
||||
"MX",
|
||||
"NAPTR",
|
||||
"NID",
|
||||
"NIMLOC",
|
||||
"NINFO",
|
||||
"NS",
|
||||
"NSAP",
|
||||
"NSAP-PTR",
|
||||
"NSEC",
|
||||
"NSEC3",
|
||||
"NSEC3PARAM",
|
||||
"NULL",
|
||||
"NXT",
|
||||
"OPENPGPKEY",
|
||||
"PTR",
|
||||
"PX",
|
||||
"RESINFO",
|
||||
"RKEY",
|
||||
"RP",
|
||||
"RRSIG",
|
||||
"RT",
|
||||
"SIG",
|
||||
"SINK",
|
||||
"SMIMEA",
|
||||
"SOA",
|
||||
"SPF",
|
||||
"SRV",
|
||||
"SSHFP",
|
||||
"SVCB",
|
||||
"TA",
|
||||
"TALINK",
|
||||
"TLSA",
|
||||
"TXT",
|
||||
"UID",
|
||||
"UINFO",
|
||||
"UNSPEC",
|
||||
"URI",
|
||||
"WKS",
|
||||
"X25",
|
||||
"ZONEMD",
|
||||
],
|
||||
),
|
||||
("-P", []),
|
||||
],
|
||||
)
|
||||
def test_rrchecker_list_standard_names(option, expected_result):
|
||||
stdout = subprocess.run(
|
||||
[
|
||||
os.environ["RRCHECKER"],
|
||||
option,
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check=True,
|
||||
).stdout.decode("utf-8")
|
||||
values = [line for line in stdout.split("\n") if line.strip()]
|
||||
|
||||
assert sorted(values) == sorted(expected_result)
|
||||
|
||||
|
||||
def run_rrchecker(option, rr_class, rr_type, rr_rest):
|
||||
with subprocess.Popen(
|
||||
[os.environ["RRCHECKER"], option],
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
) as process:
|
||||
rrchecker_output, _ = process.communicate(
|
||||
f"{rr_class} {rr_type} {rr_rest}".encode("utf-8")
|
||||
)
|
||||
return rrchecker_output.decode("utf-8").split()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("option", ["-p", "-u"])
|
||||
def test_rrchecker_conversions(option):
|
||||
tempzone_file = "tempzone"
|
||||
with open(tempzone_file, "w", encoding="utf-8") as file:
|
||||
subprocess.run(
|
||||
[
|
||||
os.environ["SHELL"],
|
||||
os.environ["TOP_SRCDIR"] + "/bin/tests/system/genzone.sh",
|
||||
"0",
|
||||
],
|
||||
stdout=file,
|
||||
stderr=subprocess.PIPE,
|
||||
check=True,
|
||||
)
|
||||
checkzone_output = subprocess.run(
|
||||
[
|
||||
os.environ["CHECKZONE"],
|
||||
"-D",
|
||||
"-q",
|
||||
".",
|
||||
tempzone_file,
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
check=True,
|
||||
).stdout.decode("utf-8")
|
||||
checkzone_output = [
|
||||
line for line in checkzone_output.splitlines() if not line.startswith(";")
|
||||
]
|
||||
|
||||
for rr in checkzone_output:
|
||||
rr_parts_orig = rr.split()
|
||||
assert len(rr_parts_orig) >= 4, f"invalid rr: {rr}"
|
||||
rr_class_orig, rr_type_orig, rr_rest_orig = (
|
||||
rr_parts_orig[2],
|
||||
rr_parts_orig[3],
|
||||
" ".join(rr_parts_orig[4:]),
|
||||
)
|
||||
rr_class, rr_type, rr_rest = rr_class_orig, rr_type_orig, rr_rest_orig
|
||||
if option == "-u":
|
||||
rr_class, rr_type, *rr_rest = run_rrchecker(
|
||||
"-u", rr_class_orig, rr_type_orig, rr_rest_orig
|
||||
)
|
||||
rr_rest = " ".join(rr_rest)
|
||||
|
||||
rr_class, rr_type, *rr_rest = run_rrchecker("-p", rr_class, rr_type, rr_rest)
|
||||
|
||||
assert rr_class_orig == rr_class
|
||||
assert rr_type_orig == rr_type
|
||||
assert rr_rest_orig == " ".join(rr_rest)
|
@ -1,14 +0,0 @@
|
||||
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
#
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
#
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
#
|
||||
# See the COPYRIGHT file distributed with this work for additional
|
||||
# information regarding copyright ownership.
|
||||
|
||||
|
||||
def test_rrchecker(run_tests_sh):
|
||||
run_tests_sh()
|
@ -1,82 +0,0 @@
|
||||
A
|
||||
NS
|
||||
MD
|
||||
MF
|
||||
CNAME
|
||||
SOA
|
||||
MB
|
||||
MG
|
||||
MR
|
||||
NULL
|
||||
WKS
|
||||
PTR
|
||||
HINFO
|
||||
MINFO
|
||||
MX
|
||||
TXT
|
||||
RP
|
||||
AFSDB
|
||||
X25
|
||||
ISDN
|
||||
RT
|
||||
NSAP
|
||||
NSAP-PTR
|
||||
SIG
|
||||
KEY
|
||||
PX
|
||||
GPOS
|
||||
AAAA
|
||||
LOC
|
||||
NXT
|
||||
EID
|
||||
NIMLOC
|
||||
SRV
|
||||
ATMA
|
||||
NAPTR
|
||||
KX
|
||||
CERT
|
||||
A6
|
||||
DNAME
|
||||
SINK
|
||||
APL
|
||||
DS
|
||||
SSHFP
|
||||
IPSECKEY
|
||||
RRSIG
|
||||
NSEC
|
||||
DNSKEY
|
||||
DHCID
|
||||
NSEC3
|
||||
NSEC3PARAM
|
||||
TLSA
|
||||
SMIMEA
|
||||
HIP
|
||||
NINFO
|
||||
RKEY
|
||||
TALINK
|
||||
CDS
|
||||
CDNSKEY
|
||||
OPENPGPKEY
|
||||
CSYNC
|
||||
ZONEMD
|
||||
SVCB
|
||||
HTTPS
|
||||
SPF
|
||||
UINFO
|
||||
UID
|
||||
GID
|
||||
UNSPEC
|
||||
NID
|
||||
L32
|
||||
L64
|
||||
LP
|
||||
EUI48
|
||||
EUI64
|
||||
URI
|
||||
CAA
|
||||
AVC
|
||||
DOA
|
||||
AMTRELAY
|
||||
RESINFO
|
||||
TA
|
||||
DLV
|
Loading…
x
Reference in New Issue
Block a user