From 59522f05cd43a9462cb6efa6f43ca50c59bafd24 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Mon, 24 Jul 2023 16:28:13 +0200 Subject: [PATCH 1/2] ioc/base: properly select the base package for the build fixes #15 --- ioc/modules/base.nix | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ioc/modules/base.nix b/ioc/modules/base.nix index f777a0a0..4c46eeee 100644 --- a/ioc/modules/base.nix +++ b/ioc/modules/base.nix @@ -139,4 +139,14 @@ in { } ]; }; + + config.nixpkgs.overlays = [ + (_final: prev: { + epnix = + prev.epnix + // { + epics-base = cfg.package; + }; + }) + ]; } From 2d6773f9f3adcf4a12fb8a8d07cffda9a5806884 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Mon, 24 Jul 2023 16:30:08 +0200 Subject: [PATCH 2/2] ioc/tests: add test for testing selection of epics-base --- ioc/tests/default-ioc/default.nix | 44 ++++++++++++++++++ ioc/tests/default-ioc/top/.gitignore | 29 ++++++++++++ ioc/tests/default-ioc/top/Makefile | 31 +++++++++++++ ioc/tests/default-ioc/top/configure/CONFIG | 45 +++++++++++++++++++ .../default-ioc/top/configure/CONFIG_SITE | 43 ++++++++++++++++++ ioc/tests/default-ioc/top/configure/Makefile | 8 ++++ ioc/tests/default-ioc/top/configure/RELEASE | 42 +++++++++++++++++ ioc/tests/default-ioc/top/configure/RULES | 6 +++ ioc/tests/default-ioc/top/configure/RULES.ioc | 2 + .../default-ioc/top/configure/RULES_DIRS | 2 + ioc/tests/default-ioc/top/configure/RULES_TOP | 3 ++ ioc/tests/default-ioc/top/epnix.nix | 13 ++++++ ioc/tests/default-ioc/top/iocBoot/Makefile | 6 +++ .../top/iocBoot/iocsimple/Makefile | 5 +++ .../default-ioc/top/iocBoot/iocsimple/st.cmd | 10 +++++ .../default-ioc/top/simpleApp/Db/Makefile | 11 +++++ .../default-ioc/top/simpleApp/Db/simple.db | 2 + ioc/tests/default-ioc/top/simpleApp/Makefile | 14 ++++++ .../default-ioc/top/simpleApp/src/Makefile | 29 ++++++++++++ .../top/simpleApp/src/simpleMain.cpp | 23 ++++++++++ ioc/tests/default.nix | 3 ++ 21 files changed, 371 insertions(+) create mode 100644 ioc/tests/default-ioc/default.nix create mode 100644 ioc/tests/default-ioc/top/.gitignore create mode 100644 ioc/tests/default-ioc/top/Makefile create mode 100644 ioc/tests/default-ioc/top/configure/CONFIG create mode 100644 ioc/tests/default-ioc/top/configure/CONFIG_SITE create mode 100644 ioc/tests/default-ioc/top/configure/Makefile create mode 100644 ioc/tests/default-ioc/top/configure/RELEASE create mode 100644 ioc/tests/default-ioc/top/configure/RULES create mode 100644 ioc/tests/default-ioc/top/configure/RULES.ioc create mode 100644 ioc/tests/default-ioc/top/configure/RULES_DIRS create mode 100644 ioc/tests/default-ioc/top/configure/RULES_TOP create mode 100644 ioc/tests/default-ioc/top/epnix.nix create mode 100644 ioc/tests/default-ioc/top/iocBoot/Makefile create mode 100644 ioc/tests/default-ioc/top/iocBoot/iocsimple/Makefile create mode 100644 ioc/tests/default-ioc/top/iocBoot/iocsimple/st.cmd create mode 100644 ioc/tests/default-ioc/top/simpleApp/Db/Makefile create mode 100644 ioc/tests/default-ioc/top/simpleApp/Db/simple.db create mode 100644 ioc/tests/default-ioc/top/simpleApp/Makefile create mode 100644 ioc/tests/default-ioc/top/simpleApp/src/Makefile create mode 100644 ioc/tests/default-ioc/top/simpleApp/src/simpleMain.cpp diff --git a/ioc/tests/default-ioc/default.nix b/ioc/tests/default-ioc/default.nix new file mode 100644 index 00000000..0fd66191 --- /dev/null +++ b/ioc/tests/default-ioc/default.nix @@ -0,0 +1,44 @@ +releaseBranch: {pkgs, ...}: let + inherit (pkgs) epnixLib; + inherit (pkgs.stdenv.hostPlatform) system; + + result = epnixLib.evalEpnixModules { + nixpkgsConfig.system = system; + epnixConfig.imports = [ + (import ./top/epnix.nix releaseBranch) + ]; + }; + + service = result.config.epnix.nixos.services.ioc.config; + + ioc = result.outputs.build; +in + pkgs.nixosTest { + name = "default-ioc-epics-base-${releaseBranch}"; + meta.maintainers = with epnixLib.maintainers; [minijackson]; + + nodes.machine = { + environment.systemPackages = [pkgs.epnix.epics-base]; + systemd.services.ioc = service; + }; + + testScript = '' + machine.wait_for_unit("default.target") + machine.wait_for_unit("ioc.service") + + with subtest("wait until started"): + assert machine.wait_until_succeeds("caget -t SIMPLE:AI").strip() == "0" + + with subtest("EPICS revision is correct"): + machine.succeed("journalctl --no-pager -u ioc.service | grep -F '## EPICS R${releaseBranch}'") + + with subtest("ai records"): + assert machine.wait_until_succeeds("caget -t SIMPLE:AI").strip() == "0" + machine.succeed("caput SIMPLE:AI 123.456") + assert machine.wait_until_succeeds("caget -t SIMPLE:AI").strip() == "123.456" + ''; + + passthru = { + inherit ioc; + }; + } diff --git a/ioc/tests/default-ioc/top/.gitignore b/ioc/tests/default-ioc/top/.gitignore new file mode 100644 index 00000000..3d648caa --- /dev/null +++ b/ioc/tests/default-ioc/top/.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/default-ioc/top/Makefile b/ioc/tests/default-ioc/top/Makefile new file mode 100644 index 00000000..19c9068d --- /dev/null +++ b/ioc/tests/default-ioc/top/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/default-ioc/top/configure/CONFIG b/ioc/tests/default-ioc/top/configure/CONFIG new file mode 100644 index 00000000..34ace577 --- /dev/null +++ b/ioc/tests/default-ioc/top/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/default-ioc/top/configure/CONFIG_SITE b/ioc/tests/default-ioc/top/configure/CONFIG_SITE new file mode 100644 index 00000000..212485eb --- /dev/null +++ b/ioc/tests/default-ioc/top/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/default-ioc/top/configure/Makefile b/ioc/tests/default-ioc/top/configure/Makefile new file mode 100644 index 00000000..92543094 --- /dev/null +++ b/ioc/tests/default-ioc/top/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/default-ioc/top/configure/RELEASE b/ioc/tests/default-ioc/top/configure/RELEASE new file mode 100644 index 00000000..bbcffd23 --- /dev/null +++ b/ioc/tests/default-ioc/top/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/gq8ysfw2yqwij1wd64vcc0nwy8p67vzx-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/default-ioc/top/configure/RULES b/ioc/tests/default-ioc/top/configure/RULES new file mode 100644 index 00000000..6d56e14e --- /dev/null +++ b/ioc/tests/default-ioc/top/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/default-ioc/top/configure/RULES.ioc b/ioc/tests/default-ioc/top/configure/RULES.ioc new file mode 100644 index 00000000..901987c6 --- /dev/null +++ b/ioc/tests/default-ioc/top/configure/RULES.ioc @@ -0,0 +1,2 @@ +#RULES.ioc +include $(CONFIG)/RULES.ioc diff --git a/ioc/tests/default-ioc/top/configure/RULES_DIRS b/ioc/tests/default-ioc/top/configure/RULES_DIRS new file mode 100644 index 00000000..3ba269dc --- /dev/null +++ b/ioc/tests/default-ioc/top/configure/RULES_DIRS @@ -0,0 +1,2 @@ +#RULES_DIRS +include $(CONFIG)/RULES_DIRS diff --git a/ioc/tests/default-ioc/top/configure/RULES_TOP b/ioc/tests/default-ioc/top/configure/RULES_TOP new file mode 100644 index 00000000..d09d668d --- /dev/null +++ b/ioc/tests/default-ioc/top/configure/RULES_TOP @@ -0,0 +1,3 @@ +#RULES_TOP +include $(CONFIG)/RULES_TOP + diff --git a/ioc/tests/default-ioc/top/epnix.nix b/ioc/tests/default-ioc/top/epnix.nix new file mode 100644 index 00000000..582e8ba8 --- /dev/null +++ b/ioc/tests/default-ioc/top/epnix.nix @@ -0,0 +1,13 @@ +releaseBranch: _: { + epnix = { + meta.name = "checks-default-ioc"; + buildConfig.src = ./.; + + epics-base.releaseBranch = releaseBranch; + + nixos.services.ioc = { + app = "simple"; + ioc = "iocsimple"; + }; + }; +} diff --git a/ioc/tests/default-ioc/top/iocBoot/Makefile b/ioc/tests/default-ioc/top/iocBoot/Makefile new file mode 100644 index 00000000..91e47d0b --- /dev/null +++ b/ioc/tests/default-ioc/top/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/default-ioc/top/iocBoot/iocsimple/Makefile b/ioc/tests/default-ioc/top/iocBoot/iocsimple/Makefile new file mode 100644 index 00000000..e1b9aa4a --- /dev/null +++ b/ioc/tests/default-ioc/top/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/default-ioc/top/iocBoot/iocsimple/st.cmd b/ioc/tests/default-ioc/top/iocBoot/iocsimple/st.cmd new file mode 100644 index 00000000..925f14f5 --- /dev/null +++ b/ioc/tests/default-ioc/top/iocBoot/iocsimple/st.cmd @@ -0,0 +1,10 @@ +#!../../bin/linux-x86_64/simple + +< envPaths + +dbLoadDatabase "../../dbd/simple.dbd" +simple_registerRecordDeviceDriver(pdbbase) + +dbLoadRecords("../../db/simple.db") + +iocInit() diff --git a/ioc/tests/default-ioc/top/simpleApp/Db/Makefile b/ioc/tests/default-ioc/top/simpleApp/Db/Makefile new file mode 100644 index 00000000..3717f9ef --- /dev/null +++ b/ioc/tests/default-ioc/top/simpleApp/Db/Makefile @@ -0,0 +1,11 @@ +TOP=../.. +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE + +DB += simple.db + +include $(TOP)/configure/RULES +#---------------------------------------- +# ADD RULES AFTER THIS LINE + diff --git a/ioc/tests/default-ioc/top/simpleApp/Db/simple.db b/ioc/tests/default-ioc/top/simpleApp/Db/simple.db new file mode 100644 index 00000000..ea161887 --- /dev/null +++ b/ioc/tests/default-ioc/top/simpleApp/Db/simple.db @@ -0,0 +1,2 @@ +record(ai, "SIMPLE:AI") { +} diff --git a/ioc/tests/default-ioc/top/simpleApp/Makefile b/ioc/tests/default-ioc/top/simpleApp/Makefile new file mode 100644 index 00000000..60ab8ae8 --- /dev/null +++ b/ioc/tests/default-ioc/top/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/default-ioc/top/simpleApp/src/Makefile b/ioc/tests/default-ioc/top/simpleApp/src/Makefile new file mode 100644 index 00000000..483225ad --- /dev/null +++ b/ioc/tests/default-ioc/top/simpleApp/src/Makefile @@ -0,0 +1,29 @@ +TOP=../.. + +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE +#============================= + +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 + +# 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 + +# 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/default-ioc/top/simpleApp/src/simpleMain.cpp b/ioc/tests/default-ioc/top/simpleApp/src/simpleMain.cpp new file mode 100644 index 00000000..e4e5e3b2 --- /dev/null +++ b/ioc/tests/default-ioc/top/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); +} diff --git a/ioc/tests/default.nix b/ioc/tests/default.nix index 563fac86..62ca3c65 100644 --- a/ioc/tests/default.nix +++ b/ioc/tests/default.nix @@ -1,6 +1,9 @@ {pkgs, ...} @ args: with pkgs.lib; { + default-ioc-epics-base-3 = import ./default-ioc "3" args; + default-ioc-epics-base-7 = import ./default-ioc "7" 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;