[PATCH] tests: strip macOS "-unsigned" suffix from binary name

Emmanuel Blot posted 1 patch 8 hours ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20260608-testing-macos-v1-1-42774498936f@meta.com
Maintainers: Thomas Huth <th.huth+qemu@posteo.eu>, "Philippe Mathieu-Daudé" <philmd@mailo.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Fabiano Rosas <farosas@suse.de>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
tests/functional/qemu_test/testcase.py | 2 ++
tests/qtest/libqtest.c                 | 6 ++++++
2 files changed, 8 insertions(+)
[PATCH] tests: strip macOS "-unsigned" suffix from binary name
Posted by Emmanuel Blot 8 hours ago
On macOS, plain QEMU binaries are named qemu-system-<arch>-unsigned.

In libqtest, qtest_get_arch() extracts the architecture by splitting
after "-system-", which yields "arm-unsigned" instead of "arm".  This
prevents the QOS graph from matching any machine node, causing all
QOS-based tests to be silently skipped.

In the functional test framework, the same suffix causes the arch to
be parsed as "unsigned", leading to wrong output directories and
teardown failures.

Strip the "-unsigned" suffix on both code paths.

Signed-off-by: Emmanuel Blot <eblot@meta.com>
---
Address issues with liqtest and functional test framework when run from
a macOS host.

Unsigned binaries on macOS may be appended an `-unsigned` suffix, which
confuse these components that rely on the binary name to recover the
guest architecture. 
---
 tests/functional/qemu_test/testcase.py | 2 ++
 tests/qtest/libqtest.c                 | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/tests/functional/qemu_test/testcase.py b/tests/functional/qemu_test/testcase.py
index eaec1bea13..2885fdd44c 100644
--- a/tests/functional/qemu_test/testcase.py
+++ b/tests/functional/qemu_test/testcase.py
@@ -204,6 +204,8 @@ def setUp(self):
         self.qemu_bin = os.getenv('QEMU_TEST_QEMU_BINARY')
         self.assertIsNotNone(self.qemu_bin, 'QEMU_TEST_QEMU_BINARY must be set')
         self.arch = self.qemu_bin.split('-')[-1]
+        if sys.platform == 'darwin' and self.arch == "unsigned":
+            self.arch = self.qemu_bin.split('-')[-2]
         self.socketdir = None
 
         self.outputdir = self.build_file('tests', 'functional',
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 4e22c66b75..e31f060152 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -1033,6 +1033,12 @@ const char *qtest_get_arch(void)
             g_auto(GStrv) tokens = g_strsplit_set(sysstr + strlen("-system-"),
                                                   " \t", 2);
             if (tokens && tokens[0]) {
+#ifdef __APPLE__
+                if (g_str_has_suffix(tokens[0], "-unsigned")) {
+                    tokens[0][strlen(tokens[0])
+                              - strlen("-unsigned")] = '\0';
+                }
+#endif
                 arch = g_steal_pointer(&tokens[0]);
             }
         }

---
base-commit: cc329c491768b2d91eb0b0984f3baa0bf805776d
change-id: 20260608-testing-macos-b95676cd3f86

Best regards,
--  
Emmanuel Blot <eblot@meta.com>
Re: [PATCH] tests: strip macOS "-unsigned" suffix from binary name
Posted by Peter Maydell 8 hours ago
On Mon, 8 Jun 2026 at 16:25, Emmanuel Blot <eblot@meta.com> wrote:
>
> On macOS, plain QEMU binaries are named qemu-system-<arch>-unsigned.
>
> In libqtest, qtest_get_arch() extracts the architecture by splitting
> after "-system-", which yields "arm-unsigned" instead of "arm".  This
> prevents the QOS graph from matching any machine node, causing all
> QOS-based tests to be silently skipped.
>
> In the functional test framework, the same suffix causes the arch to
> be parsed as "unsigned", leading to wrong output directories and
> teardown failures.
>
> Strip the "-unsigned" suffix on both code paths.
>
> Signed-off-by: Emmanuel Blot <eblot@meta.com>
> ---
> Address issues with liqtest and functional test framework when run from
> a macOS host.
>
> Unsigned binaries on macOS may be appended an `-unsigned` suffix, which
> confuse these components that rely on the binary name to recover the
> guest architecture.

I still think this not the right thing to do. The "make" process
on macos should produce and sign the binary in-place in the
build tree, so that users and test cases don't have to care
about this macos specific weirdness. (If the signing is
location-specific and we need to sign again for "make install"
that's fine. But we should produce a working binary with the
usual name in the build tree, not a non-working one or one with a
nonstandard name.)

See also this earlier thread:
https://lore.kernel.org/qemu-devel/CAFEAcA_txOHPLK+J546yjCmOEv0-ptaVkCEk5GfeL13DdqQd-w@mail.gmail.com/

