Skip to content

Commit

Permalink
Merge pull request #4 from epics-containers/dev
Browse files Browse the repository at this point in the history
Add verification to ADSimDetctor IOC testing
  • Loading branch information
gilesknap authored Sep 22, 2023
2 parents 41f79af + 01ac24c commit 43d25d1
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 4 deletions.
62 changes: 62 additions & 0 deletions tests/Dockerfile.adsimdetector
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
##### build stage ##############################################################

ARG TARGET_ARCHITECTURE
ARG BASE=23.9.3
ARG REGISTRY=ghcr.io/epics-containers

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

# In a devcontainer this folder is mounted on the host's clone of ioc-adsimdetector
WORKDIR /workspaces/ioc-adsimdetector/ibek-support

# copy the global ibek files
COPY ibek-support/_global/ _global

COPY ibek-support/iocStats/ iocStats
RUN iocStats/install.sh 3.1.16

COPY ibek-support/asyn/ asyn/
RUN asyn/install.sh R4-42

COPY ibek-support/autosave/ autosave/
RUN autosave/install.sh R5-10-2

COPY ibek-support/busy/ busy/
RUN busy/install.sh R1-7-3

COPY ibek-support/ADCore/ ADCore/
RUN ADCore/install.sh R3-12-1

COPY ibek-support/ADSimDetector/ ADSimDetector/
RUN ADSimDetector/install.sh R2-10

# Make the IOC
RUN ibek ioc generate-makefile
RUN ibek ioc compile

##### runtime preparation stage ################################################

FROM developer AS runtime_prep

# get the products from the build stage and reduce to runtime assets only
WORKDIR /min_files
RUN bash /epics/scripts/minimize.sh ${IOC} $(ls -d ${SUPPORT}/*/)

##### runtime stage ############################################################

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

# get the virtual environment from the developer stage
COPY --from=developer /venv /venv
# add products from build stage
COPY --from=runtime_prep /min_files /

# install runtime system dependencies, collected from install.sh scripts
RUN ibek support apt-install --runtime

# add ioc sample startup scripts
COPY ioc ${IOC}

ENV TARGET_ARCHITECTURE ${TARGET_ARCHITECTURE}

ENTRYPOINT ["/bin/bash", "-c", "${IOC}/start.sh"]
36 changes: 36 additions & 0 deletions tests/Verify.adsimdetector.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -xe

tmpdir=$(mktemp -d)

# TODO - we should really be sending ibek IOC YAML here instead of
# a hand coded startup script - baby steps ...
echo '
cd "$(TOP)"
dbLoadDatabase "dbd/ioc.dbd"
ioc_registerRecordDeviceDriver(pdbbase)
simDetectorConfig("TEST.CAM", 2560, 2160, 1, 50, 0)
dbLoadRecords (simDetector.template, "P=TEST, R=:CAM:, PORT=TEST.CAM, TIMEOUT=1, ADDR=0")
iocInit
' > ${tmpdir}/st.cmd

$docker cp ${tmpdir}/st.cmd test_me:/epics/ioc/config/st.cmd
$docker exec -dit test_me bash -c "cd /epics/ioc; ./start.sh"

# verify that the IOC is running
$docker exec test_me caget TEST:CAM:Acquire
# now try and run the simdetector and verify that it delivers some frames
$docker exec test_me caput TEST:CAM:Acquire 1

first=$($docker exec test_me caget TEST:CAM:ArrayCounter_RBV)
second=$($docker exec test_me caget TEST:CAM:ArrayCounter_RBV)
if [[ $first == 0 || $first == $second ]] ; then
echo "ERROR: simdetector did not deliver any frames"
exit 1
fi


2 changes: 1 addition & 1 deletion tests/Verify.asyn.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

echo "HELLO WORLD"
# TODO add tests for asyn here see adsimdetector example
2 changes: 1 addition & 1 deletion tests/Verify.busy.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

echo TODO add tests for busy support module
# TODO add tests for asyn here see adsimdetector example
4 changes: 2 additions & 2 deletions tests/_test_support_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ fi

# decide on container build tool
if which docker > /dev/null ; then
docker=docker
export docker=docker
else
echo using podman
docker=podman
export docker=podman
fi

NEWCACHE=${CACHE}-new
Expand Down

0 comments on commit 43d25d1

Please sign in to comment.