diff --git a/meta/lib/oeqa/selftest/cases/reproducible.py b/meta/lib/oeqa/selftest/cases/reproducible.py index 9597d76697..3fb0e5ee5b 100644 --- a/meta/lib/oeqa/selftest/cases/reproducible.py +++ b/meta/lib/oeqa/selftest/cases/reproducible.py @@ -239,18 +239,31 @@ class ReproducibleTests(OESelftestTestCase): # may reuse the previous log file so restart the bitbake server. bitbake("--kill-server") + def print_condensed_error_log(logs, context_lines=10, tail_lines=20): + """Prints errors with context and the end of the log.""" + + logs = logs.split("\n") + for i, line in enumerate(logs): + if line.startswith("ERROR"): + self.logger.info("Found ERROR (line %d):" % (i + 1)) + for l in logs[i-context_lines:i+context_lines]: + self.logger.info(" " + l) + + self.logger.info("End of log:") + for l in logs[-tail_lines:]: + self.logger.info(" " + l) + bitbake_failure_count = 0 if not use_sstate: if self.sstate_targets: self.logger.info("Building prebuild for %s (sstate allowed)..." % (name)) self.write_config(config) try: - bitbake("--continue "+' '.join(self.sstate_targets), limit_exc_output=20) + bitbake("--continue "+' '.join(self.sstate_targets)) except AssertionError as e: bitbake_failure_count += 1 self.logger.error("Bitbake failed! but keep going... Log:") - for line in str(e).split("\n"): - self.logger.info(" "+line) + print_condensed_error_log(str(e)) # This config fragment will disable using shared and the sstate # mirror, forcing a complete build from scratch @@ -264,13 +277,11 @@ class ReproducibleTests(OESelftestTestCase): d = get_bb_vars(capture_vars) # targets used to be called images try: - bitbake("--continue "+' '.join(getattr(self, 'images', self.targets)), limit_exc_output=20) + bitbake("--continue "+' '.join(getattr(self, 'images', self.targets))) except AssertionError as e: bitbake_failure_count += 1 - self.logger.error("Bitbake failed! but keep going... Log:") - for line in str(e).split("\n"): - self.logger.info(" "+line) + print_condensed_error_log(str(e)) # The calling function expects the existence of the deploy # directories containing the packages.