nixpkgs/nixos/tests/avahi.nix
Eelco Dolstra abe218950c Make it easier to run the tests
You can now run a test in the nixos/tests directory directly using
nix-build, e.g.

  $ nix-build '<nixos/tests/login.nix>' -A test

This gets rid of having to add the test to nixos/tests/default.nix.
(Of course, you still need to add it to nixos/release.nix if you want
Hydra to run the test.)
2014-04-14 14:02:44 +02:00

53 lines
1.8 KiB
Nix

# Test whether `avahi-daemon' and `libnss-mdns' work as expected.
import ./make-test.nix {
nodes = {
one =
{ config, pkgs, ... }: {
services.avahi.enable = true;
services.avahi.nssmdns = true;
};
two =
{ config, pkgs, ... }: {
services.avahi.enable = true;
services.avahi.nssmdns = true;
};
};
testScript =
'' startAll;
# mDNS.
$one->waitForUnit("network.target");
$one->succeed("avahi-resolve-host-name one.local | tee out >&2");
$one->succeed("test \"`cut -f1 < out`\" = one.local");
$one->succeed("avahi-resolve-host-name two.local | tee out >&2");
$one->succeed("test \"`cut -f1 < out`\" = two.local");
$two->waitForUnit("network.target");
$two->succeed("avahi-resolve-host-name one.local | tee out >&2");
$two->succeed("test \"`cut -f1 < out`\" = one.local");
$two->succeed("avahi-resolve-host-name two.local | tee out >&2");
$two->succeed("test \"`cut -f1 < out`\" = two.local");
# Basic DNS-SD.
$one->succeed("avahi-browse -r -t _workstation._tcp | tee out >&2");
$one->succeed("test `wc -l < out` -gt 0");
$two->succeed("avahi-browse -r -t _workstation._tcp | tee out >&2");
$two->succeed("test `wc -l < out` -gt 0");
# More DNS-SD.
$one->execute("avahi-publish -s \"This is a test\" _test._tcp 123 one=1 &");
$one->sleep(5);
$two->succeed("avahi-browse -r -t _test._tcp | tee out >&2");
$two->succeed("test `wc -l < out` -gt 0");
# NSS-mDNS.
$one->succeed("getent hosts one.local >&2");
$one->succeed("getent hosts two.local >&2");
$two->succeed("getent hosts one.local >&2");
$two->succeed("getent hosts two.local >&2");
'';
}