• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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: entrance to run sdk test suite
19"""
20
21import logging
22import os
23import sys
24import time
25
26from execution import execute
27from options import process_options
28from preparation import prepare_test_env
29from result import process_test_result
30
31
32def run():
33    old_env = os.environ.copy()
34    try:
35        start_time = time.time()
36        test_tasks = process_options()
37        if not test_tasks:
38            logging.error("No test task found, test suite exit!")
39            sys.exit(1)
40
41        if not prepare_test_env():
42            logging.error("Prepare test environment failed, test suite exit!")
43            sys.exit(1)
44
45        execute(test_tasks)
46        process_test_result(test_tasks, start_time)
47    except Exception as e:
48        logging.exception(e)
49    finally:
50        os.environ.clear()
51        os.environ.update(old_env)
52
53
54if __name__ == '__main__':
55    run()