本文整理汇总了Python中testdriver.reporter.testStart函数的典型用法代码示例。如果您正苦于以下问题:Python testStart函数的具体用法?Python testStart怎么用?Python testStart使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了testStart函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test1Sub5
def test1Sub5(self, oVmSrc, oVmDst):
"""
Test that basic teleporting works.
xTracker: #4749
"""
reporter.testStart('Simple teleportation');
for cSecsX2 in range(0, 10):
if self.test1ResetVmConfig(oVmSrc, fTeleporterEnabled = False) \
and self.test1ResetVmConfig(oVmDst, fTeleporterEnabled = True):
# Start the target VM.
oSessionDst, oProgressDst = self.startVmEx(oVmDst, fWait = False);
if oSessionDst is not None:
if oProgressDst.waitForOperation(iOperation = -3) == 0:
# Start the source VM.
oSessionSrc = self.startVm(oVmSrc);
if oSessionSrc is not None:
self.sleep(cSecsX2 / 2);
# Try teleport.
oProgressSrc = oSessionSrc.teleport('localhost', 6502, 'password');
if oProgressSrc:
oProgressSrc.wait();
oProgressDst.wait();
self.terminateVmBySession(oSessionSrc, oProgressSrc);
self.terminateVmBySession(oSessionDst, oProgressDst);
else:
reporter.testFailure('reconfig failed');
return reporter.testDone()[1] == 0;
示例2: testSnapshotTreeDepth
def testSnapshotTreeDepth(self):
"""
Test snapshot tree depth.
"""
reporter.testStart('snapshotTreeDepth')
try:
oVM = self.createTestVM('test-snap', 1, None, 4)
assert oVM is not None
# modify the VM config, create and attach empty HDD
oSession = self.openSession(oVM)
sHddPath = os.path.join(self.sScratchPath, 'TestSnapEmpty.vdi')
fRc = True
fRc = fRc and oSession.createAndAttachHd(sHddPath, cb=1024*1024, sController='SATA Controller', fImmutable=False)
fRc = fRc and oSession.saveSettings()
# take 250 snapshots (snapshot tree depth limit)
for i in range(1, 251):
fRc = fRc and oSession.takeSnapshot('Snapshot ' + str(i))
fRc = oSession.close() and fRc
# unregister and re-register to test loading of settings
sSettingsFile = oVM.settingsFilePath
reporter.log('unregistering VM')
oVM.unregister(vboxcon.CleanupMode_DetachAllReturnNone)
oVBox = self.oVBoxMgr.getVirtualBox()
reporter.log('opening VM %s, testing config reading' % (sSettingsFile))
oVM = oVBox.openMachine(sSettingsFile)
assert fRc is True
except:
reporter.errorXcpt()
return reporter.testDone()[1] == 0
示例3: getNextTestCfg
def getNextTestCfg(self, fSkippedLast = False):
"""
Returns the next not blacklisted test config or an empty list if
there is no test left.
"""
asTestCfgCur = self.getCurrentTestCfg();
asTestCfg = self.advanceTestCfg();
while len(asTestCfg) > 0 and self.isTestCfgBlacklisted(asTestCfg):
asTestCfg = self.advanceTestCfg();
# Compare the current and next config and close the approriate test
# categories.
reporter.testDone(fSkippedLast);
if len(asTestCfg) > 0:
idxSame = 0;
while asTestCfgCur[idxSame] == asTestCfg[idxSame]:
idxSame += 1;
for i in range(idxSame, len(asTestCfg) - 1):
reporter.testDone();
for i in range(idxSame, len(asTestCfg)):
reporter.testStart('%s' % (self.getTestIdString(asTestCfg[i], i)));
else:
# No more tests, mark all tests as done
for i in range(0, len(asTestCfgCur) - 1):
reporter.testDone();
return asTestCfg;
示例4: testBenchmark
def testBenchmark(self, sTargetOs, sBenchmark, sMountpoint, oExecutor):
"""
Runs the given benchmark on the test host.
"""
# Create a basic config
dCfg = {
'RecordSize': '64k',
'TestsetSize': '100m',
'QueueDepth': '32',
'FilePath': sMountpoint,
'TargetOs': sTargetOs
};
oTst = None;
if sBenchmark == 'iozone':
oTst = IozoneTest(oExecutor, dCfg);
elif sBenchmark == 'fio':
oTst = FioTest(oExecutor, dCfg); # pylint: disable=R0204
if oTst is not None:
reporter.testStart(sBenchmark);
fRc = oTst.prepare();
if fRc:
fRc = oTst.run();
if fRc:
fRc = oTst.reportResult();
else:
reporter.testFailure('Running the testcase failed');
else:
reporter.testFailure('Preparing the testcase failed');
oTst.cleanup();
reporter.testDone();
return fRc;
示例5: test1Sub3
def test1Sub3(self, oVM):
"""
Test that starting a teleportation target VM will fail if we give it
a bad address to bind to.
"""
reporter.testStart('bad IMachine::teleporterAddress');
# re-configure it with a bad bind-to address.
fRc = False;
oSession = self.openSession(oVM);
if oSession is not None:
fRc = oSession.setupTeleporter(True, uPort=6502, sAddress='no.such.hostname.should.ever.exist.duh');
if not oSession.saveSettings(fClose=True): fRc = False;
oSession = None;
if fRc:
# Try start it.
oSession, oProgress = self.startVmEx(oVM, fWait = False);
if oSession is not None:
oProgress.wait();
## TODO: exact error code and look for the IPRT right string.
if not oProgress.isCompleted() or oProgress.getResult() >= 0:
reporter.testFailure('%s' % (oProgress.stringifyResult(),));
self.terminateVmBySession(oSession, oProgress);
# put back the old teleporter setup.
self.test1ResetVmConfig(oVM, fTeleporterEnabled = True);
else:
reporter.testFailure('reconfig #1 failed');
return reporter.testDone()[1] == 0;
示例6: testOneVmConfig
def testOneVmConfig(self, oVM, oTestVm):
"""
Install guest OS and wait for result
"""
self.logVmInfo(oVM)
reporter.testStart('Installing %s' % (oTestVm.sVmName,))
cMsTimeout = 40*60000;
if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
cMsTimeout = 180 * 60000; # will be adjusted down.
oSession, _ = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = False, cMsTimeout = cMsTimeout);
if oSession is not None:
# The guest has connected to TXS, so we're done (for now anyways).
reporter.log('Guest reported success')
## @todo Do save + restore.
reporter.testDone()
fRc = self.terminateVmBySession(oSession)
return fRc is True
reporter.error('Installation of %s has failed' % (oTestVm.sVmName,))
oTestVm.detatchAndDeleteHd(self); # Save space.
reporter.testDone()
return False
示例7: test1
def test1(self):
"""
Executes test #1 - Negative API testing.
ASSUMES that the VMs are
"""
reporter.testStart('Test 1');
# Get the VMs.
#oVmHwVirt1 = self.getVmByName('tst-empty-hwvirt-1');
#oVmHwVirt2 = self.getVmByName('tst-empty-hwvirt-2');
oVmRaw1 = self.getVmByName('tst-empty-raw-1');
oVmRaw2 = self.getVmByName('tst-empty-raw-2');
# Reset their teleportation related configuration.
fRc = True;
#for oVM in (oVmHwVirt1, oVmHwVirt2, oVmRaw1, oVmRaw2):
for oVM in (oVmRaw1, oVmRaw2):
if not self.test1ResetVmConfig(oVM): fRc = False;
# Do the testing (don't both with fRc on the subtests).
if fRc:
self.test1Sub1(oVmRaw1);
self.test1Sub2(oVmRaw2);
self.test1Sub3(oVmRaw2);
self.test1Sub4(oVmRaw2);
self.processPendingEvents();
self.test1Sub5(oVmRaw1, oVmRaw2);
self.test1Sub6(oVmRaw1, oVmRaw2);
self.test1Sub7(oVmRaw1, oVmRaw2);
else:
reporter.testFailure('Failed to reset the VM configs')
return reporter.testDone()[1] == 0;
示例8: _installVBox
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;
示例9: test1Sub7
def test1Sub7(self, oVmSrc, oVmDst):
"""
Test the password check.
"""
reporter.testStart('Bad password')
if self.test1ResetVmConfig(oVmSrc, fTeleporterEnabled = False) \
and self.test1ResetVmConfig(oVmDst, fTeleporterEnabled = True):
# Start the target VM.
oSessionDst, oProgressDst = self.startVmEx(
oVmDst, fWait=False)
if oSessionDst is not None:
if oProgressDst.waitForOperation(iOperation=-3) == 0:
# Start the source VM.
oSessionSrc = self.startVm(oVmSrc)
if oSessionSrc is not None:
tsPasswords = (
'password-bad',
'passwor',
'pass',
'p',
'',
'Password',
)
for sPassword in tsPasswords:
reporter.testStart(sPassword)
oProgressSrc = oSessionSrc.teleport(
'localhost', 6502, sPassword)
if oProgressSrc:
oProgressSrc.wait()
reporter.log(
'src: %s' % oProgressSrc.stringifyResult())
if oProgressSrc.isSuccess():
reporter.testFailure(
'IConsole::teleport succeeded with bad password "%s"'
% sPassword)
elif oProgressSrc.getErrInfoResultCode(
) != vbox.ComError.E_FAIL:
reporter.testFailure('IConsole::teleport returns %s instead of E_FAIL' \
% (vbox.ComError.toString(oProgressSrc.getErrInfoResultCode()),))
elif oProgressSrc.getErrInfoText(
) != 'Invalid password':
reporter.testFailure('IConsole::teleport returns "%s" instead of "Invalid password"' \
% (oProgressSrc.getErrInfoText(),))
elif oProgressDst.isCompleted():
reporter.testFailure('Destination completed unexpectedly after bad password "%s"' \
% sPassword)
else:
reporter.testFailure(
'IConsole::teleport failed with password "%s"'
% sPassword)
if reporter.testDone()[1] != 0:
break
self.terminateVmBySession(oSessionSrc, oProgressSrc)
self.terminateVmBySession(oSessionDst, oProgressDst)
else:
reporter.testFailure('reconfig failed')
return reporter.testDone()[1] == 0
示例10: testAutostartForOneVM
def testAutostartForOneVM(self, sVmName):
"""
Runs one VM thru the various configurations.
"""
reporter.testStart(sVmName);
fRc = True;
self.testAutostartOneCfg(sVmName);
reporter.testDone();
return fRc;
示例11: test1RunTestProgs
def test1RunTestProgs(self, oSession, oTxsSession, fRc, sTestName):
"""
Runs all the test programs on the test machine.
"""
reporter.testStart(sTestName);
# Prepare test disk, just create filesystem without partition
reporter.testStart('mkfs.ext4');
fRc = self.txsRunTest(oTxsSession, 'Create FS', 60000,
'/sbin/mkfs.ext4',
('mkfs.ext4', '-F', '/dev/vboxtest'));
reporter.testDone();
reporter.testStart('mount');
fRc = self.txsRunTest(oTxsSession, 'Mount FS', 30000,
'/bin/mount',
('mount', '/dev/vboxtest', '/mnt'));
reporter.testDone();
reporter.testStart('iozone');
if fRc and 'iozone' in self.asTests:
oStdOut = IozoneStdOutWrapper();
fRc = self.txsRunTestRedirectStd(oTxsSession, '2G', 3600000,
'/usr/bin/iozone',
('iozone', '-r', '64k', '-s', '2g', '-t', '1', '-T', '-I',
'-H', '32','-F', '/mnt/iozone'),
(), '', '/dev/null', oStdOut, '/dev/null', '/dev/null');
if fRc is True:
reporter.log("Initial writer: " + str(oStdOut.getInitWriter()));
reporter.log("Rewriter: " + str(oStdOut.getRewriter()));
reporter.log("Initial reader: " + str(oStdOut.getReader()));
reporter.log("Re-reader: " + str(oStdOut.getRereader()));
reporter.log("Reverse reader: " + str(oStdOut.getReverseReader()));
reporter.log("Stride reader: " + str(oStdOut.getStrideReader()));
reporter.log("Random reader: " + str(oStdOut.getRandomReader()));
reporter.log("Mixed Workload: " + str(oStdOut.getMixedWorkload()));
reporter.log("Random writer: " + str(oStdOut.getRandomWriter()));
reporter.log("pwrite Writer: " + str(oStdOut.getPWrite()));
reporter.log("pread Reader: " + str(oStdOut.getPRead()));
reporter.testDone();
else:
reporter.testDone(fSkipped = True);
reporter.testStart('fio');
if fRc and 'fio' in self.asTests:
oFioWrapper = FioWrapper('64k', '2g', '32', '/mnt');
fRc = self.txsUploadString(oSession, oTxsSession, oFioWrapper.getConfig(), '${SCRATCH}/aio-test');
fRc = fRc and self.txsRunTestRedirectStd(oTxsSession, '2G', 3600000,
'/usr/bin/fio', ('fio', '${SCRATCH}/aio-test'),
(), '', '/dev/null', oFioWrapper, '/dev/null', '/dev/null');
else:
reporter.testDone(fSkipped = True);
reporter.testDone(not fRc);
return fRc;
示例12: test1UploadFile
def test1UploadFile(self, oSession, oTxsSession):
"""
Uploads a test file to the test machine.
"""
reporter.testStart('Upload file');
fRc = self.txsUploadString(oSession, oTxsSession, self.sRndData, '${SCRATCH}/' + str(uuid.uuid4()), \
cMsTimeout = 3600 * 1000);
reporter.testDone(not fRc);
return fRc;
示例13: doTest
def doTest(self, oSession):
oConsole = oSession.console
oGuest = oConsole.guest
sOSTypeId = oGuest.OSTypeId.lower()
if sOSTypeId.find("win") == -1 :
reporter.log("Only Windows guests are currently supported")
reporter.testDone()
return True
oGuestSession = oGuest.createSession("Administrator", "password", "", "Audio Validation Kit")
guestSessionWaitResult = oGuestSession.waitFor(self.oVBoxMgr.constants.GuestSessionWaitResult_Start, 2000)
reporter.log("guestSessionWaitResult = %d" % guestSessionWaitResult)
for duration in range(3, 6):
reporter.testStart("Checking for duration of " + str(duration) + " seconds")
sPathToPlayer = "D:\\win\\" + ("amd64" if (sOSTypeId.find('_64') >= 0) else "x86") + "\\ntPlayToneWaveX.exe"
oProcess = oGuestSession.processCreate(sPathToPlayer, ["xxx0", "--total-duration-in-secs", str(duration)], [], [], 0)
processWaitResult = oProcess.waitFor(self.oVBoxMgr.constants.ProcessWaitForFlag_Start, 1000)
reporter.log("Started: pid %d, waitResult %d" % (oProcess.PID, processWaitResult))
processWaitResult = oProcess.waitFor(self.oVBoxMgr.constants.ProcessWaitForFlag_Terminate, 2 * duration * 1000)
reporter.log("Terminated: pid %d, waitResult %d" % (oProcess.PID, processWaitResult))
time.sleep(1) # Give audio backend sometime to save a stream to .wav file
absFileName = self.seekLatestAudioFileName(oGuestSession, duration)
if absFileName is None:
reporter.testFailure("Unable to find audio file")
continue
reporter.log("Checking audio file '" + absFileName + "'")
diff = self.checkGuestHostTimings(absFileName + ".timing")
if diff is not None:
if diff > 0.0: # Guest sends data quicker than a host can play
if diff > 0.01: # 1% is probably good threshold here
reporter.testFailure("Guest sends audio buffers too quickly")
else:
diff = -diff; # Much worse case: guest sends data very slow, host feels starvation
if diff > 0.005: # 0.5% is probably good threshold here
reporter.testFailure("Guest sends audio buffers too slowly")
reporter.testDone()
else:
reporter.testFailure("Unable to parse a file with timings")
oGuestSession.close()
del oGuest
del oConsole
return True
示例14: test1OneVM
def test1OneVM(self, sVmName, asSkipNicTypes=(), asSupVirtModes=None, rSupCpus=range(1, 256)):
"""
Runs one VM thru the various configurations.
"""
if asSupVirtModes is None:
asSupVirtModes = self.asVirtModes
reporter.testStart(sVmName)
fRc = True
for sNicType in self.asNicTypes:
if sNicType in asSkipNicTypes:
continue
reporter.testStart(sNicType)
if sNicType == "E1000":
eNicType = vboxcon.NetworkAdapterType_I82545EM
elif sNicType == "PCNet":
eNicType = vboxcon.NetworkAdapterType_Am79C973
elif sNicType == "Virtio":
eNicType = vboxcon.NetworkAdapterType_Virtio
else:
eNicType = None
for cCpus in self.acCpus:
if cCpus == 1:
reporter.testStart("1 cpu")
else:
reporter.testStart("%u cpus" % (cCpus))
for sVirtMode in self.asVirtModes:
if sVirtMode == "raw" and cCpus > 1:
continue
if cCpus not in rSupCpus:
continue
if sVirtMode not in asSupVirtModes:
continue
hsVirtModeDesc = {}
hsVirtModeDesc["raw"] = "Raw-mode"
hsVirtModeDesc["hwvirt"] = "HwVirt"
hsVirtModeDesc["hwvirt-np"] = "NestedPaging"
reporter.testStart(hsVirtModeDesc[sVirtMode])
fHwVirt = sVirtMode != "raw"
fNestedPaging = sVirtMode == "hwvirt-np"
fRc = self.test1OneCfg(sVmName, eNicType, cCpus, fHwVirt, fNestedPaging) and fRc and True
# pychecker hack.
reporter.testDone()
reporter.testDone()
reporter.testDone()
reporter.testDone()
return fRc
示例15: test1Sub1DoTeleport
def test1Sub1DoTeleport(self, oSession, sHostname, uPort, sPassword, cMsMaxDowntime, hrcExpected, sTestName):
""" Do a bad IConsole::teleport call and check the result."""
reporter.testStart(sTestName);
fRc = False;
try:
oProgress = oSession.o.console.teleport(sHostname, uPort, sPassword, cMsMaxDowntime);
except vbox.ComException, oXcpt:
if vbox.ComError.equal(oXcpt, hrcExpected):
fRc = True;
else:
reporter.testFailure('hresult %s, expected %s' \
% (vbox.ComError.toString(oXcpt.hresult),
vbox.ComError.toString(hrcExpected)));