# -*- coding: utf-8 -*-
"""
AUtostart testcase using.
"""
__copyright__ = \
"""
Copyright (C) 2013 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 re;
import array;
# Only the main script needs to modify the path.
try: __file__
g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
# Validation Kit imports.
""" Parser for VBoxManage list runningvms """
"""file.read"""
_ = cb;
return "";
"""VBoxManage stdout write"""
# Extract the value
if idxVmNameStart is -1:
raise Exception('VBoxManageStdOutWrapper: Invalid output');
idxVmNameStart += 1;
idxVmNameEnd += 1;
return None;
"""
Base autostart helper class to provide common methods.
"""
"""
Returns a filepath based on the given regex and path to look into
or None if no matching file is found.
"""
return None;
"""
Creates a autostart config for VirtualBox
"""
for sUserAllow in asUserAllow:
for sUserDeny in asUserDeny:
return sVBoxCfg;
"""
Autostart support methods for Linux guests.
"""
"""
Install VirtualBox in the guest.
"""
if self.sTestBuild is not None:
return fRc;
asUserAllow = (), asUserDeny = ()):
"""
Configures the autostart feature in the guest.
"""
# Create autostart database directory writeable for everyone
# Create /etc/default/virtualbox
sVBoxCfg = 'VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg\n' \
+ 'VBOXAUTOSTART_DB=/etc/vbox/autostart.d\n';
fRc = fRc and self.oTestDriver.txsUploadString(oSession, oTxsSession, sVBoxCfg, '/etc/default/virtualbox');
fRc = fRc and self.oTestDriver.txsUploadString(oSession, oTxsSession, sVBoxCfg, '/etc/vbox/autostart.cfg');
return fRc;
"""
Create a new user with the given name
"""
return fRc;
# pylint: disable=R0913
"""
Runs a program as the specififed user
"""
return fRc;
# pylint: enable=R0913
"""
Create a test VM in the guest and enable autostart.
"""
_ = oSession;
'/opt/VirtualBox/VBoxManage', sUser,
'/opt/VirtualBox/VBoxManage', sUser,
'/opt/VirtualBox/VBoxManage', sUser,
return fRc;
"""
Check for VM running in the guest after autostart.
"""
_ = oSession;
else:
return fRc;
"""
Autostart support methods for Darwin guests.
"""
_ = sTestBuildDir;
"""
Install VirtualBox in the guest.
"""
_ = oSession;
_ = oTxsSession;
return False;
"""
Configures the autostart feature in the guest.
"""
_ = oSession;
_ = oTxsSession;
return False;
"""
Create a test VM in the guest and enable autostart.
"""
_ = oSession;
_ = oTxsSession;
return False;
"""
Check for VM running in the guest after autostart.
"""
_ = oSession;
_ = oTxsSession;
return False;
"""
Autostart support methods for Solaris guests.
"""
"""
Install VirtualBox in the guest.
"""
if self.sTestBuild is not None:
# Construct the .pkg filename from the tar.gz name.
if oMatch is not None:
'${SCRATCH}/' + sTestBuildFilename, \
'${SCRATCH}/' + sTestBuildFilename, \
'-n', '-a', '${SCRATCH}/autoresponse', 'SUNWvbox'));
return fRc;
asUserAllow = (), asUserDeny = ()):
"""
Configures the autostart feature in the guest.
"""
fRc = fRc and self.oTestDriver.txsUploadString(oSession, oTxsSession, sVBoxCfg, '/etc/vbox/autostart.cfg');
'setprop', 'config/config=/etc/vbox/autostart.cfg'));
return fRc;
"""
Create a new user with the given name
"""
return fRc;
# pylint: disable=R0913
"""
Runs a program as the specififed user
"""
return fRc;
# pylint: enable=R0913
"""
Create a test VM in the guest and enable autostart.
"""
_ = oSession;
'/opt/VirtualBox/VBoxManage', sUser,
'/opt/VirtualBox/VBoxManage', sUser,
return fRc;
"""
Check for VM running in the guest after autostart.
"""
_ = oSession;
else:
return fRc;
"""
Autostart support methods for Windows guests.
"""
_ = sTestBuildDir;
return;
"""
Install VirtualBox in the guest.
"""
_ = oSession;
_ = oTxsSession;
return False;
"""
Configures the autostart feature in the guest.
"""
_ = oSession;
_ = oTxsSession;
return False;
"""
Create a test VM in the guest and enable autostart.
"""
_ = oSession;
_ = oTxsSession;
return False;
"""
Check for VM running in the guest after autostart.
"""
_ = oSession;
_ = oTxsSession;
return False;
"""
Autostart testcase.
"""
#
# Overridden methods.
#
return rc;
iArg += 1;
iArg += 1;
if s not in self.asTestVMsDef:
iArg += 1;
if s not in self.asTestVMsDef:
else:
return iArg + 1;
# Remove skipped VMs from the test list.
except: pass;
# Construct the resource list the first time it's queried.
# Make sure vboxapi has been imported so we can use the constants.
if not self.importVBoxApi():
return False;
#
# Configure the VMs we're going to use.
#
# Linux VMs
if oVM is None:
return False;
# Solaris VMs
oVM = self.createTestVM(self.ksOsSolaris, 1, '4.2/autostart/tst-solaris.vdi', sKind = 'Solaris_64', \
sHddControllerType = "SATA Controller");
if oVM is None:
return False;
return True;
"""
Execute the testcase.
"""
return fRc;
#
# Test execution helpers.
#
"""
Test VirtualBoxs autostart feature in a VM.
"""
oGuestOsHlp = None;
sTestUserAllow = 'test1';
sTestUserDeny = 'test2';
sTestVmName = 'TestVM';
if oGuestOsHlp is not None:
# Create two new users
# Install VBox first
(sTestUserAllow,), (sTestUserDeny,));
# Create a VM with autostart enabled in the guest for both users
# Reboot the guest
(fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 3 * 60000, \
# Fudge factor - Allow the guest to finish starting up.
else:
else:
else:
else:
else:
else:
return fRc;
"""
Runs the specified VM thru test #1.
Returns a success indicator on the general test execution. This is not
the actual test result.
"""
# Reconfigure the VM
if oSession is not None:
oSession = None;
else:
# Start up.
oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(sVmName, fCdWait = False, fNatForwardingForTxs = True);
if oSession is not None:
# Fudge factor - Allow the guest to finish starting up.
# cleanup.
else:
return fRc;
"""
Runs one VM thru the various configurations.
"""
return fRc;
"""
Executes autostart test.
"""
# Loop thru the test VMs.
# run test on the VM.
else:
return fRc;
if __name__ == '__main__':