From 0386c7cbeb8cf5f8d15c373e570a01d54d7093ea Mon Sep 17 00:00:00 2001 From: Minijackson Date: Mon, 7 Aug 2023 13:10:02 +0200 Subject: [PATCH 1/4] pkgs/pvxs: init at 1.3.1 --- pkgs/default.nix | 1 + pkgs/epnix/support/pvxs/default.nix | 38 +++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 pkgs/epnix/support/pvxs/default.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index 6fab40d0..a56a169f 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -31,6 +31,7 @@ in epics-systemd = callPackage ./epnix/support/epics-systemd {}; ipac = callPackage ./epnix/support/ipac {}; modbus = callPackage ./epnix/support/modbus {}; + pvxs = callPackage ./epnix/support/pvxs {}; seq = callPackage ./epnix/support/seq {}; snmp = callPackage ./epnix/support/snmp {}; sscan = callPackage ./epnix/support/sscan {}; diff --git a/pkgs/epnix/support/pvxs/default.nix b/pkgs/epnix/support/pvxs/default.nix new file mode 100644 index 00000000..a0a9145a --- /dev/null +++ b/pkgs/epnix/support/pvxs/default.nix @@ -0,0 +1,38 @@ +{ + lib, + epnixLib, + mkEpicsPackage, + fetchFromGitHub, + libevent, + local_config_site ? {}, + local_release ? {}, +}: +mkEpicsPackage rec { + pname = "pvxs"; + version = "1.3.1"; + varname = "PVXS"; + + inherit local_config_site local_release; + + src = fetchFromGitHub { + owner = "mdavidsaver"; + repo = "pvxs"; + rev = version; + sha256 = "sha256-V/38TdjuBuhZE7bsvtLfQ3QH7bmwNdKHpvVeA81oOXY="; + }; + + # TODO: check pvxs cross-compilation, + # since it has a somewhat complex logic for finding libevent + propagatedNativeBuildInputs = [libevent]; + propagatedBuildInputs = [libevent]; + + # Only loopback interface is present + doCheck = false; + + meta = { + description = "PVA protocol client/server library and utilities"; + homepage = "https://mdavidsaver.github.io/pvxs/"; + license = lib.licenses.bsd3; + maintainers = with epnixLib.maintainers; [minijackson]; + }; +} From 0bd438f1ed63e2a392945f5fe16774b6c2715479 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Fri, 2 Feb 2024 13:14:57 +0100 Subject: [PATCH 2/4] ioc/tests/pvxs: add test for using PVXS inside an IOC --- ioc/tests/default.nix | 3 +- ioc/tests/support/pvxs/ioc/default.nix | 80 +++++++++++++++++++ .../pvxs/ioc/pvxsIocTestTop/.gitignore | 29 +++++++ .../support/pvxs/ioc/pvxsIocTestTop/Makefile | 31 +++++++ .../pvxs/ioc/pvxsIocTestTop/configure/CONFIG | 45 +++++++++++ .../ioc/pvxsIocTestTop/configure/CONFIG_SITE | 43 ++++++++++ .../ioc/pvxsIocTestTop/configure/Makefile | 8 ++ .../pvxs/ioc/pvxsIocTestTop/configure/RELEASE | 42 ++++++++++ .../pvxs/ioc/pvxsIocTestTop/configure/RULES | 6 ++ .../ioc/pvxsIocTestTop/configure/RULES.ioc | 2 + .../ioc/pvxsIocTestTop/configure/RULES_DIRS | 2 + .../ioc/pvxsIocTestTop/configure/RULES_TOP | 3 + .../support/pvxs/ioc/pvxsIocTestTop/epnix.nix | 13 +++ .../pvxs/ioc/pvxsIocTestTop/iocBoot/Makefile | 6 ++ .../pvxsIocTestTop/iocBoot/iocSimple/Makefile | 5 ++ .../pvxsIocTestTop/iocBoot/iocSimple/st.cmd | 11 +++ .../ioc/pvxsIocTestTop/simpleApp/Db/Makefile | 18 +++++ .../ioc/pvxsIocTestTop/simpleApp/Makefile | 14 ++++ .../ioc/pvxsIocTestTop/simpleApp/src/Makefile | 47 +++++++++++ .../pvxsIocTestTop/simpleApp/src/pvxsIoc.cpp | 39 +++++++++ .../simpleApp/src/registrar.dbd | 1 + .../simpleApp/src/simpleMain.cpp | 23 ++++++ 22 files changed, 470 insertions(+), 1 deletion(-) create mode 100644 ioc/tests/support/pvxs/ioc/default.nix create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/.gitignore create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/Makefile create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/CONFIG create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/CONFIG_SITE create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/Makefile create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RELEASE create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES.ioc create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES_DIRS create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES_TOP create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/epnix.nix create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/Makefile create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/iocSimple/Makefile create mode 100755 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/iocSimple/st.cmd create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/Db/Makefile create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/Makefile create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/Makefile create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/pvxsIoc.cpp create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/registrar.dbd create mode 100644 ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/simpleMain.cpp diff --git a/ioc/tests/default.nix b/ioc/tests/default.nix index 679e34e7..06dcd62e 100644 --- a/ioc/tests/default.nix +++ b/ioc/tests/default.nix @@ -4,9 +4,10 @@ with pkgs.lib; default-ioc-epics-base-3 = import ./default-ioc "3" args; default-ioc-epics-base-7 = import ./default-ioc "7" args; + support-autosave-simple = import ./support/autosave/simple args; + support-pvxs-ioc = import ./support/pvxs/ioc args; support-seq-simple = import ./support/seq/simple args; support-StreamDevice-simple = import ./support/StreamDevice/simple args; - support-autosave-simple = import ./support/autosave/simple args; } // (let checkCrossFor = crossSystem: let diff --git a/ioc/tests/support/pvxs/ioc/default.nix b/ioc/tests/support/pvxs/ioc/default.nix new file mode 100644 index 00000000..242ef9b5 --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/default.nix @@ -0,0 +1,80 @@ +{pkgs, ...}: let + inherit (pkgs) epnixLib; + inherit (pkgs.stdenv.hostPlatform) system; + + result = epnixLib.evalEpnixModules { + nixpkgsConfig.system = system; + epnixConfig.imports = [./pvxsIocTestTop/epnix.nix]; + }; + + service = result.config.epnix.nixos.services.ioc.config; + + ioc = result.outputs.build; +in + pkgs.nixosTest { + name = "support-pvxs-ioc"; + meta.maintainers = with epnixLib.maintainers; [minijackson]; + + nodes = { + client = { + environment.systemPackages = [ + pkgs.epnix.epics-base + pkgs.epnix.support.pvxs + ]; + networking.firewall.allowedTCPPorts = [5075]; + networking.firewall.allowedUDPPorts = [5076]; + }; + ioc = { + systemd.services.ioc = service; + networking.firewall.allowedTCPPorts = [5075]; + networking.firewall.allowedUDPPorts = [5076]; + }; + }; + + testScript = '' + import json + + start_all() + + addr_list = "EPICS_PVA_ADDR_LIST=192.168.1.2" + + def pvget(name: str): + return json.loads(client.succeed(f"{addr_list} pvget {name} -M json | cut -d' ' -f2-")) + + def pvxget(name: str): + output = client.succeed(f"{addr_list} pvxget {name}") + return output.splitlines()[1].split()[-1] + + def _pvput(utility: str, name: str, value: str): + client.succeed(f"{addr_list} {utility} {name} {value}") + + def pvput(name: str, value: str): + _pvput("pvput", name, value) + + def pvxput(name: str, value: str): + _pvput("pvxput", name, value) + + with subtest("wait until IOC starts"): + ioc.wait_for_unit("ioc.service") + client.wait_until_succeeds(f"{addr_list} pvget my:pv:name", timeout=60) + + with subtest("PV has the correct value"): + value = pvget("my:pv:name") + assert value["value"] == 42 + assert value["display"]["description"] == "My PV description" + + with subtest("PV can be set"): + pvput("my:pv:name", "1337") + assert pvget("my:pv:name")["value"] == 1337 + + with subtest("PVXS command-line utilities work"): + assert pvxget("my:pv:name") == "1337" + pvxput("my:pv:name", "42") + assert pvxget("my:pv:name") == "42" + client.succeed(f"{addr_list} pvxinfo my:pv:name") + ''; + + passthru = { + inherit ioc; + }; + } diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/.gitignore b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/.gitignore new file mode 100644 index 00000000..3d648caa --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/.gitignore @@ -0,0 +1,29 @@ +# Install directories +/bin/ +/cfg/ +/db/ +/dbd/ +/html/ +/include/ +/lib/ +/templates/ + +# Local configuration files +/configure/*.local + +# iocBoot generated files +/iocBoot/*ioc*/cdCommands +/iocBoot/*ioc*/dllPath.bat +/iocBoot/*ioc*/envPaths +/iocBoot/*ioc*/relPaths.sh + +# Build directories +O.*/ + +# Common files created by other tools +/QtC-* +/.vscode/ +*.orig +*.log +.*.swp +.DS_Store diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/Makefile b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/Makefile new file mode 100644 index 00000000..19c9068d --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/Makefile @@ -0,0 +1,31 @@ +# Makefile at top of application tree +TOP = . +include $(TOP)/configure/CONFIG + +# Directories to build, any order +DIRS += configure +DIRS += $(wildcard *Sup) +DIRS += $(wildcard *App) +DIRS += $(wildcard *Top) +DIRS += $(wildcard iocBoot) + +# The build order is controlled by these dependency rules: + +# All dirs except configure depend on configure +$(foreach dir, $(filter-out configure, $(DIRS)), \ + $(eval $(dir)_DEPEND_DIRS += configure)) + +# Any *App dirs depend on all *Sup dirs +$(foreach dir, $(filter %App, $(DIRS)), \ + $(eval $(dir)_DEPEND_DIRS += $(filter %Sup, $(DIRS)))) + +# Any *Top dirs depend on all *Sup and *App dirs +$(foreach dir, $(filter %Top, $(DIRS)), \ + $(eval $(dir)_DEPEND_DIRS += $(filter %Sup %App, $(DIRS)))) + +# iocBoot depends on all *App dirs +iocBoot_DEPEND_DIRS += $(filter %App,$(DIRS)) + +# Add any additional dependency rules here: + +include $(TOP)/configure/RULES_TOP diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/CONFIG b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/CONFIG new file mode 100644 index 00000000..34ace577 --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/CONFIG @@ -0,0 +1,45 @@ +# CONFIG - Load build configuration data +# +# Do not make changes to this file! + +# Allow user to override where the build rules come from +RULES = $(EPICS_BASE) + +# RELEASE files point to other application tops +include $(TOP)/configure/RELEASE +-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common + +ifdef T_A + -include $(TOP)/configure/RELEASE.Common.$(T_A) + -include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) +endif + +# Check EPICS_BASE is set properly +ifneq (file,$(origin EPICS_BASE)) + $(error EPICS_BASE must be set in a configure/RELEASE file) +else + ifeq ($(wildcard $(EPICS_BASE)/configure/CONFIG_BASE),) + $(error EPICS_BASE does not point to an EPICS installation) + endif +endif + +CONFIG = $(RULES)/configure +include $(CONFIG)/CONFIG + +# Override the Base definition: +INSTALL_LOCATION = $(TOP) + +# CONFIG_SITE files contain local build configuration settings +include $(TOP)/configure/CONFIG_SITE + +# Host-arch specific settings +-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common + +ifdef T_A + # Target-arch specific settings + -include $(TOP)/configure/CONFIG_SITE.Common.$(T_A) + + # Host & target specific settings + -include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) +endif + diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/CONFIG_SITE b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/CONFIG_SITE new file mode 100644 index 00000000..212485eb --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/CONFIG_SITE @@ -0,0 +1,43 @@ +# CONFIG_SITE + +# Make any application-specific changes to the EPICS build +# configuration variables in this file. +# +# Host/target specific settings can be specified in files named +# CONFIG_SITE.$(EPICS_HOST_ARCH).Common +# CONFIG_SITE.Common.$(T_A) +# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) + +# CHECK_RELEASE controls the consistency checking of the support +# applications pointed to by the RELEASE* files. +# Normally CHECK_RELEASE should be set to YES. +# Set CHECK_RELEASE to NO to disable checking completely. +# Set CHECK_RELEASE to WARN to perform consistency checking but +# continue building even if conflicts are found. +CHECK_RELEASE = YES + +# Set this when you only want to compile this application +# for a subset of the cross-compiled target architectures +# that Base is built for. +#CROSS_COMPILER_TARGET_ARCHS = vxWorks-ppc32 + +# To install files into a location other than $(TOP) define +# INSTALL_LOCATION here. +#INSTALL_LOCATION= + +# Set this when the IOC and build host use different paths +# to the install location. This may be needed to boot from +# a Microsoft FTP server say, or on some NFS configurations. +#IOCS_APPL_TOP = + +# For application debugging purposes, override the HOST_OPT and/ +# or CROSS_OPT settings from base/configure/CONFIG_SITE +#HOST_OPT = NO +#CROSS_OPT = NO + +# These allow developers to override the CONFIG_SITE variable +# settings without having to modify the configure/CONFIG_SITE +# file itself. +-include $(TOP)/../CONFIG_SITE.local +-include $(TOP)/configure/CONFIG_SITE.local + diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/Makefile b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/Makefile new file mode 100644 index 00000000..92543094 --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/Makefile @@ -0,0 +1,8 @@ +TOP=.. + +include $(TOP)/configure/CONFIG + +TARGETS = $(CONFIG_TARGETS) +CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS))) + +include $(TOP)/configure/RULES diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RELEASE b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RELEASE new file mode 100644 index 00000000..d3866518 --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RELEASE @@ -0,0 +1,42 @@ +# RELEASE - Location of external support modules +# +# IF YOU CHANGE ANY PATHS in this file or make API changes to +# any modules it refers to, you should do a "make rebuild" in +# this application's top level directory. +# +# The EPICS build process does not check dependencies against +# any files from outside the application, so it is safest to +# rebuild it completely if any modules it depends on change. +# +# Host- or target-specific settings can be given in files named +# RELEASE.$(EPICS_HOST_ARCH).Common +# RELEASE.Common.$(T_A) +# RELEASE.$(EPICS_HOST_ARCH).$(T_A) +# +# This file is parsed by both GNUmake and an EPICS Perl script, +# so it may ONLY contain definititions of paths to other support +# modules, variable definitions that are used in module paths, +# and include statements that pull in other RELEASE files. +# Variables may be used before their values have been set. +# Build variables that are NOT used in paths should be set in +# the CONFIG_SITE file. + +# Variables and paths to dependent modules: +#MODULES = /path/to/modules +#MYMODULE = $(MODULES)/my-module + +# If using the sequencer, point SNCSEQ at its top directory: +#SNCSEQ = $(MODULES)/seq-ver + +# EPICS_BASE should appear last so earlier modules can override stuff: +EPICS_BASE = /nix/store/9g8q47p14l33kbcz7agz8nz914ghmnzq-epics-base-7.0.7 + +# Set RULES here if you want to use build rules from somewhere +# other than EPICS_BASE: +#RULES = $(MODULES)/build-rules + +# These lines allow developers to override these RELEASE settings +# without having to modify this file directly. +-include $(TOP)/../RELEASE.local +-include $(TOP)/../RELEASE.$(EPICS_HOST_ARCH).local +-include $(TOP)/configure/RELEASE.local diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES new file mode 100644 index 00000000..6d56e14e --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES @@ -0,0 +1,6 @@ +# RULES + +include $(CONFIG)/RULES + +# Library should be rebuilt because LIBOBJS may have changed. +$(LIBNAME): ../Makefile diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES.ioc b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES.ioc new file mode 100644 index 00000000..901987c6 --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES.ioc @@ -0,0 +1,2 @@ +#RULES.ioc +include $(CONFIG)/RULES.ioc diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES_DIRS b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES_DIRS new file mode 100644 index 00000000..3ba269dc --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES_DIRS @@ -0,0 +1,2 @@ +#RULES_DIRS +include $(CONFIG)/RULES_DIRS diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES_TOP b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES_TOP new file mode 100644 index 00000000..d09d668d --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/configure/RULES_TOP @@ -0,0 +1,3 @@ +#RULES_TOP +include $(CONFIG)/RULES_TOP + diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/epnix.nix b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/epnix.nix new file mode 100644 index 00000000..91a433be --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/epnix.nix @@ -0,0 +1,13 @@ +{pkgs, ...}: { + epnix = { + meta.name = "checks-support-pvxs-ioc"; + buildConfig.src = ./.; + + support.modules = with pkgs.epnix.support; [pvxs]; + + nixos.services.ioc = { + app = "simple"; + ioc = "iocSimple"; + }; + }; +} diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/Makefile b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/Makefile new file mode 100644 index 00000000..91e47d0b --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/Makefile @@ -0,0 +1,6 @@ +TOP = .. +include $(TOP)/configure/CONFIG +DIRS += $(wildcard *ioc*) +DIRS += $(wildcard as*) +include $(CONFIG)/RULES_DIRS + diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/iocSimple/Makefile b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/iocSimple/Makefile new file mode 100644 index 00000000..e1b9aa4a --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/iocSimple/Makefile @@ -0,0 +1,5 @@ +TOP = ../.. +include $(TOP)/configure/CONFIG +ARCH = $(EPICS_HOST_ARCH) +TARGETS = envPaths +include $(TOP)/configure/RULES.ioc diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/iocSimple/st.cmd b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/iocSimple/st.cmd new file mode 100755 index 00000000..5eeca7b8 --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/iocBoot/iocSimple/st.cmd @@ -0,0 +1,11 @@ +#!../../bin/linux-x86_64/simple + +< envPaths + +epicsEnvSet("PREFIX", "autosave:test") + +## Register all support components +dbLoadDatabase("$(TOP)/dbd/simple.dbd") +simple_registerRecordDeviceDriver(pdbbase) + +iocInit() diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/Db/Makefile b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/Db/Makefile new file mode 100644 index 00000000..8eb97279 --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/Db/Makefile @@ -0,0 +1,18 @@ +TOP=../.. +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE + +#---------------------------------------------------- +# Create and install (or just install) into /db +# databases, templates, substitutions like this +#DB += xxx.db + +#---------------------------------------------------- +# If .db template is not named *.template add +# _template = + +include $(TOP)/configure/RULES +#---------------------------------------- +# ADD RULES AFTER THIS LINE + diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/Makefile b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/Makefile new file mode 100644 index 00000000..60ab8ae8 --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/Makefile @@ -0,0 +1,14 @@ +# Makefile at top of application tree +TOP = .. +include $(TOP)/configure/CONFIG + +# Directories to be built, in any order. +# You can replace these wildcards with an explicit list +DIRS += $(wildcard src* *Src*) +DIRS += $(wildcard db* *Db*) + +# If the build order matters, add dependency rules like this, +# which specifies that xxxSrc must be built after src: +#xxxSrc_DEPEND_DIRS += src + +include $(TOP)/configure/RULES_DIRS diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/Makefile b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/Makefile new file mode 100644 index 00000000..0e305c32 --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/Makefile @@ -0,0 +1,47 @@ +TOP=../.. + +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE +#============================= + +#============================= +# Build the IOC application + +PROD_IOC = simple +# simple.dbd will be created and installed +DBD += simple.dbd + +# simple.dbd will be made up from these files: +simple_DBD += base.dbd + +# Include dbd files from all support applications: +simple_DBD += pvxsIoc.dbd + +simple_DBD += registrar.dbd + +# Add all the support libraries needed by this IOC +#simple_LIBS += xxx +simple_LIBS += pvxsIoc pvxs + +# simple_registerRecordDeviceDriver.cpp derives from simple.dbd +simple_SRCS += simple_registerRecordDeviceDriver.cpp + +# Build the main IOC entry point on workstation OSs. +simple_SRCS_DEFAULT += simpleMain.cpp +simple_SRCS_vxWorks += -nil- + +simple_SRCS += pvxsIoc.cpp + +# Add support from base/src/vxWorks if needed +#simple_OBJS_vxWorks += $(EPICS_BASE_BIN)/vxComLibrary + +# Finally link to the EPICS Base libraries +simple_LIBS += $(EPICS_BASE_IOC_LIBS) + +#=========================== + +include $(TOP)/configure/RULES +#---------------------------------------- +# ADD RULES AFTER THIS LINE + diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/pvxsIoc.cpp b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/pvxsIoc.cpp new file mode 100644 index 00000000..8be2bbfd --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/pvxsIoc.cpp @@ -0,0 +1,39 @@ +#include +#include + +#include +#include +#include +#include + +// Adapted from the Adding custom PVs to Server here: +// https://mdavidsaver.github.io/pvxs/ioc.html#adding-custom-pvs-to-server + +static void myinitHook(initHookState state) { + if (state != initHookAfterIocBuilt) { + return; + } + + // Must provide a data type for the mailbox. + // Use pre-canned definition of scalar with meta-data + pvxs::Value initial = + pvxs::nt::NTScalar{pvxs::TypeCode::UInt32, true}.create(); + + // (optional) Provide an initial value + initial["value"] = 42u; + initial["alarm.severity"] = 0; + initial["alarm.status"] = 0; + initial["alarm.message"] = ""; + initial["display.description"] = "My PV description"; + + pvxs::server::SharedPV mypv(pvxs::server::SharedPV::buildMailbox()); + mypv.open(initial); + + pvxs::ioc::server().addPV("my:pv:name", mypv); +} + +static void pvxs_ioc_registrar() { initHookRegister(&myinitHook); } + +extern "C" { +epicsExportRegistrar(pvxs_ioc_registrar); +} diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/registrar.dbd b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/registrar.dbd new file mode 100644 index 00000000..12834046 --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/registrar.dbd @@ -0,0 +1 @@ +registrar(pvxs_ioc_registrar) diff --git a/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/simpleMain.cpp b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/simpleMain.cpp new file mode 100644 index 00000000..e4e5e3b2 --- /dev/null +++ b/ioc/tests/support/pvxs/ioc/pvxsIocTestTop/simpleApp/src/simpleMain.cpp @@ -0,0 +1,23 @@ +/* simpleMain.cpp */ +/* Author: Marty Kraimer Date: 17MAR2000 */ + +#include +#include +#include +#include +#include + +#include "epicsExit.h" +#include "epicsThread.h" +#include "iocsh.h" + +int main(int argc,char *argv[]) +{ + if(argc>=2) { + iocsh(argv[1]); + epicsThreadSleep(.2); + } + iocsh(NULL); + epicsExit(0); + return(0); +} From 50862112dbceb9359ed6f18d7a1f4b95fe07d484 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Fri, 2 Feb 2024 16:00:56 +0100 Subject: [PATCH 3/4] ioc/tests/pvxs: add test for PVXS as standalone server --- ioc/tests/default.nix | 1 + .../pvxs/standalone-server/default.nix | 90 +++++++++++++++++++ .../pvxsStandaloneServerTestTop/.gitignore | 29 ++++++ .../pvxsStandaloneServerTestTop/Makefile | 10 +++ .../configure/CONFIG | 45 ++++++++++ .../configure/CONFIG_SITE | 43 +++++++++ .../configure/Makefile | 8 ++ .../configure/RELEASE | 42 +++++++++ .../configure/RULES | 6 ++ .../configure/RULES.ioc | 2 + .../configure/RULES_DIRS | 2 + .../configure/RULES_TOP | 3 + .../pvxsStandaloneServerTestTop/epnix.nix | 8 ++ .../pvxsStandaloneServerTestTop/src/Makefile | 21 +++++ .../src/mailboxServer.cpp | 90 +++++++++++++++++++ 15 files changed, 400 insertions(+) create mode 100644 ioc/tests/support/pvxs/standalone-server/default.nix create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/.gitignore create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/Makefile create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/CONFIG create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/CONFIG_SITE create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/Makefile create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RELEASE create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES.ioc create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES_DIRS create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES_TOP create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/epnix.nix create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/src/Makefile create mode 100644 ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/src/mailboxServer.cpp diff --git a/ioc/tests/default.nix b/ioc/tests/default.nix index 06dcd62e..edad9b91 100644 --- a/ioc/tests/default.nix +++ b/ioc/tests/default.nix @@ -6,6 +6,7 @@ with pkgs.lib; support-autosave-simple = import ./support/autosave/simple args; support-pvxs-ioc = import ./support/pvxs/ioc args; + support-pvxs-standalone-server = import ./support/pvxs/standalone-server args; support-seq-simple = import ./support/seq/simple args; support-StreamDevice-simple = import ./support/StreamDevice/simple args; } diff --git a/ioc/tests/support/pvxs/standalone-server/default.nix b/ioc/tests/support/pvxs/standalone-server/default.nix new file mode 100644 index 00000000..5878fde0 --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/default.nix @@ -0,0 +1,90 @@ +{pkgs, ...}: let + inherit (pkgs) epnixLib; + inherit (pkgs.stdenv.hostPlatform) system; + + result = epnixLib.evalEpnixModules { + nixpkgsConfig.system = system; + epnixConfig.imports = [./pvxsStandaloneServerTestTop/epnix.nix]; + }; + + ioc = result.outputs.build; +in + pkgs.nixosTest { + name = "support-pvxs-standalone-server"; + meta.maintainers = with epnixLib.maintainers; [minijackson]; + + nodes = { + client = { + environment.systemPackages = [ + pkgs.epnix.epics-base + pkgs.epnix.support.pvxs + ]; + networking.firewall.allowedTCPPorts = [5075]; + networking.firewall.allowedUDPPorts = [5076]; + }; + ioc = { + systemd.services.ioc = { + wantedBy = ["multi-user.target"]; + wants = ["network-online.target"]; + after = ["network-online.target"]; + + description = "EPICS PVXS standalone IOC server"; + + serviceConfig = { + ExecStart = "${ioc}/bin/mailboxServer"; + Restart = "always"; + }; + }; + networking.firewall.allowedTCPPorts = [5075]; + networking.firewall.allowedUDPPorts = [5076]; + }; + }; + + testScript = '' + import json + + start_all() + + addr_list = "EPICS_PVA_ADDR_LIST=192.168.1.2" + + def pvget(name: str): + return json.loads(client.succeed(f"{addr_list} pvget {name} -M json | cut -d' ' -f2-")) + + def pvxget(name: str): + output = client.succeed(f"{addr_list} pvxget {name}") + return output.splitlines()[1].split()[-1] + + def _pvput(utility: str, name: str, value: str): + client.succeed(f"{addr_list} {utility} {name} {value}") + + def pvput(name: str, value: str): + _pvput("pvput", name, value) + + def pvxput(name: str, value: str): + _pvput("pvxput", name, value) + + with subtest("wait until IOC starts"): + ioc.wait_for_unit("ioc.service") + client.wait_until_succeeds(f"{addr_list} pvget my:pv:name", timeout=60) + + with subtest("PV has the correct value"): + value = pvget("my:pv:name") + assert value["value"] == 42 + assert value["display"]["description"] == "My PV description" + + with subtest("PV can be set"): + pvput("my:pv:name", "1337") + # PV is clipped + assert pvget("my:pv:name")["value"] == 100 + + with subtest("PVXS command-line utilities work"): + assert pvxget("my:pv:name") == "100" + pvxput("my:pv:name", "42") + assert pvxget("my:pv:name") == "42" + client.succeed(f"{addr_list} pvxinfo my:pv:name") + ''; + + passthru = { + inherit ioc; + }; + } diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/.gitignore b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/.gitignore new file mode 100644 index 00000000..3d648caa --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/.gitignore @@ -0,0 +1,29 @@ +# Install directories +/bin/ +/cfg/ +/db/ +/dbd/ +/html/ +/include/ +/lib/ +/templates/ + +# Local configuration files +/configure/*.local + +# iocBoot generated files +/iocBoot/*ioc*/cdCommands +/iocBoot/*ioc*/dllPath.bat +/iocBoot/*ioc*/envPaths +/iocBoot/*ioc*/relPaths.sh + +# Build directories +O.*/ + +# Common files created by other tools +/QtC-* +/.vscode/ +*.orig +*.log +.*.swp +.DS_Store diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/Makefile b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/Makefile new file mode 100644 index 00000000..d8c7ad5c --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/Makefile @@ -0,0 +1,10 @@ +# Makefile at top of application tree +TOP = . +include $(TOP)/configure/CONFIG + +DIRS += configure +DIRS += src + +src_DEPEND_DIRS += configure + +include $(TOP)/configure/RULES_TOP diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/CONFIG b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/CONFIG new file mode 100644 index 00000000..34ace577 --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/CONFIG @@ -0,0 +1,45 @@ +# CONFIG - Load build configuration data +# +# Do not make changes to this file! + +# Allow user to override where the build rules come from +RULES = $(EPICS_BASE) + +# RELEASE files point to other application tops +include $(TOP)/configure/RELEASE +-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common + +ifdef T_A + -include $(TOP)/configure/RELEASE.Common.$(T_A) + -include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) +endif + +# Check EPICS_BASE is set properly +ifneq (file,$(origin EPICS_BASE)) + $(error EPICS_BASE must be set in a configure/RELEASE file) +else + ifeq ($(wildcard $(EPICS_BASE)/configure/CONFIG_BASE),) + $(error EPICS_BASE does not point to an EPICS installation) + endif +endif + +CONFIG = $(RULES)/configure +include $(CONFIG)/CONFIG + +# Override the Base definition: +INSTALL_LOCATION = $(TOP) + +# CONFIG_SITE files contain local build configuration settings +include $(TOP)/configure/CONFIG_SITE + +# Host-arch specific settings +-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common + +ifdef T_A + # Target-arch specific settings + -include $(TOP)/configure/CONFIG_SITE.Common.$(T_A) + + # Host & target specific settings + -include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) +endif + diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/CONFIG_SITE b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/CONFIG_SITE new file mode 100644 index 00000000..212485eb --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/CONFIG_SITE @@ -0,0 +1,43 @@ +# CONFIG_SITE + +# Make any application-specific changes to the EPICS build +# configuration variables in this file. +# +# Host/target specific settings can be specified in files named +# CONFIG_SITE.$(EPICS_HOST_ARCH).Common +# CONFIG_SITE.Common.$(T_A) +# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) + +# CHECK_RELEASE controls the consistency checking of the support +# applications pointed to by the RELEASE* files. +# Normally CHECK_RELEASE should be set to YES. +# Set CHECK_RELEASE to NO to disable checking completely. +# Set CHECK_RELEASE to WARN to perform consistency checking but +# continue building even if conflicts are found. +CHECK_RELEASE = YES + +# Set this when you only want to compile this application +# for a subset of the cross-compiled target architectures +# that Base is built for. +#CROSS_COMPILER_TARGET_ARCHS = vxWorks-ppc32 + +# To install files into a location other than $(TOP) define +# INSTALL_LOCATION here. +#INSTALL_LOCATION= + +# Set this when the IOC and build host use different paths +# to the install location. This may be needed to boot from +# a Microsoft FTP server say, or on some NFS configurations. +#IOCS_APPL_TOP = + +# For application debugging purposes, override the HOST_OPT and/ +# or CROSS_OPT settings from base/configure/CONFIG_SITE +#HOST_OPT = NO +#CROSS_OPT = NO + +# These allow developers to override the CONFIG_SITE variable +# settings without having to modify the configure/CONFIG_SITE +# file itself. +-include $(TOP)/../CONFIG_SITE.local +-include $(TOP)/configure/CONFIG_SITE.local + diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/Makefile b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/Makefile new file mode 100644 index 00000000..92543094 --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/Makefile @@ -0,0 +1,8 @@ +TOP=.. + +include $(TOP)/configure/CONFIG + +TARGETS = $(CONFIG_TARGETS) +CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS))) + +include $(TOP)/configure/RULES diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RELEASE b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RELEASE new file mode 100644 index 00000000..d3866518 --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RELEASE @@ -0,0 +1,42 @@ +# RELEASE - Location of external support modules +# +# IF YOU CHANGE ANY PATHS in this file or make API changes to +# any modules it refers to, you should do a "make rebuild" in +# this application's top level directory. +# +# The EPICS build process does not check dependencies against +# any files from outside the application, so it is safest to +# rebuild it completely if any modules it depends on change. +# +# Host- or target-specific settings can be given in files named +# RELEASE.$(EPICS_HOST_ARCH).Common +# RELEASE.Common.$(T_A) +# RELEASE.$(EPICS_HOST_ARCH).$(T_A) +# +# This file is parsed by both GNUmake and an EPICS Perl script, +# so it may ONLY contain definititions of paths to other support +# modules, variable definitions that are used in module paths, +# and include statements that pull in other RELEASE files. +# Variables may be used before their values have been set. +# Build variables that are NOT used in paths should be set in +# the CONFIG_SITE file. + +# Variables and paths to dependent modules: +#MODULES = /path/to/modules +#MYMODULE = $(MODULES)/my-module + +# If using the sequencer, point SNCSEQ at its top directory: +#SNCSEQ = $(MODULES)/seq-ver + +# EPICS_BASE should appear last so earlier modules can override stuff: +EPICS_BASE = /nix/store/9g8q47p14l33kbcz7agz8nz914ghmnzq-epics-base-7.0.7 + +# Set RULES here if you want to use build rules from somewhere +# other than EPICS_BASE: +#RULES = $(MODULES)/build-rules + +# These lines allow developers to override these RELEASE settings +# without having to modify this file directly. +-include $(TOP)/../RELEASE.local +-include $(TOP)/../RELEASE.$(EPICS_HOST_ARCH).local +-include $(TOP)/configure/RELEASE.local diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES new file mode 100644 index 00000000..6d56e14e --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES @@ -0,0 +1,6 @@ +# RULES + +include $(CONFIG)/RULES + +# Library should be rebuilt because LIBOBJS may have changed. +$(LIBNAME): ../Makefile diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES.ioc b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES.ioc new file mode 100644 index 00000000..901987c6 --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES.ioc @@ -0,0 +1,2 @@ +#RULES.ioc +include $(CONFIG)/RULES.ioc diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES_DIRS b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES_DIRS new file mode 100644 index 00000000..3ba269dc --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES_DIRS @@ -0,0 +1,2 @@ +#RULES_DIRS +include $(CONFIG)/RULES_DIRS diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES_TOP b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES_TOP new file mode 100644 index 00000000..d09d668d --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/configure/RULES_TOP @@ -0,0 +1,3 @@ +#RULES_TOP +include $(CONFIG)/RULES_TOP + diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/epnix.nix b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/epnix.nix new file mode 100644 index 00000000..6b8a90dd --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/epnix.nix @@ -0,0 +1,8 @@ +{pkgs, ...}: { + epnix = { + meta.name = "checks-support-pvxs-standalone-server"; + buildConfig.src = ./.; + + support.modules = with pkgs.epnix.support; [pvxs]; + }; +} diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/src/Makefile b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/src/Makefile new file mode 100644 index 00000000..f597a1ee --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/src/Makefile @@ -0,0 +1,21 @@ +TOP=.. + +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE +#============================= + +#============================= +# Build the IOC application + +PROD_IOC = mailboxServer + +mailboxServer_LIBS += pvxsIoc pvxs Com +mailboxServer_SRCS += mailboxServer.cpp + +#=========================== + +include $(TOP)/configure/RULES +#---------------------------------------- +# ADD RULES AFTER THIS LINE + diff --git a/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/src/mailboxServer.cpp b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/src/mailboxServer.cpp new file mode 100644 index 00000000..f070cdc7 --- /dev/null +++ b/ioc/tests/support/pvxs/standalone-server/pvxsStandaloneServerTestTop/src/mailboxServer.cpp @@ -0,0 +1,90 @@ +#include + +#include + +#include +#include +#include +#include + +using namespace pvxs; + +// Adapted from the Mailbox Server example here: +// https://mdavidsaver.github.io/pvxs/example.html#mailbox-server + +int main() { + // Read $PVXS_LOG from process environment and update + // logging configuration. eg. + // export PVXS_LOG=*=DEBUG + // makes a lot of noise. + logger_config_env(); + + // Must provide a data type for the mailbox. + // Use pre-canned definition of scalar with meta-data + Value initial = nt::NTScalar{TypeCode::Float64, true}.create(); + + // (optional) Provide an initial value + initial["value"] = 42.0; + initial["alarm.severity"] = 0; + initial["alarm.status"] = 0; + initial["alarm.message"] = ""; + initial["display.description"] = "My PV description"; + + // Actually creating a mailbox PV. + // buildMailbox() installs a default onPut() handler which + // stores whatever a client sends (subject to our data type). + server::SharedPV pv(server::SharedPV::buildMailbox()); + + // (optional) Replace the default PUT handler to do a range check + pv.onPut([](server::SharedPV &pv, std::unique_ptr &&op, + Value &&top) { + // arbitrarily clip value to [-100.0, 100.0] + double val(top["value"].as()); + if (val < -100.0) { + top["value"] = -100.0; + } else if (val > 100.0) { + top["value"] = 100.0; + } + + // Provide a timestamp if the client has not (common) + Value ts(top["timeStamp"]); + if (!ts.isMarked(true, true)) { + // use current time + epicsTimeStamp now; + if (!epicsTimeGetCurrent(&now)) { + ts["secondsPastEpoch"] = now.secPastEpoch + POSIX_TIME_AT_EPICS_EPOCH; + ts["nanoseconds"] = now.nsec; + } + } + + // update the SharedPV cache and send + // a update to any subscribers + pv.post(top); + + // Required. Inform client that PUT operation is complete. + op->reply(); + }); + + // Associate a data type (and maybe initial value) with this PV + pv.open(initial); + + // Build server which will serve this PV + // Configure using process environment. + auto serv(server::Server::fromEnv()); + + serv.addPV("my:pv:name", pv); + + // (optional) Print the configuration this server is using + // with any auto-address list expanded. + std::cout << "Effective config\n" << serv.config(); + + std::cout << "Running\n"; + + // Start server and run forever, or until Ctrl+c is pressed. + // Returns on SIGINT or SIGTERM + serv.run(); + + std::cout << "Done\n"; + + return 0; +} From c79680de485dfb63c3e71a3589dffe128db77b33 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Fri, 2 Feb 2024 18:46:40 +0100 Subject: [PATCH 4/4] ioc/tests/pvxs: test PVXS' QSRV2 --- ioc/tests/default.nix | 1 + ioc/tests/support/pvxs/qsrv2/default.nix | 100 ++++++++++++++++++ .../pvxs/qsrv2/pvxsQsrv2TestTop/.gitignore | 29 +++++ .../pvxs/qsrv2/pvxsQsrv2TestTop/Makefile | 31 ++++++ .../qsrv2/pvxsQsrv2TestTop/configure/CONFIG | 45 ++++++++ .../pvxsQsrv2TestTop/configure/CONFIG_SITE | 43 ++++++++ .../qsrv2/pvxsQsrv2TestTop/configure/Makefile | 8 ++ .../qsrv2/pvxsQsrv2TestTop/configure/RELEASE | 42 ++++++++ .../qsrv2/pvxsQsrv2TestTop/configure/RULES | 6 ++ .../pvxsQsrv2TestTop/configure/RULES.ioc | 2 + .../pvxsQsrv2TestTop/configure/RULES_DIRS | 2 + .../pvxsQsrv2TestTop/configure/RULES_TOP | 3 + .../pvxs/qsrv2/pvxsQsrv2TestTop/epnix.nix | 13 +++ .../qsrv2/pvxsQsrv2TestTop/iocBoot/Makefile | 6 ++ .../iocBoot/iocSimple/Makefile | 5 + .../pvxsQsrv2TestTop/iocBoot/iocSimple/st.cmd | 18 ++++ .../pvxsQsrv2TestTop/simpleApp/Db/Makefile | 18 ++++ .../pvxsQsrv2TestTop/simpleApp/Db/simple.db | 17 +++ .../qsrv2/pvxsQsrv2TestTop/simpleApp/Makefile | 14 +++ .../pvxsQsrv2TestTop/simpleApp/src/Makefile | 39 +++++++ .../simpleApp/src/simpleMain.cpp | 23 ++++ 21 files changed, 465 insertions(+) create mode 100644 ioc/tests/support/pvxs/qsrv2/default.nix create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/.gitignore create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/Makefile create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/CONFIG create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/CONFIG_SITE create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/Makefile create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RELEASE create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES.ioc create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES_DIRS create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES_TOP create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/epnix.nix create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/Makefile create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/iocSimple/Makefile create mode 100755 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/iocSimple/st.cmd create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Db/Makefile create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Db/simple.db create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Makefile create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/src/Makefile create mode 100644 ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/src/simpleMain.cpp diff --git a/ioc/tests/default.nix b/ioc/tests/default.nix index edad9b91..7f7d020e 100644 --- a/ioc/tests/default.nix +++ b/ioc/tests/default.nix @@ -6,6 +6,7 @@ with pkgs.lib; support-autosave-simple = import ./support/autosave/simple args; support-pvxs-ioc = import ./support/pvxs/ioc args; + support-pvxs-qsrv2 = import ./support/pvxs/qsrv2 args; support-pvxs-standalone-server = import ./support/pvxs/standalone-server args; support-seq-simple = import ./support/seq/simple args; support-StreamDevice-simple = import ./support/StreamDevice/simple args; diff --git a/ioc/tests/support/pvxs/qsrv2/default.nix b/ioc/tests/support/pvxs/qsrv2/default.nix new file mode 100644 index 00000000..732c8678 --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/default.nix @@ -0,0 +1,100 @@ +{pkgs, ...}: let + inherit (pkgs) epnixLib; + inherit (pkgs.stdenv.hostPlatform) system; + + result = epnixLib.evalEpnixModules { + nixpkgsConfig.system = system; + epnixConfig.imports = [./pvxsQsrv2TestTop/epnix.nix]; + }; + + service = result.config.epnix.nixos.services.ioc.config; + + ioc = result.outputs.build; +in + pkgs.nixosTest { + name = "support-pvxs-standalone-server"; + meta.maintainers = with epnixLib.maintainers; [minijackson]; + + nodes = { + client = { + environment.systemPackages = [ + pkgs.epnix.epics-base + pkgs.epnix.support.pvxs + ]; + networking.firewall.allowedTCPPorts = [5075]; + networking.firewall.allowedUDPPorts = [5076]; + }; + ioc = { + systemd.services.ioc = service; + networking.firewall.allowedTCPPorts = [5075]; + networking.firewall.allowedUDPPorts = [5076]; + }; + }; + + testScript = '' + import json + + start_all() + + addr_list = "EPICS_PVA_ADDR_LIST=192.168.1.2" + p = "PVXS:QSRV2:" + + def pvget(name: str): + return json.loads(client.succeed(f"{addr_list} pvget {name} -M json | cut -d' ' -f2-")) + + def pvxget(name: str): + output = client.succeed(f"{addr_list} pvxget {name}") + return output.splitlines()[1].split()[-1] + + def _pvput(utility: str, name: str, value: str): + client.succeed(f"{addr_list} {utility} {name} {value}") + + def pvput(name: str, value: str): + _pvput("pvput", name, value) + + def pvxput(name: str, value: str): + _pvput("pvxput", name, value) + + with subtest("wait until IOC starts"): + ioc.wait_for_unit("ioc.service") + client.wait_until_succeeds(f"{addr_list} pvget {p}ai", timeout=60) + + with subtest("Check initial data"): + # JSON seems broken here? + #value = pvget(f"{p}ai") + #assert value["value"] == 42 + #assert value["display"]["description"] == "An ai" + + value = pvget(f"{p}stringin") + assert value["value"] == "hello" + assert value["display"]["description"] == "An stringin" + + value = pvget(f"{p}waveform") + assert value["value"] == "" + assert value["display"]["description"] == "An waveform" + + with subtest("PVs can be set"): + #pvput(f"{p}ai", "1337") + #assert pvget("{p}ai")["value"] == 1337 + + pvput(f"{p}stringin", "world") + assert pvget(f"{p}stringin")["value"] == "world" + + pvput(f"{p}waveform", '"some long text"') + assert pvget(f"{p}waveform")["value"] == "some long text" + + with subtest("PVXS command-line utilities work"): + # assert pvxget(f"{p}ai") == "1337" + assert pvxget(f"{p}ai") == "42" + pvxput(f"{p}ai", "153") + assert pvxget(f"{p}ai") == "153" + + pvxput(f"{p}waveform", "something") + assert pvxget(f"{p}waveform") == '"something"' + print(client.succeed(f"{addr_list} pvxinfo {p}waveform")) + ''; + + passthru = { + inherit ioc; + }; + } diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/.gitignore b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/.gitignore new file mode 100644 index 00000000..3d648caa --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/.gitignore @@ -0,0 +1,29 @@ +# Install directories +/bin/ +/cfg/ +/db/ +/dbd/ +/html/ +/include/ +/lib/ +/templates/ + +# Local configuration files +/configure/*.local + +# iocBoot generated files +/iocBoot/*ioc*/cdCommands +/iocBoot/*ioc*/dllPath.bat +/iocBoot/*ioc*/envPaths +/iocBoot/*ioc*/relPaths.sh + +# Build directories +O.*/ + +# Common files created by other tools +/QtC-* +/.vscode/ +*.orig +*.log +.*.swp +.DS_Store diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/Makefile b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/Makefile new file mode 100644 index 00000000..19c9068d --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/Makefile @@ -0,0 +1,31 @@ +# Makefile at top of application tree +TOP = . +include $(TOP)/configure/CONFIG + +# Directories to build, any order +DIRS += configure +DIRS += $(wildcard *Sup) +DIRS += $(wildcard *App) +DIRS += $(wildcard *Top) +DIRS += $(wildcard iocBoot) + +# The build order is controlled by these dependency rules: + +# All dirs except configure depend on configure +$(foreach dir, $(filter-out configure, $(DIRS)), \ + $(eval $(dir)_DEPEND_DIRS += configure)) + +# Any *App dirs depend on all *Sup dirs +$(foreach dir, $(filter %App, $(DIRS)), \ + $(eval $(dir)_DEPEND_DIRS += $(filter %Sup, $(DIRS)))) + +# Any *Top dirs depend on all *Sup and *App dirs +$(foreach dir, $(filter %Top, $(DIRS)), \ + $(eval $(dir)_DEPEND_DIRS += $(filter %Sup %App, $(DIRS)))) + +# iocBoot depends on all *App dirs +iocBoot_DEPEND_DIRS += $(filter %App,$(DIRS)) + +# Add any additional dependency rules here: + +include $(TOP)/configure/RULES_TOP diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/CONFIG b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/CONFIG new file mode 100644 index 00000000..34ace577 --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/CONFIG @@ -0,0 +1,45 @@ +# CONFIG - Load build configuration data +# +# Do not make changes to this file! + +# Allow user to override where the build rules come from +RULES = $(EPICS_BASE) + +# RELEASE files point to other application tops +include $(TOP)/configure/RELEASE +-include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common + +ifdef T_A + -include $(TOP)/configure/RELEASE.Common.$(T_A) + -include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) +endif + +# Check EPICS_BASE is set properly +ifneq (file,$(origin EPICS_BASE)) + $(error EPICS_BASE must be set in a configure/RELEASE file) +else + ifeq ($(wildcard $(EPICS_BASE)/configure/CONFIG_BASE),) + $(error EPICS_BASE does not point to an EPICS installation) + endif +endif + +CONFIG = $(RULES)/configure +include $(CONFIG)/CONFIG + +# Override the Base definition: +INSTALL_LOCATION = $(TOP) + +# CONFIG_SITE files contain local build configuration settings +include $(TOP)/configure/CONFIG_SITE + +# Host-arch specific settings +-include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common + +ifdef T_A + # Target-arch specific settings + -include $(TOP)/configure/CONFIG_SITE.Common.$(T_A) + + # Host & target specific settings + -include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) +endif + diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/CONFIG_SITE b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/CONFIG_SITE new file mode 100644 index 00000000..212485eb --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/CONFIG_SITE @@ -0,0 +1,43 @@ +# CONFIG_SITE + +# Make any application-specific changes to the EPICS build +# configuration variables in this file. +# +# Host/target specific settings can be specified in files named +# CONFIG_SITE.$(EPICS_HOST_ARCH).Common +# CONFIG_SITE.Common.$(T_A) +# CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) + +# CHECK_RELEASE controls the consistency checking of the support +# applications pointed to by the RELEASE* files. +# Normally CHECK_RELEASE should be set to YES. +# Set CHECK_RELEASE to NO to disable checking completely. +# Set CHECK_RELEASE to WARN to perform consistency checking but +# continue building even if conflicts are found. +CHECK_RELEASE = YES + +# Set this when you only want to compile this application +# for a subset of the cross-compiled target architectures +# that Base is built for. +#CROSS_COMPILER_TARGET_ARCHS = vxWorks-ppc32 + +# To install files into a location other than $(TOP) define +# INSTALL_LOCATION here. +#INSTALL_LOCATION= + +# Set this when the IOC and build host use different paths +# to the install location. This may be needed to boot from +# a Microsoft FTP server say, or on some NFS configurations. +#IOCS_APPL_TOP = + +# For application debugging purposes, override the HOST_OPT and/ +# or CROSS_OPT settings from base/configure/CONFIG_SITE +#HOST_OPT = NO +#CROSS_OPT = NO + +# These allow developers to override the CONFIG_SITE variable +# settings without having to modify the configure/CONFIG_SITE +# file itself. +-include $(TOP)/../CONFIG_SITE.local +-include $(TOP)/configure/CONFIG_SITE.local + diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/Makefile b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/Makefile new file mode 100644 index 00000000..92543094 --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/Makefile @@ -0,0 +1,8 @@ +TOP=.. + +include $(TOP)/configure/CONFIG + +TARGETS = $(CONFIG_TARGETS) +CONFIGS += $(subst ../,,$(wildcard $(CONFIG_INSTALLS))) + +include $(TOP)/configure/RULES diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RELEASE b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RELEASE new file mode 100644 index 00000000..d0bb2b14 --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RELEASE @@ -0,0 +1,42 @@ +# RELEASE - Location of external support modules +# +# IF YOU CHANGE ANY PATHS in this file or make API changes to +# any modules it refers to, you should do a "make rebuild" in +# this application's top level directory. +# +# The EPICS build process does not check dependencies against +# any files from outside the application, so it is safest to +# rebuild it completely if any modules it depends on change. +# +# Host- or target-specific settings can be given in files named +# RELEASE.$(EPICS_HOST_ARCH).Common +# RELEASE.Common.$(T_A) +# RELEASE.$(EPICS_HOST_ARCH).$(T_A) +# +# This file is parsed by both GNUmake and an EPICS Perl script, +# so it may ONLY contain definititions of paths to other support +# modules, variable definitions that are used in module paths, +# and include statements that pull in other RELEASE files. +# Variables may be used before their values have been set. +# Build variables that are NOT used in paths should be set in +# the CONFIG_SITE file. + +# Variables and paths to dependent modules: +#MODULES = /path/to/modules +#MYMODULE = $(MODULES)/my-module + +# If using the sequencer, point SNCSEQ at its top directory: +#SNCSEQ = $(MODULES)/seq-ver + +# EPICS_BASE should appear last so earlier modules can override stuff: +EPICS_BASE = /nix/store/07lczf4kwn5mpnyp9rnn3hn6qfghykxm-epics-base-7.0.7 + +# Set RULES here if you want to use build rules from somewhere +# other than EPICS_BASE: +#RULES = $(MODULES)/build-rules + +# These lines allow developers to override these RELEASE settings +# without having to modify this file directly. +-include $(TOP)/../RELEASE.local +-include $(TOP)/../RELEASE.$(EPICS_HOST_ARCH).local +-include $(TOP)/configure/RELEASE.local diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES new file mode 100644 index 00000000..6d56e14e --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES @@ -0,0 +1,6 @@ +# RULES + +include $(CONFIG)/RULES + +# Library should be rebuilt because LIBOBJS may have changed. +$(LIBNAME): ../Makefile diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES.ioc b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES.ioc new file mode 100644 index 00000000..901987c6 --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES.ioc @@ -0,0 +1,2 @@ +#RULES.ioc +include $(CONFIG)/RULES.ioc diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES_DIRS b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES_DIRS new file mode 100644 index 00000000..3ba269dc --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES_DIRS @@ -0,0 +1,2 @@ +#RULES_DIRS +include $(CONFIG)/RULES_DIRS diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES_TOP b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES_TOP new file mode 100644 index 00000000..d09d668d --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/configure/RULES_TOP @@ -0,0 +1,3 @@ +#RULES_TOP +include $(CONFIG)/RULES_TOP + diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/epnix.nix b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/epnix.nix new file mode 100644 index 00000000..d18fde61 --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/epnix.nix @@ -0,0 +1,13 @@ +{pkgs, ...}: { + epnix = { + meta.name = "checks-support-pvxs-qsrv2"; + buildConfig.src = ./.; + + support.modules = with pkgs.epnix.support; [pvxs]; + + nixos.services.ioc = { + app = "simple"; + ioc = "iocSimple"; + }; + }; +} diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/Makefile b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/Makefile new file mode 100644 index 00000000..91e47d0b --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/Makefile @@ -0,0 +1,6 @@ +TOP = .. +include $(TOP)/configure/CONFIG +DIRS += $(wildcard *ioc*) +DIRS += $(wildcard as*) +include $(CONFIG)/RULES_DIRS + diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/iocSimple/Makefile b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/iocSimple/Makefile new file mode 100644 index 00000000..e1b9aa4a --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/iocSimple/Makefile @@ -0,0 +1,5 @@ +TOP = ../.. +include $(TOP)/configure/CONFIG +ARCH = $(EPICS_HOST_ARCH) +TARGETS = envPaths +include $(TOP)/configure/RULES.ioc diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/iocSimple/st.cmd b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/iocSimple/st.cmd new file mode 100755 index 00000000..0e815ba4 --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/iocBoot/iocSimple/st.cmd @@ -0,0 +1,18 @@ +#!../../bin/linux-x86_64/simple + +#- You may have to change simple to something else +#- everywhere it appears in this file + +< envPaths + +## Register all support components +dbLoadDatabase "../../dbd/simple.dbd" +simple_registerRecordDeviceDriver(pdbbase) + +## Load record instances +dbLoadRecords("${TOP}/db/simple.db", "P=PVXS:QSRV2:") + +iocInit() + +## Start any sequence programs +#seq sncsimple,"user=minijackson" diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Db/Makefile b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Db/Makefile new file mode 100644 index 00000000..ea495989 --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Db/Makefile @@ -0,0 +1,18 @@ +TOP=../.. +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE + +#---------------------------------------------------- +# Create and install (or just install) into /db +# databases, templates, substitutions like this +DB += simple.db + +#---------------------------------------------------- +# If .db template is not named *.template add +# _template = + +include $(TOP)/configure/RULES +#---------------------------------------- +# ADD RULES AFTER THIS LINE + diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Db/simple.db b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Db/simple.db new file mode 100644 index 00000000..f9c7bc1e --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Db/simple.db @@ -0,0 +1,17 @@ +record(ai, "${P}ai") { + field(DESC, "An ai") + field(VAL, "42") + info(Q:form, "Hex") # hint to clients to render as hexadecimal +} + +record(stringin, "${P}stringin") { + field(DESC, "An stringin") + field(VAL, "hello") +} + +record(waveform, "${P}waveform") { + field(DESC, "An waveform") + field(FTVL, "CHAR") + field(NELM, 1024) + info(Q:form, "String") # hint to QSRV to expose char[] as string +} diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Makefile b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Makefile new file mode 100644 index 00000000..60ab8ae8 --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/Makefile @@ -0,0 +1,14 @@ +# Makefile at top of application tree +TOP = .. +include $(TOP)/configure/CONFIG + +# Directories to be built, in any order. +# You can replace these wildcards with an explicit list +DIRS += $(wildcard src* *Src*) +DIRS += $(wildcard db* *Db*) + +# If the build order matters, add dependency rules like this, +# which specifies that xxxSrc must be built after src: +#xxxSrc_DEPEND_DIRS += src + +include $(TOP)/configure/RULES_DIRS diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/src/Makefile b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/src/Makefile new file mode 100644 index 00000000..766932f1 --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/src/Makefile @@ -0,0 +1,39 @@ +TOP=../.. + +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE +#============================= + +#============================= +# Build the IOC application + +PROD_IOC = simple +# simple.dbd will be created and installed +DBD += simple.dbd + +# simple.dbd will be made up from these files: +simple_DBD += base.dbd + +# Include dbd files from all support applications: +simple_DBD += pvxsIoc.dbd + +# Add all the support libraries needed by this IOC +simple_LIBS += pvxsIoc pvxs + +# simple_registerRecordDeviceDriver.cpp derives from simple.dbd +simple_SRCS += simple_registerRecordDeviceDriver.cpp + +# Build the main IOC entry point on workstation OSs. +simple_SRCS_DEFAULT += simpleMain.cpp +simple_SRCS_vxWorks += -nil- + +# Finally link to the EPICS Base libraries +simple_LIBS += $(EPICS_BASE_IOC_LIBS) + +#=========================== + +include $(TOP)/configure/RULES +#---------------------------------------- +# ADD RULES AFTER THIS LINE + diff --git a/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/src/simpleMain.cpp b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/src/simpleMain.cpp new file mode 100644 index 00000000..e4e5e3b2 --- /dev/null +++ b/ioc/tests/support/pvxs/qsrv2/pvxsQsrv2TestTop/simpleApp/src/simpleMain.cpp @@ -0,0 +1,23 @@ +/* simpleMain.cpp */ +/* Author: Marty Kraimer Date: 17MAR2000 */ + +#include +#include +#include +#include +#include + +#include "epicsExit.h" +#include "epicsThread.h" +#include "iocsh.h" + +int main(int argc,char *argv[]) +{ + if(argc>=2) { + iocsh(argv[1]); + epicsThreadSleep(.2); + } + iocsh(NULL); + epicsExit(0); + return(0); +}