[elbe-devel] [PATCH 2/4] tests: Create test case for pbuilder

Olivier Dion dion at linutronix.de
Tue Jul 21 02:34:43 CEST 2020


Files under tests/ matching pbuilder*.xml are used for testing
pbuilder.

A pbuilder project is first created then build.  Any error will result
in an exception and thus in the test case failing.

Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 elbepack/tests/test_xml.py | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/elbepack/tests/test_xml.py b/elbepack/tests/test_xml.py
index 880f6fc5..d3242efd 100644
--- a/elbepack/tests/test_xml.py
+++ b/elbepack/tests/test_xml.py
@@ -46,3 +46,30 @@ class TestSimpleXML(ElbeTestCase):
                 system('%s control del_project %s' % (elbe_exe, uuid),
                        allow_fail=True)
 
+ at unittest.skipIf(ElbeTestCase.level != ElbeTestLevel.INITVM,
+                 "Test level not set to INITVM")
+class TestPbuilder(ElbeTestCase):
+
+    params = [os.path.join(elbe_dir, "tests", fname)
+              for fname
+              in os.listdir(os.path.join(elbe_dir, "tests"))
+              if fname.startswith("pbuilder") and fname.endswith(".xml")]
+
+    def test_pbuilder_build(self):
+
+        with tempfile.TemporaryDirectory(prefix="elbe-test-pbuilder-xml-") as build_dir:
+
+            prj  = os.path.join(build_dir, "uuid.prj")
+            uuid = None
+
+            try:
+                system('%s pbuilder create --xmlfile "%s" --writeproject "%s"' %
+                       (elbe_exe, self.params, prj))
+
+                with open(prj, "r") as f:
+                    uuid = f.read()
+                    os.chdir(build_dir)
+                    system('%s pbuilder build --project %s' % (elbe_exe, uuid))
+            else:
+                system('%s control del_project %s' % (elbe_exe, uuid),
+                       allow_fail=True)
-- 
2.27.0



More information about the elbe-devel mailing list