mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #1568 from bridadan/not-supported-test-result
Adding the ability for tests to report they aren't supported on a targetpull/1580/head
commit
8e75bd9d5f
|
@ -25,7 +25,7 @@ from shutil import rmtree
|
||||||
from os.path import join, exists, basename
|
from os.path import join, exists, basename
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext
|
from workspace_tools.utils import mkdir, run_cmd, run_cmd_ext, NotSupportedException
|
||||||
from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON
|
from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON
|
||||||
from workspace_tools.targets import TARGET_NAMES, TARGET_MAP
|
from workspace_tools.targets import TARGET_NAMES, TARGET_MAP
|
||||||
from workspace_tools.libraries import Library
|
from workspace_tools.libraries import Library
|
||||||
|
@ -139,13 +139,13 @@ def build_project(src_path, build_path, target, toolchain_name,
|
||||||
resources.inc_dirs.extend(inc_dirs)
|
resources.inc_dirs.extend(inc_dirs)
|
||||||
else:
|
else:
|
||||||
resources.inc_dirs.append(inc_dirs)
|
resources.inc_dirs.append(inc_dirs)
|
||||||
|
|
||||||
# Compile Sources
|
# Compile Sources
|
||||||
for path in src_paths:
|
for path in src_paths:
|
||||||
src = toolchain.scan_resources(path)
|
src = toolchain.scan_resources(path)
|
||||||
objects = toolchain.compile_sources(src, build_path, resources.inc_dirs)
|
objects = toolchain.compile_sources(src, build_path, resources.inc_dirs)
|
||||||
resources.objects.extend(objects)
|
resources.objects.extend(objects)
|
||||||
|
|
||||||
|
|
||||||
# Link Program
|
# Link Program
|
||||||
res, needed_update = toolchain.link_program(resources, build_path, name)
|
res, needed_update = toolchain.link_program(resources, build_path, name)
|
||||||
|
|
||||||
|
@ -162,7 +162,12 @@ def build_project(src_path, build_path, target, toolchain_name,
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if report != None:
|
if report != None:
|
||||||
end = time()
|
end = time()
|
||||||
cur_result["result"] = "FAIL"
|
|
||||||
|
if isinstance(e, NotSupportedException):
|
||||||
|
cur_result["result"] = "NOT_SUPPORTED"
|
||||||
|
else:
|
||||||
|
cur_result["result"] = "FAIL"
|
||||||
|
|
||||||
cur_result["elapsed_time"] = end - start
|
cur_result["elapsed_time"] = end - start
|
||||||
|
|
||||||
toolchain_output = toolchain.get_output()
|
toolchain_output = toolchain.get_output()
|
||||||
|
|
|
@ -44,6 +44,7 @@ from workspace_tools.tests import TEST_MAP
|
||||||
from workspace_tools.paths import BUILD_DIR
|
from workspace_tools.paths import BUILD_DIR
|
||||||
from workspace_tools.paths import HOST_TESTS
|
from workspace_tools.paths import HOST_TESTS
|
||||||
from workspace_tools.utils import ToolException
|
from workspace_tools.utils import ToolException
|
||||||
|
from workspace_tools.utils import NotSupportedException
|
||||||
from workspace_tools.utils import construct_enum
|
from workspace_tools.utils import construct_enum
|
||||||
from workspace_tools.targets import TARGET_MAP
|
from workspace_tools.targets import TARGET_MAP
|
||||||
from workspace_tools.test_db import BaseDBAccess
|
from workspace_tools.test_db import BaseDBAccess
|
||||||
|
@ -130,6 +131,7 @@ class SingleTestRunner(object):
|
||||||
TEST_RESULT_NO_IMAGE = "NO_IMAGE"
|
TEST_RESULT_NO_IMAGE = "NO_IMAGE"
|
||||||
TEST_RESULT_MBED_ASSERT = "MBED_ASSERT"
|
TEST_RESULT_MBED_ASSERT = "MBED_ASSERT"
|
||||||
TEST_RESULT_BUILD_FAILED = "BUILD_FAILED"
|
TEST_RESULT_BUILD_FAILED = "BUILD_FAILED"
|
||||||
|
TEST_RESULT_NOT_SUPPORTED = "NOT_SUPPORTED"
|
||||||
|
|
||||||
GLOBAL_LOOPS_COUNT = 1 # How many times each test should be repeated
|
GLOBAL_LOOPS_COUNT = 1 # How many times each test should be repeated
|
||||||
TEST_LOOPS_LIST = [] # We redefine no.of loops per test_id
|
TEST_LOOPS_LIST = [] # We redefine no.of loops per test_id
|
||||||
|
@ -149,7 +151,8 @@ class SingleTestRunner(object):
|
||||||
"no_image" : TEST_RESULT_NO_IMAGE,
|
"no_image" : TEST_RESULT_NO_IMAGE,
|
||||||
"end" : TEST_RESULT_UNDEF,
|
"end" : TEST_RESULT_UNDEF,
|
||||||
"mbed_assert" : TEST_RESULT_MBED_ASSERT,
|
"mbed_assert" : TEST_RESULT_MBED_ASSERT,
|
||||||
"build_failed" : TEST_RESULT_BUILD_FAILED
|
"build_failed" : TEST_RESULT_BUILD_FAILED,
|
||||||
|
"not_supproted" : TEST_RESULT_NOT_SUPPORTED
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
|
@ -476,13 +479,23 @@ class SingleTestRunner(object):
|
||||||
project_id=test_id,
|
project_id=test_id,
|
||||||
project_description=test.get_description())
|
project_description=test.get_description())
|
||||||
|
|
||||||
except ToolException:
|
except Exception, e:
|
||||||
project_name_str = project_name if project_name is not None else test_id
|
project_name_str = project_name if project_name is not None else test_id
|
||||||
print self.logger.log_line(self.logger.LogType.ERROR, 'There were errors while building project %s'% (project_name_str))
|
|
||||||
|
|
||||||
|
test_result = self.TEST_RESULT_FAIL
|
||||||
|
|
||||||
|
if isinstance(e, ToolException):
|
||||||
|
print self.logger.log_line(self.logger.LogType.ERROR, 'There were errors while building project %s'% (project_name_str))
|
||||||
|
test_result = self.TEST_RESULT_BUILD_FAILED
|
||||||
|
elif isinstance(e, NotSupportedException):
|
||||||
|
print self.logger.log_line(self.logger.LogType.INFO, 'The project %s is not supported'% (project_name_str))
|
||||||
|
test_result = self.TEST_RESULT_NOT_SUPPORTED
|
||||||
|
|
||||||
|
|
||||||
# Append test results to global test summary
|
# Append test results to global test summary
|
||||||
self.test_summary.append(
|
self.test_summary.append(
|
||||||
(self.TEST_RESULT_BUILD_FAILED, target, toolchain, test_id, 'Toolchain build failed', 0, 0, '-')
|
(test_result, target, toolchain, test_id, test.get_description(), 0, 0, '-')
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add detailed test result to test summary structure
|
# Add detailed test result to test summary structure
|
||||||
|
@ -490,13 +503,13 @@ class SingleTestRunner(object):
|
||||||
self.test_summary_ext[target][toolchain][test_id] = []
|
self.test_summary_ext[target][toolchain][test_id] = []
|
||||||
|
|
||||||
self.test_summary_ext[target][toolchain][test_id].append({ 0: {
|
self.test_summary_ext[target][toolchain][test_id].append({ 0: {
|
||||||
'result' : self.TEST_RESULT_BUILD_FAILED,
|
'result' : test_result,
|
||||||
'output' : '',
|
'output' : '',
|
||||||
'target_name' : target,
|
'target_name' : target,
|
||||||
'target_name_unique': target,
|
'target_name_unique': target,
|
||||||
'toolchain_name' : toolchain,
|
'toolchain_name' : toolchain,
|
||||||
'id' : test_id,
|
'id' : test_id,
|
||||||
'description' : 'Toolchain build failed',
|
'description' : test.get_description(),
|
||||||
'elapsed_time' : 0,
|
'elapsed_time' : 0,
|
||||||
'duration' : 0,
|
'duration' : 0,
|
||||||
'copy_method' : None
|
'copy_method' : None
|
||||||
|
@ -736,7 +749,8 @@ class SingleTestRunner(object):
|
||||||
self.TEST_RESULT_NO_IMAGE : 0,
|
self.TEST_RESULT_NO_IMAGE : 0,
|
||||||
self.TEST_RESULT_TIMEOUT : 0,
|
self.TEST_RESULT_TIMEOUT : 0,
|
||||||
self.TEST_RESULT_MBED_ASSERT : 0,
|
self.TEST_RESULT_MBED_ASSERT : 0,
|
||||||
self.TEST_RESULT_BUILD_FAILED : 0
|
self.TEST_RESULT_BUILD_FAILED : 0,
|
||||||
|
self.TEST_RESULT_NOT_SUPPORTED : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
for test in test_summary:
|
for test in test_summary:
|
||||||
|
|
|
@ -238,7 +238,7 @@ class ReportExporter():
|
||||||
tc.add_failure_info(description, _stdout)
|
tc.add_failure_info(description, _stdout)
|
||||||
elif result == 'ERROR':
|
elif result == 'ERROR':
|
||||||
tc.add_error_info(description, _stdout)
|
tc.add_error_info(description, _stdout)
|
||||||
elif result == 'SKIP':
|
elif result == 'SKIP' or result == 'NOT_SUPPORTED':
|
||||||
tc.add_skipped_info(description, _stdout)
|
tc.add_skipped_info(description, _stdout)
|
||||||
|
|
||||||
test_cases.append(tc)
|
test_cases.append(tc)
|
||||||
|
@ -282,7 +282,7 @@ class ReportExporter():
|
||||||
message = test_result['result']
|
message = test_result['result']
|
||||||
if test_result['result'] == 'FAIL':
|
if test_result['result'] == 'FAIL':
|
||||||
tc.add_failure_info(message, _stdout)
|
tc.add_failure_info(message, _stdout)
|
||||||
elif test_result['result'] == 'SKIP':
|
elif test_result['result'] == 'SKIP' or test_result["result"] == 'NOT_SUPPORTED':
|
||||||
tc.add_skipped_info(message, _stdout)
|
tc.add_skipped_info(message, _stdout)
|
||||||
elif test_result['result'] != 'OK':
|
elif test_result['result'] != 'OK':
|
||||||
tc.add_error_info(message, _stdout)
|
tc.add_error_info(message, _stdout)
|
||||||
|
@ -319,7 +319,7 @@ class ReportExporter():
|
||||||
|
|
||||||
if test_run["result"] == "FAIL":
|
if test_run["result"] == "FAIL":
|
||||||
failures.append(test_run)
|
failures.append(test_run)
|
||||||
elif test_run["result"] == "SKIP":
|
elif test_run["result"] == "SKIP" or test_run["result"] == "NOT_SUPPORTED":
|
||||||
skips.append(test_run)
|
skips.append(test_run)
|
||||||
elif test_run["result"] == "OK":
|
elif test_run["result"] == "OK":
|
||||||
successes.append(test_run)
|
successes.append(test_run)
|
||||||
|
|
|
@ -26,7 +26,7 @@ from os.path import join, splitext, exists, relpath, dirname, basename, split
|
||||||
from inspect import getmro
|
from inspect import getmro
|
||||||
|
|
||||||
from multiprocessing import Pool, cpu_count
|
from multiprocessing import Pool, cpu_count
|
||||||
from workspace_tools.utils import run_cmd, mkdir, rel_path, ToolException, split_path
|
from workspace_tools.utils import run_cmd, mkdir, rel_path, ToolException, NotSupportedException, split_path
|
||||||
from workspace_tools.settings import BUILD_OPTIONS, MBED_ORG_USER
|
from workspace_tools.settings import BUILD_OPTIONS, MBED_ORG_USER
|
||||||
import workspace_tools.hooks as hooks
|
import workspace_tools.hooks as hooks
|
||||||
|
|
||||||
|
@ -604,6 +604,9 @@ class mbedToolchain:
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def is_not_supported_error(self, output):
|
||||||
|
return "#error directive: [NOT_SUPPORTED]" in output
|
||||||
|
|
||||||
def compile_output(self, output=[]):
|
def compile_output(self, output=[]):
|
||||||
_rc = output[0]
|
_rc = output[0]
|
||||||
_stderr = output[1]
|
_stderr = output[1]
|
||||||
|
@ -621,7 +624,10 @@ class mbedToolchain:
|
||||||
for line in _stderr.splitlines():
|
for line in _stderr.splitlines():
|
||||||
self.tool_error(line)
|
self.tool_error(line)
|
||||||
|
|
||||||
raise ToolException(_stderr)
|
if self.is_not_supported_error(_stderr):
|
||||||
|
raise NotSupportedException(_stderr)
|
||||||
|
else:
|
||||||
|
raise ToolException(_stderr)
|
||||||
|
|
||||||
def compile(self, cc, source, object, includes):
|
def compile(self, cc, source, object, includes):
|
||||||
_, ext = splitext(source)
|
_, ext = splitext(source)
|
||||||
|
|
|
@ -118,6 +118,9 @@ class GCC(mbedToolchain):
|
||||||
dependencies = dependencies + [f.replace('\a', ' ') for f in file.split(" ")]
|
dependencies = dependencies + [f.replace('\a', ' ') for f in file.split(" ")]
|
||||||
return dependencies
|
return dependencies
|
||||||
|
|
||||||
|
def is_not_supported_error(self, output):
|
||||||
|
return "error: #error [NOT_SUPPORTED]" in output
|
||||||
|
|
||||||
def parse_output(self, output):
|
def parse_output(self, output):
|
||||||
# The warning/error notification is multiline
|
# The warning/error notification is multiline
|
||||||
WHERE, WHAT = 0, 1
|
WHERE, WHAT = 0, 1
|
||||||
|
|
|
@ -123,6 +123,8 @@ def rel_path(path, base, dot=False):
|
||||||
class ToolException(Exception):
|
class ToolException(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class NotSupportedException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
def split_path(path):
|
def split_path(path):
|
||||||
base, file = split(path)
|
base, file = split(path)
|
||||||
|
|
Loading…
Reference in New Issue