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

Torben Hohn torben.hohn at linutronix.de
Tue Jul 21 12:49:47 CEST 2020


On Mon, Jul 20, 2020 at 08:34:42PM -0400, Olivier Dion wrote:
> 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))

errm... you can only initvm submit one xml at a time. 

can you use this somehow with the ElbeTest Framework.
https://docs.python.org/3.4/library/unittest.html#unittest.TestSuite

iterate over the test files, and then instantiate a TestCase for each of
the files, and add it to the TestSuite.

https://docs.python.org/3.4/library/unittest.html#organizing-test-code



> +
> +                # 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))

if possible, this should be a sub test:

https://docs.python.org/3.4/library/unittest.html#distinguishing-test-iterations-using-subtests


> +
> +            else:
> +                system('%s control del_project %s' % (elbe_exe, uuid),
> +                       allow_fail=True)
> +
> -- 
> 2.27.0
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner


More information about the elbe-devel mailing list