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

Torben Hohn torben.hohn at linutronix.de
Tue Jul 21 13:12:48 CEST 2020


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

same like in PATCH 1/4 ... you treat params like a single list.
you need to iterate over it, and create TestCases...


> +
> +                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
> 
> _______________________________________________
> 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