def _installVBox(self):
        """
        Download / copy the build files into the scratch area and install them.
        """
        reporter.testStart('Installing VirtualBox');
        reporter.log('CWD=%s' % (os.getcwd(),)); # curious

        #
        # Download the build files.
        #
        for i in range(len(self._asBuildUrls)):
            if webutils.downloadFile(self._asBuildUrls[i], self._asBuildFiles[i],
                                     self.sBuildPath, reporter.log, reporter.log) is not True:
                reporter.testDone(fSkipped = True);
                return None; # Failed to get binaries, probably deleted. Skip the test run.

        #
        # Unpack anything we know what is and append it to the build files
        # list.  This allows us to use VBoxAll*.tar.gz files.
        #
        for sFile in list(self._asBuildFiles):
            if self._maybeUnpackArchive(sFile, fNonFatal = True) is not True:
                reporter.testDone(fSkipped = True);
                return None; # Failed to unpack. Probably local error, like busy
                             # DLLs on windows, no reason for failing the build.

        #
        # Go to system specific installation code.
        #
        sHost = utils.getHostOs()
        if   sHost == 'darwin':     fRc = self._installVBoxOnDarwin();
        elif sHost == 'linux':      fRc = self._installVBoxOnLinux();
        elif sHost == 'solaris':    fRc = self._installVBoxOnSolaris();
        elif sHost == 'win':        fRc = self._installVBoxOnWindows();
        else:
            reporter.error('Unsupported host "%s".' % (sHost,));
        if fRc is False:
            reporter.testFailure('Installation error.');
        elif fRc is not True:
            reporter.log('Seems installation was skipped. Old version lurking behind? Not the fault of this build/test run!');

        #
        # Install the extension pack.
        #
        if fRc is True  and  self._fAutoInstallPuelExtPack:
            fRc = self._installExtPack();
            if fRc is False:
                reporter.testFailure('Extension pack installation error.');

        # Some debugging...
        try:
            cMbFreeSpace = utils.getDiskUsage(self.sScratchPath);
            reporter.log('Disk usage after VBox install: %d MB available at %s' % (cMbFreeSpace, self.sScratchPath,));
        except:
            reporter.logXcpt('Unable to get disk free space. Ignored. Continuing.');

        reporter.testDone(fRc is None);
        return fRc;
Esempio n. 2
0
    def _installVBox(self):
        """
        Download / copy the build files into the scratch area and install them.
        """
        reporter.testStart('Installing VirtualBox');
        reporter.log('CWD=%s' % (os.getcwd(),)); # curious

        #
        # Download the build files.
        #
        for i in range(len(self._asBuildUrls)):
            if webutils.downloadFile(self._asBuildUrls[i], self._asBuildFiles[i],
                                     self.sBuildPath, reporter.log, reporter.log) is not True:
                reporter.testDone(fSkipped = True);
                return None; # Failed to get binaries, probably deleted. Skip the test run.

        #
        # Unpack anything we know what is and append it to the build files
        # list.  This allows us to use VBoxAll*.tar.gz files.
        #
        for sFile in list(self._asBuildFiles):
            if self._maybeUnpackArchive(sFile, fNonFatal = True) is not True:
                reporter.testDone(fSkipped = True);
                return None; # Failed to unpack. Probably local error, like busy
                             # DLLs on windows, no reason for failing the build.

        #
        # Go to system specific installation code.
        #
        sHost = utils.getHostOs()
        if   sHost == 'darwin':     fRc = self._installVBoxOnDarwin();
        elif sHost == 'linux':      fRc = self._installVBoxOnLinux();
        elif sHost == 'solaris':    fRc = self._installVBoxOnSolaris();
        elif sHost == 'win':        fRc = self._installVBoxOnWindows();
        else:
            reporter.error('Unsupported host "%s".' % (sHost,));
        if fRc is False:
            reporter.testFailure('Installation error.');
        elif fRc is not True:
            reporter.log('Seems installation was skipped. Old version lurking behind? Not the fault of this build/test run!');

        #
        # Install the extension pack.
        #
        if fRc is True  and  self._fAutoInstallPuelExtPack:
            fRc = self._installExtPack();
            if fRc is False:
                reporter.testFailure('Extension pack installation error.');

        # Some debugging...
        try:
            cMbFreeSpace = utils.getDiskUsage(self.sScratchPath);
            reporter.log('Disk usage after VBox install: %d MB available at %s' % (cMbFreeSpace, self.sScratchPath,));
        except:
            reporter.logXcpt('Unable to get disk free space. Ignored. Continuing.');

        reporter.testDone(fRc is None);
        return fRc;
Esempio n. 3
0
    def testIt(self, oTestVm, oSession, oTxsSession):
        """
        Executes the test.

        Returns fRc, oTxsSession.  The latter may have changed.
        """
        reporter.log("Active tests: %s" % (self.asTests, ))

        #
        # Skip the test if before 6.0
        #
        if self.oTstDrv.fpApiVer < 6.0:
            reporter.log('Requires 6.0 or later (for now)')
            return (None, oTxsSession)

        # Guess a free mount point inside the guest.
        if oTestVm.isWindows() or oTestVm.isOS2():
            self.sGuestSlash = '\\'
        else:
            self.sGuestSlash = '/'

        #
        # Create the host directory to share. Empty except for a 'candle.dir' subdir
        # that we use to check that it mounted correctly.
        #
        sShareName1 = 'shfl1'
        sShareHostPath1 = os.path.join(self.oTstDrv.sScratchPath, sShareName1)
        reporter.log2('Creating shared host folder "%s"...' %
                      (sShareHostPath1, ))
        if os.path.exists(sShareHostPath1):
            try:
                shutil.rmtree(sShareHostPath1)
            except:
                return (reporter.errorXcpt('shutil.rmtree(%s)' %
                                           (sShareHostPath1, )), oTxsSession)
        try:
            os.mkdir(sShareHostPath1)
        except:
            return (reporter.errorXcpt('os.mkdir(%s)' % (sShareHostPath1, )),
                    oTxsSession)
        try:
            os.mkdir(os.path.join(sShareHostPath1, 'candle.dir'))
        except:
            return (reporter.errorXcpt('os.mkdir(%s)' % (sShareHostPath1, )),
                    oTxsSession)

        # Guess a free mount point inside the guest.
        if oTestVm.isWindows() or oTestVm.isOS2():
            sMountPoint1 = 'V:'
        else:
            sMountPoint1 = '/mnt/' + sShareName1

        fRc = self.mountShare(oSession, oTxsSession, sShareName1,
                              sShareHostPath1, sMountPoint1)
        if fRc is not True:
            return (False, oTxsSession)
            # skip the remainder if we cannot auto mount the folder.

        #
        # Run FsPerf inside the guest.
        #
        fSkip = 'fsperf' not in self.asTests
        if fSkip is False:
            cMbFree = utils.getDiskUsage(sShareHostPath1)
            if cMbFree >= 16:
                reporter.log2('Free space: %u MBs' % (cMbFree, ))
            else:
                reporter.log('Skipping FsPerf because only %u MB free on %s' %
                             (
                                 cMbFree,
                                 sShareHostPath1,
                             ))
                fSkip = True
        if fSkip is False:
            # Common arguments:
            asArgs = [
                'FsPerf', '-d',
                sMountPoint1 + self.sGuestSlash + 'fstestdir-1', '-s8'
            ]

            # Skip part of mmap on older windows systems without CcCoherencyFlushAndPurgeCache (>= w7).
            reporter.log2('oTestVm.sGuestOsType=%s' % (oTestVm.sGuestOsType, ))
            if   oTestVm.getNonCanonicalGuestOsType() \
              in [ 'WindowsNT3x', 'WindowsNT4', 'Windows2000', 'WindowsXP', 'WindowsXP_64', 'Windows2003',
                   'Windows2003_64', 'WindowsVista', 'WindowsVista_64', 'Windows2008', 'Windows2008_64']:
                asArgs.append('--no-mmap-coherency')

            # Configure I/O block sizes according to guest memory size:
            cbMbRam = 128
            try:
                cbMbRam = oSession.o.machine.memorySize
            except:
                reporter.errorXcpt()
            reporter.log2('cbMbRam=%s' % (cbMbRam, ))
            asArgs.append('--set-block-size=1')
            asArgs.append('--add-block-size=512')
            asArgs.append('--add-block-size=4096')
            asArgs.append('--add-block-size=16384')
            asArgs.append('--add-block-size=65536')
            asArgs.append('--add-block-size=1048576')
            #   1 MiB
            if cbMbRam >= 512:
                asArgs.append('--add-block-size=33554432')
                #  32 MiB
            if cbMbRam >= 768:
                asArgs.append('--add-block-size=134217728')
                # 128 MiB

            # Putting lots (10000) of files in a single directory causes issues on OS X
            # (HFS+ presumably, though could be slow disks) and some linuxes (slow disks,
            # maybe ext2/3?).  So, generally reduce the file count to 4096 everywhere
            # since we're not here to test the host file systems, and 3072 on macs.
            if utils.getHostOs() in [
                    'darwin',
            ]:
                asArgs.append('--many-files=3072')
            elif utils.getHostOs() in [
                    'linux',
            ]:
                asArgs.append('--many-files=4096')

            # Add the extra arguments from the command line and kick it off:
            asArgs.extend(self.asExtraArgs)

            # Run FsPerf:
            reporter.log2('Starting guest FsPerf (%s)...' % (asArgs, ))
            sFsPerfPath = self._locateGstFsPerf(oTxsSession)

            ## @todo For some odd reason the combined GA/VaKit .ISO (by IPRT/fs/isomakercmd)
            #        sometimes (?) contains FsPerf as non-executable (-r--r--r-- 1 root root) on Linux.
            #
            #        So work around this for now by copying the desired FsPerf binary to the temp directory,
            #        make it executable and execute it from there.
            fISOMakerCmdIsBuggy = oTestVm.isLinux()
            if fISOMakerCmdIsBuggy:
                sFsPerfPathTemp = oTestVm.pathJoin(
                    self.oTstDrv.getGuestTempDir(oTestVm), 'FsPerf${EXESUFF}')
                if oTestVm.isWindows() \
                or oTestVm.isOS2():
                    sCopy = self.oTstDrv.getGuestSystemShell()
                    sCopyArgs = (sCopy, "/C", "copy", "/Y", sFsPerfPath,
                                 sFsPerfPathTemp)
                else:
                    sCopy = oTestVm.pathJoin(
                        self.oTstDrv.getGuestSystemDir(oTestVm), 'cp')
                    sCopyArgs = (sCopy, "-a", "-v", sFsPerfPath,
                                 sFsPerfPathTemp)
                fRc = self.oTstDrv.txsRunTest(oTxsSession,
                                              'Copying FsPerf',
                                              60 * 1000,
                                              sCopy,
                                              sCopyArgs,
                                              fCheckSessionStatus=True)
                fRc = fRc and oTxsSession.syncChMod(sFsPerfPathTemp, 0o755)
                if fRc:
                    sFsPerfPath = sFsPerfPathTemp

            fRc = self.oTstDrv.txsRunTest(oTxsSession,
                                          'Running FsPerf',
                                          90 * 60 * 1000,
                                          sFsPerfPath,
                                          asArgs,
                                          fCheckSessionStatus=True)
            reporter.log2('FsPerf -> %s' % (fRc, ))
            if fRc:
                # Do a bit of diagnosis to find out why this failed.
                if     not oTestVm.isWindows() \
                   and not oTestVm.isOS2():
                    sCmdLs = oTestVm.pathJoin(
                        self.oTstDrv.getGuestSystemDir(oTestVm), 'ls')
                    oTxsSession.syncExec(sCmdLs, (sCmdLs, "-al", sFsPerfPath),
                                         fIgnoreErrors=True)
                    oTxsSession.syncExec(sCmdLs, (sCmdLs, "-al", "-R", "/opt"),
                                         fIgnoreErrors=True)
                    oTxsSession.syncExec(sCmdLs,
                                         (sCmdLs, "-al", "-R", "/media/cdrom"),
                                         fIgnoreErrors=True)

            sTestDir = os.path.join(sShareHostPath1, 'fstestdir-1')
            if os.path.exists(sTestDir):
                fRc = reporter.errorXcpt('test directory lingers: %s' %
                                         (sTestDir, ))
                try:
                    shutil.rmtree(sTestDir)
                except:
                    fRc = reporter.errorXcpt('shutil.rmtree(%s)' %
                                             (sTestDir, ))
        else:
            reporter.testStart('FsPerf')
            reporter.testDone(fSkip or fRc is None)

        #
        # Check if auto-unmounting works.
        #
        if fRc is True:
            fRc = self.unmountShare(oSession, oTxsSession, sShareName1,
                                    sMountPoint1)

        ## @todo Add tests for multiple automount shares, random unmounting, reboot test.

        return (fRc, oTxsSession)
    def testIt(self, oTestVm, oSession, oTxsSession):
        """
        Executes the test.

        Returns fRc, oTxsSession.  The latter may have changed.
        """
        reporter.log("Active tests: %s" % (self.asTests, ))

        #
        # Skip the test if before 6.0
        #
        if self.oTstDrv.fpApiVer < 6.0:
            reporter.log('Requires 6.0 or later (for now)')
            return (None, oTxsSession)

        #
        # Create the host directory to share. Empty except for a 'candle.dir' subdir
        # that we use to check that it mounted correctly.
        #
        sSharedFolder1 = os.path.join(self.oTstDrv.sScratchPath, 'shfl1')
        reporter.log2('Creating shared host folder "%s"...' %
                      (sSharedFolder1, ))
        if os.path.exists(sSharedFolder1):
            try:
                shutil.rmtree(sSharedFolder1)
            except:
                return (reporter.errorXcpt('shutil.rmtree(%s)' %
                                           (sSharedFolder1, )), oTxsSession)
        try:
            os.mkdir(sSharedFolder1)
        except:
            return (reporter.errorXcpt('os.mkdir(%s)' % (sSharedFolder1, )),
                    oTxsSession)
        try:
            os.mkdir(os.path.join(sSharedFolder1, 'candle.dir'))
        except:
            return (reporter.errorXcpt('os.mkdir(%s)' % (sSharedFolder1, )),
                    oTxsSession)

        # Guess a free mount point inside the guest.
        if oTestVm.isWindows() or oTestVm.isOS2():
            sMountPoint1 = 'V:'
            sGuestSlash = '\\'
        else:
            sMountPoint1 = '/mnt/shfl1'
            sGuestSlash = '/'

        #
        # Automount a shared folder in the guest.
        #
        reporter.testStart('Automount')

        reporter.log2('Creating shared folder shfl1...')
        try:
            oConsole = oSession.o.console
            oConsole.createSharedFolder('shfl1', sSharedFolder1, True, True,
                                        sMountPoint1)
        except:
            reporter.errorXcpt('createSharedFolder(shfl1,%s,True,True,%s)' %
                               (sSharedFolder1, sMountPoint1))
            reporter.testDone()
            return (False, oTxsSession)

        # Check whether we can see the shared folder now.  Retry for 30 seconds.
        msStart = base.timestampMilli()
        while True:
            fRc = oTxsSession.syncIsDir(sMountPoint1 + sGuestSlash +
                                        'candle.dir')
            reporter.log2('candle.dir check -> %s' % (fRc, ))
            if fRc is not False:
                break
            if base.timestampMilli() - msStart > 30000:
                reporter.error('Shared folder mounting timed out!')
                break
            self.oTstDrv.sleep(1)

        reporter.testDone()
        if fRc is not True:
            return (False, oTxsSession)
            # skip the remainder if we cannot auto mount the folder.

        #
        # Run FsPerf inside the guest.
        #
        fSkip = 'fsperf' not in self.asTests
        if fSkip is False:
            cMbFree = utils.getDiskUsage(sSharedFolder1)
            if cMbFree >= 16:
                reporter.log2('Free space: %u MBs' % (cMbFree, ))
            else:
                reporter.log('Skipping FsPerf because only %u MB free on %s' %
                             (
                                 cMbFree,
                                 sSharedFolder1,
                             ))
                fSkip = True
        if fSkip is False:
            # Common arguments:
            asArgs = [
                'FsPerf', '-d', sMountPoint1 + sGuestSlash + 'fstestdir-1',
                '-s8'
            ]

            # Skip part of mmap on older windows systems without CcCoherencyFlushAndPurgeCache (>= w7).
            reporter.log2('oTestVm.sGuestOsType=%s' % (oTestVm.sGuestOsType, ))
            if   oTestVm.getNonCanonicalGuestOsType() \
              in [ 'WindowsNT3x', 'WindowsNT4', 'Windows2000', 'WindowsXP', 'WindowsXP_64', 'Windows2003',
                   'Windows2003_64', 'WindowsVista', 'WindowsVista_64', 'Windows2008', 'Windows2008_64']:
                asArgs.append('--no-mmap-coherency')

            # Configure I/O block sizes according to guest memory size:
            cbMbRam = 128
            try:
                cbMbRam = oSession.o.machine.memorySize
            except:
                reporter.errorXcpt()
            reporter.log2('cbMbRam=%s' % (cbMbRam, ))
            asArgs.append('--set-block-size=1')
            asArgs.append('--add-block-size=512')
            asArgs.append('--add-block-size=4096')
            asArgs.append('--add-block-size=16384')
            asArgs.append('--add-block-size=65536')
            asArgs.append('--add-block-size=1048576')
            #   1 MiB
            if cbMbRam >= 512:
                asArgs.append('--add-block-size=33554432')
                #  32 MiB
            if cbMbRam >= 768:
                asArgs.append('--add-block-size=134217728')
                # 128 MiB

            # Putting lots (10000) of files in a single directory causes issues on OS X
            # (HFS+ presumably, though could be slow disks) and some linuxes (slow disks,
            # maybe ext2/3?).  So, generally reduce the file count to 4096 everywhere
            # since we're not here to test the host file systems, and 3072 on macs.
            if utils.getHostOs() in [
                    'darwin',
            ]:
                asArgs.append('--many-files=3072')
            elif utils.getHostOs() in [
                    'linux',
            ]:
                asArgs.append('--many-files=4096')

            # Add the extra arguments from the command line and kick it off:
            asArgs.extend(self.asExtraArgs)

            # Run FsPerf:
            reporter.log2('Starting guest FsPerf (%s)...' % (asArgs, ))
            sFsPerfPath = self._locateGstFsPerf(oTxsSession)
            fRc = self.oTstDrv.txsRunTest(oTxsSession, 'FsPerf',
                                          30 * 60 * 1000, sFsPerfPath, asArgs)
            reporter.log2('FsPerf -> %s' % (fRc, ))

            sTestDir = os.path.join(sSharedFolder1, 'fstestdir-1')
            if os.path.exists(sTestDir):
                fRc = reporter.errorXcpt('test directory lingers: %s' %
                                         (sTestDir, ))
                try:
                    shutil.rmtree(sTestDir)
                except:
                    fRc = reporter.errorXcpt('shutil.rmtree(%s)' %
                                             (sTestDir, ))
        else:
            reporter.testStart('FsPerf')
            reporter.testDone(fSkip or fRc is None)

        return (fRc, oTxsSession)