[elbe-devel] [PATCH 1/4] tests: Create test case for simple xml

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


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

This is taken from the current Jenkin file for elbe-ci.  However,
there's no SDK, nor rebuild from bin-cdrom.iso.

When elbe-check-build is available, it could be add as a last step.

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

diff --git a/elbepack/tests/test_xml.py b/elbepack/tests/test_xml.py
new file mode 100644
index 00000000..880f6fc5
--- /dev/null
+++ b/elbepack/tests/test_xml.py
@@ -0,0 +1,48 @@
+# ELBE - Debian Based Embedded Rootfilesystem Builder
+# Copyright (c) 2020 Olivier Dion <dion at linutronix.de>
+#
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+import os
+import unittest
+import tempfile
+
+from elbepack.directories import elbe_dir, elbe_exe
+from elbepack.commands.test import ElbeTestCase, ElbeTestLevel
+from elbepack.shellhelper import system
+
+ at unittest.skipIf(ElbeTestCase.level != ElbeTestLevel.INITVM,
+                 "Test level not set to INITVM")
+class TestSimpleXML(ElbeTestCase):
+
+    params = [os.path.join(elbe_dir, "tests", fname)
+              for fname
+              in os.listdir(os.path.join(elbe_dir, "tests"))
+              if fname.startswith("simple") and fname.endswith(".xml")]
+
+    def test_simple_build(self):
+
+        with tempfile.TemporaryDirectory(prefix="elbe-test-simple-xml-") as build_dir:
+
+            prj  = os.path.join(build_dir, "uuid.prj")
+            uuid = None
+
+            try:
+                system('%s initvm submit "%s" --output "%s" --keep-files '
+                       '--build-sdk --writeproject "%s"' %
+                       (elbe_exe, self.params, build_dir, prj))
+
+                # Ensure project build is done
+                with open(prj, "r") as f:
+                    uuid = f.read()
+                    system("%s control list_projects | "
+                           "grep %s | grep build_done || false" %
+                           (elbe_exe, uuid))
+
+                # TODO - Uncomment this when elbe check-build is available
+                #system('%s check-build "%s"' % (elbe_exe, build_dir))
+
+            else:
+                system('%s control del_project %s' % (elbe_exe, uuid),
+                       allow_fail=True)
+
-- 
2.27.0



More information about the elbe-devel mailing list