@@ -5,7 +5,7 @@ let
55 # for a host utility with IPv6 support
66 environment.systemPackages = [ pkgs.bind ];
77 };
8−in import ./make-test.nix ({ pkgs, ...} : {
8+in import ./make-test-python.nix ({ pkgs, ...} : {
99 name = "nsd";
1010 meta = with pkgs.stdenv.lib.maintainers; {
1111 maintainers = [ aszlig ];
@@ -65,37 +65,35 @@ in import ./make-test.nix ({ pkgs, ...} : {
6565 };
6666
6767 testScript = ''
68− startAll;
68+ start_all()
6969
70− $clientv4->waitForUnit("network.target");
71− $clientv6->waitForUnit("network.target");
72− $server->waitForUnit("nsd.service");
70+ clientv4.wait_for_unit("network.target")
71+ clientv6.wait_for_unit("network.target")
72+ server.wait_for_unit("nsd.service")
7373
74− sub assertHost {
75− my ($type, $rr, $query, $expected) = @_;
76− my $self = $type eq 4 ? $clientv4 : $clientv6;
77− my $out = $self->succeed("host -$type -t $rr $query");
78− $self->log("output: $out");
79− chomp $out;
80− die "DNS IPv$type query on $query gave '$out' instead of '$expected'"
81− if ($out !~ $expected);
82− }
8374
84− foreach (4, 6) {
85− subtest "ipv$_", sub {
86− assertHost($_, "a", "example.com", qr/has no [^ ]+ record/);
87− assertHost($_, "aaaa", "example.com", qr/has no [^ ]+ record/);
75+ def assert_host(type, rr, query, expected):
76+ self = clientv4 if type == 4 else clientv6
77+ out = self.succeed(f"host -{type} -t {rr} {query}").rstrip()
78+ self.log(f"output: {out}")
79+ assert re.search(
80+ expected, out
81+ ), f"DNS IPv{type} query on {query} gave '{out}' instead of '{expected}'"
8882
89− assertHost($_, "soa", "example.com", qr/SOA.*?noc\.example\.com/);
90− assertHost($_, "a", "ipv4.example.com", qr/address 1.2.3.4$/);
91− assertHost($_, "aaaa", "ipv6.example.com", qr/address abcd::eeff$/);
9283
93− assertHost($_, "a", "deleg.example.com", qr/address 9.8.7.6$/);
94− assertHost($_, "aaaa", "deleg.example.com", qr/address fedc::bbaa$/);
84+ for ipv in 4, 6:
85+ with subtest(f"IPv{ipv}"):
86+ assert_host(ipv, "a", "example.com", "has no [^ ]+ record")
87+ assert_host(ipv, "aaaa", "example.com", "has no [^ ]+ record")
9588
96− assertHost($_, "a", "root", qr/address 1.8.7.4$/);
97− assertHost($_, "aaaa", "root", qr/address acbd::4$/);
98− };
99− }
89+ assert_host(ipv, "soa", "example.com", "SOA.*?noc\.example\.com")
90+ assert_host(ipv, "a", "ipv4.example.com", "address 1.2.3.4$")
91+ assert_host(ipv, "aaaa", "ipv6.example.com", "address abcd::eeff$")
92+
93+ assert_host(ipv, "a", "deleg.example.com", "address 9.8.7.6$")
94+ assert_host(ipv, "aaaa", "deleg.example.com", "address fedc::bbaa$")
95+
96+ assert_host(ipv, "a", "root", "address 1.8.7.4$")
97+ assert_host(ipv, "aaaa", "root", "address acbd::4$")
10098 '';
10199})