Skip to content

Commit

Permalink
update to latest dependencies. add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gilesknap committed Nov 11, 2023
1 parent f28ccae commit b6f3e1a
Show file tree
Hide file tree
Showing 12 changed files with 144 additions and 75 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ set -xe
mkdir -p ${CACHE}

# get the current version of ec CLI
pip install -r ${THIS}/../../requirements.txt
pip install -r ${THIS}/../../requirements_ec.txt

# add cache arguments - local file cache passed by github seems to be most reliable
export EC_CARGS="
Expand All @@ -37,8 +37,7 @@ export EC_CARGS="
ec -v dev build ${EC_TAG} ${EC_PLATFORM} ${EC_PUSH} ${EC_CARGS}

# extract the ioc schema from the runtime image
ec dev launch-local ${EC_TAG} --execute \
'ibek ioc generate-schema --use-defs' > ibek.ioc.schema.json
ec dev launch-local ${EC_TAG} --execute 'ibek ioc generate-schema' > ibek.ioc.schema.json

# run acceptance tests
shopt -s nullglob # expand to nothing if no tests are found
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ ARG REGISTRY=ghcr.io/epics-containers

FROM ${REGISTRY}/epics-base-${TARGET_ARCHITECTURE}-developer:${BASE} AS developer

# Get latest ibek while in development. Will come from epics-base
RUN pip install --upgrade ibek==1.5.0b6
# Get latest ibek while in development. Will come from epics-base when stable
COPY requirements.txt requirements.txt
RUN pip install --upgrade -r requirements.txt

# the devcontainer mounts the project root to /epics/ioc-adaravis
# The devcontainer mounts the project root to /epics/ioc-adsimdetector. Using
# the same location here makes devcontainer/runtime differences transparent.
WORKDIR /epics/ioc-adaravis/ibek-support

# copy the global ibek files
Expand Down
7 changes: 2 additions & 5 deletions build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

################################################################################
# generic local build script for epics-containers ioc repositories #
# generic local build script for epics-containers ioc repositories #
################################################################################

# pass rtems as first argument to build RTEMS on cross-compiler
Expand All @@ -18,7 +18,4 @@ git submodule update --init
ec dev build --arch ${TARGET_ARCHITECTURE}

# get the schema file from the developer container and save it locally
ec dev launch-local --execute \
'ibek ioc generate-schema /epics/ibek-defs/*.ibek.support.yaml' \
> ibek.ioc.schema.json

ec dev launch-local --execute 'ibek ioc generate-schema' > ibek.ioc.schema.json
62 changes: 0 additions & 62 deletions example/ioc.yaml

This file was deleted.

5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
epics-containers-cli==2.6.3
#git+https://github.com/epics-containers/epics-containers-cli.git@dev
ibek==1.5.0
# to install direct from github during development in the dev branch:
#git+https://github.com/epics-containers/ibek.git@dev
3 changes: 3 additions & 0 deletions requirements_ec.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
epics-containers-cli==2.6.4
# to install direct from github during development in the dev branch:
#git+https://github.com/epics-containers/epics-containers-cli.git@dev
26 changes: 26 additions & 0 deletions tests/example-config/calc.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
record(calc, "EXAMPLE2:SUM") {
field(DESC, "Sum A and B")
field(CALC, "A+B")
field(INPA, "EXAMPLE2:A")
field(INPB, "EXAMPLE2:B")
}

record(ao, "EXAMPLE2:A") {
field(DESC, "A voltage")
field(PREC, "3")
field(EGU, "Volts")
field(DRVL, "-10")
field(DRVH, "+10")
field(VAL, "0.000")
field(FLNK, "EXAMPLE2:SUM")
}

record(ao, "EXAMPLE2:B") {
field(DESC, "B voltage")
field(PREC, "3")
field(EGU, "Volts")
field(DRVL, "-10")
field(DRVH, "+10")
field(VAL, "0.000")
field(FLNK, "EXAMPLE2:SUM")
}
16 changes: 16 additions & 0 deletions tests/example-config/ioc.substitutions
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

