From patchwork Tue May 24 07:08:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas Meneghel Rodrigues X-Patchwork-Id: 811062 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4O78Hie011269 for ; Tue, 24 May 2011 07:08:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753785Ab1EXHIM (ORCPT ); Tue, 24 May 2011 03:08:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39104 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752341Ab1EXHIL (ORCPT ); Tue, 24 May 2011 03:08:11 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p4O78ADS022814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 24 May 2011 03:08:10 -0400 Received: from freedom.redhat.com (vpn-9-252.rdu.redhat.com [10.11.9.252]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p4O783xV021922; Tue, 24 May 2011 03:08:09 -0400 From: Lucas Meneghel Rodrigues To: autotest@test.kernel.org Cc: kvm@vger.kernel.org, Lucas Meneghel Rodrigues , Jiri Zupka Subject: [PATCH 3/4] tools: Make html_report to deal with subtest results Date: Tue, 24 May 2011 04:08:10 -0300 Message-Id: <1306220891-3993-4-git-send-email-lmr@redhat.com> In-Reply-To: <1306220891-3993-1-git-send-email-lmr@redhat.com> References: <1306220891-3993-1-git-send-email-lmr@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 24 May 2011 07:08:17 +0000 (UTC) Signed-off-by: Jiri Zupka --- client/tools/html_report.py | 124 ++++++++++++++++++++++++------------------- 1 files changed, 69 insertions(+), 55 deletions(-) diff --git a/client/tools/html_report.py b/client/tools/html_report.py index c4e97b2..563a7a9 100755 --- a/client/tools/html_report.py +++ b/client/tools/html_report.py @@ -1372,7 +1372,7 @@ function processList(ul) { } """ -stimelist = [] + def make_html_file(metadata, results, tag, host, output_file_name, dirname): @@ -1430,11 +1430,12 @@ return true; total_failed = 0 total_passed = 0 for res in results: - total_executed += 1 - if res['status'] == 'GOOD': - total_passed += 1 - else: - total_failed += 1 + if results[res][2] != None: + total_executed += 1 + if results[res][2]['status'] == 'GOOD': + total_passed += 1 + else: + total_failed += 1 stat_str = 'No test cases executed' if total_executed > 0: failed_perct = int(float(total_failed)/float(total_executed)*100) @@ -1471,39 +1472,46 @@ id="t1" class="stats table-autosort:4 table-autofilter table-stripeclass:alterna """ print >> output, result_table_prefix - for res in results: - print >> output, '' - print >> output, '%s' % res['time'] - print >> output, '%s' % res['testcase'] - if res['status'] == 'GOOD': - print >> output, 'PASS' - elif res['status'] == 'FAIL': - print >> output, 'FAIL' - elif res['status'] == 'ERROR': - print >> output, 'ERROR!' - else: - print >> output, '%s' % res['status'] - # print exec time (seconds) - print >> output, '%s' % res['exec_time_sec'] - # print log only if test failed.. - if res['log']: - #chop all '\n' from log text (to prevent html errors) - rx1 = re.compile('(\s+)') - log_text = rx1.sub(' ', res['log']) - - # allow only a-zA-Z0-9_ in html title name - # (due to bug in MS-explorer) - rx2 = re.compile('([^a-zA-Z_0-9])') - updated_tag = rx2.sub('_', res['title']) - - html_body_text = '%s%s' % (str(updated_tag), log_text) - print >> output, 'Info' % (str(updated_tag), str(html_body_text)) - else: - print >> output, '' - # print execution time - print >> output, 'Debug' % os.path.join(dirname, res['title'], "debug") + def print_result(result, indent): + while result != []: + r = result.pop(0) + print r + res = results[r][2] + print >> output, '' + print >> output, '%s' % res['time'] + print >> output, '%s' % (indent * 20, res['title']) + if res['status'] == 'GOOD': + print >> output, 'PASS' + elif res['status'] == 'FAIL': + print >> output, 'FAIL' + elif res['status'] == 'ERROR': + print >> output, 'ERROR!' + else: + print >> output, '%s' % res['status'] + # print exec time (seconds) + print >> output, '%s' % res['exec_time_sec'] + # print log only if test failed.. + if res['log']: + #chop all '\n' from log text (to prevent html errors) + rx1 = re.compile('(\s+)') + log_text = rx1.sub(' ', res['log']) + + # allow only a-zA-Z0-9_ in html title name + # (due to bug in MS-explorer) + rx2 = re.compile('([^a-zA-Z_0-9])') + updated_tag = rx2.sub('_', res['title']) + + html_body_text = '%s%s' % (str(updated_tag), log_text) + print >> output, 'Info' % (str(updated_tag), str(html_body_text)) + else: + print >> output, '' + # print execution time + print >> output, 'Debug' % os.path.join(dirname, res['subdir'], "debug") - print >> output, '' + print >> output, '' + print_result(results[r][1], indent + 1) + + print_result(results[""][1], 0) print >> output, "" @@ -1531,21 +1539,27 @@ id="t1" class="stats table-autosort:4 table-autofilter table-stripeclass:alterna output.close() -def parse_result(dirname, line): +def parse_result(dirname, line, results_data): """ Parse job status log line. @param dirname: Job results dir @param line: Status log line. + @param results_data: Dictionary with for results. """ parts = line.split() if len(parts) < 4: return None - global stimelist + global tests if parts[0] == 'START': pair = parts[3].split('=') stime = int(pair[1]) - stimelist.append(stime) + results_data[parts[1]] = [stime, [], None] + try: + parent_test = re.findall(r".*/", parts[1])[0][:-1] + results_data[parent_test][1].append(parts[1]) + except IndexError: + results_data[""][1].append(parts[1]) elif (parts[0] == 'END'): result = {} @@ -1562,24 +1576,25 @@ def parse_result(dirname, line): result['exec_time_sec'] = 'na' tag = parts[3] + result['subdir'] = parts[2] # assign actual values rx = re.compile('^(\w+)\.(.*)$') m1 = rx.findall(parts[3]) - result['testcase'] = str(tag) + if len(m1): + result['testcase'] = m1[0][1] + else: + result['testcase'] = parts[3] result['title'] = str(tag) result['status'] = parts[1] if result['status'] != 'GOOD': result['log'] = get_exec_log(dirname, tag) - if len(stimelist)>0: + if len(results_data)>0: pair = parts[4].split('=') - try: - etime = int(pair[1]) - stime = stimelist.pop() - total_exec_time_sec = etime - stime - result['exec_time_sec'] = total_exec_time_sec - except ValueError: - result['exec_time_sec'] = "Unknown" - return result + etime = int(pair[1]) + stime = results_data[parts[2]][0] + total_exec_time_sec = etime - stime + result['exec_time_sec'] = total_exec_time_sec + results_data[parts[2]][2] = result return None @@ -1702,16 +1717,15 @@ def create_report(dirname, html_path='', output_file_name=None): host = get_info_file(os.path.join(sysinfo_dir, 'hostname')) rx = re.compile('^\s+[END|START].*$') # create the results set dict - results_data = [] + results_data = {} + results_data[""] = [0, [], None] if os.path.exists(status_file_name): f = open(status_file_name, "r") lines = f.readlines() f.close() for line in lines: if rx.match(line): - result_dict = parse_result(dirname, line) - if result_dict: - results_data.append(result_dict) + parse_result(dirname, line, results_data) # create the meta info dict metalist = { 'uname': get_info_file(os.path.join(sysinfo_dir, 'uname')),