12 import ./make-test-python.nix ({ pkgs, lib, ... }: {
16 networking.firewall.allowedTCPPorts = [ ircPort ];
19 package = pkgs.inspircdMinimal;
21 <bind address="" port="${toString ircPort}" type="clients">
22 <connect name="main" allow="*" pingfreq="15">
26 } // lib.listToAttrs (builtins.map (client: lib.nameValuePair client {
28 ./common/user-account.nix
31 systemd.services.ii = {
32 requires = [ "network.target" ];
33 wantedBy = [ "default.target" ];
37 ExecPreStartPre = "mkdir -p ${iiDir}";
39 ${lib.getBin pkgs.ii}/bin/ii -n ${client} -s ${server} -i ${iiDir}
48 msg = client: "Hello, my name is ${client}";
49 clientScript = client: [
51 ${client}.wait_for_unit("network.target")
52 ${client}.systemctl("start ii")
53 ${client}.wait_for_unit("ii")
54 ${client}.wait_for_file("${iiDir}/${server}/out")
56 # wait until first PING from server arrives before joining,
57 # so we don't try it too early
59 ${client}.wait_until_succeeds("grep 'PING' ${iiDir}/${server}/out")
63 ${client}.succeed("echo '/j #${channel}' > ${iiDir}/${server}/in")
64 ${client}.wait_for_file("${iiDir}/${server}/#${channel}/in")
69 "echo '${msg client}' > ${iiDir}/${server}/#${channel}/in"
72 # check that all greetings arrived on all clients
73 ] ++ builtins.map (other: ''
75 "grep '${msg other}$' ${iiDir}/${server}/#${channel}/out"
79 # foldl', but requires a non-empty list instead of a start value
81 builtins.foldl' f (builtins.head list) (builtins.tail list);
84 ${server}.wait_for_open_port(${toString ircPort})
86 # run clientScript for all clients so that every list
87 # entry is executed by every client before advancing
89 '' + lib.concatStrings
91 (lib.zipListsWith (cs: c: cs + c))
92 (builtins.map clientScript clients));