|
| 1 | +{pkgs, ...}: let |
| 2 | + inherit (pkgs) epnixLib; |
| 3 | + inherit (pkgs.stdenv.hostPlatform) system; |
| 4 | + |
| 5 | + result = epnixLib.evalEpnixModules { |
| 6 | + nixpkgsConfig.system = system; |
| 7 | + epnixConfig.imports = [./pvxsIocTestTop/epnix.nix]; |
| 8 | + }; |
| 9 | + |
| 10 | + service = result.config.epnix.nixos.services.ioc.config; |
| 11 | + |
| 12 | + ioc = result.outputs.build; |
| 13 | +in |
| 14 | + pkgs.nixosTest { |
| 15 | + name = "support-pvxs-ioc"; |
| 16 | + meta.maintainers = with epnixLib.maintainers; [minijackson]; |
| 17 | + |
| 18 | + nodes = { |
| 19 | + client = { |
| 20 | + environment.systemPackages = [ |
| 21 | + pkgs.epnix.epics-base |
| 22 | + pkgs.epnix.support.pvxs |
| 23 | + ]; |
| 24 | + networking.firewall.allowedTCPPorts = [5075]; |
| 25 | + networking.firewall.allowedUDPPorts = [5076]; |
| 26 | + }; |
| 27 | + machine = { |
| 28 | + systemd.services.ioc = service; |
| 29 | + networking.firewall.allowedTCPPorts = [5075]; |
| 30 | + networking.firewall.allowedUDPPorts = [5076]; |
| 31 | + }; |
| 32 | + }; |
| 33 | + |
| 34 | + testScript = '' |
| 35 | + import json |
| 36 | +
|
| 37 | + start_all() |
| 38 | +
|
| 39 | + addr_list = "EPICS_PVA_ADDR_LIST=192.168.1.2" |
| 40 | +
|
| 41 | + def pvget(name: str): |
| 42 | + return json.loads(client.succeed(f"{addr_list} pvget {name} -M json | cut -d' ' -f2-")) |
| 43 | +
|
| 44 | + def pvxget(name: str): |
| 45 | + output = client.succeed(f"{addr_list} pvxget {name}") |
| 46 | + return output.splitlines()[1].split()[-1] |
| 47 | +
|
| 48 | + def _pvput(utility: str, name: str, value: str): |
| 49 | + client.succeed(f"{addr_list} {utility} {name} {value}") |
| 50 | +
|
| 51 | + def pvput(name: str, value: str): |
| 52 | + _pvput("pvput", name, value) |
| 53 | +
|
| 54 | + def pvxput(name: str, value: str): |
| 55 | + _pvput("pvxput", name, value) |
| 56 | +
|
| 57 | + with subtest("wait until IOC starts"): |
| 58 | + machine.wait_for_unit("ioc.service") |
| 59 | + client.wait_until_succeeds("EPICS_PVA_ADDR_LIST=192.168.1.2 pvget my:pv:name", timeout=60) |
| 60 | +
|
| 61 | + with subtest("PV has the correct value"): |
| 62 | + value = pvget("my:pv:name") |
| 63 | + assert value["value"] == 42 |
| 64 | + assert value["display"]["description"] == "My PV description" |
| 65 | +
|
| 66 | + with subtest("PV can be set"): |
| 67 | + pvput("my:pv:name", "1337") |
| 68 | + assert pvget("my:pv:name")["value"] == 1337 |
| 69 | +
|
| 70 | + with subtest("PVXS command-line utilities work"): |
| 71 | + assert pvxget("my:pv:name") == "1337" |
| 72 | + pvxput("my:pv:name", "42") |
| 73 | + assert pvxget("my:pv:name") == "42" |
| 74 | + client.succeed(f"{addr_list} pvxinfo my:pv:name") |
| 75 | + ''; |
| 76 | + |
| 77 | + passthru = { |
| 78 | + inherit ioc; |
| 79 | + }; |
| 80 | + } |
0 commit comments