Changeset 79208 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Jun 18, 2019 12:00:44 PM (6 years ago)
- Location:
- trunk/src/VBox/ValidationKit
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testdriver/testfileset.py
r79198 r79208 52 52 class TestFsObj(object): 53 53 """ A file system object we created in for test purposes. """ 54 def __init__(self, oParent, sPath ):54 def __init__(self, oParent, sPath, sName = None): 55 55 self.oParent = oParent # type: TestDir 56 56 self.sPath = sPath # type: str 57 self.sName = s Path# type: str57 self.sName = sName # type: str 58 58 if oParent: 59 59 assert sPath.startswith(oParent.sPath); 60 assert sName is None; 60 61 self.sName = sPath[len(oParent.sPath) + 1:]; 61 62 # Add to parent. 62 63 oParent.aoChildren.append(self); 63 64 oParent.dChildrenUpper[self.sName.upper()] = self; 65 66 def buildPath(self, sRoot, sSep): 67 """ 68 Build the path from sRoot using sSep. 69 70 This is handy for getting the path to an object in a different context 71 (OS, path) than what it was generated for. 72 """ 73 if self.oParent: 74 return self.oParent.buildPath(sRoot, sSep) + sSep + self.sName; 75 return sRoot + sSep + self.sName; 76 64 77 65 78 class TestFile(TestFsObj): … … 122 135 class TestDir(TestFsObj): 123 136 """ A file object in the guest. """ 124 def __init__(self, oParent, sPath ):125 TestFsObj.__init__(self, oParent, sPath );137 def __init__(self, oParent, sPath, sName = None): 138 TestFsObj.__init__(self, oParent, sPath, sName); 126 139 self.aoChildren = [] # type: list(TestFsObj) 127 140 self.dChildrenUpper = {} # type: dict(str, TestFsObj) … … 283 296 return ''; # never reached, but makes pylint happy. 284 297 285 def __createTestDir(self, oParent, sDir ):298 def __createTestDir(self, oParent, sDir, sName = None): 286 299 """ 287 300 Creates a test directory. 288 301 """ 289 oDir = TestDir(oParent, sDir );302 oDir = TestDir(oParent, sDir, sName); 290 303 self.aoDirs.append(oDir); 291 304 self.dPaths[sDir] = oDir; … … 314 327 # 315 328 sRoot = pathutils.joinEx(self.fDosStyle, self.sBasePath, self.sSubDir); 316 self.oRoot = self.__createTestDir(None, sRoot );329 self.oRoot = self.__createTestDir(None, sRoot, self.sSubDir); 317 330 self.oEmptyDir = self.__createTestDir(self.oRoot, pathutils.joinEx(self.fDosStyle, sRoot, 'empty')); 318 331 … … 443 456 444 457 try: 445 o File = open(sPath, 'wb');458 oOutFile = open(sPath, 'wb'); 446 459 except: 447 460 return reporter.errorXcpt('open(%s, "wb") failed' % (sPath,)); 448 461 try: 449 462 if sys.version_info[0] < 3: 450 o File.write(bytes(oFile.abContent));463 oOutFile.write(bytes(oFile.abContent)); 451 464 else: 452 o File.write(oFile.abContent);453 except: 454 try: o File.close();465 oOutFile.write(oFile.abContent); 466 except: 467 try: oOutFile.close(); 455 468 except: pass; 456 469 return reporter.errorXcpt('%s: write(%s bytes) failed' % (sPath, oFile.cbContent,)); 457 470 try: 458 o File.close();471 oOutFile.close(); 459 472 except: 460 473 return reporter.errorXcpt('%s: close() failed' % (sPath,)); -
trunk/src/VBox/ValidationKit/testdriver/vboxtestvms.py
r79180 r79208 921 921 return pathutils.joinEx(self.isWindows() or self.isOS2(), sBase, *asAppend); 922 922 923 def pathSep(self): 924 """ Returns the preferred paths separator for the guest OS. """ 925 return '\\' if self.isWindows() or self.isOS2() else '/'; 923 926 924 927 -
trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py
r79193 r79208 277 277 self.sDst = sDst; 278 278 self.fFlags = fFlags; 279 280 class tdTestCopyToFile(tdTestCopyTo): 281 pass; 282 283 class tdTestCopyToDir(tdTestCopyTo): 284 pass; 279 285 280 286 class tdTestDirCreate(tdTestGuestCtrlBase): … … 974 980 ]; 975 981 self.asTests = self.asTestsDef; 976 self. asRsrcs = ['5.3/guestctrl/50mb_rnd.dat', ];982 self.fSkipKnownBugs = False; 977 983 self.oTestFiles = None # type: vboxtestfileset.TestFileSet 978 984 … … 990 996 % (s, ' '.join(self.asTestsDef))); 991 997 return iNext; 998 if asArgs[iArg] == '--add-guest-ctrl-skip-known-bugs': 999 self.fSkipKnownBugs = True; 1000 return iArg + 1; 1001 if asArgs[iArg] == '--no-add-guest-ctrl-skip-known-bugs': 1002 self.fSkipKnownBugs = False; 1003 return iArg + 1; 992 1004 return iArg; 993 1005 … … 996 1008 reporter.log(' --add-guest-ctrl-tests <s1[:s2[:]]>'); 997 1009 reporter.log(' Default: %s (all)' % (':'.join(self.asTestsDef))); 1010 reporter.log(' --add-guest-ctrl-skip-known-bugs'); 1011 reporter.log(' Skips known bugs. Default: --no-add-guest-ctrl-skip-known-bugs'); 998 1012 return True; 999 1013 … … 1009 1023 atTests = [ 1010 1024 ( True, self.prepareGuestForTesting, None, 'Preparations',), 1011 ( True, self.testGuestCtrlSession, 'session_basic', 'Session Basics',),1012 ( True, self.testGuestCtrlExec, 'exec_basic', 'Execution',),1013 ( False, self.testGuestCtrlExecTimeout, 'exec_timeout', 'Execution Timeouts',),1014 ( False, self.testGuestCtrlSessionEnvironment, 'session_env', 'Session Environment',),1015 ( False, self.testGuestCtrlSessionFileRefs, 'session_file_ref', 'Session File References',),1016 # ( False, self.testGuestCtrlSessionDirRefs, 'session_dir_ref', 'Session Directory References',),1017 ( False, self.testGuestCtrlSessionProcRefs, 'session_proc_ref', 'Session Process References',),1018 ( False, self.testGuestCtrlDirCreate, 'dir_create', 'Creating directories',),1019 ( False, self.testGuestCtrlDirCreateTemp, 'dir_create_temp', 'Creating temporary directories',),1020 ( False, self.testGuestCtrlDirRead, 'dir_read', 'Reading directories',),1021 ( False, self.testGuestCtrlCopyTo, 'copy_to', 'Copy to guest',),1022 ( False, self.testGuestCtrlCopyFrom, 'copy_from', 'Copy from guest',),1023 ( False, self.testGuestCtrlFileStat, 'file_stat', 'Querying file information (stat)',),1024 ( False, self.testGuestCtrlFileRead, 'file_read', 'File read',),1025 ( False, self.testGuestCtrlFileWrite, 'file_write', 'File write',),1026 ( False, self.testGuestCtrlFileRemove, 'file_remove', 'Removing files',), # Destroys prepped files.1027 ( False, self.testGuestCtrlSessionReboot, 'session_reboot', 'Session w/ Guest Reboot',), # May zap /tmp.1028 ( False, self.testGuestCtrlUpdateAdditions, 'update_additions', 'Updating Guest Additions',),1025 #( True, self.testGuestCtrlSession, 'session_basic', 'Session Basics',), 1026 #( True, self.testGuestCtrlExec, 'exec_basic', 'Execution',), 1027 #( False, self.testGuestCtrlExecTimeout, 'exec_timeout', 'Execution Timeouts',), 1028 #( False, self.testGuestCtrlSessionEnvironment, 'session_env', 'Session Environment',), 1029 #( False, self.testGuestCtrlSessionFileRefs, 'session_file_ref', 'Session File References',), 1030 ##( False, self.testGuestCtrlSessionDirRefs, 'session_dir_ref', 'Session Directory References',), 1031 #( False, self.testGuestCtrlSessionProcRefs, 'session_proc_ref', 'Session Process References',), 1032 #( False, self.testGuestCtrlDirCreate, 'dir_create', 'Creating directories',), 1033 #( False, self.testGuestCtrlDirCreateTemp, 'dir_create_temp', 'Creating temporary directories',), 1034 #( False, self.testGuestCtrlDirRead, 'dir_read', 'Reading directories',), 1035 ( False, self.testGuestCtrlCopyTo, 'copy_to', 'Copy to guest',), 1036 #( False, self.testGuestCtrlCopyFrom, 'copy_from', 'Copy from guest',), 1037 #( False, self.testGuestCtrlFileStat, 'file_stat', 'Querying file information (stat)',), 1038 #( False, self.testGuestCtrlFileRead, 'file_read', 'File read',), 1039 #( False, self.testGuestCtrlFileWrite, 'file_write', 'File write',), 1040 #( False, self.testGuestCtrlFileRemove, 'file_remove', 'Removing files',), # Destroys prepped files. 1041 #( False, self.testGuestCtrlSessionReboot, 'session_reboot', 'Session w/ Guest Reboot',), # May zap /tmp. 1042 #( False, self.testGuestCtrlUpdateAdditions, 'update_additions', 'Updating Guest Additions',), 1029 1043 ]; 1030 1044 … … 3485 3499 oFile.close(); 3486 3500 3487 def testGuestCtrlCopyTo(self, oSession, oTxsSession, oTestVm): 3501 def testGuestCtrlCopyTo(self, oSession, oTxsSession, oTestVm): # pylint: disable=too-many-locals 3488 3502 """ 3489 3503 Tests copying files from host to the guest. 3490 3504 """ 3491 3505 3492 # Paths. 3493 sScratchGst = oTestVm.pathJoin(self.getGuestTempDir(oTestVm), 'testGuestCtrlCopyTo'); 3506 # 3507 # Paths and test files. 3508 # 3509 sScratchHst = os.path.join(self.oTstDrv.sScratchPath, 'cp2'); 3510 sScratchTestFilesHst = os.path.join(sScratchHst, self.oTestFiles.sSubDir); 3511 sScratchEmptyDirHst = os.path.join(sScratchTestFilesHst, self.oTestFiles.oEmptyDir.sName); 3512 sScratchNonEmptyDirHst = self.oTestFiles.chooseRandomDirFromTree().buildPath(sScratchHst, os.path.sep); 3513 sScratchTreeDirHst = os.path.join(sScratchTestFilesHst, self.oTestFiles.oTreeDir.sName); 3514 3515 sScratchGst = oTestVm.pathJoin(self.getGuestTempDir(oTestVm), 'cp2'); 3516 sScratchDstDir1Gst = oTestVm.pathJoin(sScratchGst, 'dstdir1'); 3517 sScratchDstDir2Gst = oTestVm.pathJoin(sScratchGst, 'dstdir2'); 3518 sScratchDstDir3Gst = oTestVm.pathJoin(sScratchGst, 'dstdir3'); 3519 sScratchDstDir4Gst = oTestVm.pathJoin(sScratchGst, 'dstdir4'); 3494 3520 #sScratchGstNotExist = oTestVm.pathJoin(self.getGuestTempDir(oTestVm), 'no-such-file-or-directory'); 3495 3521 sScratchHstNotExist = os.path.join(self.oTstDrv.sScratchPath, 'no-such-file-or-directory'); 3496 3522 sScratchGstPathNotFound = oTestVm.pathJoin(self.getGuestTempDir(oTestVm), 'no-such-directory', 'or-file'); 3497 3523 #sScratchHstPathNotFound = os.path.join(self.oTstDrv.sScratchPath, 'no-such-directory', 'or-file'); 3498 sSomeDirHst = self.oTstDrv.sScriptPath;3499 3524 3500 3525 if oTestVm.isWindows() or oTestVm.isOS2(): … … 3502 3527 else: 3503 3528 sScratchGstInvalid = None; 3504 3505 if oTxsSession.syncMkDir(sScratchGst) is not True: 3506 return reporter.error('TXS failed to create directory "%s"!' % (sScratchGst,)); 3507 3508 # Generate a test file in 32MB to 50 MB range. 3529 if utils.getHostOs() in ('win', 'os2'): 3530 sScratchHstInvalid = "?*|<invalid-name>"; 3531 else: 3532 sScratchHstInvalid = None; 3533 3534 for sDir in (sScratchGst, sScratchDstDir1Gst, sScratchDstDir2Gst, sScratchDstDir3Gst, sScratchDstDir4Gst): 3535 if oTxsSession.syncMkDir(sDir) is not True: 3536 return reporter.error('TXS failed to create directory "%s"!' % (sDir,)); 3537 3538 # Put the test file set under sScratchHst. 3539 if os.path.exists(sScratchHst): 3540 if base.wipeDirectory(sScratchHst) != 0: 3541 return reporter.error('Failed to wipe "%s"' % (sScratchHst,)); 3542 else: 3543 try: 3544 os.mkdir(sScratchHst); 3545 except: 3546 return reporter.errorXcpt('os.mkdir(%s)' % (sScratchHst, )); 3547 if self.oTestFiles.writeToDisk(sScratchHst) is not True: 3548 return reporter.error('Filed to write test files to "%s" on the host!' % (sScratchHst,)); 3549 3550 # Generate a test file in 32MB to 64 MB range. 3509 3551 sBigFileHst = os.path.join(self.oTstDrv.sScratchPath, 'gctrl-random.data'); 3510 cbBigFileHst = random.randrange(32*1024*1024, 50*1024*1024);3552 cbBigFileHst = random.randrange(32*1024*1024, 64*1024*1024); 3511 3553 reporter.log('cbBigFileHst=%s' % (cbBigFileHst,)); 3512 3554 cbLeft = cbBigFileHst; … … 3529 3571 # 3530 3572 atTests = [ 3531 ## @todo because of the way the test stats the source to figure out which API to use, 3532 ## not all of this necessarily testing both file and directory API variants like 3533 ## was intended. This needs to be addressed by specializing tdTestCopyTo so it 3534 ## would be possible to test feeding directories to the file API and vice versa. 3535 3536 # Nothing given 3537 [ tdTestCopyTo(), tdTestResultFailure() ], 3538 # Only one given. 3539 [ tdTestCopyTo(sSrc = sBigFileHst), tdTestResultFailure() ], 3540 [ tdTestCopyTo(sDst = sScratchGst), tdTestResultFailure() ], 3541 # Only one given, invalid flag. 3542 [ tdTestCopyTo(sSrc = sBigFileHst, fFlags = [ 0x40000000, ]), tdTestResultFailure() ], 3543 [ tdTestCopyTo(sDst = sScratchGst, fFlags = [ 0x40000000, ]), tdTestResultFailure() ], 3544 ## Apparently Main doesn't check the flags, so the first test succeeds. 3545 ## Both given, but invalid flags. 3546 #[ tdTestCopyTo(sSrc = sBigFileHst, sDst = sScratchGst, fFlags = [ 0x40000000] ), tdTestResultFailure() ], 3547 #[ tdTestCopyTo(sSrc = sSomeDirHst, sDst = sScratchGst, fFlags = [ 0x40000000] ), tdTestResultFailure() ], 3548 # Bogus source, but no destination. 3549 [ tdTestCopyTo(sSrc = sScratchHstNotExist), tdTestResultFailure() ], 3550 # Valid sources, but bogus destination (path not found). 3551 [ tdTestCopyTo(sSrc = sBigFileHst, sDst = sScratchGstPathNotFound), tdTestResultFailure() ], 3552 [ tdTestCopyTo(sSrc = sSomeDirHst, sDst = sScratchGstPathNotFound), tdTestResultFailure() ], 3573 # Nothing given: 3574 [ tdTestCopyToFile(), tdTestResultFailure() ], 3575 [ tdTestCopyToDir(), tdTestResultFailure() ], 3576 # Only source given: 3577 [ tdTestCopyToFile(sSrc = sBigFileHst), tdTestResultFailure() ], 3578 [ tdTestCopyToDir( sSrc = sScratchEmptyDirHst), tdTestResultFailure() ], 3579 # Only destination given: 3580 [ tdTestCopyToFile(sDst = oTestVm.pathJoin(sScratchGst, 'dstfile')), tdTestResultFailure() ], 3581 [ tdTestCopyToDir( sDst = sScratchGst), tdTestResultFailure() ], 3553 3582 ]; 3583 if not self.fSkipKnownBugs: 3584 atTests.extend([ 3585 ## @todo Apparently Main doesn't check the flags, so the first test succeeds. 3586 # Both given, but invalid flags. 3587 [ tdTestCopyToFile(sSrc = sBigFileHst, sDst = sScratchGst, fFlags = [ 0x40000000] ), tdTestResultFailure() ], 3588 [ tdTestCopyToDir( sSrc = sScratchEmptyDirHst, sDst = sScratchGst, fFlags = [ 0x40000000] ), 3589 tdTestResultFailure() ], 3590 ]); 3591 atTests.extend([ 3592 # Non-existing source, but no destination: 3593 [ tdTestCopyToFile(sSrc = sScratchHstNotExist), tdTestResultFailure() ], 3594 [ tdTestCopyToDir( sSrc = sScratchHstNotExist), tdTestResultFailure() ], 3595 # Valid sources, but destination path not found: 3596 [ tdTestCopyToFile(sSrc = sBigFileHst, sDst = sScratchGstPathNotFound), tdTestResultFailure() ], 3597 [ tdTestCopyToDir( sSrc = sScratchEmptyDirHst, sDst = sScratchGstPathNotFound), tdTestResultFailure() ], 3598 # Valid destination, but source file/dir not found: 3599 [ tdTestCopyToFile(sSrc = sScratchHstNotExist, sDst = oTestVm.pathJoin(sScratchGst, 'dstfile')), 3600 tdTestResultFailure() ], 3601 [ tdTestCopyToDir( sSrc = sScratchHstNotExist, sDst = sScratchGst), tdTestResultFailure() ], 3602 # Wrong type: 3603 [ tdTestCopyToFile(sSrc = sScratchEmptyDirHst, sDst = oTestVm.pathJoin(sScratchGst, 'dstfile')), 3604 tdTestResultFailure() ], 3605 [ tdTestCopyToDir( sSrc = sBigFileHst, sDst = sScratchGst), tdTestResultFailure() ], 3606 ]); 3607 # Invalid characters in destination or source path: 3554 3608 if sScratchGstInvalid is not None: 3555 # Invalid characters in destination path:3556 3609 atTests.extend([ 3557 [ tdTestCopyTo (sSrc = sBigFileHst, sDst = oTestVm.pathJoin(sScratchGst, sScratchGstInvalid)),3610 [ tdTestCopyToFile(sSrc = sBigFileHst, sDst = oTestVm.pathJoin(sScratchGst, sScratchGstInvalid)), 3558 3611 tdTestResultFailure() ], 3559 [ tdTestCopyTo (sSrc = sSomeDirHst, sDst = oTestVm.pathJoin(sScratchGst, sScratchGstInvalid)),3612 [ tdTestCopyToDir( sSrc = sScratchEmptyDirHst, sDst = oTestVm.pathJoin(sScratchGst, sScratchGstInvalid)), 3560 3613 tdTestResultFailure() ], 3561 3614 ]); 3615 if sScratchHstInvalid is not None: 3616 atTests.extend([ 3617 [ tdTestCopyToFile(sSrc = os.path.join(self.oTstDrv.sScratchPath, sScratchHstInvalid), sDst = sScratchGst), 3618 tdTestResultFailure() ], 3619 [ tdTestCopyToDir( sSrc = os.path.join(self.oTstDrv.sScratchPath, sScratchHstInvalid), sDst = sScratchGst), 3620 tdTestResultFailure() ], 3621 ]); 3562 3622 3563 3623 # … … 3565 3625 # 3566 3626 atTests.extend([ 3567 [ tdTestCopyTo (sSrc = sBigFileHst,sDst = oTestVm.pathJoin(sScratchGst, 'HostGABig.dat')),3627 [ tdTestCopyToFile(sSrc = sBigFileHst, sDst = oTestVm.pathJoin(sScratchGst, 'HostGABig.dat')), 3568 3628 tdTestResultSuccess() ], 3569 [ tdTestCopyTo (sSrc = sBigFileHst, sDst = oTestVm.pathJoin(sScratchGst, 'HostGABig.dat')),# Overwrite3629 [ tdTestCopyToFile(sSrc = sBigFileHst, sDst = oTestVm.pathJoin(sScratchGst, 'HostGABig.dat')), # Overwrite 3570 3630 tdTestResultSuccess() ], 3571 [ tdTestCopyTo (sSrc = sEmptyFileHst, sDst = oTestVm.pathJoin(sScratchGst, 'HostGABig.dat')), # Overwrite3631 [ tdTestCopyToFile(sSrc = sEmptyFileHst, sDst = oTestVm.pathJoin(sScratchGst, 'HostGABig.dat')), # Overwrite 3572 3632 tdTestResultSuccess() ], 3573 3633 ]); 3574 3634 if self.oTstDrv.fpApiVer > 5.2: # Copying files into directories via Main is supported only 6.0 and later. 3575 3635 atTests.extend([ 3576 [ tdTestCopyTo (sSrc = sBigFileHst,sDst = sScratchGst), tdTestResultSuccess() ],3577 [ tdTestCopyTo (sSrc = sBigFileHst,sDst = sScratchGst), tdTestResultSuccess() ], # Overwrite3578 [ tdTestCopyTo (sSrc = sEmptyFileHst, sDst = oTestVm.pathJoin(sScratchGst, os.path.split(sBigFileHst)[1])),3636 [ tdTestCopyToFile(sSrc = sBigFileHst, sDst = sScratchGst), tdTestResultSuccess() ], 3637 [ tdTestCopyToFile(sSrc = sBigFileHst, sDst = sScratchGst), tdTestResultSuccess() ], # Overwrite 3638 [ tdTestCopyToFile(sSrc = sEmptyFileHst, sDst = oTestVm.pathJoin(sScratchGst, os.path.split(sBigFileHst)[1])), 3579 3639 tdTestResultSuccess() ], # Overwrite 3580 3640 ]); … … 3583 3643 # Copy to a Windows alternative data stream (ADS). 3584 3644 atTests.extend([ 3585 [ tdTestCopyTo (sSrc = sBigFileHst,sDst = os.path.join(sScratchGst, 'HostGABig.dat:ADS-Test')),3645 [ tdTestCopyToFile(sSrc = sBigFileHst, sDst = os.path.join(sScratchGst, 'HostGABig.dat:ADS-Test')), 3586 3646 tdTestResultSuccess() ], 3587 [ tdTestCopyTo (sSrc = sEmptyFileHst, sDst = os.path.join(sScratchGst, 'HostGABig.dat:ADS-Test')),3647 [ tdTestCopyToFile(sSrc = sEmptyFileHst, sDst = os.path.join(sScratchGst, 'HostGABig.dat:ADS-Test')), 3588 3648 tdTestResultSuccess() ], 3589 3649 ]); … … 3593 3653 # 3594 3654 if self.oTstDrv.fpApiVer > 5.2: # Copying directories via Main is supported only in versions > 5.2. 3595 # Create a directory to copy.3596 sHstCopyDir = os.path.join(self.oTstDrv.sScratchPath, 'gctrl-srcdir');3597 try: ## @todo Take the TestFileSet idea to the generic realm, making host and guest specializations/whatever.3598 os.mkdir(sHstCopyDir);3599 os.mkdir( os.path.join(sHstCopyDir, 'subdir1'));3600 os.mkdir( os.path.join(sHstCopyDir, 'subdir2'));3601 os.mkdir( os.path.join(sHstCopyDir, 'subdir2', 'subsub1'));3602 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub1', 'file0'), 0);3603 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub1', 'file1'), 1023);3604 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub1', 'file2'), 2048);3605 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub1', 'file3'), 2047);3606 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub1', 'file4'), 16887);3607 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub1', 'file4'), 32);3608 os.mkdir( os.path.join(sHstCopyDir, 'subdir2', 'subsub2'));3609 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub2', 'file5'), 31);3610 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub2', 'file6'), 1);3611 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub2', 'file7'), 1);3612 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub2', 'file8'), 0);3613 os.mkdir( os.path.join(sHstCopyDir, 'subdir2', 'subsub3'));3614 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub3', 'file9'), 9);3615 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub3', 'file10'), 63);3616 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub3', 'file11'), 11);3617 self.__generateFile(os.path.join(sHstCopyDir, 'subdir2', 'subsub3', 'file12'), 67);3618 os.mkdir( os.path.join(sHstCopyDir, 'subdir3'));3619 self.__generateFile(os.path.join(sHstCopyDir, 'file13'), 13);3620 self.__generateFile(os.path.join(sHstCopyDir, 'file14'), 67);3621 self.__generateFile(os.path.join(sHstCopyDir, 'file15'), 1111);3622 except:3623 reporter.errorXcpt('Error generating test tree on the host for the copy test (%s)' % (sHstCopyDir,));3624 3625 3655 atTests.extend([ 3626 [ tdTestCopyTo(sSrc = sHstCopyDir, sDst = sScratchGst, fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting ]), 3656 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst), tdTestResultSuccess() ], 3657 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst), tdTestResultFailure() ], 3658 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst, 3659 fFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]), tdTestResultSuccess() ], 3660 # Try again with trailing slash, should yield the same result: 3661 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir2Gst + oTestVm.pathSep()), 3627 3662 tdTestResultSuccess() ], 3628 ## @todo r=bird: Why does this fail??? 3629 # [ tdTestCopyTo(sSrc = sHstCopyDir, sDst = oTestVm.pathJoin(sScratchGst, 'target-dir')), tdTestResultSuccess() ], 3663 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir2Gst + oTestVm.pathSep()), 3664 tdTestResultFailure() ], 3665 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir2Gst + oTestVm.pathSep(), 3666 fFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]), 3667 tdTestResultSuccess() ], 3668 ]); 3669 if not self.fSkipKnownBugs: 3670 atTests.extend([ 3671 # Copy with a different destination name just for the heck of it: 3672 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = oTestVm.pathJoin(sScratchDstDir1Gst, 'empty2')), 3673 tdTestResultSuccess() ], 3674 ]); 3675 atTests.extend([ 3676 # Now the same using a directory with files in it: 3677 [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst), tdTestResultSuccess() ], 3678 [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst), tdTestResultFailure() ], 3679 ]); 3680 if not self.fSkipKnownBugs: 3681 atTests.extend([ 3682 [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst, 3683 fFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting]), tdTestResultSuccess() ], 3684 ]); 3685 atTests.extend([ 3686 #[ tdTestRemoveGuestDir(sScratchDstDir2Gst, tdTestResult() ], 3687 # Copy the entire test tree: 3688 [ tdTestCopyToDir(sSrc = sScratchTreeDirHst, sDst = sScratchDstDir4Gst), tdTestResultSuccess() ], 3689 #[ tdTestRemoveGuestDir(sScratchDstDir3Gst, tdTestResult() ], 3630 3690 ]); 3631 3691 … … 3643 3703 3644 3704 fRc2 = False; 3645 if os.path.isdir(oCurTest.sSrc): ## @todo r=bird: Not good enough. Test case must know which one it's testing. 3705 if isinstance(oCurTest, tdTestCopyToFile): 3706 fRc2 = self.gctrlCopyFileTo(oCurGuestSession, oCurTest.sSrc, oCurTest.sDst, oCurTest.fFlags, oCurRes.fRc); 3707 else: 3646 3708 fRc2 = self.gctrlCopyDirTo(oCurGuestSession, oCurTest.sSrc, oCurTest.sDst, oCurTest.fFlags, oCurRes.fRc); 3647 else:3648 fRc2 = self.gctrlCopyFileTo(oCurGuestSession, oCurTest.sSrc, oCurTest.sDst, oCurTest.fFlags, oCurRes.fRc);3649 3709 if fRc2 is not oCurRes.fRc: 3650 3710 fRc = reporter.error('Test #%d failed: Got %s, expected %s' % (i, fRc2, oCurRes.fRc)); 3651 else:3652 pass; ## @todo verify what was copied!!3653 3711 3654 3712 fRc = oCurTest.closeSession(True) and fRc; … … 3772 3830 ]); 3773 3831 3774 #3775 # Directory tree copying:3776 #3777 atTests.extend([3778 # Copy the empty guest directory (should end up as sScratchHst/empty):3779 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst), tdTestResultSuccess() ],3780 # Repeat -- this time it should fail, as the destination directory already exists (and3781 # DirectoryCopyFlag_CopyIntoExisting is not specified):3782 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst), tdTestResultFailure() ],3783 # Add the DirectoryCopyFlag_CopyIntoExisting flag being set and it should work.3784 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst,3785 fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],3786 # Try again with trailing slash, should yield the same result:3787 [ tdTestRemoveHostDir(os.path.join(sScratchDstDir1Hst, 'empty')), tdTestResult() ],3788 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst + os.path.sep),3789 tdTestResultSuccess() ],3790 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst + os.path.sep),3791 tdTestResultFailure() ],3792 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst + os.path.sep,3793 fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],3794 # Copy with a different destination name just for the heck of it:3795 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = os.path.join(sScratchHst, 'empty2'), fIntoDst = True),3796 tdTestResultFailure() ],3797 # Now the same using a directory with files in it:3798 [ tdTestCopyFromDir(oSrc = oNonEmptyDirGst, sDst = sScratchDstDir2Hst), tdTestResultSuccess() ],3799 [ tdTestCopyFromDir(oSrc = oNonEmptyDirGst, sDst = sScratchDstDir2Hst), tdTestResultFailure() ],3800 [ tdTestCopyFromDir(oSrc = oNonEmptyDirGst, sDst = sScratchDstDir2Hst,3801 fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],3802 # Copy the entire test tree:3803 [ tdTestCopyFromDir(sSrc = self.oTestFiles.oTreeDir.sPath, sDst = sScratchDstDir3Hst), tdTestResultSuccess() ],3804 ]);3832 # 3833 # Directory tree copying: 3834 # 3835 atTests.extend([ 3836 # Copy the empty guest directory (should end up as sScratchHst/empty): 3837 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst), tdTestResultSuccess() ], 3838 # Repeat -- this time it should fail, as the destination directory already exists (and 3839 # DirectoryCopyFlag_CopyIntoExisting is not specified): 3840 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst), tdTestResultFailure() ], 3841 # Add the DirectoryCopyFlag_CopyIntoExisting flag being set and it should work. 3842 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst, 3843 fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ], 3844 # Try again with trailing slash, should yield the same result: 3845 [ tdTestRemoveHostDir(os.path.join(sScratchDstDir1Hst, 'empty')), tdTestResult() ], 3846 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst + os.path.sep), 3847 tdTestResultSuccess() ], 3848 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst + os.path.sep), 3849 tdTestResultFailure() ], 3850 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst + os.path.sep, 3851 fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ], 3852 # Copy with a different destination name just for the heck of it: 3853 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = os.path.join(sScratchHst, 'empty2'), fIntoDst = True), 3854 tdTestResultFailure() ], 3855 # Now the same using a directory with files in it: 3856 [ tdTestCopyFromDir(oSrc = oNonEmptyDirGst, sDst = sScratchDstDir2Hst), tdTestResultSuccess() ], 3857 [ tdTestCopyFromDir(oSrc = oNonEmptyDirGst, sDst = sScratchDstDir2Hst), tdTestResultFailure() ], 3858 [ tdTestCopyFromDir(oSrc = oNonEmptyDirGst, sDst = sScratchDstDir2Hst, 3859 fFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ], 3860 # Copy the entire test tree: 3861 [ tdTestCopyFromDir(sSrc = self.oTestFiles.oTreeDir.sPath, sDst = sScratchDstDir3Hst), tdTestResultSuccess() ], 3862 ]); 3805 3863 3806 3864 #
Note:
See TracChangeset
for help on using the changeset viewer.