VirtualBox

Changeset 79324 in vbox


Ignore:
Timestamp:
Jun 25, 2019 1:39:46 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131544
Message:

ValKit/tdAddGuestCtrl.py: Finished the remove (delete) tests. bugref:9320

Location:
trunk/src/VBox/ValidationKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/base.py

    r79245 r79324  
    16381638            iRc = self.innerMain(asArgs);
    16391639        except:
     1640            reporter.logXcpt();
    16401641            try:
    16411642                self.onExit(-1);
  • trunk/src/VBox/ValidationKit/tests/additions/tdAddGuestCtrl.py

    r79318 r79324  
    390390            return reporter.errorXcpt('fsObjExists failed on "%s" after deletion (type: %s)' % (self.sPath, sType));
    391391        if fExists:
    392             return reporter.errorXcpt('fsObjExists says "%s" still exists after deletion (type: %s)!' % (self.sPath, sType));
     392            return reporter.error('fsObjExists says "%s" still exists after deletion (type: %s)!' % (self.sPath, sType));
    393393        return True;
    394394
     
    409409        except:
    410410            reporter.maybeErrXcpt(self.fRcExpect, 'Removing "%s" failed' % (self.sPath,));
    411             return False;
     411            return not self.fRcExpect;
     412        if not self.fRcExpect:
     413            return reporter.error('Expected removing "%s" to failed, but it succeeded' % (self.sPath,));
     414
    412415        return self.checkRemoved('file');
    413416
     
    426429        except:
    427430            reporter.maybeErrXcpt(self.fRcExpect, 'Removing "%s" (as a directory) failed' % (self.sPath,));
    428             return False;
     431            return not self.fRcExpect;
     432        if not self.fRcExpect:
     433            return reporter.error('Expected removing "%s" (dir) to failed, but it succeeded' % (self.sPath,));
     434
    429435        return self.checkRemoved('directory');
    430436
     
    433439    Recursively remove a directory tree.
    434440    """
    435     def __init__(self, sPath, afFlags = None, fRcExpect = True, sUser = None, sPassword = None):
     441    def __init__(self, sPath, afFlags = None, fRcExpect = True, fNotExist = False, sUser = None, sPassword = None):
    436442        tdTestRemoveBase.__init__(self, sPath, fRcExpect, sUser, sPassword);
    437443        self.afFlags = afFlags if afFlags is not None else [];
     444        self.fNotExist = fNotExist; # Hack for the ContentOnly scenario where the dir does not exist.
    438445
    439446    def execute(self, oSubTstDrv):
     
    444451            reporter.maybeErrXcpt(self.fRcExpect, 'Removing directory tree "%s" failed (afFlags=%s)'
    445452                                  % (self.sPath, self.afFlags));
    446             return False;
     453            return not self.fRcExpect;
    447454
    448455        oWrappedProgress = vboxwrappers.ProgressWrapper(oProgress, oSubTstDrv.oTstDrv.oVBoxMgr, oSubTstDrv.oTstDrv,
     
    451458        if not oWrappedProgress.isSuccess():
    452459            oWrappedProgress.logResult(fIgnoreErrors = not self.fRcExpect);
    453             return False;
    454 
    455         if vboxcon.DirectoryRemoveRecFlag_ContentOnly in self.afFlags:
     460            return not self.fRcExpect;
     461        if not self.fRcExpect:
     462            return reporter.error('Expected removing "%s" (tree) to failed, but it succeeded' % (self.sPath,));
     463
     464        if vboxcon.DirectoryRemoveRecFlag_ContentAndDir not in self.afFlags  and  not self.fNotExist:
    456465            # Cannot use directoryExists here as it is buggy.
    457466            try:
     
    34243433        """
    34253434
    3426         # Something is busted here wrt progress wrappers or something... debugging.
    3427         if self.oTstDrv.fpApiVer < 10.0:
    3428             return None;
    3429 
    34303435        #
    34313436        # Create a directory with a few files in it using TXS that we'll use for the initial tests.
     
    34613466                return reporter.error('Failed to create test file "%s"!' % (sFile,));
    34623467
    3463 
    34643468        #
    34653469        # Tear down the directories and files.
     
    34863490            tdTestRemoveFile(asTestFiles[0], fRcExpect = True),
    34873491            tdTestRemoveFile(asTestFiles[0], fRcExpect = False),
    3488             tdTestRemoveTree(asTestDirs[9], fRcExpect = False), # Have subdirs, no flags == single rmdir.
    3489             tdTestRemoveTree(asTestDirs[9], afFlags = [vboxcon.DirectoryRemoveRecFlag_ContentOnly,], fRcExpect = True),
    3490             tdTestRemoveTree(asTestDirs[9], fRcExpect = True),
    3491             tdTestRemoveTree(asTestDirs[3], fRcExpect = False), # Have subdirs & files, no flags == single rmdir.
     3492            # 17:
     3493            tdTestRemoveTree(asTestDirs[8], fRcExpect = True),  # Removes empty subdirs and leaves the dir itself.
     3494            tdTestRemoveDir(asTestDirs[8], fRcExpect = True),
     3495            tdTestRemoveTree(asTestDirs[3], fRcExpect = False), # Have subdirs & files,
    34923496            tdTestRemoveTree(asTestDirs[3], afFlags = [vboxcon.DirectoryRemoveRecFlag_ContentOnly,], fRcExpect = True),
    3493             tdTestRemoveTree(asTestDirs[3], fRcExpect = True),
     3497            tdTestRemoveDir(asTestDirs[3], fRcExpect = True),
    34943498            tdTestRemoveTree(asTestDirs[0], afFlags = [vboxcon.DirectoryRemoveRecFlag_ContentAndDir,], fRcExpect = True),
    3495             tdTestRemoveTree(asTestDirs[0], afFlags = [vboxcon.DirectoryRemoveRecFlag_ContentAndDir,], fRcExpect = False),
     3499            # No error if already delete (RTDirRemoveRecursive artifact).
     3500            tdTestRemoveTree(asTestDirs[0], afFlags = [vboxcon.DirectoryRemoveRecFlag_ContentAndDir,], fRcExpect = True),
     3501            tdTestRemoveTree(asTestDirs[0], afFlags = [vboxcon.DirectoryRemoveRecFlag_ContentOnly,],
     3502                             fNotExist = True, fRcExpect = True),
     3503            # Exception is when not specifying any flags the the guest does not call RTDirRemoveRecursive but does its own thing.
     3504            tdTestRemoveTree(asTestDirs[0], afFlags = [], fRcExpect = False),
    34963505        ];
    34973506
     
    35093518            fRc = oTest.execute(self) and fRc;
    35103519            fRc = oTest.closeSession() and fRc;
    3511 
    35123520
    35133521        if fRc is True:
Note: See TracChangeset for help on using the changeset viewer.

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