From: Bertrand <bco...@us...> - 2017-02-26 11:36:44
|
Update of /cvsroot/jsbsim/JSBSim/tests In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv13040/tests Modified Files: TestInputSocket.py Log Message: Now checks that the time step obtained thru the socket is containing the expected value before using it. Index: TestInputSocket.py =================================================================== RCS file: /cvsroot/jsbsim/JSBSim/tests/TestInputSocket.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** TestInputSocket.py 30 Jan 2016 18:50:24 -0000 1.4 --- TestInputSocket.py 26 Feb 2017 11:36:41 -0000 1.5 *************** *** 157,165 **** def test_input_socket(self): # The aircraft c172x does not contain an <input> tag so we need # to add one. tree, aircraft_name, b = CopyAircraftDef(self.script_path, self.sandbox) ! self.root = tree.getroot() ! input_tag = et.SubElement(self.root, 'input') input_tag.attrib['port'] = '1137' tree.write(self.sandbox('aircraft', aircraft_name, --- 157,169 ---- def test_input_socket(self): + # First, extract the time step from the script file + tree = et.parse(self.script_path) + dt = float(tree.getroot().find('run').attrib['dt']) + # The aircraft c172x does not contain an <input> tag so we need # to add one. tree, aircraft_name, b = CopyAircraftDef(self.script_path, self.sandbox) ! root = tree.getroot() ! input_tag = et.SubElement(root, 'input') input_tag.attrib['port'] = '1137' tree.write(self.sandbox('aircraft', aircraft_name, *************** *** 178,184 **** msg = string.split(tn.sendCommand("info"), '\n') self.assertEqual(string.strip(string.split(msg[2], ':')[1]), ! string.strip(self.root.attrib['name'])) self.assertEqual(string.strip(string.split(msg[1], ':')[1]), ! string.strip(self.root.attrib['version'])) # Check that the simulation time is 0.0 --- 182,188 ---- msg = string.split(tn.sendCommand("info"), '\n') self.assertEqual(string.strip(string.split(msg[2], ':')[1]), ! string.strip(root.attrib['name'])) self.assertEqual(string.strip(string.split(msg[1], ':')[1]), ! string.strip(root.attrib['version'])) # Check that the simulation time is 0.0 *************** *** 187,190 **** --- 191,197 ---- self.assertEqual(tn.getPropertyValue("simulation/sim-time-sec"), 0.0) + # Check the time step we get through the socket interface + self.assertEqual(tn.getDeltaT(), dt) + # Check that 'iterate' iterates the correct number of times tn.sendCommand("iterate 19") |