diff options
Diffstat (limited to 'src/VBox/ValidationKit/tests/selftests')
-rw-r--r-- | src/VBox/ValidationKit/tests/selftests/Makefile.kmk | 54 | ||||
-rwxr-xr-x | src/VBox/ValidationKit/tests/selftests/tdSelfTest1.py | 66 | ||||
-rwxr-xr-x | src/VBox/ValidationKit/tests/selftests/tdSelfTest2.py | 131 | ||||
-rwxr-xr-x | src/VBox/ValidationKit/tests/selftests/tdSelfTest3.py | 125 | ||||
-rwxr-xr-x | src/VBox/ValidationKit/tests/selftests/tdSelfTest4.py | 125 |
5 files changed, 501 insertions, 0 deletions
diff --git a/src/VBox/ValidationKit/tests/selftests/Makefile.kmk b/src/VBox/ValidationKit/tests/selftests/Makefile.kmk new file mode 100644 index 00000000..946f10b8 --- /dev/null +++ b/src/VBox/ValidationKit/tests/selftests/Makefile.kmk @@ -0,0 +1,54 @@ +# $Id: Makefile.kmk $ +## @file +# VirtualBox Validation Kit - Testsuite & TestManager Tests. +# + +# +# Copyright (C) 2006-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 +# + +SUB_DEPTH = ../../../../.. +include $(KBUILD_PATH)/subheader.kmk + + +INSTALLS += ValidationKitTestsSelfTests +ValidationKitTestsSelfTests_TEMPLATE = VBoxValidationKitR3 +ValidationKitTestsSelfTests_INST = $(INST_VALIDATIONKIT)tests/selftests/ +ValidationKitTestsSelfTests_EXEC_SOURCES := \ + $(PATH_SUB_CURRENT)/tdSelfTest1.py \ + $(PATH_SUB_CURRENT)/tdSelfTest2.py \ + $(PATH_SUB_CURRENT)/tdSelfTest3.py \ + $(PATH_SUB_CURRENT)/tdSelfTest4.py + +VBOX_VALIDATIONKIT_PYTHON_SOURCES += $(ValidationKitTestsSelfTests_EXEC_SOURCES) + +$(evalcall def_vbox_validationkit_process_python_sources) +include $(FILE_KBUILD_SUB_FOOTER) + diff --git a/src/VBox/ValidationKit/tests/selftests/tdSelfTest1.py b/src/VBox/ValidationKit/tests/selftests/tdSelfTest1.py new file mode 100755 index 00000000..3509f3e6 --- /dev/null +++ b/src/VBox/ValidationKit/tests/selftests/tdSelfTest1.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# $Id: tdSelfTest1.py $ + +""" +Test Manager Self Test - Dummy Test Driver. +""" + +from __future__ import print_function; + +__copyright__ = \ +""" +Copyright (C) 2012-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 $" + + +import sys; +import os; + +print('dummydriver.py: hello world!'); +print('dummydriver.py: args: %s' % (sys.argv,)); + +print('dummydriver.py: environment:'); +for sVar in sorted(os.environ.keys()): # pylint: disable=consider-iterating-dictionary + print('%s=%s' % (sVar, os.environ[sVar])); + +if sys.argv[-1] in [ 'all', 'execute' ]: + + import time; + + for i in range(10, 1, -1): + print('dummydriver.py: %u...', i); + sys.stdout.flush(); + time.sleep(1); + print('dummydriver.py: ...0! done'); + +sys.exit(0); + diff --git a/src/VBox/ValidationKit/tests/selftests/tdSelfTest2.py b/src/VBox/ValidationKit/tests/selftests/tdSelfTest2.py new file mode 100755 index 00000000..6c0e12b8 --- /dev/null +++ b/src/VBox/ValidationKit/tests/selftests/tdSelfTest2.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# $Id: tdSelfTest2.py $ + +""" +Test Manager / Suite Self Test #2 - Everything should succeed. +""" + +__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 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 common import utils; +from testdriver import reporter; +from testdriver.base import TestDriverBase; + + +class tdSelfTest2(TestDriverBase): + """ + Test Manager / Suite Self Test #2 - Everything should succeed. + """ + + def __init__(self): + TestDriverBase.__init__(self); + + + def actionExecute(self): + reporter.testStart('reporter.testXXXX API'); + reporter.testValue('value-name1', 123456789, 'ms'); + + reporter.testStart('subtest'); + reporter.testValue('value-name2', 11223344, 'times'); + reporter.testDone(); + + reporter.testStart('subtest2'); + reporter.testValue('value-name3', 39, 'sec'); + reporter.testValue('value-name4', 42, 'ns'); + reporter.testDone(); + + reporter.testStart('subtest3'); + reporter.testDone(fSkipped = True); + + # No spaces in XML. + reporter.testStart('subtest4'); + oSubXmlFile = reporter.FileWrapperTestPipe(); + oSubXmlFile.write('<?xml version="1.0" encoding="UTF-8" ?>'); + oSubXmlFile.write('<Test timestamp="%s" name="foobar1">' % (utils.getIsoTimestamp(),)); + oSubXmlFile.write('<Test timestamp="%s" name="sub1">' % (utils.getIsoTimestamp(),)); + oSubXmlFile.write('<Passed timestamp="%s"/>' % (utils.getIsoTimestamp(),)); + oSubXmlFile.write('</Test>'); + oSubXmlFile.write('<End timestamp="%s" errors="0"/>' % (utils.getIsoTimestamp(),)); + oSubXmlFile.write('</Test>'); + oSubXmlFile.close(); + oSubXmlFile = None; + reporter.testDone(); + + # Spaces + funny line endings. + reporter.testStart('subtest5'); + oSubXmlFile = reporter.FileWrapperTestPipe(); + oSubXmlFile.write('<?xml version="1.0" encoding="UTF-8" ?>\r\n'); + oSubXmlFile.write('<Test timestamp="%s" name="foobar2">\n\n\t\n\r\n' % (utils.getIsoTimestamp(),)); + oSubXmlFile.write('<Test timestamp="%s" name="sub2">' % (utils.getIsoTimestamp(),)); + oSubXmlFile.write(' <Passed timestamp="%s"/>\n' % (utils.getIsoTimestamp(),)); + oSubXmlFile.write(' </Test>\n'); + oSubXmlFile.write(' <End timestamp="%s" errors="0"/>\r' % (utils.getIsoTimestamp(),)); + oSubXmlFile.write('</Test>'); + oSubXmlFile.close(); + reporter.testDone(); + + # A few long log times for WUI log testing. + reporter.log('long line: asdfasdfljkasdlfkjasldkfjlaksdfjl asdlfkjasdlkfjalskdfjlaksdjfa falkjaldkjfalskdjflaksdjf ' \ + 'lajksdflkjasdlfkjalsdfj asldfkjlaskdjflaksdjflaksdjflkj asdlfkjalsdkfjalsdkjflaksdj fasdlfkj ' \ + 'asdlkfj aljkasdflkj alkjdsf lakjsdf'); + reporter.log('long line: asdfasdfljkasdlfkjasldkfjlaksdfjl asdlfkjasdlkfjalskdfjlaksdjfa falkjaldkjfalskdjflaksdjf ' \ + 'lajksdflkjasdlfkjalsdfj asldfkjlaskdjflaksdjflaksdjflkj asdlfkjalsdkfjalsdkjflaksdj fasdlfkj ' \ + 'asdlkfj aljkasdflkj alkjdsf lakjsdf'); + reporter.log('long line: asdfasdfljkasdlfkjasldkfjlaksdfjl asdlfkjasdlkfjalskdfjlaksdjfa falkjaldkjfalskdjflaksdjf ' \ + 'lajksdflkjasdlfkjalsdfj asldfkjlaskdjflaksdjflaksdjflkj asdlfkjalsdkfjalsdkjflaksdj fasdlfkj ' \ + 'asdlkfj aljkasdflkj alkjdsf lakjsdf'); + + # Upload a file. + reporter.addLogFile(__file__, sKind = 'log/release/vm'); + + reporter.testDone(); + return True; + + +if __name__ == '__main__': + sys.exit(tdSelfTest2().main(sys.argv)); + diff --git a/src/VBox/ValidationKit/tests/selftests/tdSelfTest3.py b/src/VBox/ValidationKit/tests/selftests/tdSelfTest3.py new file mode 100755 index 00000000..1044dff0 --- /dev/null +++ b/src/VBox/ValidationKit/tests/selftests/tdSelfTest3.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# $Id: tdSelfTest3.py $ + +""" +Test Manager / Suite Self Test #3 - Bad XML input and other Failures. +""" + +__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 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 common import utils; +from testdriver import reporter; +from testdriver.base import TestDriverBase; + + +class tdSelfTest3(TestDriverBase): + """ + Test Manager / Suite Self Test #3 - Bad XML input and other Failures. + """ + + def __init__(self): + TestDriverBase.__init__(self); + + + def actionExecute(self): + + # Testing PushHint/PopHint. + reporter.testStart('Negative XML #1'); + oSubXmlFile = reporter.FileWrapperTestPipe(); + oSubXmlFile.write('<Test timestamp="%s" name="foobar3">\n\n\t\n\r\n' % (utils.getIsoTimestamp(),)); + oSubXmlFile.write('<Test timestamp="%s" name="sub3">' % (utils.getIsoTimestamp(),)); + oSubXmlFile.write('<Test timestamp="%s" name="subsub1">' % (utils.getIsoTimestamp(),)); + oSubXmlFile.close(); + reporter.testDone(); + + # Missing end, like we had with IRPT at one time. + reporter.testStart('Negative XML #2 (IPRT)'); + oSubXmlFile = reporter.FileWrapperTestPipe(); + oSubXmlFile.write(""" +<?xml version="1.0" encoding="UTF-8" ?> +<Test timestamp="2013-05-29T08:59:05.930602000Z" name="tstRTGetOpt"> + <Test timestamp="2013-05-29T08:59:05.930656000Z" name="Basics"> + <Passed timestamp="2013-05-29T08:59:05.930756000Z"/> + </Test> + <Test timestamp="2013-05-29T08:59:05.930995000Z" name="RTGetOpt - IPv4"> + <Passed timestamp="2013-05-29T08:59:05.931036000Z"/> + </Test> + <Test timestamp="2013-05-29T08:59:05.931161000Z" name="RTGetOpt - MAC Address"> + <Passed timestamp="2013-05-29T08:59:05.931194000Z"/> + </Test> + <Test timestamp="2013-05-29T08:59:05.931313000Z" name="RTGetOpt - Option w/ Index"> + <Passed timestamp="2013-05-29T08:59:05.931357000Z"/> + </Test> + <Test timestamp="2013-05-29T08:59:05.931475000Z" name="RTGetOptFetchValue"> + <Passed timestamp="2013-05-29T08:59:05.931516000Z"/> + </Test> + <Test timestamp="2013-05-29T08:59:05.931640000Z" name="RTGetOpt - bool on/off"> + <Passed timestamp="2013-05-29T08:59:05.931687000Z"/> + </Test> + <Test timestamp="2013-05-29T08:59:05.931807000Z" name="Standard options"> + <Passed timestamp="2013-05-29T08:59:05.931843000Z"/> + </Test> + <Test timestamp="2013-05-29T08:59:05.931963000Z" name="Options first"> + <Passed timestamp="2013-05-29T08:59:05.932035000Z"/> + </Test> +"""); + oSubXmlFile.close(); + oSubXmlFile = None; + reporter.testDone(); + + # The use of testFailure. + reporter.testStart('Using testFailure()'); + reporter.testValue('value-name3', 12345678, 'times'); + reporter.testFailure('failure detail message'); + reporter.testDone(); + + return True; + + +if __name__ == '__main__': + sys.exit(tdSelfTest3().main(sys.argv)); + diff --git a/src/VBox/ValidationKit/tests/selftests/tdSelfTest4.py b/src/VBox/ValidationKit/tests/selftests/tdSelfTest4.py new file mode 100755 index 00000000..c1eb60b6 --- /dev/null +++ b/src/VBox/ValidationKit/tests/selftests/tdSelfTest4.py @@ -0,0 +1,125 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# $Id: tdSelfTest4.py $ + +""" +Test Manager / Suite Self Test #4 - Testing result overflow handling. +""" + +__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 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.base import TestDriverBase, InvalidOption; + + +class tdSelfTest4(TestDriverBase): + """ + Test Manager / Suite Self Test #4 - Testing result overflow handling. + """ + + ## Valid tests. + kasValidTests = [ 'immediate-sub-tests', 'total-sub-tests', 'immediate-values', 'total-values', 'immediate-messages']; + + def __init__(self): + TestDriverBase.__init__(self); + self.sOptWhich = 'immediate-sub-tests'; + + def parseOption(self, asArgs, iArg): + if asArgs[iArg] == '--test': + iArg = self.requireMoreArgs(1, asArgs, iArg); + if asArgs[iArg] not in self.kasValidTests: + raise InvalidOption('Invalid test name "%s". Must be one of: %s' + % (asArgs[iArg], ', '.join(self.kasValidTests),)); + self.sOptWhich = asArgs[iArg]; + else: + return TestDriverBase.parseOption(self, asArgs, iArg); + return iArg + 1; + + def actionExecute(self): + # Too many immediate sub-tests. + if self.sOptWhich == 'immediate-sub-tests': + reporter.testStart('Too many immediate sub-tests (negative)'); + for i in range(1024): + reporter.testStart('subsub%d' % i); + reporter.testDone(); + # Too many sub-tests in total. + elif self.sOptWhich == 'total-sub-tests': + reporter.testStart('Too many sub-tests (negative)'); + # 32 * 256 = 2^(5+8) = 2^13 = 8192. + for i in range(32): + reporter.testStart('subsub%d' % i); + for j in range(256): + reporter.testStart('subsubsub%d' % j); + reporter.testDone(); + reporter.testDone(); + # Too many immediate values. + elif self.sOptWhich == 'immediate-values': + reporter.testStart('Too many immediate values (negative)'); + for i in range(512): + reporter.testValue('value%d' % i, i, 'times'); + # Too many values in total. + elif self.sOptWhich == 'total-values': + reporter.testStart('Too many sub-tests (negative)'); + for i in range(256): + reporter.testStart('subsub%d' % i); + for j in range(64): + reporter.testValue('value%d' % j, i * 10000 + j, 'times'); + reporter.testDone(); + # Too many failure reasons (only immediate since the limit is extremely low). + elif self.sOptWhich == 'immediate-messages': + reporter.testStart('Too many immediate messages (negative)'); + for i in range(16): + reporter.testFailure('Detail %d' % i); + else: + reporter.testStart('Unknown test %s' % (self.sOptWhich,)); + reporter.error('Invalid test selected: %s' % (self.sOptWhich,)); + reporter.testDone(); + return True; + + +if __name__ == '__main__': + sys.exit(tdSelfTest4().main(sys.argv)); + |