本文整理汇总了Python中mbed_greentea.mbed_greentea_log.gt_logger.gt_log_tab函数的典型用法代码示例。如果您正苦于以下问题:Python gt_log_tab函数的具体用法?Python gt_log_tab怎么用?Python gt_log_tab使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了gt_log_tab函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_binaries_for_targets
def list_binaries_for_targets(build_dir='./build', verbose_footer=False):
"""! Prints tests in target directories, only if tests exist.
@param build_dir Yotta default build directory where tests will be
@param verbose_footer Prints additional "how to use" Greentea footer
@details Skips empty / no tests for target directories.
"""
dir = build_dir
sub_dirs = [os.path.join(dir, o) for o in os.listdir(dir) if os.path.isdir(os.path.join(dir, o))] \
if os.path.exists(dir) else []
def count_tests():
result = 0
for sub_dir in sub_dirs:
test_list = load_ctest_testsuite(sub_dir, binary_type='')
if len(test_list):
for test in test_list:
result += 1
return result
if count_tests():
for sub_dir in sub_dirs:
target_name = sub_dir.split(os.sep)[-1]
gt_logger.gt_log("available tests for target '%s', location '%s'"% (target_name, os.path.abspath(os.path.join(build_dir, sub_dir))))
test_list = load_ctest_testsuite(sub_dir, binary_type='')
if len(test_list):
for test in sorted(test_list):
gt_logger.gt_log_tab("test '%s'"% test)
else:
gt_logger.gt_log_warn("no tests found in current location")
if verbose_footer:
print
print "Example: execute 'mbedgt -t TARGET_NAME -n TEST_NAME' to run test TEST_NAME for target TARGET_NAME"
示例2: get_mbed_targets_from_yotta
def get_mbed_targets_from_yotta(mbed_classic_name):
"""! Function is using 'yotta search' command to fetch matching mbed device target's name
@return Function returns list of possible targets or empty list if value not found
@details Example:
$ yt search -k mbed-target:k64f target
frdm-k64f-gcc 0.0.16: Official mbed build target for the mbed frdm-k64f development board.
frdm-k64f-armcc 0.0.10: Official mbed build target for the mbed frdm-k64f development board, using the armcc toolchain.
Note: Function prints on console
"""
result = []
cmd = ['yotta', '--plain', 'search', '-k', 'mbed-target:%s'% mbed_classic_name.lower().strip(), 'target']
gt_logger.gt_log("yotta search for mbed-target '%s'"% gt_logger.gt_bright(mbed_classic_name.lower().strip()))
gt_logger.gt_log_tab("calling yotta: %s"% " ".join(cmd))
_stdout, _stderr, _ret = run_cli_process(cmd)
if not _ret:
for line in _stdout.splitlines():
yotta_target_name = parse_yotta_search_cmd_output(line)
if yotta_target_name:
if yotta_target_name and yotta_target_name not in result:
result.append(yotta_target_name)
gt_logger.gt_log_tab("found target '%s'" % gt_logger.gt_bright(yotta_target_name))
else:
gt_logger.gt_log_err("calling yotta search failed!")
return result
示例3: get_binary_host_tests_dir
def get_binary_host_tests_dir(binary_path, level=2):
"""! Checks if in binary test group has host_tests directory
@param binary_path Path to binary in test specification
@param level How many directories above test host_tests dir exists
@return Path to host_tests dir in group binary belongs too, None if not found
"""
try:
binary_path_norm = os.path.normpath(binary_path)
current_path_norm = os.path.normpath(os.getcwd())
host_tests_path = binary_path_norm.split(os.sep)[:-level] + ['host_tests']
build_dir_candidates = ['BUILD', '.build']
idx = None
for build_dir_candidate in build_dir_candidates:
if build_dir_candidate in host_tests_path:
idx = host_tests_path.index(build_dir_candidate)
break
if idx is None:
msg = 'The following directories were not in the path: %s' % (', '.join(build_dir_candidates))
raise Exception(msg)
# Cut /<build dir>/tests/TOOLCHAIN/TARGET
host_tests_path = host_tests_path[:idx] + host_tests_path[idx+4:]
host_tests_path = os.sep.join(host_tests_path)
except Exception as e:
gt_logger.gt_log_warn("there was a problem while looking for host_tests directory")
gt_logger.gt_log_tab("level %d, path: %s"% (level, binary_path))
gt_logger.gt_log_tab(str(e))
return None
if os.path.isdir(host_tests_path):
return host_tests_path
return None
示例4: get_mbed_targets_from_yotta_local_module
def get_mbed_targets_from_yotta_local_module(mbed_classic_name, yotta_targets_path='./yotta_targets'):
"""! Function is parsing local yotta targets to fetch matching mbed device target's name
@return Function returns list of possible targets or empty list if value not found
"""
result = []
if os.path.exists(yotta_targets_path):
# All local diorectories with yotta targets
target_dirs = [target_dir_name for target_dir_name in os.listdir(yotta_targets_path) if os.path.isdir(os.path.join(yotta_targets_path, target_dir_name))]
gt_logger.gt_log("local yotta target search in '%s' for compatible mbed-target '%s'"% (gt_logger.gt_bright(yotta_targets_path), gt_logger.gt_bright(mbed_classic_name.lower().strip())))
for target_dir in target_dirs:
path = os.path.join(yotta_targets_path, target_dir, 'target.json')
try:
with open(path, 'r') as data_file:
target_json_data = json.load(data_file)
yotta_target_name = parse_mbed_target_from_target_json(mbed_classic_name, target_json_data)
if yotta_target_name:
target_dir_name = os.path.join(yotta_targets_path, target_dir)
gt_logger.gt_log_tab("inside '%s' found compatible target '%s'"% (gt_logger.gt_bright(target_dir_name), gt_logger.gt_bright(yotta_target_name)))
result.append(yotta_target_name)
except IOError as e:
gt_logger.gt_log_err(str(e))
return result
示例5: merge_multiple_test_specifications_from_file_list
def merge_multiple_test_specifications_from_file_list(test_spec_file_name_list):
"""! For each file in test_spec_file_name_list merge all test specifications into one
@param test_spec_file_name_list List of paths to different test specifications
@return TestSpec object with all test specification data inside
"""
def copy_builds_between_test_specs(source, destination):
"""! Copies build key-value pairs between two test_spec dicts
@param source Source dictionary
@param destination Dictionary with will be applied with 'builds' key-values
@return Dictionary with merged source
"""
result = destination.copy()
if 'builds' in source and 'builds' in destination:
for k in source['builds']:
result['builds'][k] = source['builds'][k]
return result
merged_test_spec = {}
for test_spec_file in test_spec_file_name_list:
gt_logger.gt_log_tab("using '%s'"% test_spec_file)
try:
with open(test_spec_file, 'r') as f:
test_spec_data = json.load(f)
merged_test_spec = copy_builds_between_test_specs(merged_test_spec, test_spec_data)
except Exception as e:
gt_logger.gt_log_err("Unexpected error while processing '%s' test specification file"% test_spec_file)
gt_logger.gt_log_tab(str(e))
merged_test_spec = {}
test_spec = TestSpec()
test_spec.parse(merged_test_spec)
return test_spec
示例6: get_mbed_target_call_yotta_target
def get_mbed_target_call_yotta_target():
"""! Calls yotta's 'yotta target' command to get information about
"""
cmd = ['yotta', '--plain', 'target']
gt_logger.gt_log("checking yotta target in current directory")
gt_logger.gt_log_tab("calling yotta: %s"% " ".join(cmd))
_stdout, _stderr, _ret = run_cli_process(cmd)
return _stdout, _stderr, _ret
示例7: format_before_run
def format_before_run(cmd, format, verbose=False):
if format:
# We will expand first
cmd_expand = GreenteaCliTestHook.expand_parameters(cmd, format)
if cmd_expand:
cmd = cmd_expand
if verbose:
gt_logger.gt_log_tab("hook expanded: %s"% cmd)
cmd = cmd.format(**format)
if verbose:
gt_logger.gt_log_tab("hook formated: %s"% cmd)
return cmd
示例8: list_binaries_for_builds
def list_binaries_for_builds(test_spec, verbose_footer=False):
"""! Parse test spec and list binaries (BOOTABLE) in lexicographical order
@param test_spec Test specification object
@param verbose_footer Prints additional "how to use" Greentea footer
"""
test_builds = test_spec.get_test_builds()
for tb in test_builds:
gt_logger.gt_log("available tests for built '%s', location '%s'"% (tb.get_name(), tb.get_path()))
for tc in sorted(tb.get_tests().keys()):
gt_logger.gt_log_tab("test '%s'"% tc)
if verbose_footer:
print
print "Example: execute 'mbedgt -t BUILD_NAME -n TEST_NAME' to run test TEST_NAME for build TARGET_NAME in current test specification"
示例9: run_command
def run_command(cmd):
"""! Runs command and prints proc stdout on screen
@paran cmd List with command line to execute e.g. ['ls', '-l]
@return Value returned by subprocess.Popen, if failed return None
"""
try:
p = Popen(cmd,
stdout=PIPE,
stderr=STDOUT)
except OSError as e:
gt_logger.gt_log_err("run_host_test.run_command(%s) failed!"% str(cmd))
gt_logger.gt_log_tab(str(e))
return None
return p
示例10: get_coverage_data
def get_coverage_data(build_path, output):
# Example GCOV output
# [1456840876.73][CONN][RXD] {{__coverage_start;c:\Work\core-util/source/PoolAllocator.cpp.gcda;6164636772393034c2733f32...a33e...b9}}
gt_logger.gt_log("checking for GCOV data...")
re_gcov = re.compile(r"^\[(\d+\.\d+)\][^\{]+\{\{(__coverage_start);([^;]+);([^}]+)\}\}$")
for line in output.splitlines():
m = re_gcov.search(line)
if m:
_, _, gcov_path, gcov_payload = m.groups()
try:
bin_gcov_payload = coverage_pack_hex_payload(gcov_payload)
coverage_dump_file(build_path, gcov_path, bin_gcov_payload)
except Exception as e:
gt_logger.gt_log_err("error while handling GCOV data: " + str(e))
gt_logger.gt_log_tab("storing %d bytes in '%s'"% (len(bin_gcov_payload), gcov_path))
示例11: run
def run(self, format=None):
"""! Runs hook after command is formated with in-place {tags}
@format Pass format dictionary to replace hook {tags} with real values
@param format Used to format string with cmd, notation used is e.g: {build_name}
"""
gt_logger.gt_log("hook '%s' execution"% self.name)
cmd = self.format_before_run(self.cmd, format)
gt_logger.gt_log_tab("hook command: %s"% cmd)
(_stdout, _stderr, ret) = self.run_cli_process(cmd)
if _stdout:
print _stdout
if ret:
gt_logger.gt_log_err("hook exited with error: %d, dumping stderr..."% ret)
print _stderr
return ret
示例12: get_mbed_target_from_current_dir
def get_mbed_target_from_current_dir():
"""! Function uses yotta target command to check current target
@return Returns current target or None if target not found (e.g. not yotta package)
"""
result = None
cmd = ['yotta', '--plain', 'target']
gt_logger.gt_log("checking yotta target in current directory")
gt_logger.gt_log_tab("calling yotta: %s"% " ".join(cmd))
_stdout, _stderr, _ret = run_cli_process(cmd)
if not _ret:
for line in _stdout.splitlines():
target = parse_yotta_target_cmd_output(line)
if target:
result = target
break
return result
示例13: build_with_yotta
def build_with_yotta(yotta_target_name, verbose = False, build_to_release = False, build_to_debug = False):
cmd = ["yotta"] # "yotta %s --target=%s,* build"
if verbose:
cmd.append("-v")
cmd.append("--target=%s,*"% yotta_target_name)
cmd.append("build")
if build_to_release:
cmd.append("-r")
elif build_to_debug:
cmd.append("-d")
gt_logger.gt_log("building your sources and tests with yotta...")
gt_logger.gt_log_tab("calling yotta: %s"% (" ".join(cmd)))
yotta_result, yotta_ret = run_cli_command(cmd, shell=False, verbose=verbose)
if yotta_result:
gt_logger.gt_log("yotta build for target '%s' was successful"% gt_logger.gt_bright(yotta_target_name))
else:
gt_logger.gt_log_err("yotta build failed!")
return yotta_result, yotta_ret
示例14: filter_ready_devices
def filter_ready_devices(mbeds_list):
"""! Filters list of MUTs to check if all MUTs are correctly detected with mbed-ls module.
@details This function logs a lot to help users figure out root cause of their problems
@param mbeds_list List of MUTs to verify
@return Tuple of (MUTS detected correctly, MUTs not detected fully)
"""
ready_mbed_devices = [] # Devices which can be used (are fully detected)
not_ready_mbed_devices = [] # Devices which can't be used (are not fully detected)
gt_logger.gt_log("detected %d device%s" % (len(mbeds_list), "s" if len(mbeds_list) != 1 else ""))
for mut in mbeds_list:
if not all(mut.values()):
gt_logger.gt_log_err("mbed-ls was unable to enumerate correctly all properties of the device!")
gt_logger.gt_log_tab(
"check with 'mbedls -j' command if all properties of your device are enumerated properly"
)
for prop in mut:
if not mut[prop]:
# Adding MUT to NOT DETECTED FULLY list
if mut not in not_ready_mbed_devices:
not_ready_mbed_devices.append(mut)
gt_logger.gt_log_err("mbed-ls property '%s' is '%s'" % (prop, str(mut[prop])))
if prop == "serial_port":
gt_logger.gt_log_tab("check if your serial port driver is correctly installed!")
if prop == "mount_point":
gt_logger.gt_log_tab("check if your OS can detect and mount mbed device mount point!")
else:
# Adding MUT to DETECTED CORRECTLY list
ready_mbed_devices.append(mut)
return (ready_mbed_devices, not_ready_mbed_devices)
示例15: get_binary_host_tests_dir
def get_binary_host_tests_dir(binary_path, level=2):
"""! Checks if in binary test group has host_tests directory
@param binary_path Path to binary in test specification
@param level How many directories above test host_tests dir exists
@return Path to host_tests dir in group binary belongs too, None if not found
"""
try:
binary_path_norm = os.path.normpath(binary_path)
current_path_norm = os.path.normpath(os.getcwd())
host_tests_path = binary_path_norm.split(os.sep)[:-level] + ['host_tests']
idx = host_tests_path.index('.build')
# Cut /.build/tests/TOOLCHAIN/TARGET
host_tests_path = host_tests_path[:idx] + host_tests_path[idx+4:]
host_tests_path = os.sep.join(host_tests_path)
except Exception as e:
gt_logger.gt_log_warn("there was a problem while looking for host_tests directory")
gt_logger.gt_log_tab("level %d, path: %s"% (level, binary_path))
gt_logger.gt_log_tab(str(e))
return None
if os.path.isdir(host_tests_path):
return host_tests_path
return None