thanks
-- PMM
Re: [PATCH] tests: strip macOS "-unsigned" suffix from binary name
Posted by Daniel P. Berrangé 8 hours ago
On Mon, Jun 08, 2026 at 04:29:47PM +0100, Peter Maydell wrote:
> On Mon, 8 Jun 2026 at 16:25, Emmanuel Blot <eblot@meta.com> wrote:
> >
> > On macOS, plain QEMU binaries are named qemu-system-<arch>-unsigned.
> >
> > In libqtest, qtest_get_arch() extracts the architecture by splitting
> > after "-system-", which yields "arm-unsigned" instead of "arm".  This
> > prevents the QOS graph from matching any machine node, causing all
> > QOS-based tests to be silently skipped.
> >
> > In the functional test framework, the same suffix causes the arch to
> > be parsed as "unsigned", leading to wrong output directories and
> > teardown failures.
> >
> > Strip the "-unsigned" suffix on both code paths.
> >
> > Signed-off-by: Emmanuel Blot <eblot@meta.com>
> > ---
> > Address issues with liqtest and functional test framework when run from
> > a macOS host.
> >
> > Unsigned binaries on macOS may be appended an `-unsigned` suffix, which
> > confuse these components that rely on the binary name to recover the
> > guest architecture.
> 
> I still think this not the right thing to do. The "make" process
> on macos should produce and sign the binary in-place in the
> build tree, so that users and test cases don't have to care
> about this macos specific weirdness. (If the signing is
> location-specific and we need to sign again for "make install"
> that's fine. But we should produce a working binary with the
> usual name in the build tree, not a non-working one or one with a
> nonstandard name.)

Yes, I was just about to write similar when I saw your message.
We should not have this custom "-unsigned" name  in the build
tree as specialcases like this break too many expectations,
especially when most devs aren't ever testing for macOS and so
won't see the special case.

With regards,
Daniel
-- 
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
Re: [PATCH] tests: strip macOS "-unsigned" suffix from binary name
Posted by Peter Maydell 8 hours ago
On Mon, 8 Jun 2026 at 16:35, Daniel P. Berrangé <berrange@redhat.com> wrote:
>
> On Mon, Jun 08, 2026 at 04:29:47PM +0100, Peter Maydell wrote:
> > On Mon, 8 Jun 2026 at 16:25, Emmanuel Blot <eblot@meta.com> wrote:
> > >
> > > On macOS, plain QEMU binaries are named qemu-system-<arch>-unsigned.
> > >
> > > In libqtest, qtest_get_arch() extracts the architecture by splitting
> > > after "-system-", which yields "arm-unsigned" instead of "arm".  This
> > > prevents the QOS graph from matching any machine node, causing all
> > > QOS-based tests to be silently skipped.
> > >
> > > In the functional test framework, the same suffix causes the arch to
> > > be parsed as "unsigned", leading to wrong output directories and
> > > teardown failures.
> > >
> > > Strip the "-unsigned" suffix on both code paths.
> > >
> > > Signed-off-by: Emmanuel Blot <eblot@meta.com>
> > > ---
> > > Address issues with liqtest and functional test framework when run from
> > > a macOS host.
> > >
> > > Unsigned binaries on macOS may be appended an `-unsigned` suffix, which
> > > confuse these components that rely on the binary name to recover the
> > > guest architecture.
> >
> > I still think this not the right thing to do. The "make" process
> > on macos should produce and sign the binary in-place in the
> > build tree, so that users and test cases don't have to care
> > about this macos specific weirdness. (If the signing is
> > location-specific and we need to sign again for "make install"
> > that's fine. But we should produce a working binary with the
> > usual name in the build tree, not a non-working one or one with a
> > nonstandard name.)
>
> Yes, I was just about to write similar when I saw your message.
> We should not have this custom "-unsigned" name  in the build
> tree as specialcases like this break too many expectations,
> especially when most devs aren't ever testing for macOS and so
> won't see the special case.

I think it's OK to have the -unsigned binary as an interim step,
where we compile to qemu-foo-unsigned and then immediately sign
to produce qemu-foo. The problem is that "make" is for some reason
not actually doing the signing step. Alex notes in that other
thread that you can make it do the signing part by manually
running "make qemu-system-aarch64". We just don't have this
working correctly so that "make all" does it.

-- PMM
Re: [PATCH] tests: strip macOS "-unsigned" suffix from binary name
Posted by Emmanuel Blot 8 hours ago
Ok thanks, got it.

I need to use `ninja -C build qemy-system-arm` to generate the signed
binary, because the default target only generates the `-unsigned`
version (I guess this is the linker's default output, macOS requires
an extra signing step).
The signed version is defined as an on-demand command which is not
part of the default build (`all`).


