--- a/.github/workflows/run_tests_in_docker.yml Sun Jul 17 18:07:46 2022 +0200
+++ b/.github/workflows/run_tests_in_docker.yml Sun Jul 17 18:17:43 2022 +0200
@@ -21,6 +21,13 @@
ref: 2a25f4dbf4e2b1e017a3a583db7dede4771fe523
path: matiec
+ - uses: actions/checkout@v3
+ with:
+ repository: open62541/open62541
+ ref: v3.0.2
+ path: open62541
+ submodules: recursive
+
- name: Cache docker image
id: cache-docker
uses: actions/cache@v3
--- a/fake_wx.py Sun Jul 17 18:07:46 2022 +0200
+++ b/fake_wx.py Sun Jul 17 18:17:43 2022 +0200
@@ -68,15 +68,17 @@
('wx',[
'Panel', 'PyCommandEvent', 'Dialog', 'PopupWindow', 'TextEntryDialog',
'Notebook', 'ListCtrl', 'TextDropTarget', 'PyControl', 'TextCtrl',
- 'SplitterWindow', 'Frame', 'Printout', 'StaticBitmap',
+ 'SplitterWindow', 'Frame', 'Printout', 'StaticBitmap', 'DropTarget',
('GetTranslation', get_translation)]),
('wx.lib.agw.advancedsplash',[]),
+ ('wx.dataview',['DataViewIndexListModel', 'PyDataViewIndexListModel']),
('wx.lib.buttons',['GenBitmapTextButton']),
('wx.adv',['EditableListBox']),
('wx.grid',[
'Grid', 'PyGridTableBase', 'GridCellEditor', 'GridCellTextEditor',
'GridCellChoiceEditor']),
('wx.lib.agw.customtreectrl',['CustomTreeCtrl']),
+ ('wx.lib.gizmos',[]),
('wx.lib.intctrl',['IntCtrl']),
('matplotlib.pyplot',[]),
('matplotlib.backends.backend_wxagg',['FigureCanvasWxAgg']),
--- a/tests/Makefile Sun Jul 17 18:07:46 2022 +0200
+++ b/tests/Makefile Sun Jul 17 18:17:43 2022 +0200
@@ -26,7 +26,7 @@
# $ make xnest_sikuli
#
# build minimal beremiz and matiec to run tests
-# $ make own_apps
+# $ make built_apps
#
# For CI/CD scripts to catch and report all failures. Use cases :
#
@@ -71,7 +71,7 @@
# SOURCE and BUILD
#
-OWN_PROJECTS=beremiz matiec
+BUILT_PROJECTS=beremiz matiec open62541
tar_opts=--absolute-names --exclude=.hg --exclude=.git --exclude=.*.pyc --exclude=.*.swp
@@ -80,7 +80,7 @@
define make_checksum_assign
$(1)_checksum = $(shell tar $(tar_opts) -c $(workspace)/$(1) | sha1sum | cut -d ' ' -f 1)
endef
-$(foreach project,$(OWN_PROJECTS),$(eval $(call make_checksum_assign,$(project))))
+$(foreach project,$(BUILT_PROJECTS),$(eval $(call make_checksum_assign,$(project))))
$(build_dir):
mkdir -p $(build_dir)
@@ -91,7 +91,7 @@
tar -C $(workspace) $(tar_opts) -c $(1) | tar -C $(build_dir) -x
touch $$@
endef
-$(foreach project,$(OWN_PROJECTS),$(eval $(call make_src_rule,$(project))))
+$(foreach project,$(BUILT_PROJECTS),$(eval $(call make_src_rule,$(project))))
$(build_dir)/matiec/iec2c: | $(build_dir)/matiec/$(matiec_checksum).sha1
cd $(build_dir)/matiec && \
@@ -99,7 +99,13 @@
./configure && \
make
-own_apps: $(build_dir)/matiec/iec2c $(build_dir)/beremiz/$(beremiz_checksum).sha1
+$(build_dir)/open62541/build/bin/libopen62541.a: | $(build_dir)/open62541/$(open62541_checksum).sha1
+ cd $(build_dir)/open62541 && \
+ rm -rf build && mkdir build && cd build && \
+ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DUA_NAMESPACE_ZERO=FULL .. && \
+ make
+
+built_apps: $(build_dir)/matiec/iec2c $(build_dir)/beremiz/$(beremiz_checksum).sha1 $(build_dir)/open62541/build/bin/libopen62541.a
touch $@
define log_command
@@ -142,7 +148,7 @@
xserver_command ?= xvfb-run -s '-screen 0 1920x1080x24'
define make_idetest_rule
-$(test_dir)/$(1)_results/.passed: own_apps
+$(test_dir)/$(1)_results/.passed: built_apps
$(call prep_test,$(1)); $(xserver_command) bash -c '$(call log_command,$(2),$(1))'
touch $$@
@@ -151,7 +157,7 @@
# Manually invoked rule xnest_{testname}.sikuli
# runs test in xnest so that one can see what happens
-xnest_$(1): own_apps
+xnest_$(1): built_apps
$(call prep_test,$(1)); $$(call xnest_run, bash -c '$(call log_command,$(2),$(1))')
ide_tests_targets += $(test_dir)/$(1)_results/.passed
@@ -162,13 +168,13 @@
ide_tests : $(ide_tests_targets)
echo "$(ide_tests_targets) : Passed"
-xnest_xterm: own_apps
+xnest_xterm: built_apps
$(call xnest_run, bash -c '(fluxbox &);xterm')
-xnest_sikuli: own_apps
+xnest_sikuli: built_apps
$(call xnest_run, bash -c '(fluxbox &);(BEREMIZPATH=$(build_dir)/beremiz xterm -e sikulix &);xterm')
-xvfb_sikuli: own_apps
+xvfb_sikuli: built_apps
echo "******************************************"
echo "On host, run 'xvncviewer 127.0.0.1:5900' to see sikuli X session"
echo "Docker container must be created with TESTDEBUG=YES. For example :"
@@ -188,7 +194,7 @@
endef
define make_clitest_rule
-$(test_dir)/$(1)_results/.passed: own_apps
+$(test_dir)/$(1)_results/.passed: built_apps
$(call prep_test,$(1)); bash -c '$(call log_command,$(2),$(1))'
touch $$@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/cli_tests/opcua_test.bash Sun Jul 17 18:17:43 2022 +0200
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+rm -f ./SRVOK ./PLCOK
+
+# Run server
+$BEREMIZPYTHONPATH - > >(
+ echo "Start SRV loop"
+ while read line; do
+ # Wait for server to print modified value
+ echo "SRV>> $line"
+ if [[ "$line" == 3.4 ]]; then
+ echo "PLC could write value"
+ touch ./SRVOK
+ fi
+ done
+ echo "End SRV loop"
+) << EOF &
+
+import sys
+import time
+
+from opcua import ua, Server
+
+server = Server()
+server.set_endpoint("opc.tcp://127.0.0.1:4840/freeopcua/server/")
+
+uri = "http://beremiz.github.io"
+idx = server.register_namespace(uri)
+
+objects = server.get_objects_node()
+
+testobj = objects.add_object(idx, "TestObject")
+testvarout = testobj.add_variable(idx, "TestOut", 1.2)
+testvar = testobj.add_variable(idx, "TestIn", 5.6)
+testvar.set_writable()
+
+server.start()
+
+try:
+ while True:
+ time.sleep(1)
+ print testvar.get_value()
+ sys.stdout.flush()
+finally:
+ server.stop()
+EOF
+SERVER_PID=$!
+
+# Start PLC with opcua test
+setsid $BEREMIZPYTHONPATH $BEREMIZPATH/Beremiz_cli.py -k \
+ --project-home $BEREMIZPATH/tests/projects/opcua_client build transfer run > >(
+echo "Start PLC loop"
+while read line; do
+ # Wait for PLC runtime to output expected value on stdout
+ echo "PLC>> $line"
+ if [[ "$line" == 1.2 ]]; then
+ echo "PLC could read value"
+ touch ./PLCOK
+ fi
+done
+echo "End PLC loop"
+) &
+PLC_PID=$!
+
+echo all subprocess started, start polling results
+res=110 # default to ETIMEDOUT
+c=30
+while ((c--)); do
+ if [[ -a ./SRVOK && -a ./PLCOK ]]; then
+ echo got results.
+ res=0 # OK success
+ break
+ else
+ echo waiting.... $c
+ sleep 1
+ fi
+done
+
+# Kill PLC and subprocess
+echo will kill PLC:$PLC_PID and SERVER:$SERVER_PID
+pkill -s $PLC_PID
+kill $SERVER_PID
+
+exit $res
--- a/tests/tools/Docker/beremiz-sikuli/Dockerfile Sun Jul 17 18:07:46 2022 +0200
+++ b/tests/tools/Docker/beremiz-sikuli/Dockerfile Sun Jul 17 18:17:43 2022 +0200
@@ -36,7 +36,7 @@
build-essential automake flex bison mercurial \
libgtk-3-dev libgl1-mesa-dev libglu1-mesa-dev \
libpython2.7-dev libssl-dev \
- python2 virtualenv
+ python2 virtualenv cmake
# link obtained from https://raiman.github.io/SikuliX1/downloads.html
RUN set -xe && \
@@ -60,7 +60,7 @@
RUN ~/beremizenv/bin/pip install \
pytest pytest-timeout ddt \
lxml future matplotlib zeroconf2 enum34 pyro sslpsk posix_spawn \
- twisted nevow autobahn click\
+ twisted nevow autobahn click opcua \
wxPython==4.1.1
# Point to python binary test scripts will use