From: Nicki Křížek Date: Fri, 25 Jul 2025 09:09:30 +0000 (+0200) Subject: Unify RR counting in isctest.check helper X-Git-Tag: v9.21.11~20^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=efd60348b9280383fe5d50042a94ea363390356d;p=thirdparty%2Fbind9.git Unify RR counting in isctest.check helper Use a common function to count the number of RRs in any section of the DNS message. For the ADDITIONAL section, stick with the dnspython convention of not including OPT and TSIG. --- diff --git a/bin/tests/system/isctest/check.py b/bin/tests/system/isctest/check.py index fd52ca9b603..ddfb85232bd 100644 --- a/bin/tests/system/isctest/check.py +++ b/bin/tests/system/isctest/check.py @@ -168,28 +168,10 @@ def empty_answer(message: dns.message.Message) -> None: assert not message.answer, str(message) -def answer_count_eq(m: dns.message.Message, expected: int): - count = sum(max(1, len(rrs)) for rrs in m.answer) - assert count == expected, str(m) - - -def authority_count_eq(m: dns.message.Message, expected: int): - count = sum(max(1, len(rrs)) for rrs in m.authority) - assert count == expected, str(m) - - -def additional_count_eq(m: dns.message.Message, expected: int): - count = sum(max(1, len(rrs)) for rrs in m.additional) - - # add one for the OPT? - opt = bool(m.opt) if hasattr(m, "opt") else bool(m.edns >= 0) - count += 1 if opt else 0 - - # add one for the TSIG? - tsig = bool(m.tsig) if hasattr(m, "tsig") else m.had_tsig - count += 1 if tsig else 0 - - assert count == expected, str(m) +def rr_count_eq(section: list, expected: int): + # NOTE: OPT and TSIG records aren't included in the count for ADDITIONAL section + count = sum(len(rrset) for rrset in section) + assert count == expected, str(section) def is_response_to(response: dns.message.Message, query: dns.message.Message) -> None: