test/buildroot: check we log bwrap's error output
Check that any errors that bubblewrap spits out on stderr make it to the log. A common case of bubblewrap failing is a runner failing to execute.
This commit is contained in:
parent
96a5499ed9
commit
ba94409d23
1 changed files with 23 additions and 1 deletions
|
|
@ -10,7 +10,7 @@ import unittest
|
|||
|
||||
import osbuild
|
||||
from osbuild.buildroot import BuildRoot
|
||||
from osbuild.monitor import NullMonitor
|
||||
from osbuild.monitor import LogMonitor, NullMonitor
|
||||
from .. import test
|
||||
|
||||
|
||||
|
|
@ -47,6 +47,28 @@ class TestBuildRoot(test.TestBase):
|
|||
r = root.run(["/usr/bin/false"], monitor)
|
||||
self.assertNotEqual(r.returncode, 0)
|
||||
|
||||
def test_runner_fail(self):
|
||||
runner = "org.osbuild.nonexistantrunner"
|
||||
libdir = os.path.abspath(os.curdir)
|
||||
var = pathlib.Path(self.tmp.name, "var")
|
||||
var.mkdir()
|
||||
|
||||
logfile = os.path.join(self.tmp.name, "log.txt")
|
||||
|
||||
with BuildRoot("/", runner, libdir=libdir, var=var) as root, \
|
||||
open(logfile, "w") as log:
|
||||
|
||||
monitor = LogMonitor(log.fileno())
|
||||
api = osbuild.api.API({}, monitor)
|
||||
root.register_api(api)
|
||||
|
||||
r = root.run(["/usr/bin/true"], monitor)
|
||||
|
||||
self.assertEqual(r.returncode, 1)
|
||||
with open(logfile) as f:
|
||||
log = f.read()
|
||||
assert log
|
||||
|
||||
@unittest.skipUnless(test.TestBase.have_test_data(), "no test-data access")
|
||||
def test_bind_mounts(self):
|
||||
runner = "org.osbuild.linux"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue