VirtualBox

Ignore:
Timestamp:
Nov 4, 2022 11:17:21 AM (2 years ago)
Author:
vboxsync
Message:

Guest Control/Main: Rewrite of the path building and directory walking code for the copyFrom / copyTo guest session tasks, to (hopefully) have a cleaner structure. The new path building now also takes into account whether a destination has a trailing delimiter and then act accordingly (see rules in GuestPath::BuildDestinationPath()). Adjusted VBoxManage and FE/Qt to also reflect that; should now work as common tools like cp. Added new test cases and also re-enabled old ones which were disabled since quite a while (should pass now). ​bugref:10286

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py

    r96407 r97395  
    48654865        if self.oTstDrv.fpApiVer > 5.2: # Copying directories via Main is supported only in versions > 5.2.
    48664866            atTests.extend([
     4867                # Without a trailing slash added to the destination this should fail,
     4868                # as the destination directory already exist.
     4869                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst),   tdTestResultFailure() ],
     4870                # Same existing host directory, but this time with DirectoryCopyFlag_CopyIntoExisting set.
     4871                # This should copy the contents of oEmptyDirGst to sScratchDstDir1Hst (empty, but anyway).
    48674872                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst,
    48684873                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]),  tdTestResultSuccess() ],
     
    48704875                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst,
    48714876                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]),  tdTestResultSuccess() ],
    4872                 # Should fail, as destination directory already exists.
    4873                 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst),   tdTestResultFailure() ],
    4874                 # Try again with trailing slash, should yield the same result:
    4875                 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir2Gst + oTestVm.pathSep(),
    4876                                   afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]),  tdTestResultSuccess() ],
    4877                 # Try again.
    4878                 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir2Gst + oTestVm.pathSep(),
    4879                                   afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]),  tdTestResultSuccess() ],
    4880                 # Should fail, as destination directory already exists.
    4881                 [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir2Gst + oTestVm.pathSep()),
    4882                   tdTestResultFailure() ],
     4877                # With a trailing slash added to the destination, copy the empty guest directory
     4878                # (should end up as sScratchHst/empty):
     4879                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst + os.path.sep), tdTestResultSuccess() ],
     4880                # Repeat -- this time it should fail, as the destination directory already exists (and
     4881                # DirectoryCopyFlag_CopyIntoExisting is not specified):
     4882                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst + os.path.sep), tdTestResultFailure() ],
     4883                # Add the DirectoryCopyFlag_CopyIntoExisting flag being set and it should work.
     4884                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = sScratchDstDir1Gst + os.path.sep,
     4885                                  afFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],
    48834886                # Copy with a different destination name just for the heck of it:
    4884                 # disabled at the moment, causes test failures due to the non-existing target
    4885                 #[ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = oTestVm.pathJoin(sScratchDstDir1Gst, 'empty2')),
    4886                 #  tdTestResultSuccess() ],
     4887                [ tdTestCopyToDir(sSrc = sScratchEmptyDirHst, sDst = oTestVm.pathJoin(sScratchDstDir1Gst, 'empty2')),
     4888                  tdTestResultSuccess() ],
    48874889            ]);
    48884890            atTests.extend([
    48894891                # Now the same using a directory with files in it:
    4890                 [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst,
    4891                                   afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]),   tdTestResultSuccess() ],
     4892                [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir2Gst,
     4893                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],
    48924894                # Again.
    4893                 [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst,
    4894                                   afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]),   tdTestResultSuccess() ],
    4895                 # Should fail, as directory is existing already.
    4896                 [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir3Gst), tdTestResultFailure() ],
     4895                [ tdTestCopyToDir(sSrc = sScratchNonEmptyDirHst, sDst = sScratchDstDir2Gst,
     4896                                  afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],
    48974897            ]);
    48984898            atTests.extend([
    48994899                # Copy the entire test tree:
    4900                 [ tdTestCopyToDir(sSrc = sScratchTreeDirHst, sDst = sScratchDstDir4Gst,
    4901                                   afFlags = [vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],
     4900                [ tdTestCopyToDir(sSrc = sScratchTreeDirHst, sDst = sScratchDstDir3Gst + os.path.sep), tdTestResultSuccess() ],
     4901                # Again, should fail this time.
     4902                [ tdTestCopyToDir(sSrc = sScratchTreeDirHst, sDst = sScratchDstDir3Gst + os.path.sep), tdTestResultFailure() ],
    49024903            ]);
    49034904
     
    49434944        oExistingFileGst        = self.oTestFiles.chooseRandomFile();
    49444945        oNonEmptyDirGst         = self.oTestFiles.chooseRandomDirFromTree(fNonEmpty = True);
     4946        oTreeDirGst             = self.oTestFiles.oTreeDir;
    49454947        oEmptyDirGst            = self.oTestFiles.oEmptyDir;
    49464948
     
    50505052            #
    50515053            atTests.extend([
    5052                 # Copy the empty guest directory (should end up as sScratchHst/empty):
    5053                 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst), tdTestResultSuccess() ],
     5054                # Without a trailing slash added to the destination this should fail,
     5055                # as the destination directory already exist.
     5056                [ tdTestCopyFromDir(sSrc = oEmptyDirGst.sPath, sDst = sScratchDstDir1Hst), tdTestResultFailure() ],
     5057                # Same existing host directory, but this time with DirectoryCopyFlag_CopyIntoExisting set.
     5058                # This should copy the contents of oEmptyDirGst to sScratchDstDir1Hst (empty, but anyway).
     5059                [ tdTestCopyFromDir(sSrc = oEmptyDirGst.sPath, sDst = sScratchDstDir1Hst,
     5060                                    afFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],
     5061                # Try again.
     5062                [ tdTestCopyFromDir(sSrc = oEmptyDirGst.sPath, sDst = sScratchDstDir1Hst,
     5063                                    afFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],
     5064                # With a trailing slash added to the destination, copy the empty guest directory
     5065                # (should end up as sScratchHst/empty):
     5066                [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst + os.path.sep), tdTestResultSuccess() ],
    50545067                # Repeat -- this time it should fail, as the destination directory already exists (and
    50555068                # DirectoryCopyFlag_CopyIntoExisting is not specified):
    5056                 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst), tdTestResultFailure() ],
     5069                [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst + os.path.sep), tdTestResultFailure() ],
    50575070                # Add the DirectoryCopyFlag_CopyIntoExisting flag being set and it should work.
    5058                 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst,
    5059                                     afFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],
    5060                 # Try again with trailing slash, should yield the same result:
    5061                 [ tdTestRemoveHostDir(os.path.join(sScratchDstDir1Hst, 'empty')), tdTestResult() ],
    5062                 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst + os.path.sep),
    5063                   tdTestResultSuccess() ],
    5064                 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst + os.path.sep),
    5065                   tdTestResultFailure() ],
    50665071                [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = sScratchDstDir1Hst + os.path.sep,
    50675072                                    afFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],
    50685073                # Copy with a different destination name just for the heck of it:
    5069                 [ tdTestCopyFromDir(oSrc = oEmptyDirGst, sDst = os.path.join(sScratchHst, 'empty2'), fIntoDst = True),
    5070                   tdTestResultFailure() ],
    5071         ## bird 2021-12-15: These seems to be failing a lot, so I've temporarily disabled them.  Please debug and re-enable.
    5072         ##        # Now the same using a directory with files in it:
    5073         ##        [ tdTestCopyFromDir(oSrc = oNonEmptyDirGst, sDst = sScratchDstDir2Hst), tdTestResultSuccess() ],
    5074         ##        [ tdTestCopyFromDir(oSrc = oNonEmptyDirGst, sDst = sScratchDstDir2Hst), tdTestResultFailure() ],
    5075         ##        [ tdTestCopyFromDir(oSrc = oNonEmptyDirGst, sDst = sScratchDstDir2Hst,
    5076         ##                            afFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],
    5077         ##        # Copy the entire test tree:
    5078         ##        [ tdTestCopyFromDir(sSrc = self.oTestFiles.oTreeDir.sPath, sDst = sScratchDstDir3Hst), tdTestResultSuccess() ],
     5074                [ tdTestCopyFromDir(sSrc = oEmptyDirGst.sPath, sDst = os.path.join(sScratchHst, 'empty2'), fIntoDst = True),
     5075                  tdTestResultSuccess() ],
     5076            ]);
     5077            atTests.extend([
     5078                # Now the same using a directory with files in it:
     5079                [ tdTestCopyFromDir(oSrc = oNonEmptyDirGst, sDst = sScratchDstDir2Hst + os.path.sep), tdTestResultSuccess() ],
     5080                # Again.
     5081                [ tdTestCopyFromDir(oSrc = oNonEmptyDirGst, sDst = sScratchDstDir2Hst, fIntoDst = True,
     5082                                    afFlags = [ vboxcon.DirectoryCopyFlag_CopyIntoExisting, ]), tdTestResultSuccess() ],
     5083            ]);
     5084            atTests.extend([
     5085                # Copy the entire test tree:
     5086                [ tdTestCopyFromDir(oSrc = oTreeDirGst, sDst = sScratchDstDir3Hst + os.path.sep), tdTestResultSuccess() ],
     5087                # Again, should fail this time.
     5088                [ tdTestCopyFromDir(oSrc = oTreeDirGst, sDst = sScratchDstDir3Hst + os.path.sep), tdTestResultFailure() ],
    50795089            ]);
    50805090
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette