diff --git a/test/scripts/auto_xts_test/run.bat b/test/scripts/auto_xts_test/run.bat index 1fda3afb00e0efee07df58c71e4767b74ea2df58..f372bb6b7858a27b502f85e1e6d1264770ac8013 100755 --- a/test/scripts/auto_xts_test/run.bat +++ b/test/scripts/auto_xts_test/run.bat @@ -56,7 +56,8 @@ call %var%\dayu200_xts\suites\acts\run.bat run -l %value% REM get result cd /d %~dp0 echo "Successfully excute script" >> log.log -if not exist result (md result) +if exist result (rd /s /q result) +md result python get_result.py ENDLOCAL exit diff --git a/test/scripts/email_config.yaml b/test/scripts/email_config.yaml new file mode 100644 index 0000000000000000000000000000000000000000..63183d6d16706085c01197d848b1dd0a27303e0e --- /dev/null +++ b/test/scripts/email_config.yaml @@ -0,0 +1,25 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +sender_email_address : +auth_code : +receiver_list : +smtp_server: +smtp_port: + +xts_report_file : ".\\auto_xts_test\\result\\summary_report.html" +sdk_report_file : "" +perf_report_file : "" +attatchment_files : + - ".\\auto_xts_test\\result\\details_report.html" + - ".\\auto_xts_test\\result\\failures_report.html" diff --git a/test/scripts/send_email.py b/test/scripts/send_email.py new file mode 100755 index 0000000000000000000000000000000000000000..ed107160d994b720331bab16bae2d43264f9d6ad --- /dev/null +++ b/test/scripts/send_email.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import os +import smtplib +import socket +from email.message import EmailMessage + +import yaml + + +def add_content(content, file_name, test_part): + if file_name == "": + content += f'

{test_part} not complete yet

' + return content + if not os.path.exists(file_name): + content += f'

{test_part} run failed

' + return content + with open(file_name, 'r') as f: + content += f.read() + return content + + +def add_attachment(msg, file_list): + for file in file_list: + if os.path.exists(file): + with open(file, 'r') as f: + msg.add_attachment(f.read(), 'html', filename=os.path.basename(file)) + + +def send_email(): + yl = open(r".\email_config.yaml", 'r') + data = yaml.safe_load(yl.read()) + sender = data["sender_email_address"] + auth_code = data["auth_code"] + receiver = data["receiver_list"] + smtp_server = data["smtp_server"] + smtp_port = data["smtp_port"] + xts_test = data["xts_report_file"] + sdk_test = data["sdk_report_file"] + perf_test = data["perf_report_file"] + attachment_files = data["attatchment_files"] + yl.close() + + msg = EmailMessage() + msg['From'] = sender + msg['To'] = ", ".join(receiver) + msg['Subject'] = "Arkcompiler Test" + + html = "" + dividing_line = '
' + html = add_content(html, xts_test, "xts_test") + html += dividing_line + html = add_content(html, sdk_test, "sdk_test") + html += dividing_line + html = add_content(html, perf_test, "perf_test") + msg.add_related(html, "html") + + add_attachment(msg, attachment_files) + + smtp = smtplib.SMTP(smtp_server, smtp_port) + smtp.login(sender, auth_code) + smtp.sendmail(sender, receiver, msg.as_string()) + smtp.quit() + + +if __name__ == "__main__": + send_email() \ No newline at end of file diff --git a/test/scripts/timer.py b/test/scripts/timer.py new file mode 100755 index 0000000000000000000000000000000000000000..e734372c5797097b2bb39f653408b3114ad1ed12 --- /dev/null +++ b/test/scripts/timer.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import os +import subprocess +import time + +import schedule + + +def job(cmd): + subprocess.run(cmd, shell=False) + + +if __name__ == "__main__": + os.chdir(os.path.dirname(os.path.realpath(__file__))) + #do preparations + schedule.every().day.at("20:00").do(job, cmd=r'.\auto_xts_test\run.bat').tag('daily_xts_task') + #do sdk_test + #do perf_test + schedule.every().day.at("20:00").do(job, cmd=r'python .\send_email.py').tag("send_email") + schedule.run_all() + while True: + schedule.run_pending() + time.sleep(1) \ No newline at end of file