# -*- coding: utf-8 -*-
# $Id$
"""
Test Manager WUI - Test Results.
"""
__copyright__ = \
"""
Copyright (C) 2012-2014 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE 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.
"""
# Python imports.
# Validation Kit imports.
from testmanager.webui.wuicontentbase import WuiContentBase, WuiListContentBase, WuiHtmlBase, WuiTmLink, WuiLinkBase, \
"""Display test case result"""
# Cyclic import hacks.
"""Translate some object to HTML."""
"""Generate HTML code for table"""
sHtml = u' <table class="tmtbl-testresult-details" width="100%%">\n';
for aoSubRows in aoTableContent:
continue; # Can happen if there is no testsuit.
sHtml += u' \n' \
u' <tr class="tmtbl-result-details-caption">\n' \
u' <td colspan="2">%s</td>\n' \
u' </tr>\n' \
iRow = 0;
iRow += 1;
sHtml += u' <td class="tmtbl-result-details-subcaption" colspan="2">%s</td>\n' \
else:
else:
sHtml += u' </tr>\n';
sHtml += u' </table>\n';
return sHtml
"""Return sStatus string surrounded by HTML highlight code """
sTmp = '<font color=%s><b>%s</b></font>' \
return sTmp
""" Formats each binary (if any) into a row with a download link. """
if sBinaries is not None:
return aoRows;
"""
Recursively generate event table rows for the result set.
oTestResult is an object of the type TestResultDataEx.
"""
# Hack: Replace empty outer test result name with (pretty) command line.
if iRow == 1:
sName = '';
else:
# Format error count.
sErrCnt = '';
# Format the include in graph checkboxes.
sResultGraph = '<input type="checkbox" name="%s" value="%s%s" title="Include result in graph."/>' \
sElapsedGraph = '';
if oTestResult.tsElapsed is not None:
sElapsedGraph = '<input type="checkbox" name="%s" value="%s%s" title="Include elapsed time in graph."/>' \
# Leaf - single row.
if oTestResult.tsElapsed is not None:
sHtml = ' <tr class="%s tmtbl-events-leaf tmtbl-events-lvl%s tmstatusrow-%s">\n' \
' <td>%s</td>\n' \
' <td>%s</td>\n' \
' <td>%s</td>\n' \
' <td>%s</td>\n' \
' <td colspan="2"%s>%s%s</td>\n' \
' <td>%s</td>\n' \
' </tr>\n' \
sResultGraph );
iRow += 1;
else:
# Multiple rows.
sHtml = ' <tr class="%s tmtbl-events-first tmtbl-events-lvl%s ">\n' \
' <td>%s</td>\n' \
' <td></td>\n' \
' <td></td>\n' \
' <td>%s</td>\n' \
' <td colspan="2">%s</td>\n' \
' <td></td>\n' \
' </tr>\n' \
iRow += 1;
# Depth.
sHtml += sChildHtml;
# Messages.
sHtml += ' <tr class="%s tmtbl-events-message tmtbl-events-lvl%s">\n' \
' <td>%s</td>\n' \
' <td></td>\n' \
' <td></td>\n' \
' <td colspan="3">%s: %s</td>\n' \
' <td></td>\n' \
' </tr>\n' \
iRow += 1;
# Values.
sHtml += ' <tr class="%s tmtbl-events-value tmtbl-events-lvl%s">\n' \
' <td>%s</td>\n' \
' <td></td>\n' \
' <td></td>\n' \
' <td>%s</td>\n' \
' <td class="tmtbl-events-number">%s</td>\n' \
' <td class="tmtbl-events-unit">%s</td>\n' \
' <td><input type="checkbox" name="%s" value="%s%s:%u" title="Include value in graph."></td>\n' \
' </tr>\n' \
iRow += 1;
# Files.
aoLinks = [
]
else:
aoLinks = [
]
sHtml += ' <tr class="%s tmtbl-events-file tmtbl-events-lvl%s">\n' \
' <td></td>\n' \
' <td>%s</td>\n' \
' <td></td>\n' \
' <td>%s</td>\n' \
' <td></td>\n' \
' <td></td>\n' \
' <td></td>\n' \
' </tr>\n' \
iRow += 1;
# Done?
if oTestResult.tsElapsed is not None:
sHtml += ' <tr class="%s tmtbl-events-final tmtbl-events-lvl%s tmstatusrow-%s">\n' \
' <td>%s</td>\n' \
' <td>%s</td>\n' \
' <td>%s</td>\n' \
' <td>%s</td>\n' \
' <td colspan="2"%s>%s%s</td>\n' \
' <td>%s</td>\n' \
' </tr>\n' \
iRow += 1;
if oTestResult.isFailure():
iFailure += 1;
"""Show detailed result"""
"""Get HTML <ul> list of Test Case name items"""
sTmp = '<ul>'
for oTestCaseData in aoTestCaseData:
sTmp += '</ul>'
else:
sTmp = 'No items'
return sTmp
"""Get HTML <ul> list of Global Resource name items"""
sTmp = '<ul>'
sTmp += '</ul>'
else:
sTmp = 'No items'
return sTmp
asHtml = []
# Test result + test set details.
aoResultRows = [
fBracketed = False),
];
cSecCfgTimeout = oTestCaseEx.cSecTimeout if oTestVarEx.cSecTimeout is None else oTestVarEx.cSecTimeout;
if cSecEffTimeout != cSecCfgTimeout:
aoResultRows += [
fBracketed = False) ),
];
aoResultRows += [ ( 'Done:',
fBracketed = False) ) ];
else:
aoResultRows.append([ 'Member No:', '#%s (of %s)' % (oTestSet.iGangMemberNo, oTestVarEx.cGangMembers) ]);
aoResultRows += [
fBracketed = False) ),
];
if oTestVarEx.sTestBoxReqExpr is not None:
if oTestVarEx.sBuildReqExpr is not None:
if oTestCaseEx.sValidationKitZips is not None and oTestCaseEx.sValidationKitZips != '@VALIDATIONKIT_ZIP@':
# Builds.
aoBuildRows = [];
if oBuildEx is not None:
aoBuildRows += [
fBracketed = False),
];
aoBuildRows += [
fBracketed = False) ),
];
aoValidationKitRows = [];
if oValidationKitEx is not None:
aoValidationKitRows += [
fBracketed = False),
];
aoValidationKitRows += [ ( 'Revision:', WuiSvnLink(oValidationKitEx.iRevision, fBracketed = False) ) ];
aoValidationKitRows += [
];
if oValidationKitEx.uidAuthor is not None:
if oValidationKitEx.sLogUrl is not None:
aoValidationKitRows += [ ( 'Log:', WuiBuildLogLink(oValidationKitEx.sLogUrl, fBracketed = False) ), ];
# TestBox.
aoTestBoxRows = [
fBracketed = False),
];
aoTestBoxRows += [
#( 'UUID:', oTestBox.uuidSystem ),
#( 'Enabled:', oTestBox.fEnabled ),
#( 'Lom Kind:', oTestBox.enmLomKind ),
#( 'Lom IP:', oTestBox.ipLom ),
];
if oTestBox.lCpuRevision is not None:
# ASSUMING x86+AMD64 versioning scheme here.
aoTestBoxRows += [
];
aoTestBoxRows += [
];
aoRows = [
];
#
# Convert the tree to a list of events, values, message and files.
#
sHtmlEvents = '';
sHtmlEvents += '<table class="tmtbl-events" id="tmtbl-events" width="100%">\n';
sHtmlEvents += ' <tr class="tmheader">\n' \
' <th>When</th>\n' \
' <th></th>\n' \
' <th>Elapsed</th>\n' \
' <th>Event name</th>\n' \
' <th colspan="2">Value (status)</th>' \
' <th></th>\n' \
' </tr>\n';
sPrettyCmdLine = ' \\<br> \n'.join(webutils.escapeElem(oTestCaseEx.sBaseCmd
+ ' '
(sTmp, _, cFailures) = self._recursivelyGenerateEvents(oTestResultTree, sPrettyCmdLine, '', 1, 0, oTestSet, 0);
sHtmlEvents += sTmp;
sHtmlEvents += '</table>\n'
#
# Put it all together.
#
sHtml = '<table class="tmtbl-testresult-details-base" width="100%">\n';
sHtml += ' <tr>\n'
sHtml += ' <td valign="top" width="80%" style="padding-left:6px">\n';
sHtml += ' <h2>Events:</h2>\n';
sHtml += ' <form action="#" method="get" id="graph-form">\n' \
' <input type="hidden" name="%s" value="%s"/>\n' \
' <input type="hidden" name="%s" value="%u"/>\n' \
' <input type="hidden" name="%s" value="%u"/>\n' \
' <input type="hidden" name="%s" value="%u"/>\n' \
' <input type="hidden" name="%s" value="%u"/>\n' \
);
sHtml += ' <input type="hidden" name="%s" value="%s"/>\n' \
sHtml += ' <p>\n';
sFormButton = '<button type="submit" onclick="%s">Show graphs</button>' \
sHtml += ' %s %s %s\n' \
}),
}),
}),
);
sHtml += ' </p>\n';
if cFailures == 1:
elif cFailures > 1:
sHtml += ' <p>Jump to failure: ';
if cFailures <= 13:
else:
sHtml += ' ... ';
sHtml += ' </p>\n';
sHtml += sHtmlEvents;
sHtml += ' </form>\n';
sHtml += ' </td>\n';
sHtml += ' </tr>\n';
sHtml += '</table>\n';
return ('Test Case result details', sHtml)
"""
WUI results content generator.
"""
"""Override initialization"""
self._asColumnHeaders = [
'Start',
'Product Build',
'Validation Kit',
'TestBox OS',
'TestBox Name',
'Test Case',
'Elapsed',
'Result',
];
'align="center"', 'align="center"', 'align="center"',
'align="center"', 'align="center"', 'align="center"',
'align="center"', 'align="center"', 'align="center"' ]
# Prepare parameter lists.
"""
Format *show all* table entry
"""
oValidationKit = None;
if oEntry.idBuildTestSuite is not None:
fBracketed = False);
fBracketed = False),];
sTestBoxTitle = u'';
if oEntry.sCpuVendor is not None:
if oEntry.sOsVersion is not None:
asFeatures = [];
#if oEntry.fChipsetIoMmu is True: asFeatures.append(u'I/O\u2011MMU');
return [
fBracketed = False),
],
[ WuiTmLink(oEntry.sTestBoxName, WuiMain.ksScriptName, self._dTestBoxLinkParams, fBracketed = False,
sTitle = sTestBoxTitle),
fBracketed = False) ],
[ WuiTmLink(oEntry.sTestCaseName, WuiMain.ksScriptName, self._dTestCaseLinkParams, fBracketed = False,
fBracketed = False), ],
];