VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/benchmarks/tdBenchmark2.py@ 92310

Last change on this file since 92310 was 92310, checked in by vboxsync, 3 years ago

ValKit/tdBenchmark2: increase the timeout. bugref:10093

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 6.7 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdBenchmark2.py 92310 2021-11-10 08:31:53Z vboxsync $
4
5"""
6VirtualBox Validation Kit - Test that runs various benchmarks.
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2010-2020 Oracle Corporation
12
13This file is part of VirtualBox Open Source Edition (OSE), as
14available from http://www.virtualbox.org. This file is free software;
15you can redistribute it and/or modify it under the terms of the GNU
16General Public License (GPL) as published by the Free Software
17Foundation, in version 2 as it comes in the "COPYING" file of the
18VirtualBox OSE distribution. VirtualBox OSE is distributed in the
19hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20
21The contents of this file may alternatively be used under the terms
22of the Common Development and Distribution License Version 1.0
23(CDDL) only, as it comes in the "COPYING.CDDL" file of the
24VirtualBox OSE distribution, in which case the provisions of the
25CDDL are applicable instead of those of the GPL.
26
27You may elect to license modified versions of this file under the
28terms and conditions of either the GPL or the CDDL or both.
29"""
30__version__ = "$Revision: 92310 $"
31
32
33# Standard Python imports.
34import os;
35import sys;
36
37# Only the main script needs to modify the path.
38try: __file__
39except: __file__ = sys.argv[0];
40g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
41sys.path.append(g_ksValidationKitDir);
42
43# Validation Kit imports.
44from testdriver import reporter;
45from testdriver import vbox;
46from testdriver import vboxcon;
47from testdriver import vboxtestvms;
48
49
50class tdBenchmark2(vbox.TestDriver):
51 """
52 Benchmark #2 - Memory.
53 """
54
55 def __init__(self):
56 vbox.TestDriver.__init__(self);
57 oTestVm = vboxtestvms.BootSectorTestVm(self.oTestVmSet, 'tst-bs-memalloc-1',
58 os.path.join(self.sVBoxBootSectors, 'bs3-memalloc-1.img'));
59 self.oTestVmSet.aoTestVms.append(oTestVm);
60
61
62 #
63 # Overridden methods.
64 #
65
66
67 def actionConfig(self):
68 self._detectValidationKit();
69 return self.oTestVmSet.actionConfig(self);
70
71 def actionExecute(self):
72 return self.oTestVmSet.actionExecute(self, self.testOneCfg);
73
74
75
76 #
77 # Test execution helpers.
78 #
79
80 def testOneCfg(self, oVM, oTestVm):
81 """
82 Runs the specified VM thru the tests.
83
84 Returns a success indicator on the general test execution. This is not
85 the actual test result.
86 """
87 fRc = False;
88
89 #
90 # Determin the RAM configurations we want to test.
91 #
92 cMbMaxGuestRam = self.oVBox.systemProperties.maxGuestRAM;
93 cMbHostAvail = self.oVBox.host.memoryAvailable;
94 cMbHostTotal = self.oVBox.host.memorySize;
95 reporter.log('cMbMaxGuestRam=%s cMbHostAvail=%s cMbHostTotal=%s' % (cMbMaxGuestRam, cMbHostAvail, cMbHostTotal,));
96
97 cMbHostAvail -= cMbHostAvail // 7; # Rough 14% safety/overhead margin.
98 if cMbMaxGuestRam < cMbHostAvail:
99 # Currently: 2048 GiB, 1536 GiB, 1024 GiB, 512 GiB, 256 GiB, 128 GiB, 64 GiB, 32 GiB
100 acMbRam = [ cMbMaxGuestRam, cMbMaxGuestRam // 4 * 3, cMbMaxGuestRam // 2, cMbMaxGuestRam // 4,
101 cMbMaxGuestRam // 8, cMbMaxGuestRam // 16 ];
102 if acMbRam[-1] > 64*1024:
103 acMbRam.append(64*1024);
104 if acMbRam[-1] > 32*1024:
105 acMbRam.append(32*1024);
106 elif cMbHostAvail > 8*1024:
107 # First entry is available memory rounded down to the nearest 8 GiB
108 cMbHostAvail = cMbHostAvail & ~(8 * 1024 - 1);
109 acMbRam = [ cMbHostAvail, ];
110
111 # The remaining entries are powers of two below that, up to 6 of these stopping at 16 GiB.
112 cMb = 8*1024;
113 while cMb < cMbHostAvail:
114 cMb *= 2;
115 while len(acMbRam) < 7 and cMb > 16 * 1024:
116 cMb //= 2;
117 acMbRam.append(cMb);
118 elif cMbHostAvail >= 16000 and cMbHostAvail > 7168:
119 # Desperate attempt at getting some darwin testruns too. We've got two
120 # with 16 GiB and they usually end up with just short of 8GiB of free RAM.
121 acMbRam = [7168,];
122 else:
123 reporter.log("Less than 8GB of host RAM available for VMs, skipping test");
124 return None;
125 reporter.log("RAM configurations: %s" % (acMbRam));
126
127 # Large pages only work with nested paging.
128 afLargePages = [False, ];
129 try:
130 if oVM.getHWVirtExProperty(vboxcon.HWVirtExPropertyType_NestedPaging):
131 afLargePages = [True, False];
132 except:
133 return reporter.errorXcpt("Failed to get HWVirtExPropertyType_NestedPaging");
134
135 #
136 # Test the RAM configurations.
137 #
138 for fLargePages in afLargePages:
139 sLargePages = 'large pages' if fLargePages is True else 'no large pages';
140 for cMbRam in acMbRam:
141 reporter.testStart('%s MiB, %s' % (cMbRam, sLargePages));
142
143 # Reconfigure the VM:
144 fRc = False
145 oSession = self.openSession(oVM);
146 if oSession:
147 fRc = oSession.setRamSize(cMbRam);
148 fRc = oSession.setLargePages(fLargePages) and fRc;
149 if fRc:
150 fRc = oSession.saveSettings();
151 if not fRc:
152 oSession.discardSettings(True);
153 oSession.close();
154 if fRc:
155 # Set up the result file
156 sXmlFile = self.prepareResultFile();
157 asEnv = [ 'IPRT_TEST_FILE=' + sXmlFile, ];
158
159 # Do the test:
160 self.logVmInfo(oVM);
161 oSession = self.startVm(oVM, sName = oTestVm.sVmName, asEnv = asEnv);
162 if oSession is not None:
163 cMsTimeout = 15 * 60000 + cMbRam // 168;
164 if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
165 cMsTimeout = self.adjustTimeoutMs(180 * 60000 + cMbRam // 168);
166
167 oRc = self.waitForTasks(cMsTimeout);
168 if oRc == oSession:
169 fRc = oSession.assertPoweredOff();
170 else:
171 reporter.error('oRc=%s, expected %s' % (oRc, oSession));
172
173 reporter.addSubXmlFile(sXmlFile);
174 self.terminateVmBySession(oSession);
175 else:
176 reporter.errorXcpt("Failed to set memory size to %s MiB or setting largePages to %s" % (cMbRam, fLargePages));
177 reporter.testDone();
178
179 return fRc;
180
181
182
183if __name__ == '__main__':
184 sys.exit(tdBenchmark2().main(sys.argv));
185
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette