diff mbox series

[v3,09/10] oeqa/selftest/recipetool: appendsrfile: add test for machine

Message ID 20231205145636.960819-10-jstephan@baylibre.com
State Accepted, archived
Commit 1c510a21487fa71e88eb46e9a0de00a82a7ba4e4
Headers show
Series Several fixes around recipetool appendsrcfile(s) and oe.recipeutils.bbappend_recipe | expand

Commit Message

Julien Stephan Dec. 5, 2023, 2:56 p.m. UTC
Add a new test for machine specific bbappend override

Signed-off-by: Julien Stephan <jstephan@baylibre.com>
---
 meta/lib/oeqa/selftest/cases/recipetool.py | 44 +++++++++++++++++++---
 1 file changed, 38 insertions(+), 6 deletions(-)

Comments

Richard Purdie Dec. 8, 2023, 8:22 a.m. UTC | #1
On Tue, 2023-12-05 at 15:56 +0100, Julien Stephan wrote:
> Add a new test for machine specific bbappend override
> 
> Signed-off-by: Julien Stephan <jstephan@baylibre.com>
> ---
>  meta/lib/oeqa/selftest/cases/recipetool.py | 44 +++++++++++++++++++---
>  1 file changed, 38 insertions(+), 6 deletions(-)
> 
> diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
> index 21cb350e8a6..c55025e7df6 100644
> --- a/meta/lib/oeqa/selftest/cases/recipetool.py
> +++ b/meta/lib/oeqa/selftest/cases/recipetool.py
> @@ -1056,7 +1056,7 @@ class RecipetoolAppendsrcBase(RecipetoolBase):
>              if p.scheme == 'file':
>                  return p.netloc + p.path, uri
>  
> -    def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, remove=None, options=''):
> +    def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, remove=None, machine=None , options=''):
>          if newfile is None:
>              newfile = self.testfile
>  
> @@ -1084,17 +1084,39 @@ class RecipetoolAppendsrcBase(RecipetoolBase):
>          expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
>                           '\n']
>  
> +        override = ""
> +        if machine:
> +            options += ' -m %s' % machine
> +            override = ':append:%s' % machine
> +            expectedlines.extend(['PACKAGE_ARCH = "${MACHINE_ARCH}"\n',
> +                                  '\n'])
> +
>          if remove:
>              for entry in remove:
> -                expectedlines.extend(['SRC_URI:remove = "%s"\n' % entry,
> +                if machine:
> +                    entry_remove_line = 'SRC_URI:remove:%s = " %s"\n' % (machine, entry)
> +                else:
> +                    entry_remove_line = 'SRC_URI:remove = "%s"\n' % entry
> +
> +                expectedlines.extend([entry_remove_line,
>                                         '\n'])
>  
>          if has_src_uri:
>              uri = 'file://%s' % filename
>              if expected_subdir:
>                  uri += ';subdir=%s' % expected_subdir
> -            expectedlines.extend(['SRC_URI += "%s"\n' % uri,
> -                                  '\n'])
> +            if machine:
> +                src_uri_line = 'SRC_URI%s = " %s"\n' % (override, uri)
> +            else:
> +                src_uri_line = 'SRC_URI += "%s"\n' % uri
> +
> +            expectedlines.extend([src_uri_line, '\n'])
> +
> +        with open("/tmp/tmp.txt", "w") as file:
> +            print(expectedlines, file=file)
> +
> +        if machine:
> +            filename = '%s/%s' % (machine, filename)
>  
>          return self._try_recipetool_appendsrcfile(testrecipe, newfile, destpath, options, expectedlines, [filename])
>  
> @@ -1153,13 +1175,23 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase):
>          self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
>          self._test_appendsrcfile(testrecipe, filepath, has_src_uri=False)
>  
> -    def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self):
> +    def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self, machine=None):
>          testrecipe = 'base-files'
>          subdir = 'tmp'
>          filepath, srcuri_entry = self._get_first_file_uri(testrecipe)
>          self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
>  
> -        self._test_appendsrcfile(testrecipe, filepath, subdir, remove=[srcuri_entry])
> +        self._test_appendsrcfile(testrecipe, filepath, subdir, machine=machine, remove=[srcuri_entry])
> +
> +    def test_recipetool_appendsrcfile_machine(self):
> +        # A very basic test
> +        self._test_appendsrcfile('base-files', 'a-file', machine='mymachine')
> +

I think this is causing problems with other selftests, e.g. this set of
failures here:


https://autobuilder.yoctoproject.org/typhoon/#/builders/127/builds/2559/steps/14/logs/stdio

with errors like:

ERROR: When reparsing /home/pokybuild/yocto-worker/oe-selftest-armhost/build/meta/recipes-core/base-files/base-files_3.0.14.bb:do_fetch, the basehash value changed from b720db5f2039a9a72917b5d400acd7f874d37014fec362112a44f90504ba79cd to 1b5f5a1ec1552e4a1e5798b2a1c23c062be5054be287d79c98e0e29da780c3b0. The metadata is not deterministic and this needs to be fixed.
ERROR: The following commands may help:
ERROR: $ bitbake base-files -cdo_fetch -Snone
ERROR: Then:
ERROR: $ bitbake base-files -cdo_fetch -Sprintdiff


since this test is running on the same metadata as the other tests are
using. We need to keep modifications isolated from the other tests that
could be running.

Cheers,

Richard
diff mbox series

Patch

diff --git a/meta/lib/oeqa/selftest/cases/recipetool.py b/meta/lib/oeqa/selftest/cases/recipetool.py
index 21cb350e8a6..c55025e7df6 100644
--- a/meta/lib/oeqa/selftest/cases/recipetool.py
+++ b/meta/lib/oeqa/selftest/cases/recipetool.py
@@ -1056,7 +1056,7 @@  class RecipetoolAppendsrcBase(RecipetoolBase):
             if p.scheme == 'file':
                 return p.netloc + p.path, uri
 
-    def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, remove=None, options=''):
+    def _test_appendsrcfile(self, testrecipe, filename=None, destdir=None, has_src_uri=True, srcdir=None, newfile=None, remove=None, machine=None , options=''):
         if newfile is None:
             newfile = self.testfile
 
@@ -1084,17 +1084,39 @@  class RecipetoolAppendsrcBase(RecipetoolBase):
         expectedlines = ['FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"\n',
                          '\n']
 
+        override = ""
+        if machine:
+            options += ' -m %s' % machine
+            override = ':append:%s' % machine
+            expectedlines.extend(['PACKAGE_ARCH = "${MACHINE_ARCH}"\n',
+                                  '\n'])
+
         if remove:
             for entry in remove:
-                expectedlines.extend(['SRC_URI:remove = "%s"\n' % entry,
+                if machine:
+                    entry_remove_line = 'SRC_URI:remove:%s = " %s"\n' % (machine, entry)
+                else:
+                    entry_remove_line = 'SRC_URI:remove = "%s"\n' % entry
+
+                expectedlines.extend([entry_remove_line,
                                        '\n'])
 
         if has_src_uri:
             uri = 'file://%s' % filename
             if expected_subdir:
                 uri += ';subdir=%s' % expected_subdir
-            expectedlines.extend(['SRC_URI += "%s"\n' % uri,
-                                  '\n'])
+            if machine:
+                src_uri_line = 'SRC_URI%s = " %s"\n' % (override, uri)
+            else:
+                src_uri_line = 'SRC_URI += "%s"\n' % uri
+
+            expectedlines.extend([src_uri_line, '\n'])
+
+        with open("/tmp/tmp.txt", "w") as file:
+            print(expectedlines, file=file)
+
+        if machine:
+            filename = '%s/%s' % (machine, filename)
 
         return self._try_recipetool_appendsrcfile(testrecipe, newfile, destpath, options, expectedlines, [filename])
 
@@ -1153,13 +1175,23 @@  class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase):
         self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
         self._test_appendsrcfile(testrecipe, filepath, has_src_uri=False)
 
-    def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self):
+    def test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(self, machine=None):
         testrecipe = 'base-files'
         subdir = 'tmp'
         filepath, srcuri_entry = self._get_first_file_uri(testrecipe)
         self.assertTrue(filepath, 'Unable to test, no file:// uri found in SRC_URI for %s' % testrecipe)
 
-        self._test_appendsrcfile(testrecipe, filepath, subdir, remove=[srcuri_entry])
+        self._test_appendsrcfile(testrecipe, filepath, subdir, machine=machine, remove=[srcuri_entry])
+
+    def test_recipetool_appendsrcfile_machine(self):
+        # A very basic test
+        self._test_appendsrcfile('base-files', 'a-file', machine='mymachine')
+
+        # Force cleaning the output of previous test
+        self.tearDownLocal()
+
+        # A more complex test: existing entry in src_uri with different param
+        self.test_recipetool_appendsrcfile_existing_in_src_uri_diff_params(machine='mymachine')
 
     def test_recipetool_appendsrcfile_replace_file_srcdir(self):
         testrecipe = 'bash'