cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#!/usr/bin/env python
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# -*- coding: utf-8 -*-
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# $Id$
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncTest Manager / Suite Self Test #4 - Testing result overflow handling.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__copyright__ = \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCopyright (C) 2010-2014 Oracle Corporation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThis file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncavailable from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncyou can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncGeneral Public License (GPL) as published by the Free Software
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncFoundation, in version 2 as it comes in the "COPYING" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution. VirtualBox OSE is distributed in the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynchope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThe contents of this file may alternatively be used under the terms
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncof the Common Development and Distribution License Version 1.0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync(CDDL) only, as it comes in the "COPYING.CDDL" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution, in which case the provisions of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCDDL are applicable instead of those of the GPL.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncYou may elect to license modified versions of this file under the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncterms and conditions of either the GPL or the CDDL or both.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__version__ = "$Revision$"
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Standard Python imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport os;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport sys;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Only the main script needs to modify the path.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctry: __file__
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncexcept: __file__ = sys.argv[0];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncg_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncsys.path.append(g_ksValidationKitDir);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Validation Kit imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testdriver import reporter;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testdriver.base import TestDriverBase, InvalidOption;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass tdSelfTest4(TestDriverBase):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Test Manager / Suite Self Test #4 - Testing result overflow handling.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## Valid tests.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync kasValidTests = [ 'immediate-sub-tests', 'total-sub-tests', 'immediate-values', 'total-values', 'immediate-messages'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync TestDriverBase.__init__(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sOptWhich = 'immediate-sub-tests';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def parseOption(self, asArgs, iArg):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if asArgs[iArg] == '--test':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg = self.requireMoreArgs(1, asArgs, iArg);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if asArgs[iArg] not in self.kasValidTests:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise InvalidOption('Invalid test name "%s". Must be one of: %s'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (asArgs[iArg], ', '.join(self.kasValidTests),));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sOptWhich = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return TestDriverBase.parseOption(self, asArgs, iArg);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return iArg + 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def actionExecute(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Too many immediate sub-tests.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sOptWhich == 'immediate-sub-tests':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('Too many immediate sub-tests (negative)');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(1024):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('subsub%d' % i);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Too many sub-tests in total.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.sOptWhich == 'total-sub-tests':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('Too many sub-tests (negative)');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # 32 * 256 = 2^(5+8) = 2^13 = 8192.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(32):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('subsub%d' % i);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for j in range(256):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('subsubsub%d' % j);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Too many immediate values.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.sOptWhich == 'immediate-values':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('Too many immediate values (negative)');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(512):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testValue('value%d' % i, i, 'times');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Too many values in total.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.sOptWhich == 'total-values':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('Too many sub-tests (negative)');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(256):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('subsub%d' % i);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for j in range(64):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testValue('value%d' % j, i * 10000 + j, 'times');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Too many failure reasons (only immediate since the limit is extremely low).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.sOptWhich == 'immediate-messages':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('Too many immediate messages (negative)');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(16):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testFailure('Detail %d' % i);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart('Unknown test %s' % (self.sOptWhich,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('Invalid test selected: %s' % (self.sOptWhich,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncif __name__ == '__main__':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sys.exit(tdSelfTest4().main(sys.argv));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync