sanitycheck: add --log-file to log everything to a file too
Currently CI plays tricks with `tee` to capture the output and post process it. This makes it more complex to handle and easier for it to fail in ways it should not. So add a simple log capture option sanity check that mirrors the stdout output, removing color encoding for errors. Change-Id: I6de0b6cfe4da9c289f537979545dddbcd49cf834 Signed-off-by: Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>
This commit is contained in:
parent
66cfcc26bc
commit
9a36cb6456
1 changed files with 23 additions and 4 deletions
|
@ -226,12 +226,20 @@ class BuildError(MakeError):
|
||||||
class ExecutionError(MakeError):
|
class ExecutionError(MakeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
log_file = None
|
||||||
|
|
||||||
# Debug Functions
|
# Debug Functions
|
||||||
def info(what):
|
def info(what):
|
||||||
sys.stdout.write(what + "\n")
|
sys.stdout.write(what + "\n")
|
||||||
|
if log_file:
|
||||||
|
log_file.write(what + "\n")
|
||||||
|
log_file.flush()
|
||||||
|
|
||||||
def error(what):
|
def error(what):
|
||||||
sys.stderr.write(COLOR_RED + what + COLOR_NORMAL + "\n")
|
sys.stderr.write(COLOR_RED + what + COLOR_NORMAL + "\n")
|
||||||
|
if log_file:
|
||||||
|
log_file(what + "\n")
|
||||||
|
log_file.flush()
|
||||||
|
|
||||||
def debug(what):
|
def debug(what):
|
||||||
if VERBOSE >= 1:
|
if VERBOSE >= 1:
|
||||||
|
@ -1174,7 +1182,10 @@ def defconfig_cb(context, goals, goal):
|
||||||
(COLOR_RED, goal.name, COLOR_NORMAL));
|
(COLOR_RED, goal.name, COLOR_NORMAL));
|
||||||
if INLINE_LOGS:
|
if INLINE_LOGS:
|
||||||
with open(goal.get_error_log()) as fp:
|
with open(goal.get_error_log()) as fp:
|
||||||
sys.stdout.write(fp.read())
|
data = fp.read()
|
||||||
|
sys.stdout.write(data)
|
||||||
|
if log_file:
|
||||||
|
log_file.write(data)
|
||||||
else:
|
else:
|
||||||
info("\tsee: " + COLOR_YELLOW + goal.get_error_log() + COLOR_NORMAL)
|
info("\tsee: " + COLOR_YELLOW + goal.get_error_log() + COLOR_NORMAL)
|
||||||
|
|
||||||
|
@ -1641,6 +1652,8 @@ def parse_arguments():
|
||||||
parser.add_argument("-i", "--inline-logs", action="store_true",
|
parser.add_argument("-i", "--inline-logs", action="store_true",
|
||||||
help="Upon test failure, print relevant log data to stdout "
|
help="Upon test failure, print relevant log data to stdout "
|
||||||
"instead of just a path to it")
|
"instead of just a path to it")
|
||||||
|
parser.add_argument("--log-file", metavar="FILENAME", action="store",
|
||||||
|
help="log also to file")
|
||||||
parser.add_argument("-m", "--last-metrics", action="store_true",
|
parser.add_argument("-m", "--last-metrics", action="store_true",
|
||||||
help="Instead of comparing metrics from the last --release, "
|
help="Instead of comparing metrics from the last --release, "
|
||||||
"compare with the results of the previous sanity check "
|
"compare with the results of the previous sanity check "
|
||||||
|
@ -1701,7 +1714,10 @@ def log_info(filename):
|
||||||
if INLINE_LOGS:
|
if INLINE_LOGS:
|
||||||
info("{:-^100}".format(filename))
|
info("{:-^100}".format(filename))
|
||||||
with open(filename) as fp:
|
with open(filename) as fp:
|
||||||
sys.stdout.write(fp.read())
|
data = fp.read()
|
||||||
|
sys.stdout.write(data)
|
||||||
|
if log_file:
|
||||||
|
log_file.write(data)
|
||||||
info("{:-^100}".format(filename))
|
info("{:-^100}".format(filename))
|
||||||
else:
|
else:
|
||||||
info("\tsee: " + COLOR_YELLOW + filename + COLOR_NORMAL)
|
info("\tsee: " + COLOR_YELLOW + filename + COLOR_NORMAL)
|
||||||
|
@ -1784,7 +1800,7 @@ def generate_coverage(outdir, ignores):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
global VERBOSE, INLINE_LOGS, CPU_COUNTS
|
global VERBOSE, INLINE_LOGS, CPU_COUNTS, log_file
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
toolchain = os.environ.get("ZEPHYR_GCC_VARIANT", None)
|
toolchain = os.environ.get("ZEPHYR_GCC_VARIANT", None)
|
||||||
|
|
||||||
|
@ -1795,6 +1811,8 @@ def main():
|
||||||
|
|
||||||
VERBOSE += args.verbose
|
VERBOSE += args.verbose
|
||||||
INLINE_LOGS = args.inline_logs
|
INLINE_LOGS = args.inline_logs
|
||||||
|
if args.log_file:
|
||||||
|
log_file = open(args.log_file, "w")
|
||||||
if args.jobs:
|
if args.jobs:
|
||||||
CPU_COUNTS = args.jobs
|
CPU_COUNTS = args.jobs
|
||||||
|
|
||||||
|
@ -1891,7 +1909,8 @@ def main():
|
||||||
ts.testcase_report(LAST_SANITY)
|
ts.testcase_report(LAST_SANITY)
|
||||||
if args.release:
|
if args.release:
|
||||||
ts.testcase_report(RELEASE_DATA)
|
ts.testcase_report(RELEASE_DATA)
|
||||||
|
if log_file:
|
||||||
|
log_file.close()
|
||||||
if failed or (warnings and args.warnings_as_errors):
|
if failed or (warnings and args.warnings_as_errors):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue