reporting.py revision cf22150eaeeb72431bf1cf65c309a431454fb22b
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# -*- coding: utf-8 -*-
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# $Id$
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncTest Result Report Writer.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThis takes a processed test result tree and creates a HTML, re-structured text,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncor normal text report from it.
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__all__ = ['HtmlReport', 'RstReport', 'TextReport'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef tryAddThousandSeparators(sPotentialInterger):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Apparently, python 3.0(/3.1) has(/will have) support for this..."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Try convert the string/value to a long.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync lVal = long(sPotentialInterger);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync lVal = long(sPotentialInterger);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return sPotentialInterger;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Convert it back to a string (paranoia) and build up the new string.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sOld = str(lVal);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync chSign = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sOld[0] == '-':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync chSign = '-';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sOld = sOld[1:];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sPotentialInterger[0] == '+':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync chSign = '+';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cchDigits = len(sOld);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iDigit = 0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sNewVal = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while iDigit < cchDigits:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if (iDigit % 3) == 0 and iDigit > 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sNewVal = ' ' + sNewVal;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sNewVal = sOld[cchDigits - iDigit - 1] + sNewVal;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iDigit += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return chSign + sNewVal;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass Table(object):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync A table as a header as well as data rows, thus this class.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self, oTest, fSplitDiff):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aasRows = [];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asHeader = ['Test',];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asUnits = ['',];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oValue in oTest.aoValues:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asHeader.append(oValue.sName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.asUnits.append(oValue.sUnit);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.addRow(oTest, fSplitDiff);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def addRow(self, oTest, fSplitDiff):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """Adds a row."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asRow = [oTest.getFullName(),];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oValue in oTest.aoValues:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asRow.append(oValue.sValue);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not fSplitDiff:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aasRows.append(asRow);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Split cells into multiple rows on '|'. Omit the first column.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iRow = 0;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asThisRow = [asRow[0], ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fMoreTodo = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while fMoreTodo:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(1, len(asRow)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asSplit = asRow[i].split('|');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asThisRow.append(asSplit[0]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asRow[i] = '|'.join(asSplit[1:])
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aasRows.append(asThisRow);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Done?
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fMoreTodo = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(1, len(asRow)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if len(asRow[i]):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fMoreTodo = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asThisRow = ['', ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iRow += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Readability hack: Add an extra row if there are diffs.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iRow > 1:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asRow[0] = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aasRows.append(asRow);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def hasTheSameHeadingAsTest(self, oTest):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Checks if the test values has the same heading."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync i = 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oValue in oTest.aoValues:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.asHeader[i] != oValue.sName:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.asUnits[i] != oValue.sUnit:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync i += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def hasTheSameHeadingAsTable(self, oTable):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Checks if the other table has the same heading."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if len(oTable.asHeader) != len(self.asHeader):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(len(self.asHeader)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.asHeader[i] != oTable.asHeader[i]:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.asUnits[i] != oTable.asUnits[i]:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def appendTable(self, oTable):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Append the rows in oTable. oTable has the same heading as us. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aasRows.extend(oTable.aasRows);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # manipulation and stuff
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def optimizeUnit(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Turns bytes into KB, MB or GB. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def addThousandSeparators(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Adds thousand separators to make numbers more readable. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for iRow in range(len(self.aasRows)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for iColumn in range(1, len(self.aasRows[iRow])):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asValues = self.aasRows[iRow][iColumn].split('|');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(len(asValues)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asValues[i] = tryAddThousandSeparators(asValues[i]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aasRows[iRow][iColumn] = '|'.join(asValues);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def getRowWidths(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """Figure out the column withs."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Header is first.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync acchColumns = [];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(len(self.asHeader)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cch = 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asWords = self.asHeader[i].split();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for s in asWords:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if len(s) > cch:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cch = len(s);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if i > 0 and len(self.asUnits[i]) > cch:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cch = len(self.asUnits[i]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync acchColumns.append(cch);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Check out all cells.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for asColumns in self.aasRows:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(len(asColumns)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if len(asColumns[i]) > acchColumns[i]:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync acchColumns[i] = len(asColumns[i]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return acchColumns;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef tabelizeTestResults(oTest, fSplitDiff):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Break the test results down into a list of tables containing the values.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync TODO: Handle passed / failed stuff too. Not important for benchmarks.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Pass 1
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoTables = [];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoStack = [];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoStack.append((oTest, 0));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while len(aoStack) > 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oCurTest, iChild = aoStack.pop();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # depth first
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iChild < len(oCurTest.aoChildren):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoStack.append((oCurTest, iChild + 1));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoStack.append((oCurTest.aoChildren[iChild], 0));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync continue;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # values -> row
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if len(oCurTest.aoValues) > 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if len(aoTables) > 0 and aoTables[len(aoTables) - 1].hasTheSameHeadingAsTest(oCurTest):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoTables[len(aoTables) - 1].addRow(oCurTest, fSplitDiff);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoTables.append(Table(oCurTest, fSplitDiff));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Pass 2 - Combine tables with the same heading.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoTables2 = [];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oTable in aoTables:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(len(aoTables2)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if aoTables2[i].hasTheSameHeadingAsTable(oTable):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoTables2[i].appendTable(oTable);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTable = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTable is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoTables2.append(oTable);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return aoTables2;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef produceHtmlReport(oTest):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Produce an HTML report on stdout (via print).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print 'not implemented: %s' % (oTest);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef produceReStructuredTextReport(oTest):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Produce a ReStructured text report on stdout (via print).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print 'not implemented: %s' % (oTest);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef produceTextReport(oTest):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Produce a text report on stdout (via print).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Report header.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo later
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Tabelize the the results and display the tables.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoTables = tabelizeTestResults(oTest, True)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oTable in aoTables:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo do max/min on the columns where we can do [GMK]B(/s).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTable.addThousandSeparators();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync acchColumns = oTable.getRowWidths();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # The header.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # This is a bit tedious and the solution isn't entirely elegant due
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # to the pick-it-up-as-you-go-along python skills.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aasHeader = [];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aasHeader.append([]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(len(oTable.asHeader)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aasHeader[0].append('');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for iColumn in range(len(oTable.asHeader)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asWords = oTable.asHeader[iColumn].split();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iLine = 0;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for s in asWords:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if len(aasHeader[iLine][iColumn]) <= 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aasHeader[iLine][iColumn] = s;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif len(s) + 1 + len(aasHeader[iLine][iColumn]) <= acchColumns[iColumn]:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aasHeader[iLine][iColumn] += ' ' + s;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iLine += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iLine >= len(aasHeader): # There must be a better way to do this...
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aasHeader.append([]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(len(oTable.asHeader)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aasHeader[iLine].append('');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aasHeader[iLine][iColumn] = s;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for asLine in aasHeader:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLine = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(len(asLine)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if i > 0: sLine += ' ';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLine += asLine[i].center(acchColumns[i]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print sLine;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Units.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLine = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(len(oTable.asUnits)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if i > 0: sLine += ' ';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLine += oTable.asUnits[i].center(acchColumns[i]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print sLine;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Separator line.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLine = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(len(oTable.asHeader)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if i > 0: sLine += ' '
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLine += '=' * acchColumns[i];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print sLine;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # The rows.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for asColumns in oTable.aasRows:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sText = asColumns[0].ljust(acchColumns[0]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(1, len(asColumns)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sText += ' ' + asColumns[i].rjust(acchColumns[i]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print sText;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync