Changeset 70660 in vbox for trunk/src/VBox/ValidationKit/tests
- Timestamp:
- Jan 21, 2018 4:18:58 PM (7 years ago)
- Location:
- trunk/src/VBox/ValidationKit/tests
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py
r70521 r70660 3168 3168 curTest = aTest[0]; # tdTestFileReadWrite, use an index, later. 3169 3169 curRes = aTest[1]; # tdTestResult 3170 reporter.log('Testing #%d, sFile="%s", cbToReadWrite=%d, sOpenMode="%s", sDisposition="%s", cbOffset=%d ...' % \3170 reporter.log('Testing #%d, sFile="%s", cbToReadWrite=%d, sOpenMode="%s", sDisposition="%s", cbOffset=%d ...' % 3171 3171 (i, curTest.sFile, curTest.cbToReadWrite, curTest.sOpenMode, curTest.sDisposition, curTest.cbOffset)); 3172 3172 curTest.setEnvironment(oSession, oTxsSession, oTestVm); … … 3175 3175 reporter.error('Test #%d failed: Could not create session' % (i,)); 3176 3176 break; 3177 3177 3178 try: 3178 3179 if curTest.cbOffset > 0: # The offset parameter is gone. … … 3182 3183 curFile.seek(curTest.cbOffset, vboxcon.FileSeekOrigin_Begin); 3183 3184 else: 3184 curFile = curGuestSession.fileOpenEx(curTest.sFile, curTest.sOpenMode, curTest.sDisposition, \3185 curFile = curGuestSession.fileOpenEx(curTest.sFile, curTest.sOpenMode, curTest.sDisposition, 3185 3186 curTest.sSharingMode, curTest.lCreationMode, curTest.cbOffset); 3186 3187 curOffset = long(curFile.offset); 3187 3188 resOffset = long(curTest.cbOffset); 3188 3189 if curOffset != resOffset: 3189 reporter.error('Test #%d failed: Initial offset on open does not match: Got %d, expected %d' \3190 reporter.error('Test #%d failed: Initial offset on open does not match: Got %d, expected %d' 3190 3191 % (i, curOffset, resOffset)); 3191 3192 fRc = False; … … 3195 3196 curTest.lCreationMode); 3196 3197 else: 3197 curFile = curGuestSession.fileOpen(curTest.sFile, curTest.sOpenMode, curTest.sDisposition, \3198 curFile = curGuestSession.fileOpen(curTest.sFile, curTest.sOpenMode, curTest.sDisposition, 3198 3199 curTest.lCreationMode); 3199 if fRc \ 3200 and curTest.cbToReadWrite > 0: 3200 if fRc and curTest.cbToReadWrite > 0: 3201 3201 ## @todo Split this up in 64K writes. Later. 3202 3202 ## @todo Test timeouts. 3203 3203 cBytesWritten = curFile.write(curTest.aBuf, 30 * 1000); 3204 if curRes.cbProcessed > 0 \3205 and curRes.cbProcessed != cBytesWritten:3206 reporter.error('Test #%d failed: Written buffer length does not match: Got %d, expected %d' \3204 if curRes.cbProcessed > 0 \ 3205 and curRes.cbProcessed != cBytesWritten: 3206 reporter.error('Test #%d failed: Written buffer length does not match: Got %d, expected %d' 3207 3207 % (i, cBytesWritten, curRes.cbProcessed)); 3208 3208 fRc = False; … … 3218 3218 reporter.logXcpt('Seeking back to initial write position failed:'); 3219 3219 fRc = False; 3220 if fRc \ 3221 and long(curFile.offset) != curTest.cbOffset: 3222 reporter.error('Test #%d failed: Initial write position does not match current position, \ 3223 got %d, expected %d' \ 3224 % (i, long(curFile.offset), curTest.cbOffset)); 3220 if fRc and long(curFile.offset) != curTest.cbOffset: 3221 reporter.error('Test #%d failed: Initial write position does not match current position, ' 3222 'got %d, expected %d' % (i, long(curFile.offset), curTest.cbOffset)); 3225 3223 fRc = False; 3226 3224 if fRc: 3227 3225 aBufRead = curFile.read(curTest.cbToReadWrite, 30 * 1000); 3228 3226 if len(aBufRead) != curTest.cbToReadWrite: 3229 reporter.error('Test #%d failed: Got buffer length %d, expected %d' \3227 reporter.error('Test #%d failed: Got buffer length %d, expected %d' 3230 3228 % (i, len(aBufRead), curTest.cbToReadWrite)); 3231 3229 fRc = False; 3232 if fRc \3233 and curRes.aBuf is not None \3234 and buffer(curRes.aBuf)!= aBufRead:3235 reporter.error('Test #%d failed: Got buffer\n%s, expected\n%s' \3230 if fRc \ 3231 and curRes.aBuf is not None \ 3232 and curRes.aBuf != aBufRead: 3233 reporter.error('Test #%d failed: Got buffer\n%s, expected\n%s' 3236 3234 % (i, aBufRead, curRes.aBuf)); 3237 3235 fRc = False; … … 3240 3238 resOffset = long(curRes.cbOffset); 3241 3239 if curOffset != resOffset: 3242 reporter.error('Test #%d failed: Final offset does not match: Got %d, expected %d' \3240 reporter.error('Test #%d failed: Final offset does not match: Got %d, expected %d' 3243 3241 % (i, curOffset, resOffset)); 3244 3242 fRc = False; -
trunk/src/VBox/ValidationKit/tests/api/tdPython1.py
r69111 r70660 36 36 import time 37 37 import threading 38 import types39 38 40 39 # Only the main script needs to modify the path. … … 107 106 reporter.errorXcpt(); 108 107 break; 109 if not isinstance(rc, types.IntType):108 if not isinstance(rc, int): 110 109 reporter.error('waitForEvents returns non-integer type'); 111 110 break; … … 204 203 205 204 # Check the return code and elapsed time. 206 if not isinstance(rc, types.IntType):205 if not isinstance(rc, int): 207 206 reporter.error('waitForEvents returns non-integer type after %u ms, expected 1' % (msElapsed,)); 208 207 elif rc != 1: -
trunk/src/VBox/ValidationKit/tests/storage/remoteexecutor.py
r70521 r70660 34 34 import os; 35 35 import shutil; 36 import StringIO 36 import sys; 37 if sys.version_info[0] >= 3: 38 from io import StringIO as StringIO; # pylint: disable=import-error,no-name-in-module 39 else: 40 from StringIO import StringIO as StringIO; # pylint: disable=import-error,no-name-in-module 37 41 import subprocess; 38 42 … … 41 45 from testdriver import reporter; 42 46 47 48 43 49 class StdInOutBuffer(object): 44 50 """ Standard input output buffer """ 45 51 46 52 def __init__(self, sInput = None): 47 self.sInput = StringIO .StringIO();53 self.sInput = StringIO(); 48 54 if sInput is not None: 49 55 self.sInput.write(self._toString(sInput)); -
trunk/src/VBox/ValidationKit/tests/storage/storagecfg.py
r70522 r70660 315 315 fRc = True; 316 316 sBlkDev = None; 317 if s elf.dSimplePools.has_key(sPool):317 if sPool in self.dSimplePools: 318 318 sDiskPath = self.dSimplePools.get(sPool); 319 319 if sDiskPath.find('zram') != -1: … … 357 357 self.dMounts.pop(sPool + '/' + sVol); 358 358 oExec.rmDir(sMountPoint); 359 if s elf.dSimplePools.has_key(sPool):359 if sPool in self.dSimplePools: 360 360 # Wipe partition table 361 361 sDiskPath = self.dSimplePools.get(sPool); … … 372 372 """ 373 373 fRc = True; 374 if s elf.dSimplePools.has_key(sPool):374 if sPool in self.dSimplePools: 375 375 self.dSimplePools.pop(sPool); 376 376 else: … … 565 565 fRc = True; 566 566 sMountPoint = None; 567 if s elf.dPools.has_key(sPool):567 if sPool in self.dPools: 568 568 sVol = 'vol' + str(self.iVolId); 569 569 sMountPoint = self.oStorOs.getMntBase() + '/' + sVol; -
trunk/src/VBox/ValidationKit/tests/storage/tdStorageBenchmark1.py
r70522 r70660 35 35 import socket; 36 36 import sys; 37 import StringIO; 37 if sys.version_info[0] >= 3: 38 from io import StringIO as StringIO; # pylint: disable=import-error,no-name-in-module 39 else: 40 from StringIO import StringIO as StringIO; # pylint: disable=import-error,no-name-in-module 38 41 39 42 # Only the main script needs to modify the path. … … 97 100 return False; 98 101 99 cfgBuf = StringIO .StringIO();102 cfgBuf = StringIO(); 100 103 cfgBuf.write('[global]\n'); 101 104 cfgBuf.write('bs=' + self.dCfg.get('RecordSize', '4k') + '\n'); … … 1143 1146 1144 1147 sIoLogFile = '%s/%s.iolog' % (self.sIoLogPath, sDrv); 1145 print sCfgmPath;1146 print sIoLogFile;1148 print(sCfgmPath); 1149 print(sIoLogFile); 1147 1150 oSession.o.machine.setExtraData('%s/IoLog' % (sCfgmPath,), sIoLogFile); 1148 1151 except: -
trunk/src/VBox/ValidationKit/tests/usb/tst-utsgadget.py
r70522 r70660 31 31 # Standard python imports. 32 32 import sys 33 import types34 33 35 34 # Validation Kit imports. … … 54 53 global g_cTests, g_cFailures; 55 54 g_cTests = g_cTests + 1; 56 if isinstance(rc, types.BooleanType):55 if isinstance(rc, bool): 57 56 if rc == fExpect: 58 57 return 'PASSED'; … … 88 87 i = i + 2; 89 88 elif asArgs[i] == '--help': 90 print 'tst-utsgadget.py [--hostname <addr|name>] [--port <num>] [--timeout <cMS>]'89 print('tst-utsgadget.py [--hostname <addr|name>] [--port <num>] [--timeout <cMS>]'); 91 90 return 0; 92 91 else: 93 print 'Unknown argument: %s' % (asArgs[i]);92 print('Unknown argument: %s' % (asArgs[i],)); 94 93 return 2; 95 94 … … 100 99 rc = oGadget.connectTo(cMsTimeout, sAddress, uPort = uPort); 101 100 if rc is False: 102 print 'connectTo failed';101 print('connectTo failed'); 103 102 return 1; 104 103 105 104 if fStdTests: 106 105 rc = oGadget.getUsbIpPort() is not None; 107 print '%s: getUsbIpPort() -> %s' % (boolRes(rc), oGadget.getUsbIpPort());106 print('%s: getUsbIpPort() -> %s' % (boolRes(rc), oGadget.getUsbIpPort(),)); 108 107 109 108 rc = oGadget.impersonate(usbgadget.g_ksGadgetImpersonationTest); 110 print '%s: impersonate()' % (boolRes(rc));109 print('%s: impersonate()' % (boolRes(rc),)); 111 110 112 111 rc = oGadget.disconnectUsb(); 113 print '%s: disconnectUsb()' % (boolRes(rc));112 print('%s: disconnectUsb()' % (boolRes(rc),)); 114 113 115 114 rc = oGadget.connectUsb(); 116 print '%s: connectUsb()' % (boolRes(rc));115 print('%s: connectUsb()' % (boolRes(rc),)); 117 116 118 117 rc = oGadget.clearImpersonation(); 119 print '%s: clearImpersonation()' % (boolRes(rc));118 print('%s: clearImpersonation()' % (boolRes(rc),)); 120 119 121 120 # Test super speed (and therefore passing configuration items) 122 121 rc = oGadget.impersonate(usbgadget.g_ksGadgetImpersonationTest, True); 123 print '%s: impersonate(, True)' % (boolRes(rc));122 print('%s: impersonate(, True)' % (boolRes(rc),)); 124 123 125 124 rc = oGadget.clearImpersonation(); 126 print '%s: clearImpersonation()' % (boolRes(rc));125 print('%s: clearImpersonation()' % (boolRes(rc),)); 127 126 128 127 # Done 129 128 rc = oGadget.disconnectFrom(); 130 print '%s: disconnectFrom() -> %s' % (boolRes(rc), rc);129 print('%s: disconnectFrom() -> %s' % (boolRes(rc), rc,)); 131 130 132 131 if g_cFailures != 0: 133 print 'tst-utsgadget.py: %u out of %u test failed' % (g_cFailures, g_cTests);132 print('tst-utsgadget.py: %u out of %u test failed' % (g_cFailures, g_cTests,)); 134 133 return 1; 135 print 'tst-utsgadget.py: all %u tests passed!' % (g_cTests);134 print('tst-utsgadget.py: all %u tests passed!' % (g_cTests,)); 136 135 return 0; 137 136 -
trunk/src/VBox/ValidationKit/tests/usb/usbgadget.py
r70521 r70660 34 34 import select 35 35 import socket 36 import sys; 36 37 import threading 37 38 import time 38 import types39 39 import zlib 40 40 … … 44 44 from testdriver import reporter; 45 45 from testdriver.base import TdTaskBase; 46 47 # Python 3 hacks: 48 if sys.version_info[0] >= 3: 49 long = int; # pylint: disable=redefined-builtin,invalid-name 50 46 51 47 52 ## @name USB gadget impersonation string constants. … … 196 201 abArray = array.array('B'); 197 202 sUtf8 = sStr.encode('utf_8'); 198 for i in range(0, len(sUtf8)):199 abArray.append(ord( sUtf8[i]))203 for ch in sUtf8: 204 abArray.append(ord(ch)); 200 205 abArray.append(0); 201 206 return abArray; … … 447 452 # the primitive approach... 448 453 sUtf8 = o.encode('utf_8'); 449 for i in range(0, len(sUtf8)):450 abPayload.append(ord( sUtf8[i]))454 for ch in sUtf8: 455 abPayload.append(ord(ch)) 451 456 abPayload.append(0); 452 elif isinstance(o, types.LongType):457 elif isinstance(o, long): 453 458 if o < 0 or o > 0xffffffff: 454 459 reporter.fatal('sendMsg: uint32_t payload is out of range: %s' % (hex(o))); 455 460 return None; 456 461 abPayload.extend(u32ToByteArray(o)); 457 elif isinstance(o, types.IntType):462 elif isinstance(o, int): 458 463 if o < 0 or o > 0xffffffff: 459 464 reporter.fatal('sendMsg: uint32_t payload is out of range: %s' % (hex(o))); … … 1063 1068 oSocket.connect((self.sHostname, self.uPort)); 1064 1069 rc = True; 1065 except socket.error as e:1066 iRc = e[0];1067 if self.__isInProgressXcpt( e):1070 except socket.error as oXcpt: 1071 iRc = oXcpt.errno; 1072 if self.__isInProgressXcpt(oXcpt): 1068 1073 # Do the actual waiting. 1069 reporter.log2('TransportTcp::connect: operation in progress (%s)...' % ( e,));1074 reporter.log2('TransportTcp::connect: operation in progress (%s)...' % (oXcpt,)); 1070 1075 try: 1071 1076 ttRc = select.select([oWakeupR], [oSocket], [oSocket, oWakeupR], cMsTimeout / 1000.0); … … 1074 1079 iRc = oSocket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR); 1075 1080 rc = iRc == 0; 1076 except socket.error as e:1077 iRc = e[0];1081 except socket.error as oXcpt2: 1082 iRc = oXcpt2.errno; 1078 1083 except: 1079 1084 iRc = -42;
Note:
See TracChangeset
for help on using the changeset viewer.