Skip to content

Commit 5319734

Browse files
committed
ioc/tests/pvxs: add test for using PVXS inside an IOC
1 parent ed01996 commit 5319734

22 files changed

+470
-1
lines changed

ioc/tests/default.nix

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ with pkgs.lib;
44
default-ioc-epics-base-3 = import ./default-ioc "3" args;
55
default-ioc-epics-base-7 = import ./default-ioc "7" args;
66

7+
support-autosave-simple = import ./support/autosave/simple args;
8+
support-pvxs-ioc = import ./support/pvxs/ioc args;
79
support-seq-simple = import ./support/seq/simple args;
810
support-StreamDevice-simple = import ./support/StreamDevice/simple args;
9-
support-autosave-simple = import ./support/autosave/simple args;
1011
}
1112
// (let
1213
checkCrossFor = crossSystem: let
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Install directories
2+
/bin/
3+
/cfg/
4+
/db/
5+
/dbd/
6+
/html/
7+
/include/
8+
/lib/
9+
/templates/
10+
11+
# Local configuration files
12+
/configure/*.local
13+
14+
# iocBoot generated files
15+
/iocBoot/*ioc*/cdCommands
16+
/iocBoot/*ioc*/dllPath.bat
17+
/iocBoot/*ioc*/envPaths
18+
/iocBoot/*ioc*/relPaths.sh
19+
20+
# Build directories
21+
O.*/
22+
23+
# Common files created by other tools
24+
/QtC-*
25+
/.vscode/
26+
*.orig
27+
*.log
28+
.*.swp
29+
.DS_Store
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Makefile at top of application tree
2+
TOP = .
3+
include $(TOP)/configure/CONFIG
4+
5+
# Directories to build, any order
6+
DIRS += configure
7+
DIRS += $(wildcard *Sup)
8+
DIRS += $(wildcard *App)
9+
DIRS += $(wildcard *Top)
10+
DIRS += $(wildcard iocBoot)
11+
12+
# The build order is controlled by these dependency rules:
13+
14+
# All dirs except configure depend on configure
15+
$(foreach dir, $(filter-out configure, $(DIRS)), \
16+
$(eval $(dir)_DEPEND_DIRS += configure))
17+
18+
# Any *App dirs depend on all *Sup dirs
19+
$(foreach dir, $(filter %App, $(DIRS)), \
20+
$(eval $(dir)_DEPEND_DIRS += $(filter %Sup, $(DIRS))))
21+
22+
# Any *Top dirs depend on all *Sup and *App dirs
23+
$(foreach dir, $(filter %Top, $(DIRS)), \
24+
$(eval $(dir)_DEPEND_DIRS += $(filter %Sup %App, $(DIRS))))
25+
26+
# iocBoot depends on all *App dirs
27+
iocBoot_DEPEND_DIRS += $(filter %App,$(DIRS))
28+
29+
# Add any additional dependency rules here:
30+
31+
include $(TOP)/configure/RULES_TOP
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# CONFIG - Load build configuration data
2+
#
3+
# Do not make changes to this file!
4+
5+
# Allow user to override where the build rules come from
6+
RULES = $(EPICS_BASE)
7+
8+
# RELEASE files point to other application tops
9+
include $(TOP)/configure/RELEASE
10+
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common
11+
12+
ifdef T_A
13+
-include $(TOP)/configure/RELEASE.Common.$(T_A)
14+
-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A)
15+
endif
16+
17+
# Check EPICS_BASE is set properly
18+
ifneq (file,$(origin EPICS_BASE))
19+
$(error EPICS_BASE must be set in a configure/RELEASE file)
20+
else
21+
ifeq ($(wildcard $(EPICS_BASE)/configure/CONFIG_BASE),)
22+
$(error EPICS_BASE does not point to an EPICS installation)
23+
endif
24+
endif
25+
26+
CONFIG = $(RULES)/configure
27+
include $(CONFIG)/CONFIG
28+
29+
# Override the Base definition:
30+
INSTALL_LOCATION = $(TOP)
31+
32+
# CONFIG_SITE files contain local build configuration settings
33+
include $(TOP)/configure/CONFIG_SITE
34+
35+
# Host-arch specific settings
36+
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common
37+
38+
ifdef T_A
39+
# Target-arch specific settings
40+
-include $(TOP)/configure/CONFIG_SITE.Common.$(T_A)
41+
42+
# Host & target specific settings
43+
-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
44+
endif
45+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# CONFIG_SITE
2+
3+
# Make any application-specific changes to the EPICS build
4+
# configuration variables in this file.
5+
#
6+
# Host/target specific settings can be specified in files named
7+
# CONFIG_SITE.$(EPICS_HOST_ARCH).Common
8+
# CONFIG_SITE.Common.$(T_A)
9+
# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A)
10+
11+
# CHECK_RELEASE controls the consistency checking of the support
12+
# applications pointed to by the RELEASE* files.
13+
# Normally CHECK_RELEASE should be set to YES.
14+
# Set CHECK_RELEASE to NO to disable checking completely.
15+
# Set CHECK_RELEASE to WARN to perform consistency checking but
16+
# continue building even if conflicts are found.
17+
CHECK_RELEASE = YES
18+
19+
# Set this when you only want to compile this application
20+
# for a subset of the cross-compiled target architectures
21+
# that Base is built for.
22+
#CROSS_COMPILER_TARGET_ARCHS = vxWorks-ppc32
23+
24+
# To install files into a location other than $(TOP) define
25+
# INSTALL_LOCATION here.
26+
#INSTALL_LOCATION=</absolute/path/to/install/top>
27+
28+
# Set this when the IOC and build host use different paths
29+
# to the install location. This may be needed to boot from
30+
# a Microsoft FTP server say, or on some NFS configurations.
31+
#IOCS_APPL_TOP = </IOC's/absolute/path/to/install/top>
32+
33+
# For application debugging purposes, override the HOST_OPT and/
34+
# or CROSS_OPT settings from base/configure/CONFIG_SITE
35+
#HOST_OPT = NO
36+
#CROSS_OPT = NO
37+
38+
# These allow developers to override the CONFIG_SITE variable
39+
# settings without having to modify the configure/CONFIG_SITE
40+
# file itself.
41+
-include $(TOP)/../CONFIG_SITE.local
42+
-include $(TOP)/configure/CONFIG_SITE.local
43+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
TOP=..
2+
3+
include $(TOP)/configure/CONFIG
4+
5+
TARGETS = $(CONFIG_TARGETS)
6+
CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS)))
7+
8+
include $(TOP)/configure/RULES
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# RELEASE - Location of external support modules
2+
#
3+
# IF YOU CHANGE ANY PATHS in this file or make API changes to
4+
# any modules it refers to, you should do a "make rebuild" in
5+
# this application's top level directory.
6+
#
7+
# The EPICS build process does not check dependencies against
8+
# any files from outside the application, so it is safest to
9+
# rebuild it completely if any modules it depends on change.
10+
#
11+
# Host- or target-specific settings can be given in files named
12+
# RELEASE.$(EPICS_HOST_ARCH).Common
13+
# RELEASE.Common.$(T_A)
14+
# RELEASE.$(EPICS_HOST_ARCH).$(T_A)
15+
#
16+
# This file is parsed by both GNUmake and an EPICS Perl script,
17+
# so it may ONLY contain definititions of paths to other support
18+
# modules, variable definitions that are used in module paths,
19+
# and include statements that pull in other RELEASE files.
20+
# Variables may be used before their values have been set.
21+
# Build variables that are NOT used in paths should be set in
22+
# the CONFIG_SITE file.
23+
24+
# Variables and paths to dependent modules:
25+
#MODULES = /path/to/modules
26+
#MYMODULE = $(MODULES)/my-module
27+
28+
# If using the sequencer, point SNCSEQ at its top directory:
29+
#SNCSEQ = $(MODULES)/seq-ver
30+
31+
# EPICS_BASE should appear last so earlier modules can override stuff:
32+
EPICS_BASE = /nix/store/9g8q47p14l33kbcz7agz8nz914ghmnzq-epics-base-7.0.7
33+
34+
# Set RULES here if you want to use build rules from somewhere
35+
# other than EPICS_BASE:
36+
#RULES = $(MODULES)/build-rules
37+
38+
# These lines allow developers to override these RELEASE settings
39+
# without having to modify this file directly.
40+
-include $(TOP)/../RELEASE.local
41+
-include $(TOP)/../RELEASE.$(EPICS_HOST_ARCH).local
42+
-include $(TOP)/configure/RELEASE.local
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# RULES
2+
3+
include $(CONFIG)/RULES
4+
5+
# Library should be rebuilt because LIBOBJS may have changed.
6+
$(LIBNAME): ../Makefile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#RULES.ioc
2+
include $(CONFIG)/RULES.ioc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#RULES_DIRS
2+
include $(CONFIG)/RULES_DIRS
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#RULES_TOP
2+
include $(CONFIG)/RULES_TOP
3+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{pkgs, ...}: {
2+
epnix = {
3+
meta.name = "checks-support-pvxs-ioc";
4+
buildConfig.src = ./.;
5+
6+
support.modules = with pkgs.epnix.support; [pvxs];
7+
8+
nixos.services.ioc = {
9+
app = "simple";
10+
ioc = "iocSimple";
11+
};
12+
};
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
TOP = ..
2+
include $(TOP)/configure/CONFIG
3+
DIRS += $(wildcard *ioc*)
4+
DIRS += $(wildcard as*)
5+
include $(CONFIG)/RULES_DIRS
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
TOP = ../..
2+
include $(TOP)/configure/CONFIG
3+
ARCH = $(EPICS_HOST_ARCH)
4+
TARGETS = envPaths
5+
include $(TOP)/configure/RULES.ioc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!../../bin/linux-x86_64/simple
2+
3+
< envPaths
4+
5+
epicsEnvSet("PREFIX", "autosave:test")
6+
7+
## Register all support components
8+
dbLoadDatabase("$(TOP)/dbd/simple.dbd")
9+
simple_registerRecordDeviceDriver(pdbbase)
10+
11+
iocInit()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
TOP=../..
2+
include $(TOP)/configure/CONFIG
3+
#----------------------------------------
4+
# ADD MACRO DEFINITIONS AFTER THIS LINE
5+
6+
#----------------------------------------------------
7+
# Create and install (or just install) into <top>/db
8+
# databases, templates, substitutions like this
9+
#DB += xxx.db
10+
11+
#----------------------------------------------------
12+
# If <anyname>.db template is not named <anyname>*.template add
13+
# <anyname>_template = <templatename>
14+
15+
include $(TOP)/configure/RULES
16+
#----------------------------------------
17+
# ADD RULES AFTER THIS LINE
18+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Makefile at top of application tree
2+
TOP = ..
3+
include $(TOP)/configure/CONFIG
4+
5+
# Directories to be built, in any order.
6+
# You can replace these wildcards with an explicit list
7+
DIRS += $(wildcard src* *Src*)
8+
DIRS += $(wildcard db* *Db*)
9+
10+
# If the build order matters, add dependency rules like this,
11+
# which specifies that xxxSrc must be built after src:
12+
#xxxSrc_DEPEND_DIRS += src
13+
14+
include $(TOP)/configure/RULES_DIRS

0 commit comments

Comments
 (0)