1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3# 4# Copyright (c) 2023 Huawei Device Co., Ltd. 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17import argparse 18import os 19import subprocess 20import time 21 22import schedule 23 24from utils.download_sdk_and_image.download import get_the_image 25 26 27def prepare_test(): 28 arguments = parse_args() 29 prepared = True 30 if not arguments.skip_download_sdk: 31 sdk_prepared = get_the_image('sdk', '', None, None) 32 prepared = prepared and sdk_prepared 33 if not arguments.skip_download_dayu: 34 dayu_prepared = get_the_image('dayu', '', None, None) 35 job(['python', './utils/flash_image/burn_image.py']) 36 prepared = prepared and dayu_prepared 37 job(['python', './utils/commit_message/get_commit_message.py']) 38 return prepared 39 40 41def parse_args(): 42 parser = argparse.ArgumentParser() 43 parser.add_argument('--skipDownloadSdk', dest='skip_download_sdk', action='store_true', default=False, 44 help='specify whether to skip the download sdk or not') 45 parser.add_argument('--skipDownloadDayu', dest='skip_download_dayu', action='store_true', default=False, 46 help='specify whether to skip the download dayu or not') 47 48 return parser.parse_args() 49 50 51def job(cmd): 52 subprocess.run(cmd, shell=False) 53 54 55def run(): 56 if not prepare_test(): 57 return 58 59 job(os.path.join(".", "auto_xts_test", "run.bat")) 60 job(f'python {os.path.join(".", "sdk_test", "entry.py")}') 61 job(f'python {os.path.join(".", "performance_test", "performance_entry.py")}') 62 job(f'python {os.path.join(".", "utils", "send_email", "send_email.py")}') 63 64 65if __name__ == '__main__': 66 schedule.every().day.at("02:10").do(run) 67 run() 68 while True: 69 schedule.run_pending() 70 time.sleep(1) 71 72 73