Commit 56cc1e9e authored by Claes's avatar Claes Committed by Esteban Blanc

Project pwrtest02 added

parent 05542d4a
pwrtest02 is a test project for the development package.
It contains scripts to create and configure a project, and a
number of test programs.
The cpp test programs has to be built with a development tree, thus the
project is generated here and the testprograms built. The test programs
are gathered in $pwrp_load/pwrtest02.tar.gz.
For manual build:
pwre commands to build and clean the project
> pwre module project
> pwre build pwrtest02 build src
> pwre build pwrtest02 build src clean
build_from_git.sh will configure and build the project and build the
test programs.
For manual handling and running the project environment it set up by
test02_setup.sh
When the project is built, the test programs will generate log-files on
$pwrp_log. They can be examined by test_xtt, eg
test_xtt -f $pwrp_log/\*.tlog
include $(pwre_dir_symbols)
ifndef variables_mk
include $(pwre_croot)/src/tools/bld/src/variables.mk
endif
ifndef rules_mk
include $(pwre_croot)/src/tools/bld/src/rules.mk
endif
all : init copy lib exe | silent
init :
copy :
lib :
exe : build_project | silent
clean : clean_project
realclean : clean
silent :
@ :
build_project :
@ $(pwre_croot)/project/pwrtest02/build_from_git.sh
clean_project:
@ echo "Cleaing project"
@ if [ -e $(pwre_croot)/project/pwrtest02/bld ]; then rm $(pwre_croot)/project/pwrtest02/bld; fi
@ if [ -e $(pwre_croot)/project/pwrtest02/src/db/directory.wb_load ]; then rm $(pwre_croot)/project/pwrtest02/src/db/directory.wb_load; fi
@ if [ -e $(pwre_croot)/project/pwrtest02/src/db/cvolpwrtest02.wb_load ]; then rm $(pwre_croot)/project/pwrtest02/src/db/cvolpwrtest02.wb_load; fi
@ if [ -e $(pwre_croot)/project/pwrtest02/src/db/volpwrtest02.db ]; then rm -r $(pwre_croot)/project/pwrtest02/src/db/volpwrtest02.db; fi
@ if [ "`eval ls $(pwre_croot)/project/pwrtest02/src/db/*.lock 2>/dev/null`" != "" ]; then rm $(pwre_croot)/project/pwrtest02/src/db/*.lock; fi
@ if [ "`eval ls $(pwre_croot)/project/pwrtest02/src/db/* 2>/dev/null`" != "" ]; then rm -r $(pwre_croot)/project/pwrtest02/src/db/*; fi
@ if [ -e $(release_root)/bld/project/pwrtest02/bld ]; then rm -r $(release_root)/bld/project/pwrtest02/bld; fi
#!/bin/bash
#
# Build pwrtest02 from git clone
#
cd $pwre_sroot/pwrtest02
nodename=`eval uname -n`
unamestr=`eval uname`
onamestr=`eval uname -o`
machine=`eval uname -m`
if [ $unamestr == "Darwin" ]; then
os="os_macos"
hw="hw_x86_64"
opsys=256
elif [ $unamestr == "FreeBSD" ]; then
os="os_freebsd"
hw="hw_x86_64"
opsys=1024
elif [ $unamestr == "OpenBSD" ]; then
os="os_openbsd"
hw="hw_x86_64"
opsys=2048
elif [ $onamestr == "Cygwin" ]; then
os="os_cygwin"
hw="hw_x86"
opsys=4096
else
if [ $machine == "x86_64" ]; then
machine="x86_64"
opsys=128
elif [ ${machine:0:3} == "arm" ]; then
machine="arm"
opsys=512
else
machine="x86"
opsys=64
fi
os="os_linux"
hw="hw_"$machine
fi
platform=${hw:3}_${os:3}
#srcdir=$pwre_croot/src/tools/docker/pwrtest02
srcdir=/home/claes/wb
export pwrp_root=$pwre_croot/project/pwrtest02
broot=$pwre_broot/$os/$hw/bld/project/pwrtest02/bld
if [ ! -e $broot ]; then
mkdir -p $broot
fi
if [ ! -e $pwrp_root/bld ]; then
ln -s $broot $pwrp_root/bld
fi
export pwrp_exe=$pwrp_root/bld/$platform/exe
export pwrp_lib=$pwrp_root/bld/$platform/lib
export pwrp_obj=$pwrp_root/bld/$platform/obj
export pwrp_lis=$pwrp_root/bld/$platform/lis
export pwrp_inc=$pwrp_root/bld/common/inc
export pwrp_load=$pwrp_root/bld/common/load
export pwrp_tmp=$pwrp_root/bld/common/tmp
export pwrp_web=$pwrp_root/bld/common/web
export pwrp_log=$pwrp_root/bld/common/log
echo "* Create directories"
if [ ! -e $pwrp_obj ]; then
mkdir -p $pwrp_obj
fi
if [ ! -e $pwrp_exe ]; then
mkdir -p $pwrp_exe
fi
if [ ! -e $pwrp_lib ]; then
mkdir -p $pwrp_lib
fi
if [ ! -e $pwrp_lis ]; then
mkdir -p $pwrp_lis
fi
if [ ! -e $pwrp_load ]; then
mkdir -p $pwrp_load
fi
if [ ! -e $pwrp_inc ]; then
mkdir -p $pwrp_inc
fi
if [ ! -e $pwrp_lis ]; then
mkdir -p $pwrp_lis
fi
if [ ! -e $pwrp_tmp ]; then
mkdir -p $pwrp_tmp
fi
if [ ! -e $pwrp_web ]; then
mkdir -p $pwrp_web
fi
if [ ! -e $pwrp_log ]; then
mkdir -p $pwrp_log
fi
export pwrp_db=$pwre_sroot/pwrtest02/src/db
export pwrp_pop=$pwre_sroot/pwrtest02/src/pop
if [ ! -e $pwrp_db ]; then
mkdir -p $pwrp_db
fi
if [ ! -e $pwrp_pop ]; then
mkdir -p $pwrp_pop
fi
echo "* Configure adm"
export pwra_db=$pwre_broot/$os/$hw/bld/project/adm/db
if [ ! -e $pwra_db ]; then
mkdir -p $pwra_db
cp $pwre_croot/src/tools/pkg/deb/adm/* $pwra_db/
fi
if [ "`eval grep CVolPwrtest02 $pwra_db/pwr_volumelist.dat`" == "" ]; then
echo "CVolPwrtest02 0.0.240.210 pwrtest02" >> $pwra_db/pwr_volumelist.dat
fi
if [ "`eval grep VolPwrTest02 $pwra_db/pwr_volumelist.dat`" == "" ]; then
echo "VolPwrTest02 0.254.254.210 pwrtest02" >> $pwra_db/pwr_volumelist.dat
fi
if [ ! -e $pwra_db/pwr_projectlist.dat ] || [ "`eval grep base $pwra_db/pwr_projectlist.dat`" == "" ]; then
echo "%base V0.0.0 $pwre_broot" > $pwra_db/pwr_projectlist.dat
fi
if [ "`eval grep pwrtest02 $pwra_db/pwr_projectlist.dat`" == "" ]; then
echo "pwrtest02 V0.0.0 $pwrp_root Test-pwrtest02 \"\"" >> $pwra_db/pwr_projectlist.dat
fi
source $pwra_db/pwr_setup.sh
source $pwra_db/pwra_env.sh set project pwrtest02
#set -o xtrace
echo "* Configure directory volume"
wb_cmd create volume/database=wbload/directory
wb_cmd @$srcdir/configure_directory pwrtest02
echo "* Configure class volume"
ls $srcdir/configure_cvolpwrtest02.pwr_com
wb_cmd -c cvolpwrtest02 @$srcdir/configure_cvolpwrtest02
wb_cmd -q create snapshot/file=\"$pwrp_db/cvolpwrtest02.wb_load\"/out=\"$pwrp_load/cvolpwrtest02.dbs\"
co_convert -so -d $pwrp_inc $pwrp_db/cvolpwrtest02.wb_load
echo "* Configure root volume"
wb_cmd -v volpwrtest02 @$srcdir/configure_volpwrtest02
wb_cmd -v volpwrtest02 build node/name=pwrt02
echo "* Build test programs"
cp $srcdir/wa_ldhtest.cpp $pwrp_appl
cp $srcdir/wa_ldhtest.h $pwrp_appl
cp $srcdir/wa_pwrwbtest.py $pwrp_appl
cp $srcdir/ra_test.py $pwrp_appl
cp $srcdir/makefile $pwrp_appl
cd $pwrp_appl
make
echo "* Run test programs"
export PYTHONPATH=$pwr_eexe
wa_ldhtest volpwrtest02
wa_pwrwbtest.py
echo "* Build package"
cd $pwrp_exe
tar -czf $pwrp_load/pwrtest02.tar.gz wa_ldhtest wa_pwrwbtest.py ra_test.py
exit
echo "* Set opsys $opsys"
cat > initdir.pwr_com <<EOF
set attr/name=Bus999-PwrTest02/attr=OperatingSystem/value="$opsys"/noconf
save
exit
EOF
wb_cmd @initdir
echo "* Build class volume"
co_convert -so -d $pwrp_inc $pwrp_db/cvolpwrtest02.wb_load
co_convert -po -d $pwrp_inc $pwrp_db/cvolpwrtest02.wb_load
wb_cmd -q create snapshot/file=\"$pwrp_db/cvolpwrtest02.wb_load\"/out=\"$pwrp_load/cvolpwrtest02.dbs\"
echo "* Load volpwrtest01a"
wb_cmd wb load/nofocode/load=\"$pwrp_db/volpwrtest01a.wb_dmp\"/out=\"$pwrp_db/volpwrtest01a.lis\"
echo "* Set opsys $opsys"
cat > initvol.pwr_com <<EOF
set attr/name=VolPwrTest02:/attr=OperatingSystem/value="$opsys"/noconf
save
exit
EOF
wb_cmd -v volpwrtest02 @initvol
wb_cmd -v volpwrtest02 build node pwrtest02 /force
echo "* Build package"
wb_cmd distr/node=pwrtest02/package
exit
my : demo_all
include $(pwr_exe)/pwrp_rules.mk
#asan = -fsanitize=address -lasan
demo_modules = $(pwrp_exe)/wa_ldhtest \
$(pwrp_exe)/wa_pwrwbtest.py \
$(pwrp_exe)/ra_test.py
pwre_conf_libpwrco=-lpwr_co
pwre_conf_libpwrrt=-lpwr_rt -lpwr_statussrv -lpwr_co -lpwr_msg_dummy
pwre_conf_libpwrdtt=-lpwr_dtt
pwre_conf_libpwrotherio=-lpwr_usbio_dummy -lpwr_usb_dummy -lpwr_cifx_dummy -lpwr_nodave_dummy -lpwr_epl_dummy
pwre_conf_libpwrprofibus=-lpwr_pnak_dummy
pwre_conf_libpwrpowerlink=
pwre_conf_libpwrpowerlinkcn=
pwre_conf_libpwrxtt=-lpwr_xtt -lpwr_ge -lpwr_cow -lpwr_flow -lpwr_glow
pwre_conf_libpwrxttgtk= -lpwr_xtt_gtk -lpwr_ge_gtk -lpwr_cow_gtk -lpwr_flow_gtk -lpwr_glow_gtk
pwre_conf_libpwrxttqt= -lpwr_xtt_qt -lpwr_ge_qt -lpwr_cow_qt -lpwr_flow_qt -lpwr_glow_qt
pwre_conf_libpwrxttmotif= -lpwr_xtt_motif -lpwr_ge_motif -lpwr_cow_motif -lpwr_flow_motif -lpwr_glow_motif
pwre_conf_libpwrwb=-lpwr_wb
pwre_conf_libpwrwbgtk=-lpwr_wb_gtk
pwre_conf_libpwrwbqt=-lpwr_wb_qt
pwre_conf_libpwrwbmotif=-lpwr_wb_motif
pwre_conf_libpwropc=-lpwr_opc
pwre_conf_libpwrremote=-lpwr_remote
pwre_conf_libpwrnmps=-lpwr_nmps
pwre_conf_libpwrtlog=-lpwr_tlog
pwre_conf_libpwrsev=-lpwr_sev
pwre_conf_lib= -lrpcsvc -lasound -lpthread -lm -ldb -lz -lcrypt -lrt -lX11 -lsqlite3 -lhdf5_openmpi -lmpi -lrabbitmq -lusb-1.0 -lrsvg-2
pwre_conf_libwb= -ldb_cxx
pwre_conf_libmq=
pwre_conf_libwmq=
pwre_conf_libpnak=
pwre_conf_libgtk= \`pkg-config --libs gtk+-2.0\`
pwre_conf_libqt=
pwre_conf_libgst= \`pkg-config --libs gstreamer-video-1.0 gstreamer-1.0\`
wb_msg_eobjs=$(pwr_obj)/pwr_msg_wb.o
rt_msg_eobjs=$(pwr_obj)/pwr_msg_rt.o $(pwr_obj)/pwr_msg_rs.o $(pwr_obj)/pwr_msg_co.o $(pwr_obj)/pwr_msg_flow.o $(pwr_obj)/pwr_msg_glow.o $(pwr_obj)/pwr_msg_ge.o
demo_all : $(demo_modules)
$(pwrp_exe)/wa_ldhtest : $(pwrp_appl)/wa_ldhtest.cpp
@ echo "Building wa_ldhtest"
@ g++ -g -o $(target) $(source) -DOS_LINUX=1 -Wall -I$(pwr_inc) -I$(pwrp_inc) -L$(pwr_lib) \
$(wb_msg_eobjs) $(rt_msg_eobjs) $(pwre_conf_libdir) \
$(pwr_obj)/rt_io_user.o $(pwr_obj)/wb_procom.o \
$(pwre_conf_libdir) $(pwre_conf_libpwrwbgtk) $(pwre_conf_libpwrxttgtk) \
$(pwre_conf_libpwrwb) \
$(pwre_conf_libpwrxtt) $(pwre_conf_libpwrwbgtk) $(pwre_conf_libpwrwb) \
$(pwre_conf_libpwrxttgtk) $(pwre_conf_libpwrxtt) \
`pkg-config --libs gtk+-2.0` \
$(pwre_conf_libpwrrt) $(pwre_conf_libwb) $(pwre_conf_lib) $(asan)
$(pwrp_exe)/wa_pwrwbtest.py : $(pwrp_appl)/wa_pwrwbtest.py
@ echo "Building wa_pwrwbtest"
@ cp -p $(source) $(target)
$(pwrp_exe)/ra_test.py : $(pwrp_appl)/ra_test.py
@ echo "Building ra_test"
@ cp -p $(source) $(target)
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
import sys
import math
import time
import pwrrt
import pwrtest
class Ctx:
#
# Static pwrrt methods
#
#
# pwrrt.init()
#
def init(self):
try:
pwrrt.init('ra_pwrrttest')
except RuntimeError as e:
self.logger.vlog('E', 'init, Unexpected exception %s', str(e))
raise e
self.logger.log('S', 'init, successfull completion')
#
# Check system status
#
def systemStatus(self):
a = pwrrt.attribute('Nodes-Pwrtest02.SystemStatus')
sts = a.value()
msg = pwrrt.getMsg(sts)
if sts % 2 == 0:
self.logger.log('E', 'System status', msg);
return
self.logger.log('S', 'System status', msg)
#
# Check plc threads
#
def plcThreads(self):
d = (
((1, 'PlcTest-H1-Dv1.ActualValue', 1),
(1, 'PlcTest-H1-Dv2.ActualValue', 1),
(1, 'PlcTest-H1-Dv3.ActualValue', 0),
(0, 'PlcTest-H1-Dv4.ActualValue', 1)),
((1, 'PlcTest-H2-Dv1.ActualValue', 1),
(1, 'PlcTest-H2-Dv2.ActualValue', 1),
(1, 'PlcTest-H2-Dv3.ActualValue', 0),
(0, 'PlcTest-H2-Dv4.ActualValue', 1)),
((1, 'PlcTest-H3-Dv1.ActualValue', 1),
(1, 'PlcTest-H3-Dv2.ActualValue', 1),
(1, 'PlcTest-H3-Dv3.ActualValue', 0),
(0, 'PlcTest-H3-Dv4.ActualValue', 1)),
((1, 'PlcTest-H4-Dv1.ActualValue', 1),
(1, 'PlcTest-H4-Dv2.ActualValue', 1),
(1, 'PlcTest-H4-Dv3.ActualValue', 0),
(0, 'PlcTest-H4-Dv4.ActualValue', 1))
)
for i in range(len(d)):
for j in range(len(d[i])):
if d[i][j][0] == 1:
a = pwrrt.attribute(d[i][j][1])
a.setValue(d[i][j][2])
time.sleep(0.1)
for i in range(len(d)):
for j in range(len(d[i])):
if d[i][j][0] == 0:
a = pwrrt.attribute(d[i][j][1])
val = a.value()
if val != d[i][j][2]:
self.logger.vlog('E', 'Plc thread %s, test value mismatch', str(i))
else:
self.logger.vlog('S', 'PlcThread %s test ok', str(i))
ctx = Ctx()
ctx.logger = pwrtest.logger('wbtest-rt', '$pwrp_log/pwrtest02_rt.tlog')
try:
ctx.init()
except:
quit()
pwrrt.login('pwrp', 'pwrp')
ctx.systemStatus()
ctx.plcThreads()
This diff is collapsed.
#include "pwr.h"
#include "co_cdh.h"
#include "rt_gdh.h"
#include "co_tst_log.h"
class wa_ldhtest {
pwr_tStatus m_sts;
ldh_tWorkbench m_ldhwb;
ldh_tSession m_ldhses;
ldh_tVolContext m_volctx;
pwr_tObjName m_vname;
pwr_tVid m_vid;
tst_log *m_log;
pwr_tOid m_test;
pwr_tOid m_test_h1;
pwr_tOid m_test_h2;
pwr_tOid m_root;
pwr_tStatus check_object(pwr_tOid oid);
public:
wa_ldhtest();
~wa_ldhtest();
void vname(char *n) {strncpy(m_vname, n, sizeof(m_vname));}
void Init();
void Close();
void ObjidToName();
void CreateObject();
void DeleteObject();
void DeleteObjectTree();
void ChangeObjectName();
void MoveObject();
void GetRootList();
void GetChild();
void GetParent();
void GetNextSibling();
void GetPreviousSibling();
void NameToAttrRef();
void AttrRefToName();
void AttrArefToObjectAref();
void GetClassList();
void GetNextObject();
void GetNextAttrRef();
void ClassNameToId();
void ClassIdToName();
void GetSuperClass();
void GetEnumValueDef();
void GetMaskBitDef();
void GetObjectClass();
void GetAttrRefTid();
void GetVolumeList();
void GetNextVolume();
void GetVolumeClass();
void GetVidInfo();
void GetVolumeInfo();
void AttachVolume();
void OpenWB();
void OpenSession();
void CopyObject();
void CopyObjectTrees();
void CreateVolume();
void GetObjectPar();
void SetObjectPar();
};
This diff is collapsed.
#! /bin/bash
#
# Local setup
# Printer command for plc documents
#export pwr_foe_gre_print="lpr -P lp1"
export PWR_BUS_ID=999
if [ -e "$pwrp_root/src/login/sysinfo.txt" ]; then
echo "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"
echo "Welcome to"
echo "`$pwr_exe/pwrp_env.sh show project`"
echo ""
cat $pwrp_login/sysinfo.txt
echo "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_"
fi
Revision history
2020-07-14 cs Project created
#!/bin/bash
nodename=`eval uname -n`
unamestr=`eval uname`
onamestr=`eval uname -o`
machine=`eval uname -m`
if [ $unamestr == "Darwin" ]; then
os="os_macos"
hw="hw_x86_64"
opsys=256
elif [ $unamestr == "FreeBSD" ]; then
os="os_freebsd"
hw="hw_x86_64"
opsys=1024
elif [ $unamestr == "OpenBSD" ]; then
os="os_openbsd"
hw="hw_x86_64"
opsys=2048
elif [ $onamestr == "Cygwin" ]; then
os="os_cygwin"
hw="hw_x86"
opsys=4096
else
if [ $machine == "x86_64" ]; then
machine="x86_64"
opsys=128
elif [ ${machine:0:3} == "arm" ]; then
machine="arm"
opsys=512
else
machine="x86"
opsys=64
fi
os="os_linux"
hw="hw_"$machine
fi
export pwra_db=$pwre_broot/$os/$hw/bld/project/adm/db
source $pwra_db/pwr_setup.sh
source $pwra_db/pwra_env.sh set project pwrtest02
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment