1 # Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http:#www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 class for handling Test Apps. Currently it provides the following features:
20 3. parse application info from its path. for example:
21 * provide download info
22 * provide partition table info
24 Test Apps should inherent from BaseApp class and overwrite the methods.
30 # timestamp used for calculate log folder name
31 LOG_FOLDER_TIMESTAMP = time.time()
34 class BaseApp(object):
37 Defines the mandatory methods that App need to implement.
38 Also implements some common methods.
40 :param app_path: the path for app.
43 def __init__(self, app_path):
47 def get_sdk_path(cls):
51 subclass must overwrite this method.
60 get SDK related tools for applications
62 subclass must overwrite this method.
64 :return: tuple, abs path of each tool
69 def get_log_folder(cls, test_suite_name):
71 By default log folder is ``${SDK_PATH}/TEST_LOGS/${test_suite_name}_${timestamp}``.
73 The log folder name is consist once start running, ensure all logs of will be put into the same folder.
75 :param test_suite_name: the test suite name, by default it's the base file name for main module
76 :return: the log folder path
78 if not test_suite_name:
79 test_suite_name = os.path.splitext(os.path.basename(sys.modules['__main__'].__file__))[0]
80 sdk_path = cls.get_sdk_path()
81 log_folder = os.path.join(sdk_path, "TEST_LOGS",
83 time.strftime("_%m%d_%H_%M_%S", time.localtime(LOG_FOLDER_TIMESTAMP)))
84 if not os.path.exists(log_folder):
85 os.makedirs(log_folder)
88 def process_app_info(self):
90 parse built app info for DUTTool
92 subclass must overwrite this method.
94 :return: required info for specific DUTTool