1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdTreeDepth1.py 70812 2018-01-30 17:46:55Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | VirtualBox Validation Kit - Medium and Snapshot Tree Depth Test #1
|
---|
7 | """
|
---|
8 |
|
---|
9 | __copyright__ = \
|
---|
10 | """
|
---|
11 | Copyright (C) 2010-2017 Oracle Corporation
|
---|
12 |
|
---|
13 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
14 | available from http://www.virtualbox.org. This file is free software;
|
---|
15 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
16 | General Public License (GPL) as published by the Free Software
|
---|
17 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
18 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
19 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
20 |
|
---|
21 | The contents of this file may alternatively be used under the terms
|
---|
22 | of the Common Development and Distribution License Version 1.0
|
---|
23 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
24 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
25 | CDDL are applicable instead of those of the GPL.
|
---|
26 |
|
---|
27 | You may elect to license modified versions of this file under the
|
---|
28 | terms and conditions of either the GPL or the CDDL or both.
|
---|
29 | """
|
---|
30 | __version__ = "$Revision: 70812 $"
|
---|
31 |
|
---|
32 |
|
---|
33 | # Standard Python imports.
|
---|
34 | import os
|
---|
35 | import sys
|
---|
36 |
|
---|
37 | # Only the main script needs to modify the path.
|
---|
38 | try: __file__
|
---|
39 | except: __file__ = sys.argv[0]
|
---|
40 | g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
---|
41 | sys.path.append(g_ksValidationKitDir)
|
---|
42 |
|
---|
43 | # Validation Kit imports.
|
---|
44 | from testdriver import base
|
---|
45 | from testdriver import reporter
|
---|
46 | from testdriver import vboxcon
|
---|
47 |
|
---|
48 |
|
---|
49 | class SubTstDrvTreeDepth1(base.SubTestDriverBase):
|
---|
50 | """
|
---|
51 | Sub-test driver for Medium and Snapshot Tree Depth Test #1.
|
---|
52 | """
|
---|
53 |
|
---|
54 | def __init__(self, oTstDrv):
|
---|
55 | base.SubTestDriverBase.__init__(self, 'tree-depth', oTstDrv)
|
---|
56 |
|
---|
57 | def testIt(self):
|
---|
58 | """
|
---|
59 | Execute the sub-testcase.
|
---|
60 | """
|
---|
61 | return self.testMediumTreeDepth() \
|
---|
62 | and self.testSnapshotTreeDepth()
|
---|
63 |
|
---|
64 | #
|
---|
65 | # Test execution helpers.
|
---|
66 | #
|
---|
67 |
|
---|
68 | def testMediumTreeDepth(self):
|
---|
69 | """
|
---|
70 | Test medium tree depth.
|
---|
71 | """
|
---|
72 | reporter.testStart('mediumTreeDepth')
|
---|
73 |
|
---|
74 | try:
|
---|
75 | oVM = self.oTstDrv.createTestVM('test-medium', 1, None, 4)
|
---|
76 | assert oVM is not None
|
---|
77 |
|
---|
78 | # create chain with 300 disk images (medium tree depth limit)
|
---|
79 | fRc = True
|
---|
80 | oSession = self.oTstDrv.openSession(oVM)
|
---|
81 | for i in range(1, 301):
|
---|
82 | sHddPath = os.path.join(self.oTstDrv.sScratchPath, 'Test' + str(i) + '.vdi')
|
---|
83 | if i is 1:
|
---|
84 | oHd = oSession.createBaseHd(sHddPath, cb=1024*1024)
|
---|
85 | else:
|
---|
86 | oHd = oSession.createDiffHd(oHd, sHddPath)
|
---|
87 | if oHd is None:
|
---|
88 | fRc = False
|
---|
89 | break
|
---|
90 |
|
---|
91 | # modify the VM config, attach HDD
|
---|
92 | fRc = fRc and oSession.attachHd(sHddPath, sController='SATA Controller', fImmutable=False, fForceResource=False)
|
---|
93 | fRc = fRc and oSession.saveSettings()
|
---|
94 | fRc = oSession.close() and fRc
|
---|
95 |
|
---|
96 | # unregister and re-register to test loading of settings
|
---|
97 | sSettingsFile = oVM.settingsFilePath
|
---|
98 | reporter.log('unregistering VM')
|
---|
99 | oVM.unregister(vboxcon.CleanupMode_DetachAllReturnNone)
|
---|
100 | oVBox = self.oTstDrv.oVBoxMgr.getVirtualBox()
|
---|
101 | reporter.log('opening VM %s, testing config reading' % (sSettingsFile))
|
---|
102 | oVM = oVBox.openMachine(sSettingsFile)
|
---|
103 |
|
---|
104 | assert fRc is True
|
---|
105 | except:
|
---|
106 | reporter.errorXcpt()
|
---|
107 |
|
---|
108 | return reporter.testDone()[1] == 0
|
---|
109 |
|
---|
110 | def testSnapshotTreeDepth(self):
|
---|
111 | """
|
---|
112 | Test snapshot tree depth.
|
---|
113 | """
|
---|
114 | reporter.testStart('snapshotTreeDepth')
|
---|
115 |
|
---|
116 | try:
|
---|
117 | oVM = self.oTstDrv.createTestVM('test-snap', 1, None, 4)
|
---|
118 | assert oVM is not None
|
---|
119 |
|
---|
120 | # modify the VM config, create and attach empty HDD
|
---|
121 | oSession = self.oTstDrv.openSession(oVM)
|
---|
122 | sHddPath = os.path.join(self.oTstDrv.sScratchPath, 'TestSnapEmpty.vdi')
|
---|
123 | fRc = True
|
---|
124 | fRc = fRc and oSession.createAndAttachHd(sHddPath, cb=1024*1024, sController='SATA Controller', fImmutable=False)
|
---|
125 | fRc = fRc and oSession.saveSettings()
|
---|
126 |
|
---|
127 | # take 250 snapshots (snapshot tree depth limit)
|
---|
128 | for i in range(1, 251):
|
---|
129 | fRc = fRc and oSession.takeSnapshot('Snapshot ' + str(i))
|
---|
130 | fRc = oSession.close() and fRc
|
---|
131 |
|
---|
132 | # unregister and re-register to test loading of settings
|
---|
133 | sSettingsFile = oVM.settingsFilePath
|
---|
134 | reporter.log('unregistering VM')
|
---|
135 | oVM.unregister(vboxcon.CleanupMode_DetachAllReturnNone)
|
---|
136 | oVBox = self.oTstDrv.oVBoxMgr.getVirtualBox()
|
---|
137 | reporter.log('opening VM %s, testing config reading' % (sSettingsFile))
|
---|
138 | oVM = oVBox.openMachine(sSettingsFile)
|
---|
139 |
|
---|
140 | assert fRc is True
|
---|
141 | except:
|
---|
142 | reporter.errorXcpt()
|
---|
143 |
|
---|
144 | return reporter.testDone()[1] == 0
|
---|
145 |
|
---|
146 |
|
---|
147 | if __name__ == '__main__':
|
---|
148 | sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
---|
149 | from tdApi1 import tdApi1
|
---|
150 | oTstDrv = tdApi1()
|
---|
151 | oTstDrv.addSubTestDriver(SubTstDrvTreeDepth1(oTstDrv))
|
---|
152 | sys.exit(oTstDrv.main(sys.argv))
|
---|
153 |
|
---|