1#!/usr/bin/env python3
2# coding: utf-8
3
4"""
5Copyright (c) 2023 Huawei Device Co., Ltd.
6Licensed under the Apache License, Version 2.0 (the "License");
7you may not use this file except in compliance with the License.
8You may obtain a copy of the License at
9
10    http://www.apache.org/licenses/LICENSE-2.0
11
12Unless required by applicable law or agreed to in writing, software
13distributed under the License is distributed on an "AS IS" BASIS,
14WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15See the License for the specific language governing permissions and
16limitations under the License.
17
18Description: entry to run sdk test daily
19"""
20
21import os
22import subprocess
23
24import utils
25
26
27def run():
28    cmd = ['python', 'run.py']
29    cmd.extend(['--hapMode', 'all'])
30    cmd.extend(['--compileMode', 'all'])
31    cmd.extend(['--logLevel', 'debug'])
32    cmd.extend(['--runHaps'])
33    cmd.extend(['--logFile', 'log' + '_' + utils.get_time_string() + '.txt'])
34
35    current_dir = os.path.dirname(os.path.abspath(__file__))
36    print(current_dir)
37    print(cmd)
38    process = subprocess.Popen(cmd, cwd=current_dir,
39                               stdout=subprocess.PIPE,
40                               stderr=subprocess.PIPE)
41
42    stdout, stderr = process.communicate(timeout=60 * 60 * 5)
43    stdout_utf8 = stdout.decode("utf-8", errors="ignore")
44    stderr_utf8 = stderr.decode("utf-8", errors="ignore")
45    print(f"cmd stdout: {stdout_utf8}")
46    print(f"cmd stderr: {stderr_utf8}")
47
48
49if __name__ == '__main__':
50    run()
51