summaryrefslogtreecommitdiffstats
path: root/src/VBox/ValidationKit/tests/network/tdNetBenchmark1.py
blob: c1dc960216d046fdd73dfdd28922351c1d5f38c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# $Id: tdNetBenchmark1.py $

"""
VirtualBox Validation Kit - Networking benchmark #1.
"""

__copyright__ = \
"""
Copyright (C) 2010-2023 Oracle and/or its affiliates.

This file is part of VirtualBox base platform packages, as
available from https://www.virtualbox.org.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, in version 3 of the
License.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see <https://www.gnu.org/licenses>.

The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
in the VirtualBox 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.

SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
"""
__version__ = "$Revision: 155244 $"


# Standard Python imports.
import os;
import socket
import sys;

# Only the main script needs to modify the path.
try:    __file__
except: __file__ = sys.argv[0];
g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
sys.path.append(g_ksValidationKitDir);

# Validation Kit imports.
from testdriver import reporter;
from testdriver import base;
from testdriver import vbox;
from testdriver import vboxcon;


class tdNetBenchmark1(vbox.TestDriver):                                         # pylint: disable=too-many-instance-attributes
    """
    Networking benchmark #1.
    """

    def __init__(self):
        vbox.TestDriver.__init__(self);
        self.asRsrcs            = None;
        self.sLocalName         = socket.getfqdn();
        self.sLocalIP           = None
        self.sRemoteName        = None;
        self.sRemoteIP          = None;
        self.sGuestName         = None;
        self.sGuestIP           = None;
        self.oGuestToGuestVM    = None;
        self.oGuestToGuestSess  = None;
        self.oGuestToGuestTxs   = None;
        self.asTestVMsDef       = ['tst-rhel5', 'tst-win2k3ent', 'tst-sol10'];
        self.asTestVMs          = self.asTestVMsDef;
        self.asSkipVMs          = [];
        self.asVirtModesDef     = ['hwvirt', 'hwvirt-np', 'raw',]
        self.asVirtModes        = self.asVirtModesDef
        self.acCpusDef          = [1, 2,]
        self.acCpus             = self.acCpusDef;
        self.asNicTypesDef      = ['E1000', 'PCNet', 'Virtio',];
        self.asNicTypes         = self.asNicTypesDef;
        self.sNicAttachmentDef  = 'bridged';
        self.sNicAttachment     = self.sNicAttachmentDef;
        self.asSetupsDef        = ['g2h', 'g2r', 'g2g',];
        self.asSetups           = self.asSetupsDef;
        self.cSecsRunDef        = 30;
        self.cSecsRun           = self.cSecsRunDef;
        self.asTestsDef         = ['tcp-latency', 'tcp-throughput', 'udp-latency', 'udp-throughput', 'tbench'];
        self.asTests            = self.asTestsDef
        self.acbLatencyPktsDef  = [32, 1024, 4096, 8192, 65536,];
        self.acbLatencyPkts     = self.acbLatencyPktsDef
        self.acbThroughputPktsDef = [8192, 65536];
        self.acbThroughputPkts  = self.acbThroughputPktsDef

        try: self.sLocalName = socket.gethostbyname(self.sLocalName);
        except: pass;

    #
    # Overridden methods.
    #
    def showUsage(self):
        rc = vbox.TestDriver.showUsage(self);
        reporter.log('');
        reporter.log('tdNetBenchmark1 Options:');
        reporter.log('  --remote-host  <hostname|address>');
        reporter.log('  --local-host   <hostname|address>');
        reporter.log('  --guest-host   <hostname|address>');
        reporter.log('  --virt-modes   <m1[:m2[:]]');
        reporter.log('      Default: %s' % (':'.join(self.asVirtModesDef)));
        reporter.log('  --cpu-counts   <c1[:c2[:]]');
        reporter.log('      Default: %s' % (':'.join(str(c) for c in self.acCpusDef)));
        reporter.log('  --nic-types    <type1[:type2[:...]]>');
        reporter.log('      Default: %s' % (':'.join(self.asNicTypes)));
        reporter.log('  --nic-attachment <bridged|nat>');
        reporter.log('      Default: %s' % (self.sNicAttachmentDef));
        reporter.log('  --setups       <s1[:s2[:]]>');
        reporter.log('      Default: %s  (all)' % (':'.join(self.asSetupsDef)));
        reporter.log('  --secs-per-run <seconds>');
        reporter.log('      Default: %s' % (self.cSecsRunDef));
        reporter.log('  --tests        <s1[:s2[:]]>');
        reporter.log('      Default: %s  (all)' % (':'.join(self.asTestsDef)));
        reporter.log('  --latency-sizes <size1[:size2[:...]]>');
        reporter.log('      Default: %s' % (':'.join(str(cb) for cb in self.acbLatencyPktsDef))); # pychecker bug?
        reporter.log('  --throughput-sizes <size1[:size2[:...]]>');
        reporter.log('      Default: %s' % (':'.join(str(cb) for cb in self.acbThroughputPktsDef))); # pychecker bug?
        reporter.log('  --test-vms     <vm1[:vm2[:...]]>');
        reporter.log('      Test the specified VMs in the given order. Use this to change');
        reporter.log('      the execution order or limit the choice of VMs');
        reporter.log('      Default: %s  (all)' % (':'.join(self.asTestVMsDef)));
        reporter.log('  --skip-vms     <vm1[:vm2[:...]]>');
        reporter.log('      Skip the specified VMs when testing.');
        reporter.log('  --quick');
        reporter.log('      Shorthand for: --virt-modes hwvirt --cpu-counts 1 --secs-per-run 5 --latency-sizes 32');
        reporter.log('                     --throughput-sizes 8192 --test-vms tst-rhel5:tst-win2k3ent:tst-sol10');
        return rc;

    def parseOption(self, asArgs, iArg):                                        # pylint: disable=too-many-branches,too-many-statements
        if asArgs[iArg] == '--remote-host':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--remote-host" takes an IP address or a hostname');
            self.sRemoteName = asArgs[iArg];
        elif asArgs[iArg] == '--local-host':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--local-host" takes an IP address or a hostname');
            self.sLocalName = asArgs[iArg];
        elif asArgs[iArg] == '--guest-host':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--guest-host" takes an IP address or a hostname');
            self.sGuestName = asArgs[iArg];
        elif asArgs[iArg] == '--virt-modes':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--virt-modes" takes a colon separated list of modes');
            self.asVirtModes = asArgs[iArg].split(':');
            for s in self.asVirtModes:
                if s not in self.asVirtModesDef:
                    raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
                        % (s, ' '.join(self.asVirtModesDef)));
        elif asArgs[iArg] == '--cpu-counts':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--cpu-counts" takes a colon separated list of cpu counts');
            self.acCpus = [];
            for s in asArgs[iArg].split(':'):
                try: c = int(s);
                except: raise base.InvalidOption('The "--cpu-counts" value "%s" is not an integer' % (s,));
                if c <= 0:  raise base.InvalidOption('The "--cpu-counts" value "%s" is zero or negative' % (s,));
                self.acCpus.append(c);
        elif asArgs[iArg] == '--nic-types':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--nic-types" takes a colon separated list of NIC types');
            self.asNicTypes = asArgs[iArg].split(':');
        elif asArgs[iArg] == '--nic-attachment':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--nic-attachment" takes an argument');
            self.sNicAttachment = asArgs[iArg];
            if self.sNicAttachment not in ('bridged', 'nat'):
                raise base.InvalidOption('The "--nic-attachment" value "%s" is not supported. Valid values are: bridged, nat' \
                        % (self.sNicAttachment));
        elif asArgs[iArg] == '--setups':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--setups" takes a colon separated list of setups');
            self.asSetups = asArgs[iArg].split(':');
            for s in self.asSetups:
                if s not in self.asSetupsDef:
                    raise base.InvalidOption('The "--setups" value "%s" is not valid; valid values are: %s' \
                        % (s, ' '.join(self.asSetupsDef)));
        elif asArgs[iArg] == '--secs-per-run':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--secs-per-run" takes second count');
            try:    self.cSecsRun = int(asArgs[iArg]);
            except: raise base.InvalidOption('The "--secs-per-run" value "%s" is not an integer' % (self.cSecsRun,));
            if self.cSecsRun <= 0:
                raise base.InvalidOption('The "--secs-per-run" value "%s" is zero or negative.' % (self.cSecsRun,));
        elif asArgs[iArg] == '--tests':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--tests" takes a colon separated list of tests');
            self.asTests = asArgs[iArg].split(':');
            for s in self.asTests:
                if s not in self.asTestsDef:
                    raise base.InvalidOption('The "--tests" value "%s" is not valid; valid values are: %s' \
                        % (s, ' '.join(self.asTestsDef)));
        elif asArgs[iArg] == '--latency-sizes':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--latency-sizes" takes a colon separated list of sizes');
            self.acbLatencyPkts = [];
            for s in asArgs[iArg].split(':'):
                try: cb = int(s);
                except: raise base.InvalidOption('The "--latency-sizes" value "%s" is not an integer' % (s,));
                if cb <= 0: raise base.InvalidOption('The "--latency-sizes" value "%s" is zero or negative' % (s,));
                self.acbLatencyPkts.append(cb);
        elif asArgs[iArg] == '--throughput-sizes':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--throughput-sizes" takes a colon separated list of sizes');
            self.acbThroughputPkts = [];
            for s in asArgs[iArg].split(':'):
                try: cb = int(s);
                except: raise base.InvalidOption('The "--throughput-sizes" value "%s" is not an integer' % (s,));
                if cb <= 0: raise base.InvalidOption('The "--throughput-sizes" value "%s" is zero or negative' % (s,));
                self.acbThroughputPkts.append(cb);
        elif asArgs[iArg] == '--test-vms':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--test-vms" takes colon separated list');
            self.asTestVMs = asArgs[iArg].split(':');
            for s in self.asTestVMs:
                if s not in self.asTestVMsDef:
                    raise base.InvalidOption('The "--test-vms" value "%s" is not valid; valid values are: %s' \
                        % (s, ' '.join(self.asTestVMsDef)));
        elif asArgs[iArg] == '--skip-vms':
            iArg += 1;
            if iArg >= len(asArgs): raise base.InvalidOption('The "--skip-vms" takes colon separated list');
            self.asSkipVMs = asArgs[iArg].split(':');
            for s in self.asSkipVMs:
                if s not in self.asTestVMsDef:
                    reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s));
        elif asArgs[iArg] == '--quick':
            self.cSecsRun           = 5;
            self.asVirtModes        = ['hwvirt',];
            self.acCpus             = [1,];
            self.acbLatencyPkts     = [32,];
            self.acbThroughputPkts  = [8192,];
            self.asTestVMs          = ['tst-rhel5', 'tst-win2k3ent', 'tst-sol10',];
        else:
            return vbox.TestDriver.parseOption(self, asArgs, iArg);
        return iArg + 1;

    def completeOptions(self):
        # Remove skipped VMs from the test list.
        for sVM in self.asSkipVMs:
            try:    self.asTestVMs.remove(sVM);
            except: pass;

        # Resolve any names we've been given.
        self.sLocalIP  = base.tryGetHostByName(self.sLocalName);
        self.sRemoteIP = base.tryGetHostByName(self.sRemoteName);
        self.sGuestIP  = base.tryGetHostByName(self.sGuestName);

        reporter.log('Local IP : %s' % (self.sLocalIP));
        reporter.log('Remote IP: %s' % (self.sRemoteIP));
        if self.sGuestIP is None:
            reporter.log('Guest IP : use tst-guest2guest');
        else:
            reporter.log('Guest IP : %s' % (self.sGuestIP));

        return vbox.TestDriver.completeOptions(self);

    def getResourceSet(self):
        # Construct the resource list the first time it's queried.
        if self.asRsrcs is None:
            self.asRsrcs = [];
            if 'tst-rhel5' in self.asTestVMs  or  'g2g' in self.asSetups:
                self.asRsrcs.append('3.0/tcp/rhel5.vdi');
            if 'tst-rhel5-64' in self.asTestVMs:
                self.asRsrcs.append('3.0/tcp/rhel5-64.vdi');
            if 'tst-sles11' in self.asTestVMs:
                self.asRsrcs.append('3.0/tcp/sles11.vdi');
            if 'tst-sles11-64' in self.asTestVMs:
                self.asRsrcs.append('3.0/tcp/sles11-64.vdi');
            if 'tst-oel' in self.asTestVMs:
                self.asRsrcs.append('3.0/tcp/oel.vdi');
            if 'tst-oel-64' in self.asTestVMs:
                self.asRsrcs.append('3.0/tcp/oel-64.vdi');
            if 'tst-win2k3ent' in self.asTestVMs:
                self.asRsrcs.append('3.0/tcp/win2k3ent-acpi.vdi');
            if 'tst-win2k3ent-64' in self.asTestVMs:
                self.asRsrcs.append('3.0/tcp/win2k3ent-64.vdi');
            if 'tst-win2k8' in self.asTestVMs:
                self.asRsrcs.append('3.0/tcp/win2k8.vdi');
            if 'tst-sol10' in self.asTestVMs:
                self.asRsrcs.append('3.0/tcp/solaris10.vdi');
            if 'tst-sol11' in self.asTestVMs:
                self.asRsrcs.append('3.0/tcp/solaris11.vdi');
        return self.asRsrcs;

    def actionConfig(self):
        # Some stupid trickery to guess the location of the iso. ## fixme - testsuite unzip ++
        sVBoxValidationKit_iso = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxValidationKit.iso'));
        if not os.path.isfile(sVBoxValidationKit_iso):
            sVBoxValidationKit_iso = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../VBoxTestSuite.iso'));
        if not os.path.isfile(sVBoxValidationKit_iso):
            sVBoxValidationKit_iso = '/mnt/ramdisk/vbox/svn/trunk/validationkit/VBoxValidationKit.iso';
        if not os.path.isfile(sVBoxValidationKit_iso):
            sVBoxValidationKit_iso = '/mnt/ramdisk/vbox/svn/trunk/testsuite/VBoxTestSuite.iso';
        if not os.path.isfile(sVBoxValidationKit_iso):
            sCur = os.getcwd();
            for i in range(0, 10):
                sVBoxValidationKit_iso = os.path.join(sCur, 'validationkit/VBoxValidationKit.iso');
                if os.path.isfile(sVBoxValidationKit_iso):
                    break;
                sVBoxValidationKit_iso = os.path.join(sCur, 'testsuite/VBoxTestSuite.iso');
                if os.path.isfile(sVBoxValidationKit_iso):
                    break;
                sCur = os.path.abspath(os.path.join(sCur, '..'));
                if i is None: pass; # shut up pychecker/pylint.
        if not os.path.isfile(sVBoxValidationKit_iso):
            sVBoxValidationKit_iso = '/home/bird/validationkit/VBoxValidationKit.iso';
        if not os.path.isfile(sVBoxValidationKit_iso):
            sVBoxValidationKit_iso = '/home/bird/testsuite/VBoxTestSuite.iso';

        # Make sure vboxapi has been imported so we can use the constants.
        if not self.importVBoxApi():
            return False;

        # Guest to Guest VM.
        if self.sGuestName is None and 'g2g' in self.asSetups:
            oVM = self.createTestVM('tst-guest2guest', 0, '3.0/tcp/rhel5.vdi', sKind = 'RedHat', fIoApic = True, \
                    eNic0Type = vboxcon.NetworkAdapterType_I82545EM, \
                    eNic0AttachType = vboxcon.NetworkAttachmentType_Bridged, \
                    fVirtEx = True, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;
            self.oGuestToGuestVM = oVM;

        #
        # Configure the VMs we're going to use.
        #
        eNic0AttachType = vboxcon.NetworkAttachmentType_Bridged;
        if self.sNicAttachment == 'nat':
            eNic0AttachType = vboxcon.NetworkAttachmentType_NAT;

        # Linux VMs
        if 'tst-rhel5' in self.asTestVMs:
            oVM = self.createTestVM('tst-rhel5', 1, '3.0/tcp/rhel5.vdi', sKind = 'RedHat', fIoApic = True, \
                eNic0AttachType = eNic0AttachType, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;

        if 'tst-rhel5-64' in self.asTestVMs:
            oVM = self.createTestVM('tst-rhel5-64', 1, '3.0/tcp/rhel5-64.vdi', sKind = 'RedHat_64', \
                eNic0AttachType = eNic0AttachType, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;

        if 'tst-sles11' in self.asTestVMs:
            oVM = self.createTestVM('tst-sles11', 1, '3.0/tcp/sles11.vdi', sKind = 'OpenSUSE', fIoApic = True, \
                eNic0AttachType = eNic0AttachType, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;

        if 'tst-sles11-64' in self.asTestVMs:
            oVM = self.createTestVM('tst-sles11-64', 1, '3.0/tcp/sles11-64.vdi', sKind = 'OpenSUSE_64', \
                eNic0AttachType = eNic0AttachType, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;

        if 'tst-oel' in self.asTestVMs:
            oVM = self.createTestVM('tst-oel', 1, '3.0/tcp/oel.vdi', sKind = 'Oracle', fIoApic = True, \
                eNic0AttachType = eNic0AttachType, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;

        if 'tst-oel-64' in self.asTestVMs:
            oVM = self.createTestVM('tst-oel-64', 1, '3.0/tcp/oel-64.vdi', sKind = 'Oracle_64', \
                eNic0AttachType = eNic0AttachType, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;

        # Windows VMs
        if 'tst-win2k3ent' in self.asTestVMs:
            oVM = self.createTestVM('tst-win2k3ent', 1, '3.0/tcp/win2k3ent-acpi.vdi', sKind = 'Windows2003', \
                eNic0AttachType = eNic0AttachType, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;

        if 'tst-win2k3ent-64' in self.asTestVMs:
            oVM = self.createTestVM('tst-win2k3ent-64', 1, '3.0/tcp/win2k3ent-64.vdi', sKind = 'Windows2003_64', \
                eNic0AttachType = eNic0AttachType, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;

        if 'tst-win2k8' in self.asTestVMs:
            oVM = self.createTestVM('tst-win2k8', 1, '3.0/tcp/win2k8.vdi', sKind = 'Windows2008_64', \
                eNic0AttachType = eNic0AttachType, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;

        # Solaris VMs
        if 'tst-sol10' in self.asTestVMs:
            oVM = self.createTestVM('tst-sol10', 1, '3.0/tcp/solaris10.vdi', sKind = 'Solaris_64', \
                eNic0AttachType = eNic0AttachType, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;

        if 'tst-sol11' in self.asTestVMs:
            oVM = self.createTestVM('tst-sol11', 1, '3.0/tcp/os2009-11.vdi', sKind = 'Solaris_64', \
                eNic0AttachType = eNic0AttachType, sDvdImage = sVBoxValidationKit_iso);
            if oVM is None:
                return False;

        return True;

    def actionExecute(self):
        """
        Execute the testcase.
        """
        fRc = self.test1();
        return fRc;


    #
    # Test execution helpers.
    #

    def test1RunTestProgs(self, oTxsSession, fRc, sTestName, sAddr):
        """
        Runs all the test programs against one 'server' machine.
        """
        reporter.testStart(sTestName);

        reporter.testStart('TCP latency');
        if fRc and 'tcp-latency' in self.asTests and sAddr is not None:
            for cbPkt in self.acbLatencyPkts:
                fRc = self.txsRunTest(oTxsSession, '%u bytes' % (cbPkt), self.cSecsRun * 1000 * 4,
                                      '${CDROM}/${OS/ARCH}/NetPerf${EXESUFF}',
                                      ('NetPerf', '--client', sAddr, '--interval', self.cSecsRun, '--len', cbPkt,
                                       '--mode', 'latency'));
                if not fRc:
                    break;
            reporter.testDone();
        else:
            reporter.testDone(fSkipped = True);

        reporter.testStart('TCP throughput');
        if fRc and 'tcp-throughput' in self.asTests and sAddr is not None:
            for cbPkt in self.acbThroughputPkts:
                fRc = self.txsRunTest(oTxsSession, '%u bytes' % (cbPkt), self.cSecsRun * 2 * 1000 * 4,
                                      '${CDROM}/${OS/ARCH}/NetPerf${EXESUFF}',
                                      ('NetPerf', '--client', sAddr, '--interval', self.cSecsRun, '--len', cbPkt,
                                       '--mode', 'throughput'));
                if not fRc:
                    break;
            reporter.testDone();
        else:
            reporter.testDone(fSkipped = True);

        reporter.testStart('UDP latency');
        if fRc and 'udp-latency' in self.asTests and sAddr is not None:
            ## @todo Netperf w/UDP.
            reporter.testDone(fSkipped = True);
        else:
            reporter.testDone(fSkipped = True);

        reporter.testStart('UDP throughput');
        if fRc and 'udp-throughput' in self.asTests and sAddr is not None:
            ## @todo Netperf w/UDP.
            reporter.testDone(fSkipped = True);
        else:
            reporter.testDone(fSkipped = True);

        reporter.testStart('tbench');
        if fRc and 'tbench' in self.asTests and sAddr is not None:
            ## @todo tbench.
            reporter.testDone(fSkipped = True);
        else:
            reporter.testDone(fSkipped = True);

        reporter.testDone(not fRc);
        return fRc;

    def test1OneCfg(self, sVmName, eNicType, cCpus, fHwVirt, fNestedPaging):
        """
        Runs the specified VM thru test #1.

        Returns a success indicator on the general test execution. This is not
        the actual test result.
        """
        oVM = self.getVmByName(sVmName);

        # Reconfigure the VM
        fRc = True;
        oSession = self.openSession(oVM);
        if oSession is not None:
            fRc = fRc and oSession.setNicType(eNicType);
            fRc = fRc and oSession.enableVirtEx(fHwVirt);
            fRc = fRc and oSession.enableNestedPaging(fNestedPaging);
            fRc = fRc and oSession.setCpuCount(cCpus);
            fRc = fRc and oSession.saveSettings();
            fRc = oSession.close() and fRc and True; # pychecker hack.
            oSession = None;
        else:
            fRc = False;

        # Start up.
        if fRc is True:
            self.logVmInfo(oVM);
            oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(sVmName, fCdWait = True);
            if oSession is not None:
                self.addTask(oTxsSession);

                # Fudge factor - Allow the guest to finish starting up.
                self.sleep(5);

                # Benchmark #1 - guest <-> host.
                if 'g2h' in self.asSetups:
                    self.test1RunTestProgs(oTxsSession, fRc, 'guest <-> host',  self.sLocalIP);

                # Benchmark #2 - guest <-> host.
                if 'g2r' in self.asSetups:
                    self.test1RunTestProgs(oTxsSession, fRc, 'guest <-> remote', self.sRemoteIP);

                # Benchmark #3 - guest <-> guest.
                if 'g2g' in self.asSetups:
                    self.test1RunTestProgs(oTxsSession, fRc, 'guest <-> guest',  self.sGuestIP);

                # cleanup.
                self.removeTask(oTxsSession);
                self.terminateVmBySession(oSession)
            else:
                fRc = False;
        return fRc;

    def test1OneVM(self, sVmName, asSkipNicTypes = (), asSupVirtModes = None, rSupCpus = range(1, 256)):
        """
        Runs one VM thru the various configurations.
        """
        if asSupVirtModes is None:
            asSupVirtModes = self.asVirtModes;

        reporter.testStart(sVmName);
        fRc = True;
        for sNicType in self.asNicTypes:
            if sNicType in asSkipNicTypes:
                continue;
            reporter.testStart(sNicType);

            if sNicType == 'E1000':
                eNicType = vboxcon.NetworkAdapterType_I82545EM;
            elif sNicType == 'PCNet':
                eNicType = vboxcon.NetworkAdapterType_Am79C973;
            elif sNicType == 'Virtio':
                eNicType = vboxcon.NetworkAdapterType_Virtio;
            else:
                eNicType = None;

            for cCpus in self.acCpus:
                if cCpus == 1:  reporter.testStart('1 cpu');
                else:           reporter.testStart('%u cpus' % (cCpus));

                for sVirtMode in self.asVirtModes:
                    if sVirtMode == 'raw' and cCpus > 1:
                        continue;
                    if cCpus not in rSupCpus:
                        continue;
                    if sVirtMode not in asSupVirtModes:
                        continue;
                    hsVirtModeDesc = {};
                    hsVirtModeDesc['raw']       = 'Raw-mode';
                    hsVirtModeDesc['hwvirt']    = 'HwVirt';
                    hsVirtModeDesc['hwvirt-np'] = 'NestedPaging';
                    reporter.testStart(hsVirtModeDesc[sVirtMode]);

                    fHwVirt       = sVirtMode != 'raw';
                    fNestedPaging = sVirtMode == 'hwvirt-np';
                    fRc = self.test1OneCfg(sVmName, eNicType, cCpus, fHwVirt, fNestedPaging)  and  fRc and True; # pychecker hack.

                    reporter.testDone();
                reporter.testDone();
            reporter.testDone();
        reporter.testDone();
        return fRc;

    def test1(self):
        """
        Executes test #1.
        """

        # Start the VM for the guest to guest testing, if required.
        fRc = True;
        if 'g2g' in self.asSetups  and  self.sGuestName is None:
            self.oGuestToGuestSess, self.oGuestToGuestTxs = self.startVmAndConnectToTxsViaTcp('tst-guest2guest', fCdWait = True);
            if self.oGuestToGuestSess is None:
                return False;
            self.sGuestIP = self.oGuestToGuestSess.getPrimaryIp();
            reporter.log('tst-guest2guest IP: %s' % (self.sGuestIP));

            # Start the test servers on it.
            fRc = self.oGuestToGuestTxs.syncExec('${CDROM}/${OS/ARCH}/NetPerf${EXESUFF}',
                                                 ('NetPerf', '--server', '--daemonize'), fWithTestPipe=False);

        # Loop thru the test VMs.
        if fRc:
            for sVM in self.asTestVMs:
                # figure args.
                asSkipNicTypes = [];
                if sVM not in ('tst-sles11', 'tst-sles11-64'):
                    asSkipNicTypes.append('Virtio');
                if sVM in ('tst-sol11', 'tst-sol10'):
                    asSkipNicTypes.append('PCNet');
                asSupVirtModes = None;
                if sVM in ('tst-sol11', 'tst-sol10'): # 64-bit only
                    asSupVirtModes = ('hwvirt', 'hwvirt-np',);

                # run test on the VM.
                if not self.test1OneVM(sVM, asSkipNicTypes, asSupVirtModes):
                    fRc = False;

        # Kill the guest to guest VM and clean up the state.
        if self.oGuestToGuestSess is not None:
            self.terminateVmBySession(self.oGuestToGuestSess);
            self.oGuestToGuestSess = None;
            self.oGuestToGuestTxs  = None;
            self.sGuestIP          = None;

        return fRc;



if __name__ == '__main__':
    sys.exit(tdNetBenchmark1().main(sys.argv));