VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/additions/tdAddSharedFolders1.py@ 78676

Last change on this file since 78676 was 78676, checked in by vboxsync, 6 years ago

tdAddSharedFolders1.py: Fix for 5.2 bugref:9172

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.6 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4"""
5VirtualBox Validation Kit - Shared Folders #1.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2010-2019 Oracle Corporation
11
12This file is part of VirtualBox Open Source Edition (OSE), as
13available from http://www.virtualbox.org. This file is free software;
14you can redistribute it and/or modify it under the terms of the GNU
15General Public License (GPL) as published by the Free Software
16Foundation, in version 2 as it comes in the "COPYING" file of the
17VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
20The contents of this file may alternatively be used under the terms
21of the Common Development and Distribution License Version 1.0
22(CDDL) only, as it comes in the "COPYING.CDDL" file of the
23VirtualBox OSE distribution, in which case the provisions of the
24CDDL are applicable instead of those of the GPL.
25
26You may elect to license modified versions of this file under the
27terms and conditions of either the GPL or the CDDL or both.
28"""
29__version__ = "$Revision: 78676 $"
30
31# Standard Python imports.
32import os
33import shutil
34import sys
35
36# Only the main script needs to modify the path.
37try: __file__
38except: __file__ = sys.argv[0];
39g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
40sys.path.append(g_ksValidationKitDir);
41
42# Validation Kit imports.
43from testdriver import reporter;
44from testdriver import base;
45from common import utils;
46
47
48class SubTstDrvAddSharedFolders1(base.SubTestDriverBase):
49 """
50 Sub-test driver for executing shared folders tests.
51 """
52
53 def __init__(self, oTstDrv):
54 base.SubTestDriverBase.__init__(self, 'add-shared-folders', oTstDrv);
55
56 self.asTestsDef = [ 'fsperf', ];
57 self.asTests = self.asTestsDef;
58 self.asExtraArgs = [];
59
60 def parseOption(self, asArgs, iArg):
61 if asArgs[iArg] == '--add-shared-folders-tests': # 'add' as in 'additions', not the verb.
62 iArg += 1;
63 iNext = self.oTstDrv.requireMoreArgs(1, asArgs, iArg);
64 if asArgs[iArg] == 'all':
65 self.asTests = self.asTestsDef;
66 else:
67 self.asTests = asArgs[iArg].split(':');
68 for s in self.asTests:
69 if s not in self.asTestsDef:
70 raise base.InvalidOption('The "--add-shared-folders-tests" value "%s" is not valid; valid values are: %s'
71 % (s, ' '.join(self.asTestsDef)));
72 return iNext;
73 elif asArgs[iArg] == '--add-shared-folders-extra-arg':
74 iArg += 1;
75 iNext = self.oTstDrv.requireMoreArgs(1, asArgs, iArg);
76 self.asExtraArgs.append(asArgs[iArg]);
77 return iNext;
78 return iArg;
79
80 def showUsage(self):
81 base.SubTestDriverBase.showUsage(self);
82 reporter.log(' --add-shared-folders-tests <t1[:t2[:]]>');
83 reporter.log(' Default: all (%s)' % (':'.join(self.asTestsDef)));
84 reporter.log(' --add-shared-folders-extra-args <fsperf-arg>');
85 reporter.log(' Adds an extra FsPerf argument. Can be repeated.');
86
87 return True;
88
89 def testIt(self, oTestVm, oSession, oTxsSession):
90 """
91 Executes the test.
92
93 Returns fRc, oTxsSession. The latter may have changed.
94 """
95 reporter.log("Active tests: %s" % (self.asTests,));
96
97 #
98 # Skip the test if before 6.0
99 #
100 if self.oTstDrv.fpApiVer < 6.0:
101 reporter.log('Requires 6.0 or later (for now)');
102 return (None, oTxsSession);
103
104 #
105 # Create the host directory to share. Empty except for a 'candle.dir' subdir
106 # that we use to check that it mounted correctly.
107 #
108 sSharedFolder1 = os.path.join(self.oTstDrv.sScratchPath, 'shfl1');
109 reporter.log2('Creating shared host folder "%s"...' % (sSharedFolder1,));
110 if os.path.exists(sSharedFolder1):
111 try: shutil.rmtree(sSharedFolder1);
112 except: return (reporter.errorXcpt('shutil.rmtree(%s)' % (sSharedFolder1,)), oTxsSession);
113 try: os.mkdir(sSharedFolder1);
114 except: return (reporter.errorXcpt('os.mkdir(%s)' % (sSharedFolder1,)), oTxsSession);
115 try: os.mkdir(os.path.join(sSharedFolder1, 'candle.dir'));
116 except: return (reporter.errorXcpt('os.mkdir(%s)' % (sSharedFolder1,)), oTxsSession);
117
118 # Guess a free mount point inside the guest.
119 if oTestVm.isWindows() or oTestVm.isOS2():
120 sMountPoint1 = 'V:';
121 sGuestSlash = '\\';
122 else:
123 sMountPoint1 = '/mnt/shfl1';
124 sGuestSlash = '/';
125
126 #
127 # Automount a shared folder in the guest.
128 #
129 reporter.testStart('Automount');
130
131 reporter.log2('Creating shared folder shfl1...');
132 try:
133 oConsole = oSession.o.console;
134 oConsole.createSharedFolder('shfl1', sSharedFolder1, True, True, sMountPoint1);
135 except:
136 reporter.errorXcpt('createSharedFolder(shfl1,%s,True,True,%s)' % (sSharedFolder1,sMountPoint1));
137 reporter.testDone();
138 return (False, oTxsSession);
139
140 # Check whether we can see the shared folder now. Retry for 30 seconds.
141 msStart = base.timestampMilli();
142 while True:
143 fRc = oTxsSession.syncIsDir(sMountPoint1 + sGuestSlash + 'candle.dir');
144 reporter.log2('candle.dir check -> %s' % (fRc,));
145 if fRc is not False:
146 break;
147 if base.timestampMilli() - msStart > 30000:
148 reporter.error('Shared folder mounting timed out!');
149 break;
150 self.oTstDrv.sleep(1);
151
152 reporter.testDone();
153 if fRc is not True:
154 return (False, oTxsSession); # skip the remainder if we cannot auto mount the folder.
155
156 #
157 # Run FsPerf inside the guest.
158 #
159 reporter.testStart('FsPerf');
160 fSkip = 'fsperf' not in self.asTests;
161 if fSkip is False:
162 cMbFree = utils.getDiskUsage(sSharedFolder1);
163 if cMbFree >= 16:
164 reporter.log2('Free space: %u MBs' % (cMbFree,));
165 else:
166 reporter.log('Skipping FsPerf because only %u MB free on %s' % (cMbFree, sSharedFolder1,));
167 fSkip = True;
168 if fSkip is False:
169 # Common arguments:
170 asArgs = ['FsPerf', '-d', sMountPoint1 + sGuestSlash + 'fstestdir-1', '-s8'];
171
172 # Skip part of mmap on older windows systems without CcCoherencyFlushAndPurgeCache (>= w7).
173 reporter.log2('oTestVm.sGuestOsType=%s' % (oTestVm.sGuestOsType,));
174 if oTestVm.getNonCanonicalGuestOsType() \
175 in [ 'WindowsNT3x', 'WindowsNT4', 'Windows2000', 'WindowsXP', 'WindowsXP_64', 'Windows2003',
176 'Windows2003_64', 'WindowsVista', 'WindowsVista_64', 'Windows2008', 'Windows2008_64']:
177 asArgs.append('--no-mmap-coherency');
178
179 # Configure I/O block sizes according to guest memory size:
180 cbMbRam = 128;
181 try: cbMbRam = oSession.o.machine.memorySize;
182 except: reporter.errorXcpt();
183 reporter.log2('cbMbRam=%s' % (cbMbRam,));
184 asArgs.append('--set-block-size=1');
185 asArgs.append('--add-block-size=512');
186 asArgs.append('--add-block-size=4096');
187 asArgs.append('--add-block-size=16384');
188 asArgs.append('--add-block-size=65536');
189 asArgs.append('--add-block-size=1048576'); # 1 MiB
190 if cbMbRam >= 512:
191 asArgs.append('--add-block-size=33554432'); # 32 MiB
192 if cbMbRam >= 768:
193 asArgs.append('--add-block-size=134217728'); # 128 MiB
194
195 asArgs.extend(self.asExtraArgs);
196 reporter.log2('Starting guest FsPerf (%s)...' % (asArgs,));
197 fRc = self.oTstDrv.txsRunTest(oTxsSession, 'FsPerf', 10 * 60 * 1000,
198 '${CDROM}/vboxvalidationkit/${OS/ARCH}/FsPerf${EXESUFF}', asArgs);
199 reporter.log2('FsPerf -> %s' % (fRc,));
200
201 sTestDir = os.path.join(sSharedFolder1, 'fstestdir-1');
202 if os.path.exists(sTestDir):
203 fRc = reporter.errorXcpt('test directory lingers: %s' % (sTestDir,));
204 try: shutil.rmtree(sTestDir);
205 except: fRc = reporter.errorXcpt('shutil.rmtree(%s)' % (sTestDir,));
206
207 reporter.testDone(fSkip or fRc is None);
208
209
210 return (fRc, oTxsSession);
211
212
213
214if __name__ == '__main__':
215 reporter.error('Cannot run standalone, use tdAddBasic1.py');
216 sys.exit(1);
217
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