From: Ovidiu Mircescu Date: Fri, 18 Apr 2014 14:48:44 +0000 (+0200) Subject: Add a test for most of the examples. X-Git-Tag: V7_5_0a1~4^2~2^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f674bc736b2aa9a912eb180828878b94bcf13789;p=tools%2Fyacsgen.git Add a test for most of the examples. The test_compo.py script can test the coupling.xml schema of an example directory. --- diff --git a/Examples/build.sh b/Examples/build.sh index caca301..cc1c2f7 100755 --- a/Examples/build.sh +++ b/Examples/build.sh @@ -6,15 +6,21 @@ cur_dir=`pwd` script_dir=`dirname $0` # activate stop on error -set -e +#set -e cd $script_dir list_dirs="calcium1 calcium2 cpp1 cpp2 cppgui1 fort1 fort2 pydoc1 pygui1 pyth1 pyth2 types1 hxx1" for dir in $list_dirs ; do cd $dir - echo Building $dir ... "(see build.log & build.err)" - ./build.sh > build.log 2> build.err + echo Building $dir ... + ./build.sh >build.log 2>&1 + ret=$? + if [ $ret -ne 0 ] ; then + echo "Stop on error. See:" + echo " "`pwd`/build.log + exit 1 + fi cd .. done diff --git a/Examples/calcium1/Makefile b/Examples/calcium1/Makefile index bd8fd4a..44ca12d 100644 --- a/Examples/calcium1/Makefile +++ b/Examples/calcium1/Makefile @@ -27,4 +27,4 @@ code1.o:code1.f $(FC) -c code1.f -fPIC -I$(KERNEL_ROOT_DIR)/include/salome -fexceptions clean: - rm -rf *.o *.so install traceExec_proc appli *.bak pycompos_* build.err build.log + rm -rf *.o *.so install traceExec_proc appli *.bak pycompos_* *.err *.log diff --git a/Examples/calcium1/build.sh b/Examples/calcium1/build.sh index 8a905e1..f0cdb2d 100755 --- a/Examples/calcium1/build.sh +++ b/Examples/calcium1/build.sh @@ -1,3 +1,6 @@ source ../exec.sh make python components.py + +# test +appli/runSession ../test_compo.py diff --git a/Examples/calcium2/Makefile b/Examples/calcium2/Makefile index bd8fd4a..44ca12d 100644 --- a/Examples/calcium2/Makefile +++ b/Examples/calcium2/Makefile @@ -27,4 +27,4 @@ code1.o:code1.f $(FC) -c code1.f -fPIC -I$(KERNEL_ROOT_DIR)/include/salome -fexceptions clean: - rm -rf *.o *.so install traceExec_proc appli *.bak pycompos_* build.err build.log + rm -rf *.o *.so install traceExec_proc appli *.bak pycompos_* *.err *.log diff --git a/Examples/calcium2/build.sh b/Examples/calcium2/build.sh index 8a905e1..f7d4916 100755 --- a/Examples/calcium2/build.sh +++ b/Examples/calcium2/build.sh @@ -1,3 +1,7 @@ source ../exec.sh make python components.py + +# test +appli/runSession ../test_compo.py + diff --git a/Examples/cpp1/Makefile b/Examples/cpp1/Makefile index a3dda0e..1fd0ce1 100644 --- a/Examples/cpp1/Makefile +++ b/Examples/cpp1/Makefile @@ -18,4 +18,4 @@ # clean: - rm -rf *.o *.so appli install *.bak traceExec_proc cppcompos_* build.err build.log + rm -rf *.o *.so appli install *.bak traceExec_proc cppcompos_* *.err *.log diff --git a/Examples/cpp1/build.sh b/Examples/cpp1/build.sh index 8430376..c23f5ca 100755 --- a/Examples/cpp1/build.sh +++ b/Examples/cpp1/build.sh @@ -1 +1,5 @@ ../exec.sh python components.py + +# test +appli/runSession ../test_compo.py + diff --git a/Examples/cpp2/Makefile b/Examples/cpp2/Makefile index e5cfcff..cd67526 100644 --- a/Examples/cpp2/Makefile +++ b/Examples/cpp2/Makefile @@ -22,4 +22,4 @@ include ../makefile.inc prog:prog.cxx g++ -o prog prog.cxx -L./install/lib/salome -lcompo1Exelib -lSalomeIDLcppcompos clean: - rm -rf *.o prog install appli *.bak compo1_inst_1 traceExec_proc cppcompos_* build.err build.log + rm -rf *.o prog install appli *.bak compo1_inst_1 traceExec_proc cppcompos_* *.err *.log diff --git a/Examples/cpp2/build.sh b/Examples/cpp2/build.sh index fb1f667..c7dfc37 100755 --- a/Examples/cpp2/build.sh +++ b/Examples/cpp2/build.sh @@ -2,3 +2,6 @@ source ../exec.sh python components.py make +# test +appli/runSession ../test_compo.py + diff --git a/Examples/cppgui1/Makefile b/Examples/cppgui1/Makefile index a734346..6ad3d3a 100644 --- a/Examples/cppgui1/Makefile +++ b/Examples/cppgui1/Makefile @@ -18,4 +18,4 @@ # clean: - rm -rf *.o *.so cppcompos_* appli install *.bak traceExec_proc build.err build.log + rm -rf *.o *.so cppcompos_* appli install *.bak traceExec_proc *.err *.log diff --git a/Examples/fort1/Makefile b/Examples/fort1/Makefile index 70eca4f..f6e71ac 100644 --- a/Examples/fort1/Makefile +++ b/Examples/fort1/Makefile @@ -33,4 +33,4 @@ bidul.o:bidul.f $(FC) -c bidul.f -fPIC -I$(KERNEL_ROOT_DIR)/include/salome -fexceptions clean: - rm -rf *.o *.so fcompos_* install appli traceExec_proc *.bak build.err build.log + rm -rf *.o *.so fcompos_* install appli traceExec_proc *.bak *.err *.log diff --git a/Examples/fort1/build.sh b/Examples/fort1/build.sh index 8a905e1..f7d4916 100755 --- a/Examples/fort1/build.sh +++ b/Examples/fort1/build.sh @@ -1,3 +1,7 @@ source ../exec.sh make python components.py + +# test +appli/runSession ../test_compo.py + diff --git a/Examples/fort2/Makefile b/Examples/fort2/Makefile index ced9c90..3acad54 100644 --- a/Examples/fort2/Makefile +++ b/Examples/fort2/Makefile @@ -33,4 +33,4 @@ code2.o:code2.f $(FC) -c code2.f -I$(KERNEL_ROOT_DIR)/include/salome -fexceptions clean: - rm -rf *.o prog1 prog2 fcode1_inst_1 fcode2_inst_1 fcompos_* install traceExec_proc *.bak appli build.err build.log + rm -rf *.o prog1 prog2 fcode1_inst_1 fcode2_inst_1 fcompos_* install traceExec_proc *.bak appli *.err *.log diff --git a/Examples/fort2/build.sh b/Examples/fort2/build.sh index 66bd3c5..c7dfc37 100755 --- a/Examples/fort2/build.sh +++ b/Examples/fort2/build.sh @@ -1,3 +1,7 @@ source ../exec.sh python components.py make + +# test +appli/runSession ../test_compo.py + diff --git a/Examples/hxx1/Makefile b/Examples/hxx1/Makefile index 5a16a4a..ebfce1d 100644 --- a/Examples/hxx1/Makefile +++ b/Examples/hxx1/Makefile @@ -18,4 +18,4 @@ # clean: - rm -rf parse_* appli install hxxcompos_* COMPONENTCPP_* *.bak build.err build.log + rm -rf parse_* appli install hxxcompos_* COMPONENTCPP_* *.bak *.err *.log diff --git a/Examples/hxx1/build.sh b/Examples/hxx1/build.sh index da0953e..23792fd 100755 --- a/Examples/hxx1/build.sh +++ b/Examples/hxx1/build.sh @@ -14,6 +14,5 @@ cd .. ../exec.sh python component.py appli/salome start -t -sleep 2 appli/salome shell python test_compohxx.py appli/salome killall diff --git a/Examples/pydoc1/Makefile b/Examples/pydoc1/Makefile index a3df1cb..a803c78 100644 --- a/Examples/pydoc1/Makefile +++ b/Examples/pydoc1/Makefile @@ -18,4 +18,4 @@ # clean: - rm -rf *.pyc pycompos_* appli install *.bak traceExec_proc build.err build.log + rm -rf *.pyc pycompos_* appli install *.bak traceExec_proc *.err *.log diff --git a/Examples/pygui1/Makefile b/Examples/pygui1/Makefile index a3df1cb..a803c78 100644 --- a/Examples/pygui1/Makefile +++ b/Examples/pygui1/Makefile @@ -18,4 +18,4 @@ # clean: - rm -rf *.pyc pycompos_* appli install *.bak traceExec_proc build.err build.log + rm -rf *.pyc pycompos_* appli install *.bak traceExec_proc *.err *.log diff --git a/Examples/pyth1/Makefile b/Examples/pyth1/Makefile index f7a10ea..a2a609e 100644 --- a/Examples/pyth1/Makefile +++ b/Examples/pyth1/Makefile @@ -18,4 +18,4 @@ # clean: - rm -rf *.o *.so *.pyc pycompos_* appli install *.bak traceExec_proc build.err build.log + rm -rf *.o *.so *.pyc pycompos_* appli install *.bak traceExec_proc *.err *.log diff --git a/Examples/pyth1/build.sh b/Examples/pyth1/build.sh index 8430376..c23f5ca 100755 --- a/Examples/pyth1/build.sh +++ b/Examples/pyth1/build.sh @@ -1 +1,5 @@ ../exec.sh python components.py + +# test +appli/runSession ../test_compo.py + diff --git a/Examples/pyth2/Makefile b/Examples/pyth2/Makefile index aeeabe5..c9936ce 100644 --- a/Examples/pyth2/Makefile +++ b/Examples/pyth2/Makefile @@ -18,4 +18,4 @@ # clean: - rm -rf *.o *.so *.pyc pycompos_* appli install *.bak traceExec_proc compo2_inst_1 build.err build.log + rm -rf *.o *.so *.pyc pycompos_* appli install *.bak traceExec_proc compo2_inst_1 *.err *.log diff --git a/Examples/pyth2/build.sh b/Examples/pyth2/build.sh index 8430376..c23f5ca 100755 --- a/Examples/pyth2/build.sh +++ b/Examples/pyth2/build.sh @@ -1 +1,5 @@ ../exec.sh python components.py + +# test +appli/runSession ../test_compo.py + diff --git a/Examples/test_compo.py b/Examples/test_compo.py new file mode 100755 index 0000000..a76bed3 --- /dev/null +++ b/Examples/test_compo.py @@ -0,0 +1,51 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- +import unittest + +import os +import sys + +import imp +salome_module = imp.load_source("SALOME", os.path.join("appli", "salome")) + +class TestCompo(unittest.TestCase): + def setUp(self): + #start salome and connect to it + salome_module.main(["start", "-t"]) + import runSession + runSession.configureSession() + import setenv + setenv.main(True) + + # creat study and load catalogs + import SALOMERuntime + SALOMERuntime.RuntimeSALOME_setRuntime() + salome_runtime = SALOMERuntime.getSALOMERuntime() + + import salome + salome.salome_init() + + mc = salome.naming_service.Resolve('/Kernel/ModulCatalog') + ior = salome.orb.object_to_string(mc) + session_catalog = salome_runtime.loadCatalog("session", ior) + salome_runtime.addCatalog(session_catalog) + + def test_exec_scheme(self): + import pilot + import loader + + xmlLoader = loader.YACSLoader() + try: + p = xmlLoader.load("coupling.xml") + except IOError,ex: + self.fail("IO exception:" + ex); + self.assertTrue(p.isValid()) + e = pilot.ExecutorSwig() + e.RunW(p) + self.assertEqual(p.getEffectiveState(), pilot.DONE) + + def tearDown(self): + salome_module.main(["killall"]) + +if __name__ == '__main__': + unittest.main() diff --git a/Examples/types1/Makefile b/Examples/types1/Makefile index ffe9c05..0961fbb 100644 --- a/Examples/types1/Makefile +++ b/Examples/types1/Makefile @@ -18,4 +18,4 @@ # clean: - rm -rf *.o *.so *.bak mymodule_* appli install *.bak traceExec_* build.err build.log + rm -rf *.o *.so *.bak mymodule_* appli install *.bak traceExec_* *.err *.log diff --git a/Examples/types1/build.sh b/Examples/types1/build.sh index 8430376..c23f5ca 100755 --- a/Examples/types1/build.sh +++ b/Examples/types1/build.sh @@ -1 +1,5 @@ ../exec.sh python components.py + +# test +appli/runSession ../test_compo.py +