repro-build-test.py: Use bitbake env to get image filename

Message ID 20230109155257.26183-1-venkata.pyla@toshiba-tsip.com
State Accepted, archived
Headers show
Series repro-build-test.py: Use bitbake env to get image filename | expand

Commit Message

venkata.pyla@toshiba-tsip.com Jan. 9, 2023, 3:52 p.m. UTC
From: venkata pyla <venkata.pyla@toshiba-tsip.com>

The hard-coded distro name 'debian' will break the test when other
distros are used.

So the image_name is prepared using bitbake environment variables.

Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
---
 testsuite/repro-build-test.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Henning Schild Jan. 10, 2023, 1 p.m. UTC | #1
Am Mon,  9 Jan 2023 21:22:57 +0530
schrieb venkata.pyla@toshiba-tsip.com:

> From: venkata pyla <venkata.pyla@toshiba-tsip.com>
> 
> The hard-coded distro name 'debian' will break the test when other
> distros are used.
> 
> So the image_name is prepared using bitbake environment variables.
> 
> Signed-off-by: venkata pyla <venkata.pyla@toshiba-tsip.com>
> ---
>  testsuite/repro-build-test.py | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/testsuite/repro-build-test.py
> b/testsuite/repro-build-test.py index 5d92e2c..1c0b05b 100755
> --- a/testsuite/repro-build-test.py
> +++ b/testsuite/repro-build-test.py
> @@ -29,11 +29,14 @@ class ReproBuild(CIBuilder):
>  
>      def get_image_path(self, target_name):
>          image_dir = "tmp/deploy/images"
> -        target_params = target_name.split(":")
> -        machine = target_params[1].split("-")[0]
> -        distro = "debian-" + target_params[1].split("-")[1]
> -        image_type = target_params[2]
> -        return
> f"{image_dir}/{machine}/{image_type}-{distro}-{machine}.tar.gz"
> +        output = process.getoutput(
> +            f'bitbake -e {target_name} '
> +            r'| grep "^MACHINE=\|^IMAGE_FULLNAME="'
> +        )

there is start_vm.get_bitbake_var, maybe you can use that. And we could
think about moving that to another place, because it has little to do
with "start_vm".

Henning

> +        env = dict(d.split("=", 1) for d in output.splitlines())
> +        machine = env["MACHINE"].strip("\"")
> +        image_name = env["IMAGE_FULLNAME"].strip("\"")
> +        return f"{image_dir}/{machine}/{image_name}.tar.gz"
>  
>      def build_repro_image(
>          self, target, source_date_epoch=None,
> image_name="image.tar.gz"
Uladzimir Bely March 30, 2023, 7:14 a.m. UTC | #2
In mail from Monday, 9 January 2023 18:52:57 +03 user venkata.pyla@toshiba-
tsip.com wrote:
> From: venkata pyla <venkata.pyla@toshiba-tsip.com>
> 
> The hard-coded distro name 'debian' will break the test when other
> distros are used.
> 
> So the image_name is prepared using bitbake environment variables.

Applied to next, thanks.

Patch

diff --git a/testsuite/repro-build-test.py b/testsuite/repro-build-test.py
index 5d92e2c..1c0b05b 100755
--- a/testsuite/repro-build-test.py
+++ b/testsuite/repro-build-test.py
@@ -29,11 +29,14 @@  class ReproBuild(CIBuilder):
 
     def get_image_path(self, target_name):
         image_dir = "tmp/deploy/images"
-        target_params = target_name.split(":")
-        machine = target_params[1].split("-")[0]
-        distro = "debian-" + target_params[1].split("-")[1]
-        image_type = target_params[2]
-        return f"{image_dir}/{machine}/{image_type}-{distro}-{machine}.tar.gz"
+        output = process.getoutput(
+            f'bitbake -e {target_name} '
+            r'| grep "^MACHINE=\|^IMAGE_FULLNAME="'
+        )
+        env = dict(d.split("=", 1) for d in output.splitlines())
+        machine = env["MACHINE"].strip("\"")
+        image_name = env["IMAGE_FULLNAME"].strip("\"")
+        return f"{image_dir}/{machine}/{image_name}.tar.gz"
 
     def build_repro_image(
         self, target, source_date_epoch=None, image_name="image.tar.gz"