On Mon, Jun 8, 2026 at 5:38 PM Peter Maydell <peter.maydell@linaro.org> wrote:
>
> >
> On Mon, 8 Jun 2026 at 16:35, Daniel P. Berrangé <berrange@redhat.com> wrote:
> >
> > On Mon, Jun 08, 2026 at 04:29:47PM +0100, Peter Maydell wrote:
> > > On Mon, 8 Jun 2026 at 16:25, Emmanuel Blot <eblot@meta.com> wrote:
> > > >
> > > > On macOS, plain QEMU binaries are named qemu-system-<arch>-unsigned.
> > > >
> > > > In libqtest, qtest_get_arch() extracts the architecture by splitting
> > > > after "-system-", which yields "arm-unsigned" instead of "arm".  This
> > > > prevents the QOS graph from matching any machine node, causing all
> > > > QOS-based tests to be silently skipped.
> > > >
> > > > In the functional test framework, the same suffix causes the arch to
> > > > be parsed as "unsigned", leading to wrong output directories and
> > > > teardown failures.
> > > >
> > > > Strip the "-unsigned" suffix on both code paths.
> > > >
> > > > Signed-off-by: Emmanuel Blot <eblot@meta.com>
> > > > ---
> > > > Address issues with liqtest and functional test framework when run from
> > > > a macOS host.
> > > >
> > > > Unsigned binaries on macOS may be appended an `-unsigned` suffix, which
> > > > confuse these components that rely on the binary name to recover the
> > > > guest architecture.
> > >
> > > I still think this not the right thing to do. The "make" process
> > > on macos should produce and sign the binary in-place in the
> > > build tree, so that users and test cases don't have to care
> > > about this macos specific weirdness. (If the signing is
> > > location-specific and we need to sign again for "make install"
> > > that's fine. But we should produce a working binary with the
> > > usual name in the build tree, not a non-working one or one with a
> > > nonstandard name.)
> >
> > Yes, I was just about to write similar when I saw your message.
> > We should not have this custom "-unsigned" name  in the build
> > tree as specialcases like this break too many expectations,
> > especially when most devs aren't ever testing for macOS and so
> > won't see the special case.
>
> I think it's OK to have the -unsigned binary as an interim step,
> where we compile to qemu-foo-unsigned and then immediately sign
> to produce qemu-foo. The problem is that "make" is for some reason
> not actually doing the signing step. Alex notes in that other
> thread that you can make it do the signing part by manually
> running "make qemu-system-aarch64". We just don't have this
> working correctly so that "make all" does it.
>
> -- PMM
Re: [PATCH] tests: strip macOS "-unsigned" suffix from binary name
Posted by Peter Maydell 8 hours ago
On Mon, 8 Jun 2026 at 16:57, Emmanuel Blot <eblot@meta.com> wrote:
>
> Ok thanks, got it.
>
> I need to use `ninja -C build qemy-system-arm` to generate the signed
> binary, because the default target only generates the `-unsigned`
> version (I guess this is the linker's default output, macOS requires
> an extra signing step).
> The signed version is defined as an on-demand command which is not
> part of the default build (`all`).

Right, this is the bug that needs fixing. The default target should
build the signed binary.

-- PMM
Re: [PATCH] tests: strip macOS "-unsigned" suffix from binary name
Posted by Pierrick Bouvier 7 hours ago
On 6/8/2026 9:08 AM, Peter Maydell wrote:
> On Mon, 8 Jun 2026 at 16:57, Emmanuel Blot <eblot@meta.com> wrote:
>>
>> Ok thanks, got it.
>>
>> I need to use `ninja -C build qemy-system-arm` to generate the signed
>> binary, because the default target only generates the `-unsigned`
>> version (I guess this is the linker's default output, macOS requires
>> an extra signing step).
>> The signed version is defined as an on-demand command which is not
>> part of the default build (`all`).
> 
> Right, this is the bug that needs fixing. The default target should
> build the signed binary.
> 
> -- PMM
> 

For information, I recently offered to Alex to do a rewrite of tcg
makefiles in meson natively. It's not the first time, and certainly not
the last time, that we waste hours/days debugging dependencies there,
this has to stop.

After this weekend, I am close from a proof of concept covering aarch64
and multiarch tests. It fixes any issue we had with dependencies, among
other improvements.

So hopefully the fix for that will be to wait for the meson version. If
anyone wants to spend cycle and fix existing Makefiles, feel free to do
it also, but they will be gone at some point.

Regards,
Pierrick
Re: [PATCH] tests: strip macOS "-unsigned" suffix from binary name
Posted by Peter Maydell 6 hours ago
On Mon, 8 Jun 2026 at 17:43, Pierrick Bouvier
<pierrick.bouvier@oss.qualcomm.com> wrote:
>
> On 6/8/2026 9:08 AM, Peter Maydell wrote:
> > On Mon, 8 Jun 2026 at 16:57, Emmanuel Blot <eblot@meta.com> wrote:
> >>
> >> Ok thanks, got it.
> >>
> >> I need to use `ninja -C build qemy-system-arm` to generate the signed
> >> binary, because the default target only generates the `-unsigned`
> >> version (I guess this is the linker's default output, macOS requires
> >> an extra signing step).
> >> The signed version is defined as an on-demand command which is not
> >> part of the default build (`all`).
> >
> > Right, this is the bug that needs fixing. The default target should
> > build the signed binary.

> For information, I recently offered to Alex to do a rewrite of tcg
> makefiles in meson natively. It's not the first time, and certainly not
> the last time, that we waste hours/days debugging dependencies there,
> this has to stop.

This isn't related at all to the TCG makefiles, though. It's
purely an issue with the main meson build files (which is why
it's shown up here with the qtest tests).

thanks
-- PMM