It appears that our build tests are only check for successful
builds. We also want to make sure builds fail when they are
expected to. This adds a should_fail boolean to bitbake() and
perform_build_test()
testsuite/cibase.py | 4 ++--
testsuite/cibuilder.py | 12 ++++++++----
2 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/testsuite/cibase.py b/testsuite/cibase.py
index 6ffedcea..0a006a21 100755
--- a/testsuite/cibase.py
+++ b/testsuite/cibase.py
@@ -14,12 +14,12 @@ from avocado.utils import process
class CIBaseTest(CIBuilder):
- def perform_build_test(self, targets, **kwargs):
+ def perform_build_test(self, targets, should_fail=False, **kwargs):
self.configure(**kwargs)
self.log.info("Starting build...")
- self.bitbake(targets, **kwargs)
+ self.bitbake(targets, should_fail=should_fail, **kwargs)
def perform_wic_partition_test(self, targets, wic_deploy_parts, **kwargs):
self.configure(wic_deploy_parts=wic_deploy_parts, **kwargs)
diff --git a/testsuite/cibuilder.py b/testsuite/cibuilder.py
index cd5e70ba..366f6a1f 100755
--- a/testsuite/cibuilder.py
+++ b/testsuite/cibuilder.py
@@ -281,7 +281,8 @@ class CIBuilder(Test):
if os.path.exists(self.build_dir + '/' + src):
shutil.move(self.build_dir + '/' + src, self.build_dir + '/' + dst)
- def bitbake(self, target, bitbake_cmd=None, sig_handler=None, **kwargs):
+ def bitbake(self, target, bitbake_cmd=None, should_fail=False,
+ sig_handler=None, **kwargs):
self.check_init()
self.log.info("===================================================")
self.log.info(f"Building {str(target)}")
@@ -318,13 +319,16 @@ class CIBuilder(Test):
continue
if fd == p1.stdout.fileno():
self.log.info(p1.stdout.readline().rstrip())
- if fd == p1.stderr.fileno():
+ if fd == p1.stderr.fileno() and should_fail is False:
app_log.error(p1.stderr.readline().rstrip())
if p1.poll() is not None:
break
p1.wait()
- if p1.returncode:
- self.fail("Bitbake failed")
+ if should_fail is False:
+ if p1.returncode:
+ self.fail("Bitbake failed")
+ elif p1.returncode == 0:
+ self.fail("Bitbake suceeded but was expected to fail!")
def backupfile(self, path):
self.check_init()
--
2.47.3