# -*- coding: utf-8 -*-
# $Id$
"""
Simple testcase for txsclient.py.
"""
__copyright__ = \
"""
Copyright (C) 2010-2014 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
"""
# Standard python imports.
import os
import sys
import types
# Validation Kit imports.
"""Checks a boolean result."""
global g_cTests, g_cFailures;
return 'PASSED';
return 'FAILED';
"""Checks a string result."""
global g_cTests, g_cFailures;
return 'PASSED';
return 'FAILED';
sAddress = 'localhost';
uPort = None;
i = 1;
if asArgs[i] == '--hostname':
i = i + 2;
elif asArgs[i] == '--port':
i = i + 2;
elif asArgs[i] == '--reversed-setup':
i = i + 1;
elif asArgs[i] == '--timeout':
i = i + 2;
elif asArgs[i] == '--reboot':
i = i + 1;
elif asArgs[i] == '--help':
print 'tst-txsclient.py [--hostname <addr|name>] [--port <num>] [--timeout <cMS>] [--reboot] [--reversed-setup]'
return 0;
else:
print 'Unknown argument: %s' % (asArgs[i]);
return 2;
if uPort is None:
else:
oSession = txsclient.openTcpSession(cMsTimeout, sAddress, uPort = uPort, fReversedSetup = fReversedSetup);
if oSession is None:
print 'openTcpSession failed';
return 1;
if fStdTests:
# Get the UUID of the remote instance.
else:
# Create and remove a directory on the scratch area.
# Create a two-level subdir.
# Check out a simple file.
print '%s: GET FILE(${SCRATCH}/howdyfile) -> "%s" expected "howdy-replaced"' % (stringRes(rc, 'howdy-replaced'), rc);
# Finally, some file uploading and downloading with unicode filenames.
strUpFile = 'tst-txsclient-upload.bin';
strDwnFile = 'tst-txsclient-download.bin';
try:
except:
print 'INFO: no urandom... falling back on a simple string.'
abRandFile = 'asdflkjasdlfkjasdlfkjq023942relwjgkna9epr865u2nm345;hndafgoukhasre5kb2453km';
abRandFile += abRandFile;
try:
oLocalFile.close();
except:
print('%s: PUT FILE(%s, ${SCRATCH}/tst-txsclient-uploaded.bin) -> %s' % (boolRes(rc), strUpFile, rc));
print('%s: GET FILE(${SCRATCH}/tst-txsclient-uploaded.bin, tst-txsclient-downloaded.txt) -> %s'
try:
oLocalFile.close();
if abRandFile == abDwnFile:
else:
print 'abRandFile=%s' % (abRandFile,);
print 'abDwnFile =%s' % (abRandFile,);
except:
except: pass;
except: pass;
# Execute some simple thing, if available.
# Intentionally skip this test if file is not available due to
# another inserted CD-ROM (e.g. not TestSuite.iso).
oStdOut='${SCRATCH}/stdout', \
oStdErr='${SCRATCH}/stderr');
print('%s: EXEC(%s there is not such parameter > ${SCRATCH}/stdout 2> ${SCRATCH}/stderr) -> %s'
print 'INFO: GET FILE(${SCRATCH}/stdout) -> "%s"' % (rc);
print 'INFO: GET FILE(${SCRATCH}/stderr) -> "%s"' % (rc);
print 'TESTING: syncExec...'
print 'TESTING: syncExec...'
#print 'TESTING: syncExec sleep 30...'
else:
print 'SKIP: Execution of %s skipped, does not exist on CD-ROM' % (sProg,);
# Execute a non-existing file on CD-ROM.
if rc is None:
else:
# Done
elif fReboot:
print 'TESTING: syncReboot...'
if g_cFailures != 0:
return 1;
print 'tst-txsclient.py: all %u tests passed!' % (g_cTests);
return 0;
if __name__ == '__main__':