Changeset 56688 in vbox for trunk/src/VBox
- Timestamp:
- Jun 29, 2015 8:07:38 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py
r56687 r56688 91 91 Provides credentials to pass to the guest. 92 92 """ 93 def __init__(self, sUser, sPassword, sDomain): 94 self.sUser = sUser; 95 self.sPassword = sPassword; 96 self.sDomain = sDomain; 93 def __init__(self, sUser = None, sPassword = None, sDomain = None, oTestVm = None): 94 # If no user is specified, select the default user and 95 # password for the given test VM. 96 if sUser is None: 97 assert sPassword is None; 98 assert sDomain is None; 99 assert oTestVm is not None; 100 101 ## @todo fix this so all VMs have several usable test users with the same passwords (or none). 102 sUser = 'test'; 103 sPassword = 'password'; 104 if oTestVm.isWindows(): 105 #sPassword = ''; # stupid config mistake. 106 sPassword = 'password'; 107 sUser = 'Administrator'; 108 sDomain = ''; 109 110 self.sUser = sUser; 111 self.sPassword = sPassword if sPassword is not None else ''; 112 self.sDomain = sDomain if sDomain is not None else ''; 97 113 98 114 class tdTestGuestCtrlBase(object): … … 137 153 138 154 try: 139 reporter.log('Waiting for session "%s" to start within % ldms...' % (sName, self.timeoutMS));155 reporter.log('Waiting for session "%s" to start within %dms...' % (sName, self.timeoutMS)); 140 156 fWaitFor = [ vboxcon.GuestSessionWaitForFlag_Start ]; 141 157 waitResult = self.oGuestSession.waitForArray(fWaitFor, self.timeoutMS); … … 147 163 and waitResult != vboxcon.GuestSessionWaitResult_WaitFlagNotSupported: 148 164 # Just log, don't assume an error here (will be done in the main loop then). 149 reporter.log('Session did not start successfully, returned wait result: % ld' \150 % (waitResult ));165 reporter.log('Session did not start successfully, returned wait result: %d' \ 166 % (waitResult,)); 151 167 return (False, None); 152 168 reporter.log('Session "%s" successfully started' % (sName,)); 153 169 except: 154 170 # Just log, don't assume an error here (will be done in the main loop then). 155 reporter.logXcpt('Waiting for guest session "%s" to start failed:' % (sName)); 171 reporter.logXcpt('Waiting for guest session "%s" (usr=%s;pw=%s;dom=%s) to start failed:' 172 % (sName, self.oCreds.sUser, self.oCreds.sPassword, self.oCreds.sDomain,)); 156 173 return (False, None); 157 174 else: … … 382 399 return len(aoSession); 383 400 384 class tdTestSessionE nv(tdTestGuestCtrlBase):385 """ 386 Test the guest session environment.387 """ 388 def __init__(self, sUser = "", sPassword = "", aEnv= None):401 class tdTestSessionEx(tdTestGuestCtrlBase): 402 """ 403 Test the guest session. 404 """ 405 def __init__(self, aoSteps = None, enmUser = None): 389 406 tdTestGuestCtrlBase.__init__(self); 390 self.oCreds = tdCtxCreds(sUser, sPassword, sDomain = ""); 391 self.aEnv = aEnv or []; 407 assert enmUser == None; # For later. 408 self.enmUser = enmUser; 409 self.aoSteps = aoSteps if aoSteps is not None else []; 410 411 def execute(self, oTstDrv, oVmSession, oTxsSession, oTestVm, sMsgPrefix): 412 """ 413 Executes the test. 414 """ 415 # 416 # Create a session. 417 # 418 assert self.enmUser == None; # For later. 419 self.oCreds = tdCtxCreds(oTestVm = oTestVm); 420 self.setEnvironment(oVmSession, oTxsSession, oTestVm); 421 reporter.log2('%s: %s steps' % (sMsgPrefix, len(self.aoSteps),)); 422 fRc, oCurSession = self.createSession(sMsgPrefix); 423 if fRc is True: 424 # 425 # Execute the tests. 426 # 427 try: 428 fRc = self.executeSteps(oTstDrv, oCurSession, sMsgPrefix); 429 except: 430 reporter.errorXcpt('%s: Unexpected exception executing test steps' % (sMsgPrefix,)); 431 fRc = False; 432 433 fRc2 = self.closeSession(); 434 if fRc2 is False: 435 reporter.error('%s: Session could not be closed' % (sMsgPrefix,)); 436 fRc = False; 437 else: 438 reporter.error('%s: Session creation failed' % (sMsgPrefix,)); 439 fRc = False; 440 return fRc; 441 442 def executeSteps(self, oTstDrv, oGstCtrlSession, sMsgPrefix): 443 """ 444 Executes just the steps. 445 Returns True on success, False on test failure. 446 """ 447 fRc = True; 448 for (i, oStep) in enumerate(self.aoSteps): 449 fRc2 = oStep.execute(oTstDrv, oGstCtrlSession, sMsgPrefix + ', step #%d' % i); 450 if fRc2 is False: 451 fRc = False; 452 return fRc; 453 454 455 # 456 # Scheduling Environment Changes with the Guest Control Session. 457 # 458 459 class tdStepSessionSetEnv(object): 460 """ 461 Guest session environment: schedule putenv 462 """ 463 def __init__(self, sVar, sValue, hrcExpected = 0): 464 self.sVar = sVar; 465 self.sValue = sValue; 466 self.hrcExpected = hrcExpected; 467 468 def execute(self, oTstDrv, oGstCtrlSession, sMsgPrefix): 469 """ 470 Executes the step. 471 Returns True on success, False on test failure. 472 """ 473 reporter.log2('tdStepSessionSetEnv: sVar=%s sValue=%s hrcExpected=%#x' % (self.sVar, self.sValue, self.hrcExpected,)); 474 try: 475 if oTstDrv.fpApiVer >= 5.0: 476 oGstCtrlSession.environmentScheduleSet(self.sVar, self.sValue); 477 else: 478 oGstCtrlSession.environmentSet(self.sVar, self.sValue); 479 except vbox.ComException, oXcpt: 480 # Is this an expected failure? 481 if vbox.ComError.equal(oXcpt, self.hrcExpected): 482 return True; 483 reporter.errorXcpt('%s: Expected hrc=%#x (%s) got %#x (%s) instead (setenv %s=%s)' 484 % (sMsgPrefix, self.hrcExpected, vbox.ComError.toString(self.hrcExpected), 485 vbox.ComError.getXcptResult(oXcpt), 486 vbox.ComError.toString(vbox.ComError.getXcptResult(oXcpt)), 487 self.sVar, self.sValue,)); 488 return False; 489 except: 490 reporter.errorXcpt('%s: Unexpected exception in tdStepSessionSetEnv::execute (%s=%s)' 491 % (sMsgPrefix, self.sVar, self.sValue,)); 492 return False; 493 494 # Should we succeed? 495 if self.hrcExpected != 0: 496 reporter.error('%s: Expected hrcExpected=%#x, got S_OK (putenv %s=%s)' 497 % (sMsgPrefix, self.hrcExpected, self.sVar, self.sValue,)); 498 return False; 499 return True; 500 501 class tdStepSessionUnsetEnv(object): 502 """ 503 Guest session environment: schedule unset. 504 """ 505 def __init__(self, sVar, hrcExpected = 0): 506 self.sVar = sVar; 507 self.hrcExpected = hrcExpected; 508 509 def execute(self, oTstDrv, oGstCtrlSession, sMsgPrefix): 510 """ 511 Executes the step. 512 Returns True on success, False on test failure. 513 """ 514 reporter.log2('tdStepSessionUnsetEnv: sVar=%s hrcExpected=%#x' % (self.sVar, self.hrcExpected,)); 515 try: 516 if oTstDrv.fpApiVer >= 5.0: 517 oGstCtrlSession.environmentScheduleUnset(self.sVar); 518 else: 519 oGstCtrlSession.environmentUnset(self.sVar); 520 except vbox.ComException, oXcpt: 521 # Is this an expected failure? 522 if vbox.ComError.equal(oXcpt, self.hrcExpected): 523 return True; 524 reporter.errorXcpt('%s: Expected hrc=%#x (%s) got %#x (%s) instead (unsetenv %s)' 525 % (sMsgPrefix, self.hrcExpected, vbox.ComError.toString(self.hrcExpected), 526 vbox.ComError.getXcptResult(oXcpt), 527 vbox.ComError.toString(vbox.ComError.getXcptResult(oXcpt)), 528 self.sVar,)); 529 return False; 530 except: 531 reporter.errorXcpt('%s: Unexpected exception in tdStepSessionUnsetEnv::execute (%s)' 532 % (sMsgPrefix, self.sVar,)); 533 return False; 534 535 # Should we succeed? 536 if self.hrcExpected != 0: 537 reporter.error('%s: Expected hrcExpected=%#x, got S_OK (unsetenv %s)' 538 % (sMsgPrefix, self.hrcExpected, self.sVar,)); 539 return False; 540 return True; 541 542 class tdStepSessionBulkEnv(object): 543 """ 544 Guest session environment: Bulk environment changes. 545 """ 546 def __init__(self, asEnv = None, hrcExpected = 0): 547 self.asEnv = asEnv if asEnv is not None else []; 548 self.hrcExpected = hrcExpected; 549 550 def execute(self, oTstDrv, oGstCtrlSession, sMsgPrefix): 551 """ 552 Executes the step. 553 Returns True on success, False on test failure. 554 """ 555 reporter.log2('tdStepSessionBulkEnv: asEnv=%s hrcExpected=%#x' % (self.asEnv, self.hrcExpected,)); 556 try: 557 if oTstDrv.fpApiVer >= 5.0: 558 oTstDrv.oVBoxMgr.setArray(oGstCtrlSession, 'environmentChanges', self.asEnv); 559 else: 560 oTstDrv.oVBoxMgr.setArray(oGstCtrlSession, 'environment', self.asEnv); 561 except vbox.ComException, oXcpt: 562 # Is this an expected failure? 563 if vbox.ComError.equal(oXcpt, self.hrcExpected): 564 return True; 565 reporter.errorXcpt('%s: Expected hrc=%#x (%s) got %#x (%s) instead (asEnv=%s)' 566 % (sMsgPrefix, self.hrcExpected, vbox.ComError.toString(self.hrcExpected), 567 vbox.ComError.getXcptResult(oXcpt), 568 vbox.ComError.toString(vbox.ComError.getXcptResult(oXcpt)), 569 self.asEnv,)); 570 return False; 571 except: 572 reporter.errorXcpt('%s: Unexpected exception writing the environmentChanges property (asEnv=%s).' 573 % (sMsgPrefix, self.asEnv)); 574 return False; 575 return True; 576 577 class tdStepSessionClearEnv(tdStepSessionBulkEnv): 578 """ 579 Guest session environment: clears the scheduled environment changes. 580 """ 581 def __init__(self): 582 tdStepSessionBulkEnv.__init__(self); 583 584 585 class tdStepSessionCheckEnv(object): 586 """ 587 Check the currently scheduled environment changes of a guest control session. 588 """ 589 def __init__(self, asEnv = None): 590 self.asEnv = asEnv if asEnv is not None else []; 591 592 def execute(self, oTstDrv, oGstCtrlSession, sMsgPrefix): 593 """ 594 Executes the step. 595 Returns True on success, False on test failure. 596 """ 597 reporter.log2('tdStepSessionCheckEnv: asEnv=%s' % (self.asEnv,)); 598 599 # 600 # Get the environment change list. 601 # 602 try: 603 if oTstDrv.fpApiVer >= 5.0: 604 asCurEnv = oTstDrv.oVBoxMgr.getArray(oGstCtrlSession, 'environmentChanges'); 605 else: 606 asCurEnv = oTstDrv.oVBoxMgr.getArray(oGstCtrlSession, 'environment'); 607 except: 608 reporter.errorXcpt('%s: Unexpected exception reading the environmentChanges property.' % (sMsgPrefix,)); 609 return False; 610 611 # 612 # Compare it with the expected one by trying to remove each expected value 613 # and the list anything unexpected. 614 # 615 fRc = True; 616 asCopy = list(asCurEnv); # just in case asCurEnv is immutable 617 for sExpected in self.asEnv: 618 try: 619 asCopy.remove(sExpected); 620 except: 621 reporter.error('%s: Expected "%s" to be in the resulting environment' % (sMsgPrefix, sExpected,)); 622 fRc = False; 623 for sUnexpected in asCopy: 624 reporter.error('%d: Unexpected "%s" in the resulting environment' % (sMsgPrefix, sUnexpected,)); 625 fRc = False; 626 627 if fRc is not True: 628 reporter.log2('%s: Current environment: %s' % (sMsgPrefix, asCurEnv)); 629 return fRc; 630 631 # 632 # 633 # 392 634 393 635 class tdTestSessionFileRefs(tdTestGuestCtrlBase): … … 496 738 tdTestResult.__init__(self, fRc = fRc); 497 739 self.cNumSessions = cNumSessions; 498 499 class tdTestResultSessionEnv(tdTestResult):500 """501 Test result for guest session environment tests.502 """503 def __init__(self, fRc = False, cNumVars = 0):504 tdTestResult.__init__(self, fRc = fRc);505 self.cNumVars = cNumVars;506 507 740 508 741 class SubTstDrvAddGuestCtrl(base.SubTestDriverBase): … … 982 1215 if oTest.uExitStatus != oRes.uExitStatus \ 983 1216 or oTest.iExitCode != oRes.iExitCode: 984 reporter.error('Test #%d failed: Got exit status + code %d,%d, expected %d,%d' % \ 985 (i, oTest.uExitStatus, oTest.iExitCode, \ 986 oRes.uExitStatus, oRes.iExitCode)); 1217 reporter.error('Test #%d failed: Got exit status + code %d,%d, expected %d,%d' 1218 % (i, oTest.uExitStatus, oTest.iExitCode, oRes.uExitStatus, oRes.iExitCode)); 987 1219 return False; 988 1220 if fRc is True: … … 991 1223 and oRes.sBuf is not None: 992 1224 if bytes(oTest.sBuf) != bytes(oRes.sBuf): 993 reporter.error('Test #%d failed: Got buffer\n%s (% ld bytes), expected\n%s (%ld bytes)' %994 (i, map(hex, map(ord, oTest.sBuf)), len(oTest.sBuf), \995 1225 reporter.error('Test #%d failed: Got buffer\n%s (%d bytes), expected\n%s (%d bytes)' 1226 % (i, map(hex, map(ord, oTest.sBuf)), len(oTest.sBuf), \ 1227 map(hex, map(ord, oRes.sBuf)), len(oRes.sBuf))); 996 1228 return False; 997 1229 else: 998 reporter.log2('Test #%d passed: Buffers match (% ld bytes)' % (i, len(oRes.sBuf)));1230 reporter.log2('Test #%d passed: Buffers match (%d bytes)' % (i, len(oRes.sBuf))); 999 1231 elif oRes.sBuf is not None \ 1000 1232 and len(oRes.sBuf): … … 1004 1236 elif oRes.cbStdOut > 0 \ 1005 1237 and oRes.cbStdOut != oTest.cbStdOut: 1006 reporter.error('Test #%d failed: Got % ld stdout data, expected %ld'1238 reporter.error('Test #%d failed: Got %d stdout data, expected %d' 1007 1239 % (i, oTest.cbStdOut, oRes.cbStdOut)); 1008 1240 return False; … … 1022 1254 #tsStart = base.timestampMilli(); 1023 1255 1024 reporter.log2('Using session user=%s, sDomain=%s, session name=%s, session timeout=% ld' \1256 reporter.log2('Using session user=%s, sDomain=%s, session name=%s, session timeout=%d' \ 1025 1257 % (oGuestSession.user, oGuestSession.domain, \ 1026 1258 oGuestSession.name, oGuestSession.timeout)); 1027 reporter.log2('Executing cmd=%s, aFlags=%s, timeout=% ld, args=%s, env=%s' \1259 reporter.log2('Executing cmd=%s, aFlags=%s, timeout=%d, args=%s, env=%s' \ 1028 1260 % (oTest.sCmd, oTest.aFlags, oTest.timeoutMS, \ 1029 1261 oTest.aArgs, oTest.aEnv)); … … 1033 1265 oTest.aEnv, oTest.aFlags, oTest.timeoutMS); 1034 1266 if curProc is not None: 1035 reporter.log2('Process start requested, waiting for start (% ldms) ...' % (oTest.timeoutMS,));1267 reporter.log2('Process start requested, waiting for start (%dms) ...' % (oTest.timeoutMS,)); 1036 1268 fWaitFor = [ vboxcon.ProcessWaitForFlag_Start ]; 1037 1269 waitResult = curProc.waitForArray(fWaitFor, oTest.timeoutMS); 1038 reporter.log2('Wait result returned: %d, current process status is: % ld' % (waitResult, curProc.status));1270 reporter.log2('Wait result returned: %d, current process status is: %d' % (waitResult, curProc.status)); 1039 1271 1040 1272 if curProc.status == vboxcon.ProcessStatus_Started: … … 1045 1277 fWaitFor.append(vboxcon.ProcessWaitForFlag_StdErr); 1046 1278 ## @todo Add vboxcon.ProcessWaitForFlag_StdIn. 1047 reporter.log2('Process (PID % ld) started, waiting for termination (%dms), waitFlags=%s ...' \1279 reporter.log2('Process (PID %d) started, waiting for termination (%dms), waitFlags=%s ...' \ 1048 1280 % (curProc.PID, oTest.timeoutMS, fWaitFor)); 1049 1281 while True: … … 1057 1289 buf = curProc.Read(1, 64 * 1024, oTest.timeoutMS); 1058 1290 if len(buf): 1059 reporter.log2('Process (PID % ld) got %ld bytes of stdout data' % (curProc.PID, len(buf)));1291 reporter.log2('Process (PID %d) got %d bytes of stdout data' % (curProc.PID, len(buf))); 1060 1292 oTest.cbStdOut += len(buf); 1061 1293 oTest.sBuf = buf; # Appending does *not* work atm, so just assign it. No time now. … … 1066 1298 buf = curProc.Read(2, 64 * 1024, oTest.timeoutMS); 1067 1299 if len(buf): 1068 reporter.log2('Process (PID % ld) got %ld bytes of stderr data' % (curProc.PID, len(buf)));1300 reporter.log2('Process (PID %d) got %d bytes of stderr data' % (curProc.PID, len(buf))); 1069 1301 oTest.cbStdErr += len(buf); 1070 1302 oTest.sBuf = buf; # Appending does *not* work atm, so just assign it. No time now. … … 1072 1304 if waitResult == vboxcon.ProcessWaitResult_StdIn \ 1073 1305 or waitResult == vboxcon.ProcessWaitResult_WaitFlagNotSupported: 1074 pass; #reporter.log2('Process (PID % ld) needs stdin data' % (curProc.pid,));1306 pass; #reporter.log2('Process (PID %d) needs stdin data' % (curProc.pid,)); 1075 1307 # Termination or error? 1076 1308 if waitResult == vboxcon.ProcessWaitResult_Terminate \ 1077 1309 or waitResult == vboxcon.ProcessWaitResult_Error \ 1078 1310 or waitResult == vboxcon.ProcessWaitResult_Timeout: 1079 reporter.log2('Process (PID % ld) reported terminate/error/timeout: %ld, status: %ld' \1311 reporter.log2('Process (PID %d) reported terminate/error/timeout: %d, status: %d' \ 1080 1312 % (curProc.PID, waitResult, curProc.status)); 1081 1313 break; … … 1083 1315 # Just skip reads which returned nothing. 1084 1316 pass; 1085 reporter.log2('Final process status (PID % ld) is: %ld' % (curProc.PID, curProc.status));1086 reporter.log2('Process (PID % ld) %ld stdout, %ld stderr' % (curProc.PID, oTest.cbStdOut, oTest.cbStdErr));1317 reporter.log2('Final process status (PID %d) is: %d' % (curProc.PID, curProc.status)); 1318 reporter.log2('Process (PID %d) %d stdout, %d stderr' % (curProc.PID, oTest.cbStdOut, oTest.cbStdErr)); 1087 1319 oTest.uExitStatus = curProc.status; 1088 1320 oTest.iExitCode = curProc.exitCode; 1089 reporter.log2('Process (PID % ld) has exit code: %ld' % (curProc.PID, oTest.iExitCode));1321 reporter.log2('Process (PID %d) has exit code: %d' % (curProc.PID, oTest.iExitCode)); 1090 1322 except KeyboardInterrupt: 1091 reporter.error('Process (PID % ld) execution interrupted' % (curProc.PID,));1323 reporter.error('Process (PID %d) execution interrupted' % (curProc.PID,)); 1092 1324 if curProc is not None: 1093 1325 curProc.close(); … … 1104 1336 """ 1105 1337 1106 if oTestVm.isWindows():1107 sUser = "Administrator";1108 else:1109 sUser = "vbox";1110 sPassword = "password";1111 1112 1338 aaTests = [ 1113 # No environment set. 1114 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword), 1115 tdTestResultSessionEnv(fRc = False) ], 1116 # Invalid stuff. 1117 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword, aEnv = [ '=FOO' ]), 1118 tdTestResultSessionEnv(fRc = False) ], 1119 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword, aEnv = [ '====' ]), 1120 tdTestResultSessionEnv(fRc = False) ], 1121 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword, aEnv = [ '=BAR' ]), 1122 tdTestResultSessionEnv(fRc = False) ], 1123 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword, aEnv = [ u'ß$%ß&' ]), 1124 tdTestResultSessionEnv(fRc = False) ], 1125 # Key only. 1126 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword, aEnv = [ 'FOO=' ]), 1127 tdTestResultSessionEnv(fRc = True, cNumVars = 1) ], 1128 # Values. 1129 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword, aEnv = [ 'FOO' ]), 1130 tdTestResultSessionEnv(fRc = True, cNumVars = 1) ], 1131 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword, aEnv = [ 'FOO=BAR' ]), 1132 tdTestResultSessionEnv(fRc = True, cNumVars = 1) ], 1133 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword, aEnv = [ 'FOO=BAR', 'BAR=BAZ' ]), 1134 tdTestResultSessionEnv(fRc = True, cNumVars = 2) ], 1339 # Check basic operations. 1340 tdTestSessionEx([ # Initial environment is empty. 1341 tdStepSessionCheckEnv(), 1342 # Check clearing empty env. 1343 tdStepSessionClearEnv(), 1344 tdStepSessionCheckEnv(), 1345 # Check set. 1346 tdStepSessionSetEnv('FOO', 'BAR'), 1347 tdStepSessionCheckEnv(['FOO=BAR',]), 1348 tdStepSessionClearEnv(), 1349 tdStepSessionCheckEnv(), 1350 # Check unset. 1351 tdStepSessionUnsetEnv('BAR'), 1352 tdStepSessionCheckEnv(['BAR']), 1353 tdStepSessionClearEnv(), 1354 tdStepSessionCheckEnv(), 1355 # Set + unset. 1356 tdStepSessionSetEnv('FOO', 'BAR'), 1357 tdStepSessionCheckEnv(['FOO=BAR',]), 1358 tdStepSessionUnsetEnv('FOO'), 1359 tdStepSessionCheckEnv(['FOO']), 1360 # Bulk environment changes (via attrib) (shall replace existing 'FOO'). 1361 tdStepSessionBulkEnv( ['PATH=/bin:/usr/bin', 'TMPDIR=/var/tmp', 'USER=root']), 1362 tdStepSessionCheckEnv(['PATH=/bin:/usr/bin', 'TMPDIR=/var/tmp', 'USER=root']), 1363 ]), 1364 tdTestSessionEx([ # Check that setting the same value several times works. 1365 tdStepSessionSetEnv('FOO','BAR'), 1366 tdStepSessionCheckEnv([ 'FOO=BAR',]), 1367 tdStepSessionSetEnv('FOO','BAR2'), 1368 tdStepSessionCheckEnv([ 'FOO=BAR2',]), 1369 tdStepSessionSetEnv('FOO','BAR3'), 1370 tdStepSessionCheckEnv([ 'FOO=BAR3',]), 1371 # Add a little unsetting to the mix. 1372 tdStepSessionSetEnv('BAR', 'BEAR'), 1373 tdStepSessionCheckEnv([ 'FOO=BAR3', 'BAR=BEAR',]), 1374 tdStepSessionUnsetEnv('FOO'), 1375 tdStepSessionCheckEnv([ 'FOO', 'BAR=BEAR',]), 1376 tdStepSessionSetEnv('FOO','BAR4'), 1377 tdStepSessionCheckEnv([ 'FOO=BAR4', 'BAR=BEAR',]), 1378 # The environment is case sensitive. 1379 tdStepSessionSetEnv('foo','BAR5'), 1380 tdStepSessionCheckEnv([ 'FOO=BAR4', 'BAR=BEAR', 'foo=BAR5']), 1381 tdStepSessionUnsetEnv('foo'), 1382 tdStepSessionCheckEnv([ 'FOO=BAR4', 'BAR=BEAR', 'foo']), 1383 ]), 1384 tdTestSessionEx([ # Bulk settings merges stuff, last entry standing. 1385 tdStepSessionBulkEnv(['FOO=bar', 'foo=bar', 'FOO=doofus', 'TMPDIR=/tmp', 'foo=bar2']), 1386 tdStepSessionCheckEnv(['FOO=doofus', 'TMPDIR=/tmp', 'foo=bar2']), 1387 ]), 1388 # Invalid variable names. 1389 tdTestSessionEx([ tdStepSessionSetEnv('', 'FOO', vbox.ComError.E_INVALIDARG), 1390 tdStepSessionCheckEnv(), 1391 tdStepSessionSetEnv('=', '===', vbox.ComError.E_INVALIDARG), 1392 tdStepSessionCheckEnv(), 1393 tdStepSessionSetEnv('FOO=', 'BAR', vbox.ComError.E_INVALIDARG), 1394 tdStepSessionCheckEnv(), 1395 tdStepSessionSetEnv('=FOO', 'BAR', vbox.ComError.E_INVALIDARG), 1396 tdStepSessionCheckEnv(), 1397 tdStepSessionBulkEnv(['=', 'foo=bar'], vbox.ComError.E_INVALIDARG), 1398 tdStepSessionCheckEnv(), 1399 tdStepSessionBulkEnv(['=FOO', 'foo=bar'], vbox.ComError.E_INVALIDARG), 1400 tdStepSessionCheckEnv(), 1401 ]), 1135 1402 # A bit more weird keys/values. 1136 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword, aEnv = [ '$$$=' ]), 1137 tdTestResultSessionEnv(fRc = True, cNumVars = 1) ], 1138 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword, aEnv = [ '$$$=%%%' ]), 1139 tdTestResultSessionEnv(fRc = True, cNumVars = 1) ], 1140 # Same stuff. 1141 [ tdTestSessionEnv(sUser = sUser, sPassword = sPassword, aEnv = [ 'FOO=BAR', 'FOO=BAR' ]), 1142 tdTestResultSessionEnv(fRc = True, cNumVars = 1) ] 1403 tdTestSessionEx([ tdStepSessionSetEnv('$$$', ''), 1404 tdStepSessionCheckEnv([ '$$$=',]), ]), 1405 tdTestSessionEx([ tdStepSessionSetEnv('$$$', '%%%'), 1406 tdStepSessionCheckEnv([ '$$$=%%%',]), 1407 ]), 1408 tdTestSessionEx([ tdStepSessionSetEnv(u'ß$%ß&', ''), 1409 tdStepSessionCheckEnv([ u'ß$%ß&=',]), 1410 ]), 1411 # Misc stuff. 1412 tdTestSessionEx([ tdStepSessionSetEnv('FOO', ''), 1413 tdStepSessionCheckEnv(['FOO=',]), 1414 ]), 1415 tdTestSessionEx([ tdStepSessionSetEnv('FOO', 'BAR'), 1416 tdStepSessionCheckEnv(['FOO=BAR',]) 1417 ],), 1418 tdTestSessionEx([ tdStepSessionSetEnv('FOO', 'BAR'), 1419 tdStepSessionSetEnv('BAR', 'BAZ'), 1420 tdStepSessionCheckEnv([ 'FOO=BAR', 'BAR=BAZ',]), 1421 ]), 1143 1422 ]; 1144 1423 1145 # The IGuestSession::environment attribute changed late in 5.0 development. 1146 sEnvironmentChangesAttr = 'environmentChanges' if self.oTstDrv.fpApiVer >= 5.0 else 'environment'; 1147 1148 # Parameters. 1424 # 1425 # Work through the tests. 1426 # 1149 1427 fRc = True; 1150 for (i, aTest) in enumerate(aaTests): 1151 curTest = aTest[0]; # tdTestExec, use an index, later. 1152 curRes = aTest[1]; # tdTestResult 1153 curTest.setEnvironment(oSession, oTxsSession, oTestVm); 1154 reporter.log('Testing #%d, user="%s", sPassword="%s", env="%s" (%d)...' \ 1155 % (i, curTest.oCreds.sUser, curTest.oCreds.sPassword, curTest.aEnv, len(curTest.aEnv))); 1156 curGuestSessionName = 'testGuestCtrlSessionEnvironment: Test #%d' % (i,); 1157 fRc2, curGuestSession = curTest.createSession(curGuestSessionName); 1158 if fRc2 is not True: 1159 reporter.error('Test #%d failed: Session creation failed: Got %s, expected True' % (i, fRc2)); 1428 for (i, oCurTest) in enumerate(aaTests): 1429 try: 1430 fRc2 = oCurTest.execute(self.oTstDrv, oSession, oTxsSession, oTestVm, 'test %#d' % (i,)); 1431 if fRc2 is not True: 1432 fRc = False; 1433 except: 1434 reporter.errorXcpt('Unexpected exception executing test #%d' % (i,)); 1160 1435 fRc = False; 1161 break;1162 # Make sure environment is empty.1163 curEnv = self.oTstDrv.oVBoxMgr.getArray(curGuestSession, sEnvironmentChangesAttr);1164 reporter.log2('Test #%d: Environment initially has %d elements' % (i, len(curEnv)));1165 if len(curEnv) != 0:1166 reporter.error('Test #%d failed: Initial session environment has %d vars, expected 0' % (i, len(curEnv)));1167 fRc = False;1168 break;1169 try:1170 for (_, aEnv) in enumerate(curTest.aEnv):1171 aElems = aEnv.split('=');1172 strKey = ''; ## @todo s/Key/Var/g1173 strValue = '';1174 if len(aElems) > 0:1175 strKey = aElems[0];1176 if len(aElems) == 2:1177 strValue = aElems[1];1178 reporter.log2('Test #%d: Single var="%s", value="%s" (%d) ...' \1179 % (i, strKey, strValue, len(aElems)));1180 try:1181 if self.oTstDrv.fpApiVer >= 5.0:1182 curGuestSession.environmentScheduleSet(strKey, strValue);1183 else:1184 curGuestSession.environmentSet(strKey, strValue);1185 except:1186 # Setting environment variables might fail (e.g. if empty name specified). Check.1187 reporter.logXcpt('Test #%d failed: Setting environment variable failed:' % (i,));1188 curEnv = self.oTstDrv.oVBoxMgr.getArray(curGuestSession, sEnvironmentChangesAttr);1189 if len(curEnv) is not curRes.cNumVars:1190 reporter.error('Test #%d failed: Session environment has %d vars, expected %d' \1191 % (i, len(curEnv), curRes.cNumVars));1192 fRc = False;1193 break;1194 else:1195 reporter.log('Test #%d: API reported an error (single), good' % (i,));1196 ## @todo environmentGet() has been removed in 5.0 because it's not up to the task of returning all the1197 ## putenv strings forms and gives the impression that the environment is something it isn't. This test1198 ## should be rewritten using the attribute. What's more, there should be an Unset test here, shouldn't1199 ## there?1200 #1201 #reporter.log2('Getting key="%s" ...' % (strKey,));1202 #try:1203 # strValue2 = curGuestSession.environmentGet(strKey);1204 # if strKey.isalnum() \1205 # and strValue != strValue2:1206 # reporter.error('Test #%d failed: Got environment value "%s", expected "%s" (var: "%s")' \1207 # % (i, strValue2, strValue, strKey));1208 # fRc = False;1209 # break;1210 # # Getting back an empty value when specifying an invalid key is fine.1211 # reporter.log2('Got key "%s=%s"' % (strKey, strValue2));1212 #except UnicodeDecodeError: # Might happen on unusal values, fine.1213 # if strValue != strValue2:1214 # reporter.error('Test #%d failed: Got (undecoded) environment variable "%s", ' \1215 # 'expected "%s" (var: "%s")' \1216 # % (i, strValue2, strValue, strKey));1217 # fRc = False;1218 # break;1219 #except:1220 # if strKey == "" \1221 # or not strKey.isalnum():1222 # reporter.log('Test #%d: API reported an error (invalid key "%s"), good' % (i, strKey));1223 # else:1224 # reporter.errorXcpt('Test #%d failed: Getting environment variable:' % (i));1225 if fRc is False:1226 continue;1227 # Set the same stuff again, this time all at once using the array.1228 if len(curTest.aEnv):1229 reporter.log('Test #%d: Array %s (%d)' % (i, curTest.aEnv, len(curTest.aEnv)));1230 try:1231 ## @todo No return (e.g. boolean) value available thru wrapper.1232 #curGuestSession.environmentSetArray(curTest.aEnv);1233 pass;1234 except:1235 # Setting environment variables might fail (e.g. if empty name specified). Check.1236 curEnv = self.oTstDrv.oVBoxMgr.getArray(curGuestSession, sEnvironmentChangesAttr);1237 if len(curEnv) is not curRes.cNumVars:1238 reporter.error('Test #%d failed: Session environment has %d vars, expected %d (array)' \1239 % (i, len(curEnv), curRes.cNumVars));1240 fRc = False;1241 break;1242 else:1243 reporter.log('Test #%d: API reported an error (array), good' % (i,));1244 ## @todo Get current system environment and add it to curRes.cNumVars before comparing!1245 reporter.log('Test #%d: Environment size' % (i,));1246 curEnv = self.oTstDrv.oVBoxMgr.getArray(curGuestSession, sEnvironmentChangesAttr);1247 reporter.log2('Test #%d: Environment (%d) -> %s' % (i, len(curEnv), curEnv));1248 if len(curEnv) != curRes.cNumVars:1249 reporter.error('Test #%d failed: Session environment has %d vars (%s), expected %d' \1250 % (i, len(curEnv), curEnv, curRes.cNumVars));1251 fRc = False;1252 break;1253 1254 self.oTstDrv.oVBoxMgr.setArray(curGuestSession, sEnvironmentChangesAttr, []);1255 curEnv = self.oTstDrv.oVBoxMgr.getArray(curGuestSession, sEnvironmentChangesAttr);1256 if len(curEnv) is not 0:1257 reporter.error('Test #%d failed: Session environment has %d vars, expected 0');1258 fRc = False;1259 break;1260 except:1261 reporter.errorXcpt('Test #%d failed:' % (i,));1262 1263 fRc2 = curTest.closeSession();1264 if fRc2 is False:1265 reporter.error('Test #%d failed: Session could not be closed' % (i,));1266 fRc = False;1267 break;1268 1436 1269 1437 return (fRc, oTxsSession); … … 1392 1560 1393 1561 try: 1562 # r=bird: multiSession[0].oGuestSession is None! Why don't you just use 'assert' or 'if' to check 1563 # the functioning of the __testcase__? 1564 1394 1565 # Make sure that accessing the first opened guest session does not work anymore because we just removed (closed) it. 1395 1566 curSessionName = multiSession[0].oGuestSession.name; … … 1444 1615 and waitResult != vboxcon.GuestSessionWaitResult_WaitFlagNotSupported: 1445 1616 # Just log, don't assume an error here (will be done in the main loop then). 1446 reporter.log('Session did not start successfully, returned wait result: % ld' \1617 reporter.log('Session did not start successfully, returned wait result: %d' \ 1447 1618 % (waitResult)); 1448 1619 return (False, oTxsSession); … … 1464 1635 # do not support terminating guest processes. 1465 1636 except: 1466 reporter.errorXcpt('Opening stale file #% ld failed:' % (i,));1637 reporter.errorXcpt('Opening stale file #%d failed:' % (i,)); 1467 1638 fRc = False; 1468 1639 break; … … 1471 1642 cFiles = len(self.oTstDrv.oVBoxMgr.getArray(oGuestSession, 'files')); 1472 1643 if cFiles != cStaleFiles: 1473 reporter.error('Test failed: Got % ld stale files, expected %ld' % (cFiles, cStaleFiles));1644 reporter.error('Test failed: Got %d stale files, expected %d' % (cFiles, cStaleFiles)); 1474 1645 fRc = False; 1475 1646 … … 1489 1660 aaFiles.append(oCurFile); 1490 1661 except: 1491 reporter.errorXcpt('Opening non-stale file #% ld failed:' % (i,));1662 reporter.errorXcpt('Opening non-stale file #%d failed:' % (i,)); 1492 1663 fRc = False; 1493 1664 break; … … 1495 1666 cFiles = len(self.oTstDrv.oVBoxMgr.getArray(oGuestSession, 'files')); 1496 1667 if cFiles != cStaleFiles * 2: 1497 reporter.error('Test failed: Got % ld total files, expected %ld' % (cFiles, cStaleFiles * 2));1668 reporter.error('Test failed: Got %d total files, expected %d' % (cFiles, cStaleFiles * 2)); 1498 1669 fRc = False; 1499 1670 if fRc: … … 1503 1674 aaFiles[i].close(); 1504 1675 except: 1505 reporter.errorXcpt('Waiting for non-stale file #% ld failed:' % (i,));1676 reporter.errorXcpt('Waiting for non-stale file #%d failed:' % (i,)); 1506 1677 fRc = False; 1507 1678 break; … … 1511 1682 # a reference in aaFiles[] for). 1512 1683 if cFiles != cStaleFiles: 1513 reporter.error('Test failed: Got % ld total files, expected %ld' \1684 reporter.error('Test failed: Got %d total files, expected %d' \ 1514 1685 % (cFiles, cStaleFiles)); 1515 1686 fRc = False; … … 1523 1694 curFilesStatus = aaFiles[i].status; 1524 1695 if curFilesStatus != vboxcon.FileStatus_Closed: 1525 reporter.error('Test failed: Non-stale file #% ld has status %ld, expected %ld' \1696 reporter.error('Test failed: Non-stale file #%d has status %d, expected %d' \ 1526 1697 % (i, curFilesStatus, vboxcon.FileStatus_Closed)); 1527 1698 fRc = False; 1528 1699 except: 1529 reporter.errorXcpt('Checking status of file #% ld failed:' % (i,));1700 reporter.errorXcpt('Checking status of file #%d failed:' % (i,)); 1530 1701 fRc = False; 1531 1702 break; … … 1533 1704 reporter.log2('All non-stale files closed'); 1534 1705 cFiles = len(self.oTstDrv.oVBoxMgr.getArray(oGuestSession, 'files')); 1535 reporter.log2('Final guest session file count: % ld' % (cFiles,));1706 reporter.log2('Final guest session file count: %d' % (cFiles,)); 1536 1707 # Now try to close the session and see what happens. 1537 1708 reporter.log2('Closing guest session ...'); … … 1580 1751 and waitResult != vboxcon.GuestSessionWaitResult_WaitFlagNotSupported: 1581 1752 # Just log, don't assume an error here (will be done in the main loop then). 1582 reporter.log('Session did not start successfully, returned wait result: % ld' \1753 reporter.log('Session did not start successfully, returned wait result: %d' \ 1583 1754 % (waitResult)); 1584 1755 return (False, oTxsSession); … … 1600 1771 # do not support terminating guest processes. 1601 1772 except: 1602 reporter.logXcpt('Creating stale process #% ld failed:' % (i,));1773 reporter.logXcpt('Creating stale process #%d failed:' % (i,)); 1603 1774 fRc = False; 1604 1775 break; … … 1607 1778 cProcs = len(self.oTstDrv.oVBoxMgr.getArray(oGuestSession, 'processes')); 1608 1779 if cProcs != cStaleProcs: 1609 reporter.error('Test failed: Got % ld stale processes, expected %ld' % (cProcs, cStaleProcs));1780 reporter.error('Test failed: Got %d stale processes, expected %d' % (cProcs, cStaleProcs)); 1610 1781 fRc = False; 1611 1782 … … 1624 1795 aaProcs.append(oCurProc); 1625 1796 except: 1626 reporter.logXcpt('Creating non-stale process #% ld failed:' % (i,));1797 reporter.logXcpt('Creating non-stale process #%d failed:' % (i,)); 1627 1798 fRc = False; 1628 1799 break; … … 1634 1805 curProcStatus = aaProcs[i].status; 1635 1806 if aaProcs[i].status != vboxcon.ProcessStatus_TerminatedNormally: 1636 reporter.error('Test failed: Waiting for non-stale processes #% ld'1637 ' resulted in status % ld, expected %ld' \1807 reporter.error('Test failed: Waiting for non-stale processes #%d' 1808 ' resulted in status %d, expected %d' \ 1638 1809 % (i, curProcStatus, vboxcon.ProcessStatus_TerminatedNormally)); 1639 1810 fRc = False; 1640 1811 except: 1641 reporter.logXcpt('Waiting for non-stale process #% ld failed:' % (i,));1812 reporter.logXcpt('Waiting for non-stale process #%d failed:' % (i,)); 1642 1813 fRc = False; 1643 1814 break; … … 1647 1818 # a reference in aaProcs[] for). 1648 1819 if cProcs != (cStaleProcs * 2): 1649 reporter.error('Test failed: Got % ld total processes, expected %ld' \1820 reporter.error('Test failed: Got %d total processes, expected %d' \ 1650 1821 % (cProcs, cStaleProcs)); 1651 1822 fRc = False; … … 1657 1828 curProcStatus = aaProcs[i].status; 1658 1829 if aaProcs[i].status != vboxcon.ProcessStatus_TerminatedNormally: 1659 reporter.error('Test failed: Non-stale processes #% ld has status %ld, expected %ld' \1830 reporter.error('Test failed: Non-stale processes #%d has status %d, expected %d' \ 1660 1831 % (i, curProcStatus, vboxcon.ProcessStatus_TerminatedNormally)); 1661 1832 fRc = False; … … 1689 1860 cProcs = len(self.oTstDrv.oVBoxMgr.getArray(oGuestSession, 'processes')); 1690 1861 if cProcs != (cStaleProcs * 2): # Still should be 20 processes because we terminated the 10 newest ones. 1691 reporter.error('Test failed: Got % ld total processes, expected %ld' % (cProcs, cStaleProcs * 2));1862 reporter.error('Test failed: Got %d total processes, expected %d' % (cProcs, cStaleProcs * 2)); 1692 1863 fRc = False; 1693 1864 cProcs = len(self.oTstDrv.oVBoxMgr.getArray(oGuestSession, 'processes')); 1694 reporter.log2('Final guest session processes count: % ld' % (cProcs,));1865 reporter.log2('Final guest session processes count: %d' % (cProcs,)); 1695 1866 # Now try to close the session and see what happens. 1696 1867 reporter.log2('Closing guest session ...'); … … 1909 2080 if waitResult != vboxcon.GuestSessionWaitResult_Start \ 1910 2081 and waitResult != vboxcon.GuestSessionWaitResult_WaitFlagNotSupported: 1911 reporter.error('Session did not start successfully, returned wait result: % ld' \2082 reporter.error('Session did not start successfully, returned wait result: %d' \ 1912 2083 % (waitResult)); 1913 2084 return (False, oTxsSession); … … 2083 2254 waitRes = curProc.waitForArray([ vboxcon.ProcessWaitForFlag_Start ], 30 * 1000); 2084 2255 if waitRes != vboxcon.ProcessWaitResult_Start: 2085 reporter.error('Waiting for process 1 to start failed, got status % ld');2256 reporter.error('Waiting for process 1 to start failed, got status %d'); 2086 2257 fRc = False; 2087 2258 if fRc: … … 2097 2268 waitRes = curProc.waitForArray([ vboxcon.ProcessWaitForFlag_Terminate ], 5000); 2098 2269 if waitRes != vboxcon.ProcessWaitResult_Timeout: 2099 reporter.error('Waiting for process 1 did not time out when it should, got wait result % ld' % (waitRes,));2270 reporter.error('Waiting for process 1 did not time out when it should, got wait result %d' % (waitRes,)); 2100 2271 fRc = False; 2101 2272 else: … … 2114 2285 waitRes = curProc.waitForArray([ vboxcon.ProcessWaitForFlag_Start ], 30 * 1000); 2115 2286 if waitRes != vboxcon.ProcessWaitResult_Start: 2116 reporter.error('Waiting for process 1 to start failed, got status % ld');2287 reporter.error('Waiting for process 1 to start failed, got status %d'); 2117 2288 fRc = False; 2118 2289 if fRc: … … 2120 2291 waitRes = curProc.waitForArray([ vboxcon.ProcessWaitForFlag_Terminate ], 30 * 1000); 2121 2292 if waitRes != vboxcon.ProcessWaitResult_Timeout: 2122 reporter.error('Waiting for process 2 did not time out when it should, got wait result % ld' \2293 reporter.error('Waiting for process 2 did not time out when it should, got wait result %d' \ 2123 2294 % (waitRes,)); 2124 2295 fRc = False; … … 2126 2297 reporter.log('Waiting for process 2 indicated an error, good'); 2127 2298 if curProc.status != vboxcon.ProcessStatus_TimedOutKilled: 2128 reporter.error('Status of process 2 wrong; excepted % ld, got %ld' \2299 reporter.error('Status of process 2 wrong; excepted %d, got %d' \ 2129 2300 % (vboxcon.ProcessStatus_TimedOutKilled, curProc.status)); 2130 2301 fRc = False; 2131 2302 else: 2132 reporter.log('Status of process 2 correct (% ld)' % (vboxcon.ProcessStatus_TimedOutKilled,));2303 reporter.log('Status of process 2 correct (%d)' % (vboxcon.ProcessStatus_TimedOutKilled,)); 2133 2304 ## @todo Add curProc.terminate() as soon as it's implemented. 2134 2305 except: … … 2441 2612 (fRc2, cDirs, cFiles) = self.gctrlReadDir(curTest, curRes, curGuestSession); 2442 2613 curTest.closeSession(); 2443 reporter.log2('Test #%d: Returned % ld directories, %ld files total' % (i, cDirs, cFiles));2614 reporter.log2('Test #%d: Returned %d directories, %d files total' % (i, cDirs, cFiles)); 2444 2615 if fRc2 is curRes.fRc: 2445 2616 if fRc2 is True: 2446 2617 if curRes.numFiles != cFiles: 2447 reporter.error('Test #%d failed: Got % ld files, expected %ld' % (i, cFiles, curRes.numFiles));2618 reporter.error('Test #%d failed: Got %d files, expected %d' % (i, cFiles, curRes.numFiles)); 2448 2619 fRc = False; 2449 2620 break; 2450 2621 if curRes.numDirs != cDirs: 2451 reporter.error('Test #%d failed: Got % ld directories, expected %ld' % (i, cDirs, curRes.numDirs));2622 reporter.error('Test #%d failed: Got %d directories, expected %d' % (i, cDirs, curRes.numDirs)); 2452 2623 fRc = False; 2453 2624 break; … … 2610 2781 eFileType = fileObjInfo.type; 2611 2782 if curRes.eFileType != eFileType: 2612 reporter.error('Test #%d failed: Got file type % ld, expected %ld' % (i, eFileType, curRes.eFileType));2783 reporter.error('Test #%d failed: Got file type %d, expected %d' % (i, eFileType, curRes.eFileType)); 2613 2784 fRc = False; 2614 2785 break; 2615 2786 cbFile = long(fileObjInfo.objectSize); 2616 2787 if curRes.cbSize != cbFile: 2617 reporter.error('Test #%d failed: Got % ld bytes size, expected %ld bytes' % (i, cbFile, curRes.cbSize));2788 reporter.error('Test #%d failed: Got %d bytes size, expected %d bytes' % (i, cbFile, curRes.cbSize)); 2618 2789 fRc = False; 2619 2790 break; … … 2712 2883 curTest = aTest[0]; # tdTestFileReadWrite, use an index, later. 2713 2884 curRes = aTest[1]; # tdTestResult 2714 reporter.log('Testing #%d, sFile="%s", cbToReadWrite=%d, sOpenMode="%s", sDisposition="%s", cbOffset=% ld ...' % \2885 reporter.log('Testing #%d, sFile="%s", cbToReadWrite=%d, sOpenMode="%s", sDisposition="%s", cbOffset=%d ...' % \ 2715 2886 (i, curTest.sFile, curTest.cbToReadWrite, curTest.sOpenMode, curTest.sDisposition, curTest.cbOffset)); 2716 2887 curTest.setEnvironment(oSession, oTxsSession, oTestVm); … … 2731 2902 resOffset = long(curTest.cbOffset); 2732 2903 if curOffset != resOffset: 2733 reporter.error('Test #%d failed: Initial offset on open does not match: Got % ld, expected %ld' \2904 reporter.error('Test #%d failed: Initial offset on open does not match: Got %d, expected %d' \ 2734 2905 % (i, curOffset, resOffset)); 2735 2906 fRc = False; … … 2748 2919 if curRes.cbProcessed > 0 \ 2749 2920 and curRes.cbProcessed is not len(aBufRead): 2750 reporter.error('Test #%d failed: Read buffer length does not match: Got % ld, expected %ld' \2921 reporter.error('Test #%d failed: Read buffer length does not match: Got %d, expected %d' \ 2751 2922 % (i, len(aBufRead), curRes.cbProcessed)); 2752 2923 fRc = False; … … 2754 2925 if curRes.aBuf is not None \ 2755 2926 and bytes(curRes.aBuf) != bytes(aBufRead): 2756 reporter.error('Test #%d failed: Got buffer\n%s (% ld bytes), expected\n%s (%ld bytes)' \2927 reporter.error('Test #%d failed: Got buffer\n%s (%d bytes), expected\n%s (%d bytes)' \ 2757 2928 % (i, map(hex, map(ord, aBufRead)), len(aBufRead), \ 2758 2929 map(hex, map(ord, curRes.aBuf)), len(curRes.aBuf))); … … 2764 2935 resOffset = long(curRes.cbOffset); 2765 2936 if curOffset != resOffset: 2766 reporter.error('Test #%d failed: Final offset does not match: Got % ld, expected %ld' \2937 reporter.error('Test #%d failed: Final offset does not match: Got %d, expected %d' \ 2767 2938 % (i, curOffset, resOffset)); 2768 2939 fRc = False; … … 2826 2997 curTest = aTest[0]; # tdTestFileReadWrite, use an index, later. 2827 2998 curRes = aTest[1]; # tdTestResult 2828 reporter.log('Testing #%d, sFile="%s", cbToReadWrite=%d, sOpenMode="%s", sDisposition="%s", cbOffset=% ld ...' % \2999 reporter.log('Testing #%d, sFile="%s", cbToReadWrite=%d, sOpenMode="%s", sDisposition="%s", cbOffset=%d ...' % \ 2829 3000 (i, curTest.sFile, curTest.cbToReadWrite, curTest.sOpenMode, curTest.sDisposition, curTest.cbOffset)); 2830 3001 curTest.setEnvironment(oSession, oTxsSession, oTestVm); … … 2845 3016 resOffset = long(curTest.cbOffset); 2846 3017 if curOffset != resOffset: 2847 reporter.error('Test #%d failed: Initial offset on open does not match: Got % ld, expected %ld' \3018 reporter.error('Test #%d failed: Initial offset on open does not match: Got %d, expected %d' \ 2848 3019 % (i, curOffset, resOffset)); 2849 3020 fRc = False; … … 2862 3033 if curRes.cbProcessed > 0 \ 2863 3034 and curRes.cbProcessed != cBytesWritten: 2864 reporter.error('Test #%d failed: Written buffer length does not match: Got % ld, expected %ld' \3035 reporter.error('Test #%d failed: Written buffer length does not match: Got %d, expected %d' \ 2865 3036 % (i, cBytesWritten, curRes.cbProcessed)); 2866 3037 fRc = False; … … 2879 3050 and long(curFile.offset) != curTest.cbOffset: 2880 3051 reporter.error('Test #%d failed: Initial write position does not match current position, \ 2881 got % ld, expected %ld' \3052 got %d, expected %d' \ 2882 3053 % (i, long(curFile.offset), curTest.cbOffset)); 2883 3054 fRc = False; … … 2885 3056 aBufRead = curFile.read(curTest.cbToReadWrite, 30 * 1000); 2886 3057 if len(aBufRead) != curTest.cbToReadWrite: 2887 reporter.error('Test #%d failed: Got buffer length % ld, expected %ld' \3058 reporter.error('Test #%d failed: Got buffer length %d, expected %d' \ 2888 3059 % (i, len(aBufRead), curTest.cbToReadWrite)); 2889 3060 fRc = False; … … 2898 3069 resOffset = long(curRes.cbOffset); 2899 3070 if curOffset != resOffset: 2900 reporter.error('Test #%d failed: Final offset does not match: Got % ld, expected %ld' \3071 reporter.error('Test #%d failed: Final offset does not match: Got %d, expected %d' \ 2901 3072 % (i, curOffset, resOffset)); 2902 3073 fRc = False;
Note:
See TracChangeset
for help on using the changeset viewer.