VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/usb/tst-utsgadget.py@ 60488

Last change on this file since 60488 was 60488, checked in by vboxsync, 9 years ago

ValidationKit/usb: Fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: tst-utsgadget.py 60488 2016-04-14 10:33:11Z vboxsync $
3
4"""
5Simple testcase for usbgadget2.py.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2016 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: 60488 $"
30
31# Standard python imports.
32import os
33import sys
34import types
35
36# Validation Kit imports.
37sys.path.insert(0, '.');
38sys.path.insert(0, '..');
39import usbgadget2 as usbgadget;
40import testdriver.reporter as reporter
41from common import utils;
42
43g_cTests = 0;
44g_cFailures = 0
45
46def boolRes(rc, fExpect = True):
47 """Checks a boolean result."""
48 global g_cTests, g_cFailures;
49 g_cTests = g_cTests + 1;
50 if isinstance(rc, types.BooleanType):
51 if rc == fExpect:
52 return 'PASSED';
53 g_cFailures = g_cFailures + 1;
54 return 'FAILED';
55
56def stringRes(rc, sExpect):
57 """Checks a string result."""
58 global g_cTests, g_cFailures;
59 g_cTests = g_cTests + 1;
60 if isinstance(rc, basestring):
61 if rc == sExpect:
62 return 'PASSED';
63 g_cFailures = g_cFailures + 1;
64 return 'FAILED';
65
66def main(asArgs): # pylint: disable=C0111,R0914,R0915
67 cMsTimeout = 30*1000;
68 sAddress = 'localhost';
69 uPort = None;
70 fStdTests = True;
71
72 i = 1;
73 while i < len(asArgs):
74 if asArgs[i] == '--hostname':
75 sAddress = asArgs[i + 1];
76 i = i + 2;
77 elif asArgs[i] == '--port':
78 uPort = int(asArgs[i + 1]);
79 i = i + 2;
80 elif asArgs[i] == '--timeout':
81 cMsTimeout = long(asArgs[i + 1]);
82 i = i + 2;
83 elif asArgs[i] == '--help':
84 print 'tst-utsgadget.py [--hostname <addr|name>] [--port <num>] [--timeout <cMS>]'
85 return 0;
86 else:
87 print 'Unknown argument: %s' % (asArgs[i]);
88 return 2;
89
90 oGadget = usbgadget.UsbGadget();
91 if uPort is None:
92 rc = oGadget.connectTo(cMsTimeout, sAddress);
93 else:
94 rc = oGadget.connectTo(cMsTimeout, sAddress, uPort = uPort);
95 if rc is False:
96 print 'connectTo failed';
97 return 1;
98
99 if fStdTests:
100
101
102 # Done
103 rc = oGadget.disconnectFrom();
104 print '%s: disconnect() -> %s' % (boolRes(rc), rc);
105
106 if g_cFailures != 0:
107 print 'tst-utsgadget.py: %u out of %u test failed' % (g_cFailures, g_cTests);
108 return 1;
109 print 'tst-utsgadget.py: all %u tests passed!' % (g_cTests);
110 return 0;
111
112
113if __name__ == '__main__':
114 reporter.incVerbosity();
115 reporter.incVerbosity();
116 reporter.incVerbosity();
117 reporter.incVerbosity();
118 sys.exit(main(sys.argv));
119
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