# Macros:
# IOC Device prefix
file $(IOCSTATS)/db/iocAdminSoft.db
{
pattern { IOC }
{ "test-ioc" }
}

# Macros:
# IOC Device prefix
file $(IOCSTATS)/db/iocAdminScanMon.db
{
pattern { IOC }
{ "test-ioc" }
}
12 changes: 12 additions & 0 deletions tests/example-config/st.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Example hand coded IOC startup script for example-config
cd "/epics/ioc"

epicsEnvSet "EPICS_CA_MAX_ARRAY_BYTES", '6000000'

dbLoadDatabase "dbd/ioc.dbd"
ioc_registerRecordDeviceDriver(pdbbase)

dbLoadRecords("config/calc.db")
dbLoadRecords("/tmp/ioc.db")

iocInit()
26 changes: 26 additions & 0 deletions tests/example-ibek-config/ioc.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
record(calc, "EXAMPLE:IBEK:SUM") {
field(DESC, "Sum A and B")
field(CALC, "A+B")
field(INPA, "EXAMPLE:IBEK:A")
field(INPB, "EXAMPLE:IBEK:B")
}

record(ao, "EXAMPLE:IBEK:A") {
field(DESC, "A voltage")
field(PREC, "3")
field(EGU, "Volts")
field(DRVL, "-10")
field(DRVH, "+10")
field(VAL, "0.000")
field(FLNK, "EXAMPLE:IBEK:SUM")
}

record(ao, "EXAMPLE:IBEK:B") {
field(DESC, "B voltage")
field(PREC, "3")
field(EGU, "Volts")
field(DRVL, "-10")
field(DRVH, "+10")
field(VAL, "0.000")
field(FLNK, "EXAMPLE:IBEK:SUM")
}
9 changes: 9 additions & 0 deletions tests/example-ibek-config/ioc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ioc_name: test-ibek-ioc
description: a basic example for testing ioc-template

entities:
- type: devIocStats.iocAdminSoft
IOC: test-ibek-ioc

- type: epics.StartupCommand
command: dbLoadRecords("/epics/ioc/config/ioc.db")
40 changes: 40 additions & 0 deletions tests/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

# test script for ioc-template to verify that the container loads and the
# generic IOC will start - demonstrating that the correct runtime libraries
# all present and correct and that mounting IOC config or ibek config
# works as expected.

THIS_DIR=$(realpath $(dirname $0))
ROOT=$(realpath ${THIS_DIR}/..)

set -ex

cd ${ROOT}
# Build the container (inherit arguments from CI workflow if set) ##############
ec dev build ${EC_TAG}

# try out an ibek config IOC instance with the generic IOC #####################
ec dev launch-local tests/example-config --args '-dit' ${EC_TAG}
ec dev wait-pv EXAMPLE2:A --attempts 20
ec dev exec 'caput EXAMPLE2:A 1.3'
ec dev exec 'caput EXAMPLE2:B 1.2'
ec dev exec 'caget EXAMPLE2:SUM' | grep '2.5'

# Test an ibek IOC #############################################################
ec dev launch-local tests/example-ibek-config --args '-dit' ${EC_TAG}
ec dev wait-pv EXAMPLE:IBEK:A --attempts 20
ec dev exec 'caput EXAMPLE:IBEK:A 1.3'
ec dev exec 'caput EXAMPLE:IBEK:B 1.2'
ec dev exec 'caget EXAMPLE:IBEK:SUM' | grep '2.5'
ec dev exec 'caget test-ibek-ioc:EPICS_VERS' | grep 'R7.0.7'

# Stop the test IOC ############################################################
ec dev stop

# Done #########################################################################
echo
echo "All tests passed!"



0 comments on commit b6f3e1a

Please sign in to comment.