import string # pylint: disable=W0402 # Only the main script needs to modify the path. # Validation Kit imports. Class for handling a guest process input/output stream. Appends and converts a byte sequence to this object; handy for displaying a guest stream. Provides the actual test environment. Should be kept ## The desired Main API result. Provides credentials to pass to the guest. Base class for all guest control tests. Note: This test ASSUMES that working Guest Additions were installed and running on the guest to be tested. ## IGuestSession reference or None. Sets the test environment required for this test. Creates (opens) a guest session. Returns (True, IGuestSession) on success or (False, None) on failure. # Just log, don't assume an error here (will be done in the main loop then). reporter.
logXcpt(
'Creating a guest session "%s" failed; sUser="%s", pw="%s", sDomain="%s":' # Be nice to Guest Additions < 4.3: They don't support session handling and # therefore return WaitFlagNotSupported. # Just log, don't assume an error here (will be done in the main loop then). reporter.
log(
'Session did not start successfully, returned wait result: %ld' \
# Just log, don't assume an error here (will be done in the main loop then). reporter.
log(
'Warning: Session already set; this is probably not what you want');
Sets the current guest session and closes Closes the guest session. # Just log, don't assume an error here (will be done in the main loop then). Test for copying files from the guest to the host. Test for copying files from the host to the guest. Test for directoryCreate call. Test for the directoryCreateTemp call. Test for the directoryOpen call. Test for the opening, reading and closing a certain directory. Specifies exactly one guest control execution test. Has a default timeout of 5 minutes (for safety). Test for the file exists API call (fileExists). Test querying guest file information. Test querying guest file information. Test for the IGuestFile object. Test for the file size query API call (fileQuerySize). Tests reading from guest files. Test the guest session handling. Helper for returning the number of currently opened guest sessions of a VM. Test the guest session environment. Tests session file (IGuestFile) reference counting. Tests session directory (IGuestDirectory) reference counting. Tests session process (IGuestProcess) reference counting. Test updating the Guest Additions inside the guest. Base class for test results. ## The overall test result. Test result for reading guest directories. Holds a guest process execution test result, including the exit code, status + aFlags. ## The overall test result. ## Desired buffer result from stdout/stderr. Use with caution! Test result for stat'ing guest files. ## @todo Add more information. Test result for reading + writing guest directories. Test result for guest session counts. Test result for guest session environment tests. Sub-test driver for executing guest control (VBoxService, IGuest) tests. 'session_basic',
'session_env',
'session_file_ref',
'session_dir_ref',
'session_proc_ref', \
'exec_basic',
'exec_errorlevel',
'exec_timeout', \
'dir_create',
'dir_create_temp',
'dir_read', \
'file_remove',
'file_stat',
'file_read',
'file_write', \
'copy_to',
'copy_from', \
if asArgs[
iArg] ==
'all':
# Nice for debugging scripts. raise base.
InvalidOption(
'The "--add-guest-ctrl-tests" value "%s" is not valid; valid values are: %s' \
Returns fRc, oTxsSession. The latter may have changed. #reporter.testStart('Session Directory References'); #fSkip = 'session_dir_ref' not in self.asTests; # fRc, oTxsSession = self.testGuestCtrlSessionDirRefs(oSession, oTxsSession, oTestVm); #reporter.testDone(fSkip); # reporter.testStart('Copy to guest'); # fSkip = 'copy_to' not in self.asTests or fRc is False; # fRc, oTxsSession = self.testGuestCtrlCopyTo(oSession, oTxsSession, oTestVm); # reporter.testDone(fSkip); # reporter.testStart('File read'); # fSkip = 'file_read' not in self.asTests or fRc is False; # fRc, oTxsSession = self.testGuestCtrlFileRead(oSession, oTxsSession, oTestVm); # reporter.testDone(fSkip); # reporter.testStart('File write'); # fSkip = 'file_write' not in self.asTests or fRc is False; # fRc, oTxsSession = self.testGuestCtrlFileWrite(oSession, oTxsSession, oTestVm); # reporter.testDone(fSkip); # Skip test for updating Guest Additions if we run on a too old (Windows) guest. Helper function to copy a single file from the guest to the host. # Just log, don't assume an error here (will be done in the main loop then). Helper function to copy a single file from host to the guest. # Just log, don't assume an error here (will be done in the main loop then). Copies files / directories to the host. Source always contains the absolute path, subDir all paths ## @todo r=bird: The use subDir and sSubDir in this method is extremely confusing!! # Just follow the coding guidelines and ALWAYS use prefixes, please! #reporter.log2('Directory="%s", filter="%s", aFlags="%s"' % (sCurDir, sFilter, aFlags)); #reporter.log2('\tSkipping "%s"' % (oFsObjInfo.name,)); continue;
# Skip "." and ".." entries. #reporter.log2('\tDirectory "%s"' % (oFsObjInfo.name,)); # Just log, don't assume an error here (will be done in the main loop then). #reporter.log2('\tFile "%s"' % (oFsObjInfo.name,)); #reporter.log2('\tSymlink "%s" -- not tested yet' % oFsObjInfo.name); reporter.
error(
'\tDirectory "%s" contains invalid directory entry "%s" (%d)' \
# No necessarily an error -- could be VBOX_E_OBJECT_NOT_FOUND. See reference. #reporter.log2('\tNo more directory entries for "%s"' % (sCurDir,)); # Just log, don't assume an error here (will be done in the main loop then). # Just log, don't assume an error here (will be done in the main loop then). Copies files / directories to the guest. Source always contains the absolute path, subDir all paths below it. # Note: Current test might want to test copying empty sources # Note: Symlinks intentionally not considered here. # Just log, don't assume an error here (will be done in the main loop then). Helper function to create a guest directory specified in # Directory does not exist but we want it to. # Just log, don't assume an error here (will be done in the main loop then). # Directory creation failed, which was the expected result. Helper function to read a guest directory specified in cDirs =
0;
# Number of directories read. cFiles =
0;
# Number of files read. #reporter.log2('Directory="%s", filter="%s", aFlags="%s"' % (sCurDir, sFilter, aFlags)); #reporter.log2('\tSkipping "%s"' % oFsObjInfo.name); continue;
# Skip "." and ".." entries. #reporter.log2('\tDirectory "%s"' % oFsObjInfo.name); #reporter.log2('\tFile "%s"' % oFsObjInfo.name); #reporter.log2('\tSymlink "%s" -- not tested yet' % oFsObjInfo.name); reporter.
error(
'\tDirectory "%s" contains invalid directory entry "%s" (type %d)' % \
# No necessarily an error -- could be VBOX_E_OBJECT_NOT_FOUND. See reference. #reporter.log2('\tNo more directory entries for "%s"' % (sCurDir,)); # Just log, don't assume an error here (will be done in the main loop then). # Just log, don't assume an error here (will be done in the main loop then). Wrapper function around gctrlExecute to provide more sanity checking when needed in actual execution tests. # Compare exit status / code on successful process execution. reporter.
error(
'Test #%d failed: Got exit status + code %d,%d, expected %d,%d' % \
# Compare test / result buffers on successful process execution. reporter.
error(
'Test #%d failed: Got buffer\n%s (%ld bytes), expected\n%s (%ld bytes)' %
reporter.
error(
'Test #%d failed: Got no buffer data, expected\n%s (%dbytes)' %
reporter.
error(
'Test #%d failed: Got %ld stdout data, expected %ld' Helper function to execute a program on a guest, specified in ## @todo Compare execution timeouts! #tsStart = base.timestampMilli(); reporter.
log2(
'Using session user=%s, sDomain=%s, session name=%s, session timeout=%ld' \
reporter.
log2(
'Executing cmd=%s, aFlags=%s, timeout=%ld, args=%s, env=%s' \
## @todo Add vboxcon.ProcessWaitForFlag_StdIn. reporter.
log2(
'Process (PID %ld) started, waiting for termination (%dms), waitFlags=%s ...' \
oTest.
sBuf =
buf;
# Appending does *not* work atm, so just assign it. No time now. oTest.
sBuf =
buf;
# Appending does *not* work atm, so just assign it. No time now. pass;
#reporter.log2('Process (PID %ld) needs stdin data' % (curProc.pid,)); # Just skip reads which returned nothing. # Just log, don't assume an error here (will be done in the main loop then). Tests the guest session environment. reporter.
log(
'Testing #%d, user="%s", sPassword="%s", env="%s" (%d)...' \
reporter.
error(
'Test #%d failed: Session creation failed: Got %s, expected True' % (i,
fRc2));
# Make sure environment is empty. reporter.
log2(
'Test #%d: Single key="%s", value="%s" (%d) ...' \
# Setting environment variables might fail (e.g. if empty name specified). Check. reporter.
logXcpt(
'Test #%d failed: Setting environment variable failed:' % (i,));
reporter.
error(
'Test #%d failed: Session environment has %d vars, expected %d' \
reporter.
log(
'Test #%d: API reported an error (single), good' % (i,));
reporter.
error(
'Test #%d failed: Got environment variable "%s", expected "%s" (key: "%s")' \
# Getting back an empty value when specifying an invalid key is fine. reporter.
error(
'Test #%d failed: Got (undecoded) environment variable "%s", ' \
'expected "%s" (key: "%s")' \
reporter.
log(
'Test #%d: API reported an error (invalid key "%s"), good' % (i,
strKey));
# Set the same stuff again, this time all at once using the array. ## @todo No return (e.g. boolean) value available thru wrapper. #curGuestSession.environmentSetArray(curTest.aEnv); # Setting environment variables might fail (e.g. if empty name specified). Check. reporter.
error(
'Test #%d failed: Session environment has %d vars, expected %d (array)' \
reporter.
log(
'Test #%d: API reported an error (array), good' % (i,));
## @todo Get current system environment and add it to curRes.cNumVars before comparing! reporter.
error(
'Test #%d failed: Session environment has %d vars (%s), expected %d' \
reporter.
error(
'Test #%d failed: Session environment has %d vars, expected 0');
reporter.
error(
'Test #%d failed: Session could not be closed' % (i,));
Tests the guest session handling. # User account without a passwort - forbidden. # Note: On Guest Additions < 4.3 this always succeeds because these don't # support creating dedicated sessions. Instead, guest process creation # then will fail. See note below. reporter.
log(
'Testing #%d, user="%s", sPassword="%s", sDomain="%s" ...' \
# See note about < 4.3 Guest Additions above. reporter.
error(
'Test #%d failed: Session creation failed: Got %s, expected %s' \
# On Guest Additions < 4.3 getSessionCount() always will return 1, so skip the reporter.
error(
'Test #%d failed: Session count does not match: Got %d, expected %d' \
reporter.
error(
'Test #%d failed: Session name does not match: Got "%s", expected "%s"' \
reporter.
error(
'Test #%d failed: Session could not be closed' % (i,));
# Actually, this is 32, but we don't test session 0. reporter.
log2(
'Opening multiple guest tsessions at once ...');
reporter.
log(
'MultiSession #%d exceeded concurrent guest session count, good' % (i,));
# Make sure that accessing the first opened guest session does not work anymore because we just removed (closed) it. reporter.
logXcpt(
'Could not access first removed MultiSession object, good:');
# Try Accessing last opened session which did not get removed yet. ## @todo Test session timeouts. Tests the guest session file reference handling. sFile =
"C:\\windows\\system32\\kernel32.dll";
# Number of stale guest files to create. "testGuestCtrlSessionFileRefs");
# Be nice to Guest Additions < 4.3: They don't support session handling and # therefore return WaitFlagNotSupported. # Just log, don't assume an error here (will be done in the main loop then). reporter.
log(
'Session did not start successfully, returned wait result: %ld' \
# Open guest files and "forget" them (stale entries). # For them we don't have any references anymore intentionally. # Note: Use a timeout in the call above for not letting the stale processes # hanging around forever. This can happen if the installed Guest Additions # do not support terminating guest processes. # Open non-stale files and close them again. # Here we count the stale files (that is, files we don't have a reference # anymore for) and the opened and then closed non-stale files (that we still keep # a reference in aaFiles[] for). reporter.
error(
'Test failed: Got %ld total files, expected %ld' \
# Check if all (referenced) non-stale files now are in "closed" state. reporter.
log2(
'Checking statuses of all non-stale files ...');
reporter.
error(
'Test failed: Non-stale file #%ld has status %ld, expected %ld' \
# Now try to close the session and see what happens. #def testGuestCtrlSessionDirRefs(self, oSession, oTxsSession, oTestVm): # Tests the guest session directory reference handling. # return (fRc, oTxsSession); Tests the guest session process reference handling. sCmd =
"C:\\windows\\system32\\cmd.exe";
# Number of stale guest processes to create. "testGuestCtrlSessionProcRefs");
# Be nice to Guest Additions < 4.3: They don't support session handling and # therefore return WaitFlagNotSupported. # Just log, don't assume an error here (will be done in the main loop then). reporter.
log(
'Session did not start successfully, returned wait result: %ld' \
# Fire off forever-running processes and "forget" them (stale entries). # For them we don't have any references anymore intentionally. # Note: Use a timeout in the call above for not letting the stale processes # hanging around forever. This can happen if the installed Guest Additions # do not support terminating guest processes. # Fire off non-stale processes and wait for termination. sArgs = [
'/C',
'dir',
'/S',
'C:\\Windows\\system'];
reporter.
log2(
'Waiting for non-stale processes to terminate');
reporter.
error(
'Test failed: Waiting for non-stale processes #%ld' ' resulted in status %ld, expected %ld' \
# Here we count the stale processes (that is, processes we don't have a reference # anymore for) and the started + terminated non-stale processes (that we still keep # a reference in aaProcs[] for). reporter.
error(
'Test failed: Got %ld total processes, expected %ld' \
# Check if all (referenced) non-stale processes now are in "terminated" state. reporter.
error(
'Test failed: Non-stale processes #%ld has status %ld, expected %ld' \
# Fire off blocking processes which are terminated via terminate(). sArgs = [
'/C',
'dir',
'/S',
'C:\\Windows'];
# Note: Use a timeout in the call above for not letting the stale processes # hanging around forever. This can happen if the installed Guest Additions # do not support terminating guest processes. except:
# Termination might not be supported, just skip and log it. if cProcs != (
cStaleProcs *
2):
# Still should be 20 processes because we terminated the 10 newest ones. # Now try to close the session and see what happens. Tests the basic execution feature. sImageOut =
"C:\\windows\\system32\\cmd.exe";
reporter.
error(
'Implement me!');
## @todo Implement non-Windows bits. # Non-existent / invalid image. # Use an invalid format string. # Enable as soon as ERROR_BAD_DEVICE is implemented. #[ tdTestExec(sCmd = "CON", sUser = sUser, sPassword = sPassword), # tdTestResultExec(fRc = False) ] ## @todo Get path of installed Guest Additions. Later. [
tdTestExec(
sCmd =
"C:\\Program Files\\Oracle\\VirtualBox Guest Additions\\VBoxControl.exe",
# [ tdTestExec(sCmd = sImageOut, aArgs = [ '/C', 'set', 'TEST_NONEXIST' ], # sUser = sUser, sPassword = sPassword), # tdTestResultExec(fRc = True, iExitCode = 1) ] # [ tdTestExec(sCmd = sImageOut, aArgs = [ '/C', 'set', 'windir' ], # sUser = sUser, sPassword = sPassword, # aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut, vboxcon.ProcessCreateFlag_WaitForStdErr ]), # tdTestResultExec(fRc = True, sBuf = 'windir=C:\\WINDOWS\r\n') ], # [ tdTestExec(sCmd = sImageOut, aArgs = [ '/C', 'set', 'TEST_FOO' ], # sUser = sUser, sPassword = sPassword, # aEnv = [ 'TEST_FOO=BAR' ], # aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut, vboxcon.ProcessCreateFlag_WaitForStdErr ]), # tdTestResultExec(fRc = True, sBuf = 'TEST_FOO=BAR\r\n') ], # [ tdTestExec(sCmd = sImageOut, aArgs = [ '/C', 'set', 'TEST_FOO' ], # sUser = sUser, sPassword = sPassword, # aEnv = [ 'TEST_FOO=BAR', 'TEST_BAZ=BAR' ], # aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut, vboxcon.ProcessCreateFlag_WaitForStdErr ]), # tdTestResultExec(fRc = True, sBuf = 'TEST_FOO=BAR\r\n') ] ## @todo Create some files (or get files) we know the output size of to validate output length! ## @todo Add task which gets killed at some random time while letting the guest output something. # Manual test, not executed automatically. reporter.
log(
'No OS-specific tests for non-Windows yet!');
# Build up the final test array for the first batch. # Single execution stuff. Nice for debugging. # First batch: One session per guest process. reporter.
error(
'Test #%d failed: Could not create session' % (i,));
reporter.
log(
'Now using one guest session for all tests ...');
# Second batch: One session for *all* guest processes. reporter.
error(
'Session did not start successfully, returned wait result: %ld' \
# Just log, don't assume an error here (will be done in the main loop then). # Note: Not waiting for the guest session to start here # is intentional. This must be handled by the process execution # Just log, don't assume an error here (will be done in the main loop then). Tests handling of error levels from started guest processes. sImage =
"C:\\windows\\system32\\cmd.exe";
reporter.
error(
'Implement me!');
## @todo Implement non-Windows bits. # [ tdTestExec(sCmd = sImage, aArgs = [ '/C', 'dir', 'c:\\windows\\system32' ], # sUser = sUser, sPassword = sPassword, aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut ]), # tdTestResultExec(fRc = True, iExitCode = 0) ], # [ tdTestExec(sCmd = sImage, aArgs = [ '/C', 'dir', 'c:\\nonexisting-file' ], # sUser = sUser, sPassword = sPassword, aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut ]), # tdTestResultExec(fRc = True, iExitCode = 1) ], # [ tdTestExec(sCmd = sImage, aArgs = [ '/C', 'dir', 'c:\\nonexisting-dir\\' ], # sUser = sUser, sPassword = sPassword, aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut ]), # tdTestResultExec(fRc = True, iExitCode = 1) ], # [ tdTestExec(sCmd = sImage, aArgs = [ '/C', 'dir', 'c:\\windows\\system32' ], # sUser = sUser, sPassword = sPassword, aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdErr ]), # tdTestResultExec(fRc = True, iExitCode = 0) ], # [ tdTestExec(sCmd = sImage, aArgs = [ '/C', 'dir', 'c:\\nonexisting-file' ], # sUser = sUser, sPassword = sPassword, aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdErr ]), # tdTestResultExec(fRc = True, iExitCode = 1) ], # [ tdTestExec(sCmd = sImage, aArgs = [ '/C', 'dir', 'c:\\nonexisting-dir\\' ], # sUser = sUser, sPassword = sPassword, aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdErr ]), # tdTestResultExec(fRc = True, iExitCode = 1) ], # [ tdTestExec(sCmd = sImage, aArgs = [ '/C', 'dir', 'c:\\windows\\system32' ], # sUser = sUser, sPassword = sPassword, # aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut, vboxcon.ProcessCreateFlag_WaitForStdErr ]), # tdTestResultExec(fRc = True, iExitCode = 0) ], # [ tdTestExec(sCmd = sImage, aArgs = [ '/C', 'dir', 'c:\\nonexisting-file' ], # sUser = sUser, sPassword = sPassword, # aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut, vboxcon.ProcessCreateFlag_WaitForStdErr ]), # tdTestResultExec(fRc = True, iExitCode = 1) ], # [ tdTestExec(sCmd = sImage, aArgs = [ '/C', 'dir', 'c:\\nonexisting-dir\\' ], # sUser = sUser, sPassword = sPassword, # aFlags = [ vboxcon.ProcessCreateFlag_WaitForStdOut, vboxcon.ProcessCreateFlag_WaitForStdErr ]), # tdTestResultExec(fRc = True, iExitCode = 1) ] reporter.
log(
'No OS-specific tests for non-Windows yet!');
reporter.
error(
'Test #%d failed: Could not create session' % (i,));
Tests handling of timeouts of started guest processes. sImage =
"C:\\windows\\system32\\cmd.exe";
reporter.
error(
'Implement me!');
## @todo Implement non-Windows bits. # Create a process which never terminates and should timeout when # waiting for termination. reporter.
log(
'Waiting for process 1 being started ...');
reporter.
error(
'Waiting for process 1 to start failed, got status %ld');
reporter.
log(
'Waiting for process 1 to time out within 1ms ...');
reporter.
error(
'Waiting for process 1 did not time out when it should (1)');
reporter.
log(
'Waiting for process 1 timed out (1), good');
reporter.
log(
'Waiting for process 1 to time out within 5000ms ...');
reporter.
error(
'Waiting for process 1 did not time out when it should, got wait result %ld' % (
waitRes,));
reporter.
log(
'Waiting for process 1 timed out (5000), good');
## @todo Add curProc.terminate() as soon as it's implemented. # Create a lengthly running guest process which will be killed by VBoxService on the # guest because it ran out of execution time (5 seconds). reporter.
log(
'Waiting for process 2 being started ...');
reporter.
error(
'Waiting for process 1 to start failed, got status %ld');
reporter.
log(
'Waiting for process 2 to get killed because it ran out of execution time ...');
reporter.
error(
'Waiting for process 2 did not time out when it should, got wait result %ld' \
reporter.
log(
'Waiting for process 2 indicated an error, good');
reporter.
error(
'Status of process 2 wrong; excepted %ld, got %ld' \
## @todo Add curProc.terminate() as soon as it's implemented. Tests creation of guest directories. sScratch =
"C:\\Temp\\vboxtest\\testGuestCtrlDirCreate\\";
# Following two should fail on Windows (paths too long). Both should timeout. reporter.
log(
'No OS-specific tests for non-Windows yet!');
reporter.
error(
'Test #%d failed: Could not create session' % (i,));
Tests creation of temporary directories. # if oTestVm.isWindows(): # sScratch = "C:\\Temp\\vboxtest\\testGuestCtrlDirCreateTemp\\"; # FIXME: Failing test. Non Windows path # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'bar', # tdTestResult(fRc = False) ] reporter.
log(
'No OS-specific tests for non-Windows yet!');
# [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # sDirectory = sScratch), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # sDirectory = sScratch), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'X', # sDirectory = sScratch), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'X', # sDirectory = sScratch), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # sDirectory = sScratch, fSecure = True), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # sDirectory = sScratch, fSecure = True), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # sDirectory = sScratch, fSecure = True), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # sDirectory = sScratch, fSecure = True), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # fSecure = True, fMode = 0700), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # fSecure = True, fMode = 0700), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # fSecure = True, fMode = 0755), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = 'XXX', # fSecure = True, fMode = 0755), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, # sTemplate = "XXX-".join(random.choice(string.ascii_lowercase) for i in range(32)), # fSecure = True, fMode = 0755), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = "".join('X' for i in range(32)), # fSecure = True, fMode = 0755), # tdTestResult(fRc = True) ], # [ tdTestDirCreateTemp(sUser = sUser, sPassword = sPassword, sTemplate = "".join('X' for i in range(128)), # fSecure = True, fMode = 0755), # tdTestResult(fRc = True) ] reporter.
log(
'Testing #%d, sTemplate="%s", fMode=%#o, path="%s", secure="%s" ...' %
reporter.
error(
'Test #%d failed: Could not create session' % (i,));
Tests opening and reading (enumerating) guest directories. reporter.
log(
'No OS-specific tests for non-Windows yet!');
reporter.
error(
'Test #%d failed: Could not create session' % (i,));
Tests removing guest files. # Try to delete system files. # Try delete some unimportant media stuff. # Second attempt should fail. reporter.
log(
'No OS-specific tests for non-Windows yet!');
reporter.
error(
'Test #%d failed: Could not create session' % (i,));
Tests querying file information through stat. # Directories; should fail. reporter.
log(
'No OS-specific tests for non-Windows yet!');
reporter.
error(
'Test #%d failed: Could not create session' % (i,));
## @todo Add more checks later. Tests reading from guest files. # Opening non-existing file when it should exist. # Create a file which must not exist (but it hopefully does). # Open a file which must exist. # Try truncating a file which already is opened with a different sharing mode (and thus should fail). # Reading from beginning. curTest =
aTest[
0];
# tdTestFileReadWrite, use an index, later. reporter.
log(
'Testing #%d, sFile="%s", cbToReadWrite=%d, sOpenMode="%s", sDisposition="%s", cbOffset=%ld ...' % \
reporter.
error(
'Test #%d failed: Could not create session' % (i,));
reporter.
error(
'Test #%d failed: Initial offset on open does not match: Got %ld, expected %ld' \
## @todo Split this up in 64K reads. Later. reporter.
error(
'Test #%d failed: Read buffer length does not match: Got %ld, expected %ld' \
reporter.
error(
'Test #%d failed: Got buffer\n%s (%ld bytes), expected\n%s (%ld bytes)' \
reporter.
error(
'Test #%d failed: Final offset does not match: Got %ld, expected %ld' \
Tests writing to guest files. sScratch =
"C:\\Temp\\vboxtest\\testGuestCtrlFileWrite\\";
# Write to a non-existing file. # Append the same amount of data to the just created file. curTest =
aTest[
0];
# tdTestFileReadWrite, use an index, later. reporter.
log(
'Testing #%d, sFile="%s", cbToReadWrite=%d, sOpenMode="%s", sDisposition="%s", cbOffset=%ld ...' % \
reporter.
error(
'Test #%d failed: Could not create session' % (i,));
reporter.
error(
'Test #%d failed: Initial offset on open does not match: Got %ld, expected %ld' \
## @todo Split this up in 64K writes. Later. reporter.
error(
'Test #%d failed: Written buffer length does not match: Got %ld, expected %ld' \
# Verify written content by seeking back to the initial offset and # re-read & compare the written data. reporter.
error(
'Test #%d failed: Initial write position does not match current position, \ reporter.
error(
'Test #%d failed: Got buffer length %ld, expected %ld' \
reporter.
error(
'Test #%d failed: Final offset does not match: Got %ld, expected %ld' \
Tests copying files from host to the guest. sScratch =
"C:\\Temp\\vboxtest\\testGuestCtrlCopyTo\\";
# Some stupid trickery to guess the location of the iso. reporter.
log(
'Warning: Validation Kit .ISO not found -- some tests might fail');
# Nothing to copy (source and/or destination is empty). # Destination is a directory, should fail. ## @todo Add testing the CopyTo flags here! ## @todo Check for Windows (7) host. # Copying directories with contain files we don't have read access to. # Copying directories with regular files. reporter.
log(
'No OS-specific tests for non-Windows yet!');
reporter.
log(
'Testing #%d, sSrc="%s", sDst="%s", aFlags="%s" ...' % \
reporter.
error(
'Test #%d failed: Could not create session' % (i,));
## @todo Verify the copied results (size, checksum?). Tests copying files from guest to the host. # Nothing to copy (sDst is empty / unreachable). ## @todo Add testing the CopyFrom aFlags here! # [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll', # sDst = 'C:\\non-exist\\'), tdTestResult(fRc = False) ], # [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll', # sDst = 'C:\\non\\exist\\'), tdTestResult(fRc = False) ], # [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll', # sDst = 'C:\\non\\exist\\renamedfile.dll'), tdTestResult(fRc = False) ], # [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll', # sDst = os.path.join(sScratch, 'renamedfile.dll')), tdTestResult(fRc = True) ], # [ tdTestCopyFrom(sUser = sUser, sPassword = sPassword, sSrc = 'C:\\Windows\\system32\\ole32.dll', # sDst = os.path.join(sScratch, 'renamedfile.dll')), tdTestResult(fRc = True) ], # Destination is a directory, should fail. ## @todo Add testing the CopyFrom aFlags here! reporter.
log(
'No OS-specific tests for non-Windows yet!');
reporter.
log(
'Testing #%d, sSrc="%s", sDst="%s", aFlags="%s" ...' % \
reporter.
error(
'Test #%d failed: Could not create session' % (i,));
## @todo Verify the copied results (size, checksum?). Tests updating the Guest Additions inside the guest. # Some stupid trickery to guess the location of the iso. reporter.
log(
'Warning: Validation Kit .ISO not found -- some tests might fail');
# Test the (optional) installer arguments. This will extract the # installer into our guest's scratch directory. # Some debg ISO. Only enable locally. #[ tdTestUpdateAdditions(sUser = sUser, sPassword = sPassword, # sSrc = "V:\\Downloads\\VBoxGuestAdditions-r80354.iso"), # tdTestResult(fRc = True) ] reporter.
log(
'No OS-specific tests for non-Windows yet!');
reporter.
log(
'Testing #%d, sSrc="%s", aFlags="%s" ...' % \
reporter.
error(
'Test #%d failed: Could not create session' % (i,));
reporter.
log(
'Waiting for updating Guest Additions failed');
reporter.
logXcpt(
'Updating Guest Additions waiting exception for sSrc="%s", aFlags="%s":' \
# Just log, don't assume an error here (will be done in the main loop then). reporter.
logXcpt(
'Updating Guest Additions exception for sSrc="%s", aFlags="%s":' \
## @todo Verify if Guest Additions were really updated (build, revision, ...). Guest control using VBoxService on the guest. Shows the testdriver usage. reporter.
log(
' Same as --virt-modes hwvirt --cpu-counts 1.');
Parses the testdriver arguments from the command line. # Test execution helpers. Runs the specified VM thru the tests. Returns a success indicator on the general test execution. This is not fManual =
False;
# Manual override for local testing. (Committed version shall be False.) Helper function to report an error of a Helper function to return the remaining time (in ms) based from a timeout value and the start time (both in ms). return 0xFFFFFFFE;
# Wait forever. return 0;
# No time left. For manually testing certain bits. sCmd =
'c:\\windows\\system32\\cmd.exe';
aArgs = [
'/C',
'dir',
'/S',
'c:\\windows' ];