Changeset 70796 in vbox
- Timestamp:
- Jan 29, 2018 6:01:27 PM (7 years ago)
- Location:
- trunk/src/VBox/ValidationKit/tests/serial
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/serial/Makefile.kmk
r70769 r70796 33 33 ValidationKitTestsSerial_INST = $(INST_VALIDATIONKIT)tests/serial/ 34 34 ValidationKitTestsSerial_EXEC_SOURCES := \ 35 $(PATH_SUB_CURRENT)/tdSerial1.py 35 $(PATH_SUB_CURRENT)/tdSerial1.py \ 36 $(PATH_SUB_CURRENT)/loopback.py 36 37 37 38 VBOX_VALIDATIONKIT_PYTHON_SOURCES += $(ValidationKitTestsSerial_EXEC_SOURCES) -
trunk/src/VBox/ValidationKit/tests/serial/tdSerial1.py
r70771 r70796 48 48 from testdriver import reporter; 49 49 from testdriver import vbox; 50 50 from testdriver import vboxcon; 51 52 import loopback; 51 53 52 54 class tdSerial1(vbox.TestDriver): … … 59 61 self.asRsrcs = None; 60 62 self.oTestVmSet = self.oTestVmManager.selectSet(self.oTestVmManager.kfGrpStdSmoke); 61 self.asSerialModesDef = ['RawFile' ]; # @todo: Add Tcp, TcpServ, Pipe, PipeServ, HostDev63 self.asSerialModesDef = ['RawFile', 'Tcp', 'TcpServ', 'NamedPipe', 'NamedPipeServ', 'HostDev']; 62 64 self.asSerialModes = self.asSerialModesDef; 63 self.asSerialTestsDef = ['Write' ]; # @todo: Add read write and modem line control65 self.asSerialTestsDef = ['Write', 'ReadWrite']; 64 66 self.asSerialTests = self.asSerialTestsDef; 67 self.oLoopback = None; 68 self.sLocation = None; 65 69 66 70 # … … 132 136 return os.path.join(oTestDrv.sScratchPath, oTestVm.sVmName + sInfix + sRandom + sSuffix); 133 137 134 def testWrite(self, oSession, oTxsSession, sCom1RawFile, oTestVm): 138 def setupSerialMode(self, oSession, oTestVm, sMode): 139 """ 140 Sets up the serial mode. 141 """ 142 fRc = True; 143 fServer = False; 144 sLocation = None; 145 ePortMode = vboxcon.PortMode_Disconnected; 146 if sMode == 'RawFile': 147 sLocation = self._generateRawPortFilename(self, oTestVm, '-com1-', '.out'); 148 ePortMode = vboxcon.PortMode_RawFile; 149 elif sMode == 'Tcp': 150 sLocation = '127.0.0.1:1234'; 151 self.oLoopback = loopback.SerialLoopback(loopback.g_ksLoopbackTcpServ, sLocation); 152 ePortMode = vboxcon.PortMode_TCP; 153 elif sMode == 'TcpServ': 154 fServer = True; 155 sLocation = '1234'; 156 ePortMode = vboxcon.PortMode_TCP; 157 self.oLoopback = loopback.SerialLoopback(loopback.g_ksLoopbackTcpClient, '127.0.0.1:1234'); 158 elif sMode == 'NamedPipe': 159 sLocation = self._generateRawPortFilename(self, oTestVm, '-com1-', '.out'); 160 ePortMode = vboxcon.PortMode_HostPipe; 161 self.oLoopback = loopback.SerialLoopback(loopback.g_ksLoopbackNamedPipeServ, sLocation); 162 elif sMode == 'NamedPipeServ': 163 fServer = True; 164 sLocation = self._generateRawPortFilename(self, oTestVm, '-com1-', '.out'); 165 ePortMode = vboxcon.PortMode_HostPipe; 166 self.oLoopback = loopback.SerialLoopback(loopback.g_ksLoopbackNamedPipeClient, sLocation); 167 elif sMode == 'HostDev': 168 sLocation = '/dev/ttyUSB0'; 169 ePortMode = vboxcon.PortMode_HostDevice; 170 else: 171 reporter.log('warning, invalid mode %s given' % (sMode, )); 172 fRc = False; 173 174 if fRc: 175 fRc = oSession.changeSerialPortAttachment(0, ePortMode, sLocation, fServer); 176 if fRc and (sMode == 'TcpServ' or sMode == 'NamedPipeServ'): 177 self.sleep(2); # Fudge to allow the TCP server to get started. 178 fRc = self.oLoopback.connect(); 179 if not fRc: 180 reporter.log('Failed to connect to %s' % (sLocation, )); 181 self.sLocation = sLocation; 182 183 return fRc; 184 185 def testWrite(self, oSession, oTxsSession, oTestVm, sMode): 135 186 """ 136 187 Does a simple write test verifying the output. … … 149 200 if not fRc: 150 201 reporter.testFailure('Running serial test utility failed'); 151 el se:202 elif sMode == 'RawFile': 152 203 # Open serial port and verify 153 204 cLast = 0; 154 205 try: 155 oFile = open(s Com1RawFile, 'rb');206 oFile = open(self.sLocation, 'rb'); 156 207 sFmt = '=I'; 157 208 cBytes = 4; … … 169 220 reporter.testFailure('Verifying the written data failed'); 170 221 reporter.testDone(); 222 return fRc; 223 224 def testReadWrite(self, oSession, oTxsSession, oTestVm): 225 """ 226 Does a simple write test verifying the output. 227 """ 228 _ = oSession; 229 230 reporter.testStart('ReadWrite'); 231 tupCmdLine = ('SerialTest', '--tests', 'readwrite', '--txbytes', '1048576', '--device'); 232 if oTestVm.isWindows(): 233 tupCmdLine += (r'\\.\COM1',); 234 elif oTestVm.isLinux(): 235 tupCmdLine += (r'/dev/ttyS0',); 236 237 fRc = self.txsRunTest(oTxsSession, 'SerialTest', 600 * 1000, \ 238 '${CDROM}/${OS/ARCH}/SerialTest${EXESUFF}', tupCmdLine); 239 if not fRc: 240 reporter.testFailure('Running serial test utility failed'); 241 242 reporter.testDone(); 243 return fRc; 244 245 def isModeCompatibleWithTest(self, sMode, sTest): 246 """ 247 Returns whether the given port mode and test combination is 248 supported for testing. 249 """ 250 if sMode == 'RawFile' and sTest == 'ReadWrite': 251 return False; 252 elif sMode != 'RawFile' and sTest == 'Write': 253 return False; 254 255 return True; 171 256 172 257 def testOneVmConfig(self, oVM, oTestVm): … … 177 262 # Reconfigure the VM 178 263 fRc = True; 179 sCom1RawFile = self._generateRawPortFilename(self, oTestVm, '-com1-', '.out');180 264 oSession = self.openSession(oVM); 181 265 if oSession is not None: 182 fRc = oSession. setupSerialToRawFile(0, sCom1RawFile)266 fRc = oSession.enableSerialPort(0); 183 267 184 268 fRc = fRc and oSession.saveSettings(); … … 194 278 self.addTask(oTxsSession); 195 279 196 for sTest in self.asSerialTests: 197 if sTest == 'Write': 198 fRc = self.testWrite(oSession, oTxsSession, sCom1RawFile, oTestVm); 280 for sMode in self.asSerialModes: 281 reporter.testStart(sMode); 282 fRc = self.setupSerialMode(oSession, oTestVm, sMode); 283 if fRc: 284 for sTest in self.asSerialTests: 285 # Skip tests which don't work with the current mode. 286 if self.isModeCompatibleWithTest(sMode, sTest): 287 if sTest == 'Write': 288 fRc = self.testWrite(oSession, oTxsSession, oTestVm, sMode); 289 if sTest == 'ReadWrite': 290 fRc = self.testReadWrite(oSession, oTxsSession, oTestVm); 291 if self.oLoopback is not None: 292 self.oLoopback.shutdown(); 293 self.oLoopback = None; 294 295 reporter.testDone(); 199 296 200 297 self.removeTask(oTxsSession);
Note:
See TracChangeset
for help on using the changeset viewer.