From 4f19f467865cd3b6b49ce5c39502a031525cfc16 Mon Sep 17 00:00:00 2001 From: duerpei Date: Wed, 10 Aug 2022 17:01:23 +0800 Subject: conftest: get zip file name dynamically Get zip file name dynamically, and the name of the zip file is formatted as follows: agl-test-log-13.0.1-raspberrypi4-20200808.zip And delete some useless comments Bug-AGL: SPEC-4345 Signed-off-by: duerpei Change-Id: Id321deb0232388a2ab4271d04ee6c5979a625672 --- conftest.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/conftest.py b/conftest.py index eade841..5dea9a4 100644 --- a/conftest.py +++ b/conftest.py @@ -36,8 +36,15 @@ def setup_compress_function(): json.dump(summary_data,summary_file,indent=4,sort_keys=False) summary_file.close() + #Get zip file name + issue = subprocess.getoutput('cat /etc/issue') + version = issue[23:-7] + machine_name = subprocess.getoutput('uname -n') + date = subprocess.getoutput('date +%Y%m%d') + zip_name = "agl-test-log-" + version + '-' + machine_name + '-' + date + #Creat summary report in html - html = get_summary_report_html(summary_data) + html = get_summary_report_html(summary_data,zip_name) html_path = TMP_LOGS_DIR + "test-report/summary-report.html" html_file = open(html_path,"w") html_file.write(html) @@ -49,14 +56,10 @@ def setup_compress_function(): shutil.copyfile(source_file,target_file) #Package the test report - #TODO The name of the zip file is formatted as follows: - # agl-test-log-13.0.1-raspberrypi4-20200808.zip - base_name = REPORT_LOGS_DIR + "agl-test-log-xxx" + base_name = REPORT_LOGS_DIR + zip_name root_dir = TMP_LOGS_DIR + "test-report" shutil.make_archive(base_name,"zip",root_dir) - # TODO: - # Upload the final log to Artifactorial #Summarize all reports.json file def get_summary_data(report_files): @@ -107,7 +110,7 @@ def get_summary_data(report_files): return summary_data #Generate content for summary report json file -def get_summary_report_html(summary_data): +def get_summary_report_html(summary_data,zip_name): status = "fail" if(summary_data["summary"]["summary_total"]==summary_data["summary"]["summary_passed"]): status = "success" @@ -163,7 +166,7 @@ def get_summary_report_html(summary_data): html = html + "Detail log :" #TODO update the link address for agl-test-log-xxx.zip html = html + "agl-test-log-13.0.1-raspberrypi4-20200808.zip" + html = html + "\">" + zip_name + ".zip" html = html + "" html = html + "" -- cgit