tdTreeDepth1.py revision f494a0572bb12f7671e0adf39f9a4aec3307b9dc
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync# -*- coding: utf-8 -*-
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncVirtualBox Validation Kit - Medium and Snapshot Tree Depth Test #1
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncCopyright (C) 2010-2015 Oracle Corporation
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncThis file is part of VirtualBox Open Source Edition (OSE), as
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncavailable from http://www.virtualbox.org. This file is free software;
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncyou can redistribute it and/or modify it under the terms of the GNU
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncGeneral Public License (GPL) as published by the Free Software
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncFoundation, in version 2 as it comes in the "COPYING" file of the
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncVirtualBox OSE distribution. VirtualBox OSE is distributed in the
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsynchope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncThe contents of this file may alternatively be used under the terms
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncof the Common Development and Distribution License Version 1.0
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync(CDDL) only, as it comes in the "COPYING.CDDL" file of the
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncVirtualBox OSE distribution, in which case the provisions of the
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncCDDL are applicable instead of those of the GPL.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncYou may elect to license modified versions of this file under the
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncterms and conditions of either the GPL or the CDDL or both.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync# Standard Python imports.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync# Only the main script needs to modify the path.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsyncg_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync# Validation Kit imports.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync Medium and Snapshot Tree Depth Test #1.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync # Overridden methods.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync Import the API.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync Execute the testcase.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync # Test execution helpers.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync Test medium tree depth.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync assert oVM is not None
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync # create chain with 300 disk images (medium tree depth limit)
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync sHddPath = os.path.join(self.sScratchPath, 'Test' + str(i) + '.vdi')
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync oHd = oSession.createBaseHd(sHddPath, cb=1024*1024)
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync if oHd is None:
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync # modify the VM config, attach HDD
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync fRc = fRc and oSession.attachHd(sHddPath, sController='SATA Controller', fImmutable=False, fForceResource=False)
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync # unregister and re-register to test loading of settings
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync oVM.unregister(vboxcon.CleanupMode_DetachAllReturnNone)
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync reporter.log('opening VM %s, testing config reading' % (sSettingsFile))
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync Test snapshot tree depth.
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync assert oVM is not None
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync # modify the VM config, create and attach empty HDD
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync sHddPath = os.path.join(self.sScratchPath, 'TestSnapEmpty.vdi')
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync fRc = fRc and oSession.createAndAttachHd(sHddPath, cb=1024*1024, sController='SATA Controller', fImmutable=False)
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync # take 250 snapshots (snapshot tree depth limit)
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync fRc = fRc and oSession.takeSnapshot('Snapshot ' + str(i))
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync # unregister and re-register to test loading of settings
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync oVM.unregister(vboxcon.CleanupMode_DetachAllReturnNone)
f494a0572bb12f7671e0adf39f9a4aec3307b9dcvboxsync reporter.log('opening VM %s, testing config reading' % (sSettingsFile))