public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fiona Ebner <f.ebner@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>, pve-devel@lists.proxmox.com
Subject: Re: [PATCH qemu-server v3 1/3] tests: improve multiarch build support by introducing local get_host_arch helper
Date: Tue, 10 Feb 2026 14:22:08 +0100	[thread overview]
Message-ID: <16e76695-0f35-4b72-aefe-0ae87df1b622@proxmox.com> (raw)
In-Reply-To: <20260205141959.3615131-2-d.csapak@proxmox.com>

Am 05.02.26 um 3:19 PM schrieb Dominik Csapak:
> Since mocking imported functions have to be done for each package that
> imports them, we would have to mock get_host_arch for each package that
> imports it from PVE::Tools. Instead, introduce one local helper here
> that uses the function from PVE::Tools. This allows us to only need to
> override it one time.
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>

Reviewed-by: Fiona Ebner <f.ebner@proxmox.com>

with two small comments below

> @@ -29,6 +30,11 @@ my $arch_to_qemu_binary = {
>      x86_64 => '/usr/bin/qemu-system-x86_64',
>  };
>  
> +# wrapper around the Tools helper, having it here makes it easier for testing

To be even clearer: "easier to mock for testing"

> +sub get_host_arch {
> +    return PVE::Tools::get_host_arch();
> +}
> +
>  sub get_command_for_arch($) {
>      my ($arch) = @_;
>      return '/usr/bin/kvm' if get_host_arch() eq $arch; # i.e. native arch
> diff --git a/src/test/run_config2command_tests.pl b/src/test/run_config2command_tests.pl
> index 4c872d1c..c20f2377 100755
> --- a/src/test/run_config2command_tests.pl
> +++ b/src/test/run_config2command_tests.pl
> @@ -253,9 +253,6 @@ $qemu_server_module->mock(
>      kernel_has_vhost_net => sub {
>          return 1; # TODO: make this per-test configurable?
>      },
> -    get_host_arch => sub() {
> -        return $current_test->{host_arch} // 'x86_64';
> -    },
>      get_iscsi_initiator_name => sub {
>          return 'iqn.1993-08.org.debian:01:aabbccddeeff';
>      },
> @@ -388,6 +385,9 @@ $pve_common_tools->mock(
>              },
>          );
>      },
> +    get_host_arch => sub() {

Pre-existing from before the move, but I think we should drop the
parentheses for consistency with other mocked functions

> +        return $current_test->{host_arch} // 'x86_64';
> +    },
>  );
>  
>  my $pve_cpuconfig;





  reply	other threads:[~2026-02-10 13:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05 14:17 [PATCH qemu-server v3 0/3] improve multiarch build support Dominik Csapak
2026-02-05 14:17 ` [PATCH qemu-server v3 1/3] tests: improve multiarch build support by introducing local get_host_arch helper Dominik Csapak
2026-02-10 13:22   ` Fiona Ebner [this message]
2026-02-05 14:17 ` [PATCH qemu-server v3 2/3] tests: improve multiarch build support by allowing re-init of cpu models Dominik Csapak
2026-02-10 13:22   ` Fiona Ebner
2026-02-10 14:33     ` Dominik Csapak
2026-02-05 14:17 ` [PATCH qemu-server v3 3/3] tests: cfg2cmd: add some architecture tests Dominik Csapak
2026-02-10 13:22   ` Fiona Ebner
2026-02-10 14:34     ` Dominik Csapak
2026-02-10 14:37       ` Fiona Ebner
2026-02-10 14:45         ` Dominik Csapak
2026-02-11  9:27 ` superseded: [PATCH qemu-server v3 0/3] improve multiarch build support Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16e76695-0f35-4b72-aefe-0ae87df1b622@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal