[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[certi-cvs] certi/test/testFederate testFederateMain.cc CMa...
From: |
CERTI CVS commits |
Subject: |
[certi-cvs] certi/test/testFederate testFederateMain.cc CMa... |
Date: |
Wed, 16 Apr 2014 13:47:07 +0000 |
CVSROOT: /sources/certi
Module name: certi
Changes by: Eric NOULARD <erk> 14/04/16 13:47:07
Modified files:
test/testFederate: testFederateMain.cc CMakeLists.txt
testFederate.hh
Added files:
test/testFederate: dtest_testFederate.py
Log message:
Add automatic test federate script
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/test/testFederate/testFederateMain.cc?cvsroot=certi&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/certi/test/testFederate/CMakeLists.txt?cvsroot=certi&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/certi/test/testFederate/testFederate.hh?cvsroot=certi&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/certi/test/testFederate/dtest_testFederate.py?cvsroot=certi&rev=1.1
Patches:
Index: testFederateMain.cc
===================================================================
RCS file: /sources/certi/certi/test/testFederate/testFederateMain.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- testFederateMain.cc 3 Mar 2014 14:29:32 -0000 1.1
+++ testFederateMain.cc 16 Apr 2014 13:47:06 -0000 1.2
@@ -19,6 +19,9 @@
std::wstring federationName =
testFederate::getWString(args.federation_name_arg);
std::wstring FOMpath = testFederate::getWString(args.fom_model_arg);
+ // Create a federate object.
+ // This object inherit from appropriate FederateAmbassador class
+ // and embbed the appropriate RTIambassador object.
testFederate myFederate(federateName);
myFederate.setVerbosityLevel(verboseLevel);
myFederate.createFederationExecution(federationName,FOMpath);
Index: CMakeLists.txt
===================================================================
RCS file: /sources/certi/certi/test/testFederate/CMakeLists.txt,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- CMakeLists.txt 7 Mar 2014 18:25:17 -0000 1.3
+++ CMakeLists.txt 16 Apr 2014 13:47:06 -0000 1.4
@@ -81,8 +81,8 @@
ARCHIVE DESTINATION lib)
# DTest script not ready [yet]
-#install(FILES
-# dtest_testFederation.py
-# PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE WORLD_READ WORLD_EXECUTE
-# DESTINATION share/scripts)
+install(FILES
+ dtest_testFederate.py
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE WORLD_READ
WORLD_EXECUTE
+ DESTINATION share/scripts)
Index: testFederate.hh
===================================================================
RCS file: /sources/certi/certi/test/testFederate/testFederate.hh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- testFederate.hh 7 Mar 2014 18:01:22 -0000 1.2
+++ testFederate.hh 16 Apr 2014 13:47:07 -0000 1.3
@@ -2,29 +2,29 @@
#define TEST_FEDERATE_HH
#if defined(HLA13)
-#include <RTI.hh>
-#include <NullFederateAmbassador.hh>
-typedef NullFederateAmbassador NullFederateAmbassador_t;
-typedef RTI::RTIambassador RTIambassador_t;
-#include <fedtime.hh>
-#define NSRTI(a) "RTI::a"
+ #include <RTI.hh>
+ #include <NullFederateAmbassador.hh>
+ typedef NullFederateAmbassador NullFederateAmbassador_t;
+ typedef RTI::RTIambassador RTIambassador_t;
+ #include <fedtime.hh>
+ #define NSRTI(a) "RTI::a"
#elif defined(IEEE1516_2000)
-#include <RTI/RTI1516.h>
-#include <RTI/Enums.h>
-#include <RTI/NullFederateAmbassador.h>
-typedef rti1516::NullFederateAmbassador NullFederateAmbassador_t;
-typedef rti1516::RTIambassador RTIambassador_t ;
-#include <RTI/RTI1516fedTime.h>
-#define NSRTI(a) "rti1516::##a"
+ #include <RTI/RTI1516.h>
+ #include <RTI/Enums.h>
+ #include <RTI/NullFederateAmbassador.h>
+ typedef rti1516::NullFederateAmbassador NullFederateAmbassador_t;
+ typedef rti1516::RTIambassador RTIambassador_t ;
+ #include <RTI/RTI1516fedTime.h>
+ #define NSRTI(a) "rti1516::##a"
#elif defined(IEEE1516_2010)
-#include <RTI/RTI1516.h>
-#include <RTI/Enums.h>
-#include <RTI/NullFederateAmbassador.h>
-typedef rti1516e::NullFederateAmbassador NullFederateAmbassador_t;
-typedef rti1516e::RTIambassador RTIambassador_t;
-#define NSRTI(a) "rti1516e::##a"
+ #include <RTI/RTI1516.h>
+ #include <RTI/Enums.h>
+ #include <RTI/NullFederateAmbassador.h>
+ typedef rti1516e::NullFederateAmbassador NullFederateAmbassador_t;
+ typedef rti1516e::RTIambassador RTIambassador_t;
+ #define NSRTI(a) "rti1516e::##a"
#else
-#error "No one of HLA13, IEEE1516_2000 or IEEE1516_2010 defined --> ERROR"
+ #error "None of HLA13, IEEE1516_2000 or IEEE1516_2010 defined --> ERROR"
#endif
#include <string>
Index: dtest_testFederate.py
===================================================================
RCS file: dtest_testFederate.py
diff -N dtest_testFederate.py
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ dtest_testFederate.py 16 Apr 2014 13:47:06 -0000 1.1
@@ -0,0 +1,192 @@
+#!/usr/bin/env python
+
+##-----------------------------------------------------------------------
+##
+## DTest - A Distributed test framework
+##
+## Copyright (c) 2006-2008 Eric NOULARD, Lionel DUROYON and Frederik DEWEERDT
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+##-----------------------------------------------------------------------
+
+import logging
+import os
+import time
+import threading
+import getopt, sys
+import dtest
+# uncomment this if you want Promela/SPIN trace
+#from dtest.Promela_trace_handler import PromelaTraceHandler
+
+pseudoExecActive=0
+
+def usage():
+ print "Usage:\n %s [--help] [--pseudoexec] [--certi_home=<path>]
[--display=<display>] --rtig=<user>@[<host>]:<rtig_path>
--billard=<user>@[<host>]:<billard_path>" % sys.argv[0]
+
+def getUserHostPath(argument):
+ if argument.find("@") != -1:
+ (user,argument) = argument.split("@",1)
+ else:
+ user = os.environ["USER"]
+ if argument.find(":") != -1:
+ (host,path) = argument.split(":",1)
+ else:
+ host = "localhost"
+ path = argument
+ retval = dict()
+ retval['user'] = user
+ retval['host'] = host
+ retval['path'] = path
+ return retval
+
+def createAnotherOneFederateSequence(federateTester):
+ federateTester.timeout = 20
+ federateTester.stdout = file(federateTester.name + ".out",'w+')
+ federateTester.stdin = file(federateTester.name + ".in",'w+')
+ federateTester.stderr = file(federateTester.name + ".err",'w+')
+ federateTester.addRunStep("barrier","RTIG started")
+ federateTester.addRunStep("runCommand",command=".
"+certi_home+"/share/scripts/myCERTI_env.sh "+rtig_param['host'])
+ federateTester.addRunStep("runCommand",command="export DISPLAY="+display)
+ federateTester.addRunStep("barrier","First Federate started")
+ federateTester.addRunStep("runCommand",command=federate_param['path']+" -n
\""+federateTester.name+"\"")
+# federateTester.addRunStep("expectFromCommand",pattern="Synchronization")
+ federateTester.addRunStep("barrier","All Federate(s) started")
+ federateTester.addRunStep("expectFromCommand",pattern="RTIA:: End
execution.")
+ federateTester.addRunStep("terminateCommand")
+ federateTester.addRunStep("barrier","All Federate(s) ended")
+
+try:
+ opts, args = getopt.getopt(sys.argv[1:], "hr:b:c:p:d:", ["help","rtig=",
"federate=","certi_home=","pseudoexec","display="])
+except getopt.GetoptError, err:
+ print >> sys.stderr, "opt = %s, msg = %s" % (err.opt,err.msg)
+ usage()
+ sys.exit(2)
+
+## default values
+certi_home_defined=False
+display=":0.0"
+rtig_param = getUserHostPath("rtig")
+federate_param = getUserHostPath("CertiTestFederate-IEEE1516_2000")
+
+for o, a in opts:
+ if o in ("--help"):
+ usage()
+ sys.exit(2)
+ if o in ("--pseudoexec"):
+ pseudoExecActive=1
+ if o in ("-r", "--rtig"):
+ rtig_param = getUserHostPath(a)
+ if o in ("-b", "--federate"):
+ federate_param = getUserHostPath(a)
+ if o in ("-c", "--certi_home"):
+ certi_home = a
+ certi_home_defined=True
+ if o in ("--display"):
+ display = a;
+
+if not certi_home_defined:
+ if os.environ.has_key("CERTI_HOME"):
+ certi_home=os.environ["CERTI_HOME"]
+ else:
+ print "You must define CERTI_HOME environment variable"
+ sys.exit(2)
+
+firstFederate = dtest.DTester("firstFederate",
+
session=dtest.SSHSessionHandler(federate_param['user'],host=federate_param['host']))
+
+rtig = dtest.DTester("rtig",
+
session=dtest.SSHSessionHandler(rtig_param['user'],host=rtig_param['host']))
+# you may change the default time out value
+rtig.timeout = 40
+# you add want to save the output of your dtester to a file.
+rtig.stdout = file(rtig.name + ".out",'w+')
+rtig.stdin = file(rtig.name + ".in",'w+')
+rtig.stderr = file(rtig.name + ".err",'w+')
+
+# describe RTIG run steps
+rtig.addRunStep("ok",True,"CERTI RTIG and Federate Starts")
+rtig.addRunStep("runCommand",command=".
"+certi_home+"/share/scripts/myCERTI_env.sh "+rtig_param['host'])
+rtig.addRunStep("runCommand",command=rtig_param['path'])
+rtig.addRunStep("expectFromCommand",pattern="CERTI RTIG up and
running",timeout=5)
+rtig.addRunStep("barrier","RTIG started")
+rtig.addRunStep("barrier","All Federate(s) ended")
+rtig.addRunStep("terminateCommand")
+rtig.addRunStep("waitCommandTermination")
+rtig.addRunStep("ok",True,"CERTI RTIG and federate Ends")
+
+# describe federate run steps
+firstFederate.timeout = 20
+firstFederate.stdout = file(firstFederate.name + ".out",'w+')
+firstFederate.stdin = file(firstFederate.name + ".in",'w+')
+firstFederate.stderr = file(firstFederate.name + ".err",'w+')
+firstFederate.addRunStep("barrier","RTIG started")
+firstFederate.addRunStep("runCommand",command=".
"+certi_home+"/share/scripts/myCERTI_env.sh "+rtig_param['host'])
+firstFederate.addRunStep("runCommand",command="export DISPLAY="+display)
+firstFederate.addRunStep("runCommand",command=federate_param['path']+" -n
\""+firstFederate.name+"\"")
+#firstFederate.addRunStep("expectFromCommand",pattern="Press ENTER to start
execution")
+firstFederate.addRunStep("barrier","First Federate started")
+firstFederate.addRunStep("barrier","All Federate(s) started")
+firstFederate.addRunStep("sendToCommand",string="\n")
+firstFederate.addRunStep("expectFromCommand",pattern="RTIA:: End execution.")
+firstFederate.addRunStep("terminateCommand")
+firstFederate.addRunStep("barrier","All Federate(s) ended")
+
+#instanciate more billards
+federate2 = dtest.DTester("Federate2",
+
session=dtest.SSHSessionHandler(federate_param['user'],host=federate_param['host']))
+
+federate3 = dtest.DTester("Federate3",
+
session=dtest.SSHSessionHandler(federate_param['user'],host=federate_param['host']))
+
+federate4 = dtest.DTester("Federate4",
+
session=dtest.SSHSessionHandler(federate_param['user'],host=federate_param['host']))
+
+createAnotherOneFederateSequence(federate2)
+createAnotherOneFederateSequence(federate3)
+createAnotherOneFederateSequence(federate4)
+
+# Here begins the test
+dtest.DTestMaster.logger.setLevel(level=logging.WARNING)
+dtest.DTester.logger.setLevel(level=logging.WARNING)
+dtest.SSHSessionHandler.logger.setLevel(level=logging.WARNING)
+
+# Add some trace Handlers
+traceManager = dtest.TraceManager()
+# TAP goes to stdout
+traceManager.register(dtest.TAPTraceHandler())
+# MSC goes to file MSC-trace
+traceManager.register(dtest.MSCTraceHandler(output="billard-trace.msc"))
+# Promela goes to PROMELA_trace
+#traceManager.register(PromelaTraceHandler())
+
+def goTest():
+ myDTestMaster = dtest.DTestMaster("CERTI test Federate autotest","Launch
RTIG + several federate(s)")
+ myDTestMaster.registerTraceManager(traceManager)
+ myDTestMaster.trace=1
+
+ if (pseudoExecActive):
+ myDTestMaster.setPseudoExec(1)
+ myDTestMaster.timeout = 40
+ myDTestMaster.register(rtig)
+ myDTestMaster.register(firstFederate)
+ myDTestMaster.register(federate2)
+ myDTestMaster.register(federate3)
+ #myDTestMaster.register(federate4)
+ myDTestMaster.startTestSequence()
+ myDTestMaster.waitTestSequenceEnd()
+
+goTest()
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [certi-cvs] certi/test/testFederate testFederateMain.cc CMa...,
CERTI CVS commits <=