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

Olivier Dion dion at linutronix.de
Mon Aug 3 18:39:58 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 | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/elbepack/tests/test_xml.py b/elbepack/tests/test_xml.py
index f397a90b..17cc21cf 100644
--- a/elbepack/tests/test_xml.py
+++ b/elbepack/tests/test_xml.py
@@ -52,3 +52,33 @@ 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.param, prj))
+
+                with open(prj, "r") as f:
+                    uuid = f.read()
+                    os.chdir(build_dir)
+                    system('%s pbuilder build --project %s' % (elbe_exe, uuid))
+            # pylint: disable=try-except-raise
+            except:
+                raise
+            else:
+                system('%s control del_project %s' % (elbe_exe, uuid),
+                       allow_fail=True)
-- 
2.28.0



More information about the elbe-devel mailing list