diff mbox series

[v5,4/5] oeqa/sdk/meson: improve test to validate host/build target assignments

Message ID 20250407211806.1782316-4-tom.hochstein@oss.nxp.com
State New
Headers show
Series [v5,1/5] toolchain-scripts: Add Meson settings for Yocto build SDK | expand

Commit Message

Tom Hochstein April 7, 2025, 9:18 p.m. UTC
From: Ross Burton <ross.burton@arm.com>

Use 'meson introspect' to dump JSON describing the build configuration
and validate that the build and host architectures are correctly set in
the meson.cross file.

Also instead of calling ninja directly, call the relevant meson commands.

Fixes: [YOCTO #15485]
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Tom Hochstein <tom.hochstein@oss.nxp.com>
---
 meta/lib/oeqa/sdk/cases/meson.py | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Comments

Mathieu Dubois-Briand April 8, 2025, 1:37 p.m. UTC | #1
On Mon Apr 7, 2025 at 11:18 PM CEST, Tom Hochstein via lists.openembedded.org wrote:
> From: Ross Burton <ross.burton@arm.com>
>
> Use 'meson introspect' to dump JSON describing the build configuration
> and validate that the build and host architectures are correctly set in
> the meson.cross file.
>
> Also instead of calling ninja directly, call the relevant meson commands.
>
> Fixes: [YOCTO #15485]
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> Signed-off-by: Tom Hochstein <tom.hochstein@oss.nxp.com>
> ---
>  meta/lib/oeqa/sdk/cases/meson.py | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/meta/lib/oeqa/sdk/cases/meson.py b/meta/lib/oeqa/sdk/cases/meson.py
> index 1edf78720a..407b94d242 100644
> --- a/meta/lib/oeqa/sdk/cases/meson.py
> +++ b/meta/lib/oeqa/sdk/cases/meson.py
> @@ -4,6 +4,7 @@
>  # SPDX-License-Identifier: MIT
>  #
>  
> +import json
>  import os
>  import subprocess
>  import tempfile
> @@ -39,10 +40,17 @@ class MesonTest(OESDKTestCase):
>              self.assertTrue(os.path.isdir(dirs["source"]))
>              os.makedirs(dirs["build"])
>  
> -            log = self._run("meson --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs))
> -            # Check that Meson thinks we're doing a cross build and not a native
> -            self.assertIn("Build type: cross build", log)
> -            self._run("ninja -C {build} -v".format(**dirs))
> -            self._run("DESTDIR={install} ninja -C {build} -v install".format(**dirs))
> +            log = self._run("meson setup --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs))
> +
> +            # Check that the host (gcc) and build (cross-gcc) compilers are different
> +            data = json.loads(self._run("meson introspect --compilers {build}".format(**dirs)))
> +            self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"])
> +            # Check that the system architectures were set correctly
> +            data = json.loads(self._run("meson introspect --machines {build}".format(**dirs)))
> +            self.assertEqual(data["build"]["cpu"], self.td["SDK_ARCH"])
> +            self.assertEqual(data["host"]["cpu"], self.td["HOST_ARCH"])
> +
> +            self._run("meson compile -C {build} -v".format(**dirs))
> +            self._run("meson install -C {build} --destdir {install}".format(**dirs))
>  
>              self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libepoxy.so"))

Hi,

Thanks for the new version, but we have a new error now:

Traceback (most recent call last):
  File "/srv/pokybuild/yocto-worker/qemux86/build/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy
    self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"])
                        ~~~~~~~~~~~~~^^^^^
KeyError: 'c'

https://autobuilder.yoctoproject.org/valkyrie/#/builders/30/builds/1330

Can you have a look at this please?
Tom Hochstein April 8, 2025, 3:10 p.m. UTC | #2
On 4/8/2025 8:37 AM, Mathieu Dubois-Briand wrote:
> [You don't often get email from mathieu.dubois-briand@bootlin.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
> 
> On Mon Apr 7, 2025 at 11:18 PM CEST, Tom Hochstein via lists.openembedded.org wrote:
>> From: Ross Burton <ross.burton@arm.com>
>>
>> Use 'meson introspect' to dump JSON describing the build configuration
>> and validate that the build and host architectures are correctly set in
>> the meson.cross file.
>>
>> Also instead of calling ninja directly, call the relevant meson commands.
>>
>> Fixes: [YOCTO #15485]
>> Signed-off-by: Ross Burton <ross.burton@arm.com>
>> Signed-off-by: Tom Hochstein <tom.hochstein@oss.nxp.com>
>> ---
>>   meta/lib/oeqa/sdk/cases/meson.py | 18 +++++++++++++-----
>>   1 file changed, 13 insertions(+), 5 deletions(-)
>>
>> diff --git a/meta/lib/oeqa/sdk/cases/meson.py b/meta/lib/oeqa/sdk/cases/meson.py
>> index 1edf78720a..407b94d242 100644
>> --- a/meta/lib/oeqa/sdk/cases/meson.py
>> +++ b/meta/lib/oeqa/sdk/cases/meson.py
>> @@ -4,6 +4,7 @@
>>   # SPDX-License-Identifier: MIT
>>   #
>>
>> +import json
>>   import os
>>   import subprocess
>>   import tempfile
>> @@ -39,10 +40,17 @@ class MesonTest(OESDKTestCase):
>>               self.assertTrue(os.path.isdir(dirs["source"]))
>>               os.makedirs(dirs["build"])
>>
>> -            log = self._run("meson --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs))
>> -            # Check that Meson thinks we're doing a cross build and not a native
>> -            self.assertIn("Build type: cross build", log)
>> -            self._run("ninja -C {build} -v".format(**dirs))
>> -            self._run("DESTDIR={install} ninja -C {build} -v install".format(**dirs))
>> +            log = self._run("meson setup --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs))
>> +
>> +            # Check that the host (gcc) and build (cross-gcc) compilers are different
>> +            data = json.loads(self._run("meson introspect --compilers {build}".format(**dirs)))
>> +            self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"])
>> +            # Check that the system architectures were set correctly
>> +            data = json.loads(self._run("meson introspect --machines {build}".format(**dirs)))
>> +            self.assertEqual(data["build"]["cpu"], self.td["SDK_ARCH"])
>> +            self.assertEqual(data["host"]["cpu"], self.td["HOST_ARCH"])
>> +
>> +            self._run("meson compile -C {build} -v".format(**dirs))
>> +            self._run("meson install -C {build} --destdir {install}".format(**dirs))
>>
>>               self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libepoxy.so"))
> 
> Hi,
> 
> Thanks for the new version, but we have a new error now:
> 
> Traceback (most recent call last):
>    File "/srv/pokybuild/yocto-worker/qemux86/build/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy
>      self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"])
>                          ~~~~~~~~~~~~~^^^^^
> KeyError: 'c'

Thanks, Mathieu.

Ross, can you have a look?

> 
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/30/builds/1330
> 
> Can you have a look at this please?
> 
> --
> Mathieu Dubois-Briand, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
>
Tom Hochstein April 10, 2025, 1:28 p.m. UTC | #3
On 4/8/2025 10:10 AM, Tom Hochstein via lists.openembedded.org wrote:
> On 4/8/2025 8:37 AM, Mathieu Dubois-Briand wrote:
>> [You don't often get email from mathieu.dubois-briand@bootlin.com. 
>> Learn why this is important at 
>> https://aka.ms/LearnAboutSenderIdentification ]
>>
>> On Mon Apr 7, 2025 at 11:18 PM CEST, Tom Hochstein via 
>> lists.openembedded.org wrote:
>>> From: Ross Burton <ross.burton@arm.com>
>>>
>>> Use 'meson introspect' to dump JSON describing the build configuration
>>> and validate that the build and host architectures are correctly set in
>>> the meson.cross file.
>>>
>>> Also instead of calling ninja directly, call the relevant meson 
>>> commands.
>>>
>>> Fixes: [YOCTO #15485]
>>> Signed-off-by: Ross Burton <ross.burton@arm.com>
>>> Signed-off-by: Tom Hochstein <tom.hochstein@oss.nxp.com>
>>> ---
>>>   meta/lib/oeqa/sdk/cases/meson.py | 18 +++++++++++++-----
>>>   1 file changed, 13 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/meta/lib/oeqa/sdk/cases/meson.py 
>>> b/meta/lib/oeqa/sdk/cases/meson.py
>>> index 1edf78720a..407b94d242 100644
>>> --- a/meta/lib/oeqa/sdk/cases/meson.py
>>> +++ b/meta/lib/oeqa/sdk/cases/meson.py
>>> @@ -4,6 +4,7 @@
>>>   # SPDX-License-Identifier: MIT
>>>   #
>>>
>>> +import json
>>>   import os
>>>   import subprocess
>>>   import tempfile
>>> @@ -39,10 +40,17 @@ class MesonTest(OESDKTestCase):
>>>               self.assertTrue(os.path.isdir(dirs["source"]))
>>>               os.makedirs(dirs["build"])
>>>
>>> -            log = self._run("meson --warnlevel 1 -Degl=no -Dglx=no 
>>> -Dx11=false {build} {source}".format(**dirs))
>>> -            # Check that Meson thinks we're doing a cross build and 
>>> not a native
>>> -            self.assertIn("Build type: cross build", log)
>>> -            self._run("ninja -C {build} -v".format(**dirs))
>>> -            self._run("DESTDIR={install} ninja -C {build} -v 
>>> install".format(**dirs))
>>> +            log = self._run("meson setup --warnlevel 1 -Degl=no 
>>> -Dglx=no -Dx11=false {build} {source}".format(**dirs))
>>> +
>>> +            # Check that the host (gcc) and build (cross-gcc) 
>>> compilers are different
>>> +            data = json.loads(self._run("meson introspect 
>>> --compilers {build}".format(**dirs)))
>>> +            self.assertNotEqual(data["build"]["c"]["exelist"], 
>>> data["host"]["c"]["exelist"])
>>> +            # Check that the system architectures were set correctly
>>> +            data = json.loads(self._run("meson introspect --machines 
>>> {build}".format(**dirs)))
>>> +            self.assertEqual(data["build"]["cpu"], self.td["SDK_ARCH"])
>>> +            self.assertEqual(data["host"]["cpu"], self.td["HOST_ARCH"])
>>> +
>>> +            self._run("meson compile -C {build} -v".format(**dirs))
>>> +            self._run("meson install -C {build} --destdir 
>>> {install}".format(**dirs))
>>>
>>>               self.check_elf(os.path.join(dirs["install"], "usr", 
>>> "local", "lib", "libepoxy.so"))
>>
>> Hi,
>>
>> Thanks for the new version, but we have a new error now:
>>
>> Traceback (most recent call last):
>>    File 
>> "/srv/pokybuild/yocto-worker/qemux86/build/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy
>>      self.assertNotEqual(data["build"]["c"]["exelist"], 
>> data["host"]["c"]["exelist"])
>>                          ~~~~~~~~~~~~~^^^^^
>> KeyError: 'c'
> 
> Thanks, Mathieu.
> 
> Ross, can you have a look?

An update: I thought this was working for me, but I realize now that I 
may not be running the modified test. This is what I ended up running 
after looking around using oe-selftest list commands, as it was the only 
thing that looked close to an SDK meson test:

`oe-selftest -r devtool.DevtoolIdeSdkTests.test_devtool_ide_sdk_code_meson`

How do I run the modified test?

> 
>>
>> https://autobuilder.yoctoproject.org/valkyrie/#/builders/30/builds/1330
>>
>> Can you have a look at this please?
>>
>> -- 
>> Mathieu Dubois-Briand, Bootlin
>> Embedded Linux and Kernel engineering
>> https://bootlin.com
>>
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#214542): https://lists.openembedded.org/g/openembedded-core/message/214542
> Mute This Topic: https://lists.openembedded.org/mt/112142020/3617670
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [tom.hochstein@oss.nxp.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Tom Hochstein April 10, 2025, 3:28 p.m. UTC | #4
On 4/10/2025 8:28 AM, Tom Hochstein via lists.openembedded.org wrote:
> On 4/8/2025 10:10 AM, Tom Hochstein via lists.openembedded.org wrote:
>> On 4/8/2025 8:37 AM, Mathieu Dubois-Briand wrote:
>>> [You don't often get email from mathieu.dubois-briand@bootlin.com. 
>>> Learn why this is important at 
>>> https://aka.ms/LearnAboutSenderIdentification ]
>>>
>>> On Mon Apr 7, 2025 at 11:18 PM CEST, Tom Hochstein via 
>>> lists.openembedded.org wrote:
>>>> From: Ross Burton <ross.burton@arm.com>
>>>>
>>>> Use 'meson introspect' to dump JSON describing the build configuration
>>>> and validate that the build and host architectures are correctly set in
>>>> the meson.cross file.
>>>>
>>>> Also instead of calling ninja directly, call the relevant meson 
>>>> commands.
>>>>
>>>> Fixes: [YOCTO #15485]
>>>> Signed-off-by: Ross Burton <ross.burton@arm.com>
>>>> Signed-off-by: Tom Hochstein <tom.hochstein@oss.nxp.com>
>>>> ---
>>>
>>> Hi,
>>>
>>> Thanks for the new version, but we have a new error now:
>>>
>>> Traceback (most recent call last):
>>>    File 
>>> "/srv/pokybuild/yocto-worker/qemux86/build/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy
>>>      self.assertNotEqual(data["build"]["c"]["exelist"], 
>>> data["host"]["c"]["exelist"])
>>>                          ~~~~~~~~~~~~~^^^^^
>>> KeyError: 'c'
>>
>> Thanks, Mathieu.
>>
>> Ross, can you have a look?
> 
> An update: I thought this was working for me, but I realize now that I 
> may not be running the modified test. This is what I ended up running 
> after looking around using oe-selftest list commands, as it was the only 
> thing that looked close to an SDK meson test:
> 
> `oe-selftest -r devtool.DevtoolIdeSdkTests.test_devtool_ide_sdk_code_meson`
> 
> How do I run the modified test?
> 

Never mind, I figured it out and successfully ran `bitbake -c testsdk 
core-image-minimal` with no failures, including the modified test.

RESULTS - meson.MesonTest.test_epoxy: PASSED (19.43s)

Trying now with core-image-sato as is done on the autobuilder.

>>
>>>
>>> https://autobuilder.yoctoproject.org/valkyrie/#/builders/30/builds/1330
>>>
>>> Can you have a look at this please?
>>>
>>> -- 
>>> Mathieu Dubois-Briand, Bootlin
>>> Embedded Linux and Kernel engineering
>>> https://bootlin.com
>>>
>>
>>
>>
>>
>>
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#214669): https://lists.openembedded.org/g/openembedded-core/message/214669
> Mute This Topic: https://lists.openembedded.org/mt/112142020/3617670
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [tom.hochstein@oss.nxp.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Tom Hochstein April 10, 2025, 6:58 p.m. UTC | #5
On 4/10/2025 10:28 AM, Tom Hochstein via lists.openembedded.org wrote:
> On 4/10/2025 8:28 AM, Tom Hochstein via lists.openembedded.org wrote:
>> On 4/8/2025 10:10 AM, Tom Hochstein via lists.openembedded.org wrote:
>>> On 4/8/2025 8:37 AM, Mathieu Dubois-Briand wrote:
>>>> [You don't often get email from mathieu.dubois-briand@bootlin.com. 
>>>> Learn why this is important at 
>>>> https://aka.ms/LearnAboutSenderIdentification ]
>>>>
>>>> On Mon Apr 7, 2025 at 11:18 PM CEST, Tom Hochstein via 
>>>> lists.openembedded.org wrote:
>>>>> From: Ross Burton <ross.burton@arm.com>
>>>>>
>>>>> Use 'meson introspect' to dump JSON describing the build configuration
>>>>> and validate that the build and host architectures are correctly 
>>>>> set in
>>>>> the meson.cross file.
>>>>>
>>>>> Also instead of calling ninja directly, call the relevant meson 
>>>>> commands.
>>>>>
>>>>> Fixes: [YOCTO #15485]
>>>>> Signed-off-by: Ross Burton <ross.burton@arm.com>
>>>>> Signed-off-by: Tom Hochstein <tom.hochstein@oss.nxp.com>
>>>>> ---
>>>>
>>>> Hi,
>>>>
>>>> Thanks for the new version, but we have a new error now:
>>>>
>>>> Traceback (most recent call last):
>>>>    File 
>>>> "/srv/pokybuild/yocto-worker/qemux86/build/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy
>>>>      self.assertNotEqual(data["build"]["c"]["exelist"], 
>>>> data["host"]["c"]["exelist"])
>>>>                          ~~~~~~~~~~~~~^^^^^
>>>> KeyError: 'c'
>>>
>>> Thanks, Mathieu.
>>>
>>> Ross, can you have a look?
>>
>> An update: I thought this was working for me, but I realize now that I 
>> may not be running the modified test. This is what I ended up running 
>> after looking around using oe-selftest list commands, as it was the 
>> only thing that looked close to an SDK meson test:
>>
>> `oe-selftest -r 
>> devtool.DevtoolIdeSdkTests.test_devtool_ide_sdk_code_meson`
>>
>> How do I run the modified test?
>>
> 
> Never mind, I figured it out and successfully ran `bitbake -c testsdk 
> core-image-minimal` with no failures, including the modified test.
> 
> RESULTS - meson.MesonTest.test_epoxy: PASSED (19.43s)
> 
> Trying now with core-image-sato as is done on the autobuilder.

Unfortunately, I still cannot reproduce the issue. Another variance was
that I had used the default machine qemux86-64, while the autobuilder
test failed using qemux86. I updated the machine, but still cannot
reproduce the error.

> 
>>>
>>>>
>>>> https://autobuilder.yoctoproject.org/valkyrie/#/builders/30/builds/1330
>>>>
>>>> Can you have a look at this please?
>>>>
>>>> -- 
>>>> Mathieu Dubois-Briand, Bootlin
>>>> Embedded Linux and Kernel engineering
>>>> https://bootlin.com
>>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#214680): https://lists.openembedded.org/g/openembedded-core/message/214680
> Mute This Topic: https://lists.openembedded.org/mt/112142020/3617670
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [tom.hochstein@oss.nxp.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Mathieu Dubois-Briand April 11, 2025, 10:01 a.m. UTC | #6
On Thu Apr 10, 2025 at 8:58 PM CEST, Tom Hochstein via lists.openembedded.org wrote:
> On 4/10/2025 10:28 AM, Tom Hochstein via lists.openembedded.org wrote:
>> On 4/10/2025 8:28 AM, Tom Hochstein via lists.openembedded.org wrote:
>>> On 4/8/2025 10:10 AM, Tom Hochstein via lists.openembedded.org wrote:
>>>> On 4/8/2025 8:37 AM, Mathieu Dubois-Briand wrote:
>>>>>
>>>>> Hi,
>>>>>
>>>>> Thanks for the new version, but we have a new error now:
>>>>>
>>>>> Traceback (most recent call last):
>>>>>    File 
>>>>> "/srv/pokybuild/yocto-worker/qemux86/build/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy
>>>>>      self.assertNotEqual(data["build"]["c"]["exelist"], 
>>>>> data["host"]["c"]["exelist"])
>>>>>                          ~~~~~~~~~~~~~^^^^^
>>>>> KeyError: 'c'
>>>>
>>>> Thanks, Mathieu.
>>>>
>>>> Ross, can you have a look?
>>>
>>> An update: I thought this was working for me, but I realize now that I 
>>> may not be running the modified test. This is what I ended up running 
>>> after looking around using oe-selftest list commands, as it was the 
>>> only thing that looked close to an SDK meson test:
>>>
>>> `oe-selftest -r 
>>> devtool.DevtoolIdeSdkTests.test_devtool_ide_sdk_code_meson`
>>>
>>> How do I run the modified test?
>>>
>> 
>> Never mind, I figured it out and successfully ran `bitbake -c testsdk 
>> core-image-minimal` with no failures, including the modified test.
>> 
>> RESULTS - meson.MesonTest.test_epoxy: PASSED (19.43s)
>> 
>> Trying now with core-image-sato as is done on the autobuilder.
>
> Unfortunately, I still cannot reproduce the issue. Another variance was
> that I had used the default machine qemux86-64, while the autobuilder
> test failed using qemux86. I updated the machine, but still cannot
> reproduce the error.
>

Hi,

Ok, I managed to reproduce the error withe the following process:

git clone git://web.git.yoctoproject.org/poky-ci-archive -b autobuilder.yoctoproject.org/valkyrie/a-full-1363
cd poky-ci-archive 
. oe-init-build-env

Adding following in my local.conf:
IMAGE_CLASSES += "testimage"
MACHINE = "qemux86"
DISTRO = "poky"
SDKMACHINE = "i686"
PACKAGE_CLASSES = "package_rpm package_deb package_ipk"
INHERIT += 'image-buildinfo'

bitbake core-image-sato -c populate_sdk
bitbake core-image-sato -c testsdk

And I got this error:

Traceback (most recent call last):
  File "/home/mdubois-briand/swat/oe-sefltest/poky-contrib/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy
    self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"])
                        ~~~~~~~~~~~~~^^^^^
KeyError: 'c'

Best regards,
Mathieu
Mathieu Dubois-Briand April 11, 2025, 10:13 a.m. UTC | #7
On Fri Apr 11, 2025 at 12:01 PM CEST, Mathieu Dubois-Briand via lists.openembedded.org wrote:
> Hi,
>
> Ok, I managed to reproduce the error withe the following process:
>
> git clone git://web.git.yoctoproject.org/poky-ci-archive -b autobuilder.yoctoproject.org/valkyrie/a-full-1363
> cd poky-ci-archive 
> . oe-init-build-env
>
> Adding following in my local.conf:
> IMAGE_CLASSES += "testimage"
> MACHINE = "qemux86"
> DISTRO = "poky"
> SDKMACHINE = "i686"
> PACKAGE_CLASSES = "package_rpm package_deb package_ipk"
> INHERIT += 'image-buildinfo'
>
> bitbake core-image-sato -c populate_sdk
> bitbake core-image-sato -c testsdk
>
> And I got this error:
>
> Traceback (most recent call last):
>   File "/home/mdubois-briand/swat/oe-sefltest/poky-contrib/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy
>     self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"])
>                         ~~~~~~~~~~~~~^^^^^
> KeyError: 'c'
>
> Best regards,
> Mathieu

Also reproduced with core-image-minimal, if you don't want to loose time
building core-image-sato.
Tom Hochstein April 11, 2025, 3:37 p.m. UTC | #8
On 4/11/2025 5:13 AM, Mathieu Dubois-Briand wrote:
> On Fri Apr 11, 2025 at 12:01 PM CEST, Mathieu Dubois-Briand via lists.openembedded.org wrote:
>> Hi,
>>
>> Ok, I managed to reproduce the error withe the following process:
>>
>> git clone git://web.git.yoctoproject.org/poky-ci-archive -b autobuilder.yoctoproject.org/valkyrie/a-full-1363
>> cd poky-ci-archive
>> . oe-init-build-env
>>
>> Adding following in my local.conf:
>> IMAGE_CLASSES += "testimage"
>> MACHINE = "qemux86"
>> DISTRO = "poky"
>> SDKMACHINE = "i686"
>> PACKAGE_CLASSES = "package_rpm package_deb package_ipk"
>> INHERIT += 'image-buildinfo'
>>
>> bitbake core-image-sato -c populate_sdk
>> bitbake core-image-sato -c testsdk
>>
>> And I got this error:
>>
>> Traceback (most recent call last):
>>    File "/home/mdubois-briand/swat/oe-sefltest/poky-contrib/meta/lib/oeqa/sdk/cases/meson.py", line 47, in test_epoxy
>>      self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"])
>>                          ~~~~~~~~~~~~~^^^^^
>> KeyError: 'c'
>>
>> Best regards,
>> Mathieu
> 
> Also reproduced with core-image-minimal, if you don't want to loose time
> building core-image-sato.
> 
> 

Thanks, Mathieu! I can reproduce it now.

The key in your steps to reproduce is setting SDKMACHINE = "i686". So
the SDK is built for i686, but the build machine is x86_64, so the test
is not valid.

How should it be fixed? Testing for the mismatch and raising SkipTest in
MesonTest.setUp?

Tom
Mathieu Dubois-Briand April 15, 2025, 8:29 a.m. UTC | #9
On Fri Apr 11, 2025 at 5:37 PM CEST, Tom Hochstein wrote:
>
> Thanks, Mathieu! I can reproduce it now.
>
> The key in your steps to reproduce is setting SDKMACHINE = "i686". So
> the SDK is built for i686, but the build machine is x86_64, so the test
> is not valid.
>
> How should it be fixed? Testing for the mismatch and raising SkipTest in
> MesonTest.setUp?
>
> Tom

I'm not really familiar with these tests to be honest, so I cannot
really help you on that. Sorry.
diff mbox series

Patch

diff --git a/meta/lib/oeqa/sdk/cases/meson.py b/meta/lib/oeqa/sdk/cases/meson.py
index 1edf78720a..407b94d242 100644
--- a/meta/lib/oeqa/sdk/cases/meson.py
+++ b/meta/lib/oeqa/sdk/cases/meson.py
@@ -4,6 +4,7 @@ 
 # SPDX-License-Identifier: MIT
 #
 
+import json
 import os
 import subprocess
 import tempfile
@@ -39,10 +40,17 @@  class MesonTest(OESDKTestCase):
             self.assertTrue(os.path.isdir(dirs["source"]))
             os.makedirs(dirs["build"])
 
-            log = self._run("meson --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs))
-            # Check that Meson thinks we're doing a cross build and not a native
-            self.assertIn("Build type: cross build", log)
-            self._run("ninja -C {build} -v".format(**dirs))
-            self._run("DESTDIR={install} ninja -C {build} -v install".format(**dirs))
+            log = self._run("meson setup --warnlevel 1 -Degl=no -Dglx=no -Dx11=false {build} {source}".format(**dirs))
+
+            # Check that the host (gcc) and build (cross-gcc) compilers are different
+            data = json.loads(self._run("meson introspect --compilers {build}".format(**dirs)))
+            self.assertNotEqual(data["build"]["c"]["exelist"], data["host"]["c"]["exelist"])
+            # Check that the system architectures were set correctly
+            data = json.loads(self._run("meson introspect --machines {build}".format(**dirs)))
+            self.assertEqual(data["build"]["cpu"], self.td["SDK_ARCH"])
+            self.assertEqual(data["host"]["cpu"], self.td["HOST_ARCH"])
+
+            self._run("meson compile -C {build} -v".format(**dirs))
+            self._run("meson install -C {build} --destdir {install}".format(**dirs))
 
             self.check_elf(os.path.join(dirs["install"], "usr", "local", "lib", "libepoxy.so"))