All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests/unit/test-qga: only run tests for commands the host provides
@ 2026-10-30 23:08 Brad Smith
  2026-10-31 13:03 ` Roman Bogorodskiy
  0 siblings, 1 reply; 3+ messages in thread
From: Brad Smith @ 2026-10-30 23:08 UTC (permalink / raw)
  To: Michael Roth, Kostiantyn Kostiuk; +Cc: qemu-devel

tests/unit/test-qga: only run tests for commands the host provides

guest-fsfreeze-status is only implemented when CONFIG_FSFREEZE is
set (Linux and FreeBSD), and guest-get-users is only built on POSIX
hosts when HAVE_UTMPX is set, so neither command exists on hosts such
as OpenBSD. Only build and register these tests where the commands
are available.

Signed-off-by: Brad Smith <brad@comstyle.com>
---
 tests/unit/test-qga.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
index b1c84c188b..ef796f2f7d 100644
--- a/tests/unit/test-qga.c
+++ b/tests/unit/test-qga.c
@@ -787,6 +787,7 @@ static void test_qga_config(gconstpointer data)
     g_free(env[0]);
 }
 
+#ifdef CONFIG_FSFREEZE
 static void test_qga_fsfreeze_status(gconstpointer fix)
 {
     const TestFixture *fixture = fix;
@@ -800,6 +801,7 @@ static void test_qga_fsfreeze_status(gconstpointer fix)
     status = qdict_get_try_str(ret, "return");
     g_assert_cmpstr(status, ==, "thawed");
 }
+#endif
 
 static QDict *wait_for_guest_exec_completion(int fd, int64_t pid)
 {
@@ -1028,6 +1030,7 @@ static void test_qga_guest_get_timezone(gconstpointer fix)
     g_assert(qdict_haskey(val, "offset"));
 }
 
+#ifdef HAVE_UTMPX
 static void test_qga_guest_get_users(gconstpointer fix)
 {
     const TestFixture *fixture = fix;
@@ -1042,6 +1045,7 @@ static void test_qga_guest_get_users(gconstpointer fix)
     val = qdict_get_qlist(ret, "return");
     g_assert_nonnull(val);
 }
+#endif
 
 static void test_qga_guest_get_osinfo(gconstpointer data)
 {
@@ -1133,8 +1137,10 @@ int main(int argc, char **argv)
     g_test_add_data_func("/qga/invalid-oob", &fix, test_qga_invalid_oob);
     g_test_add_data_func("/qga/invalid-cmd", &fix, test_qga_invalid_cmd);
     g_test_add_data_func("/qga/invalid-args", &fix, test_qga_invalid_args);
+#ifdef CONFIG_FSFREEZE
     g_test_add_data_func("/qga/fsfreeze-status", &fix,
                          test_qga_fsfreeze_status);
+#endif
 
     g_test_add_data_func("/qga/blockedrpcs", NULL, test_qga_blockedrpcs);
     g_test_add_data_func("/qga/allowedrpcs", NULL, test_qga_allowedrpcs);
@@ -1152,8 +1158,10 @@ int main(int argc, char **argv)
                          test_qga_guest_get_host_name);
     g_test_add_data_func("/qga/guest-get-timezone", &fix,
                          test_qga_guest_get_timezone);
+#ifdef HAVE_UTMPX
     g_test_add_data_func("/qga/guest-get-users", &fix,
                          test_qga_guest_get_users);
+#endif
 
     ret = g_test_run();
 
-- 
2.56.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] tests/unit/test-qga: only run tests for commands the host provides
  2026-10-30 23:08 [PATCH] tests/unit/test-qga: only run tests for commands the host provides Brad Smith
@ 2026-10-31 13:03 ` Roman Bogorodskiy
  2026-10-31 21:20   ` Brad Smith
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Bogorodskiy @ 2026-10-31 13:03 UTC (permalink / raw)
  To: Brad Smith; +Cc: Michael Roth, Kostiantyn Kostiuk, qemu-devel

  Brad Smith wrote:

> tests/unit/test-qga: only run tests for commands the host provides
> 
> guest-fsfreeze-status is only implemented when CONFIG_FSFREEZE is
> set (Linux and FreeBSD), and guest-get-users is only built on POSIX
> hosts when HAVE_UTMPX is set, so neither command exists on hosts such
> as OpenBSD. Only build and register these tests where the commands
> are available.

Does that also need something like:

--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -170,7 +170,7 @@ if have_system
   tests += {'test-qdev': [qom, hwcore]}
 endif

-if have_ga and host_os in ['freebsd', 'linux']
+if have_ga and host_os in ['freebsd', 'linux', 'openbsd']
   tests += {'test-qga': ['../qtest/libqmp.c', '../qtest/libqtest.c']}
   test_deps += {'test-qga': qga}
 endif

Otherwise it's not clear how to spot these issues if the test never runs
on OpenBSD.

> Signed-off-by: Brad Smith <brad@comstyle.com>
> ---
>  tests/unit/test-qga.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
> index b1c84c188b..ef796f2f7d 100644
> --- a/tests/unit/test-qga.c
> +++ b/tests/unit/test-qga.c
> @@ -787,6 +787,7 @@ static void test_qga_config(gconstpointer data)
>      g_free(env[0]);
>  }
>  
> +#ifdef CONFIG_FSFREEZE
>  static void test_qga_fsfreeze_status(gconstpointer fix)
>  {
>      const TestFixture *fixture = fix;
> @@ -800,6 +801,7 @@ static void test_qga_fsfreeze_status(gconstpointer fix)
>      status = qdict_get_try_str(ret, "return");
>      g_assert_cmpstr(status, ==, "thawed");
>  }
> +#endif
>  
>  static QDict *wait_for_guest_exec_completion(int fd, int64_t pid)
>  {
> @@ -1028,6 +1030,7 @@ static void test_qga_guest_get_timezone(gconstpointer fix)
>      g_assert(qdict_haskey(val, "offset"));
>  }
>  
> +#ifdef HAVE_UTMPX
>  static void test_qga_guest_get_users(gconstpointer fix)
>  {
>      const TestFixture *fixture = fix;
> @@ -1042,6 +1045,7 @@ static void test_qga_guest_get_users(gconstpointer fix)
>      val = qdict_get_qlist(ret, "return");
>      g_assert_nonnull(val);
>  }
> +#endif
>  
>  static void test_qga_guest_get_osinfo(gconstpointer data)
>  {
> @@ -1133,8 +1137,10 @@ int main(int argc, char **argv)
>      g_test_add_data_func("/qga/invalid-oob", &fix, test_qga_invalid_oob);
>      g_test_add_data_func("/qga/invalid-cmd", &fix, test_qga_invalid_cmd);
>      g_test_add_data_func("/qga/invalid-args", &fix, test_qga_invalid_args);
> +#ifdef CONFIG_FSFREEZE
>      g_test_add_data_func("/qga/fsfreeze-status", &fix,
>                           test_qga_fsfreeze_status);
> +#endif
>  
>      g_test_add_data_func("/qga/blockedrpcs", NULL, test_qga_blockedrpcs);
>      g_test_add_data_func("/qga/allowedrpcs", NULL, test_qga_allowedrpcs);
> @@ -1152,8 +1158,10 @@ int main(int argc, char **argv)
>                           test_qga_guest_get_host_name);
>      g_test_add_data_func("/qga/guest-get-timezone", &fix,
>                           test_qga_guest_get_timezone);
> +#ifdef HAVE_UTMPX
>      g_test_add_data_func("/qga/guest-get-users", &fix,
>                           test_qga_guest_get_users);
> +#endif
>  
>      ret = g_test_run();
>  
> -- 
> 2.56.0
> 
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] tests/unit/test-qga: only run tests for commands the host provides
  2026-10-31 13:03 ` Roman Bogorodskiy
@ 2026-10-31 21:20   ` Brad Smith
  0 siblings, 0 replies; 3+ messages in thread
From: Brad Smith @ 2026-10-31 21:20 UTC (permalink / raw)
  To: Roman Bogorodskiy; +Cc: Michael Roth, Kostiantyn Kostiuk, qemu-devel

On 2026-10-31 9:03 a.m., Roman Bogorodskiy wrote:
>    Brad Smith wrote:
>
>> tests/unit/test-qga: only run tests for commands the host provides
>>
>> guest-fsfreeze-status is only implemented when CONFIG_FSFREEZE is
>> set (Linux and FreeBSD), and guest-get-users is only built on POSIX
>> hosts when HAVE_UTMPX is set, so neither command exists on hosts such
>> as OpenBSD. Only build and register these tests where the commands
>> are available.
> Does that also need something like:
>
> --- a/tests/unit/meson.build
> +++ b/tests/unit/meson.build
> @@ -170,7 +170,7 @@ if have_system
>     tests += {'test-qdev': [qom, hwcore]}
>   endif
>
> -if have_ga and host_os in ['freebsd', 'linux']
> +if have_ga and host_os in ['freebsd', 'linux', 'openbsd']
>     tests += {'test-qga': ['../qtest/libqmp.c', '../qtest/libqtest.c']}
>     test_deps += {'test-qga': qga}
>   endif
>
> Otherwise it's not clear how to spot these issues if the test never runs
> on OpenBSD.
There are multiple patches pending. Once they're in then I'll send the 
proper patch.
>> Signed-off-by: Brad Smith <brad@comstyle.com>
>> ---
>>   tests/unit/test-qga.c | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/tests/unit/test-qga.c b/tests/unit/test-qga.c
>> index b1c84c188b..ef796f2f7d 100644
>> --- a/tests/unit/test-qga.c
>> +++ b/tests/unit/test-qga.c
>> @@ -787,6 +787,7 @@ static void test_qga_config(gconstpointer data)
>>       g_free(env[0]);
>>   }
>>   
>> +#ifdef CONFIG_FSFREEZE
>>   static void test_qga_fsfreeze_status(gconstpointer fix)
>>   {
>>       const TestFixture *fixture = fix;
>> @@ -800,6 +801,7 @@ static void test_qga_fsfreeze_status(gconstpointer fix)
>>       status = qdict_get_try_str(ret, "return");
>>       g_assert_cmpstr(status, ==, "thawed");
>>   }
>> +#endif
>>   
>>   static QDict *wait_for_guest_exec_completion(int fd, int64_t pid)
>>   {
>> @@ -1028,6 +1030,7 @@ static void test_qga_guest_get_timezone(gconstpointer fix)
>>       g_assert(qdict_haskey(val, "offset"));
>>   }
>>   
>> +#ifdef HAVE_UTMPX
>>   static void test_qga_guest_get_users(gconstpointer fix)
>>   {
>>       const TestFixture *fixture = fix;
>> @@ -1042,6 +1045,7 @@ static void test_qga_guest_get_users(gconstpointer fix)
>>       val = qdict_get_qlist(ret, "return");
>>       g_assert_nonnull(val);
>>   }
>> +#endif
>>   
>>   static void test_qga_guest_get_osinfo(gconstpointer data)
>>   {
>> @@ -1133,8 +1137,10 @@ int main(int argc, char **argv)
>>       g_test_add_data_func("/qga/invalid-oob", &fix, test_qga_invalid_oob);
>>       g_test_add_data_func("/qga/invalid-cmd", &fix, test_qga_invalid_cmd);
>>       g_test_add_data_func("/qga/invalid-args", &fix, test_qga_invalid_args);
>> +#ifdef CONFIG_FSFREEZE
>>       g_test_add_data_func("/qga/fsfreeze-status", &fix,
>>                            test_qga_fsfreeze_status);
>> +#endif
>>   
>>       g_test_add_data_func("/qga/blockedrpcs", NULL, test_qga_blockedrpcs);
>>       g_test_add_data_func("/qga/allowedrpcs", NULL, test_qga_allowedrpcs);
>> @@ -1152,8 +1158,10 @@ int main(int argc, char **argv)
>>                            test_qga_guest_get_host_name);
>>       g_test_add_data_func("/qga/guest-get-timezone", &fix,
>>                            test_qga_guest_get_timezone);
>> +#ifdef HAVE_UTMPX
>>       g_test_add_data_func("/qga/guest-get-users", &fix,
>>                            test_qga_guest_get_users);
>> +#endif
>>   
>>       ret = g_test_run();
>>   
>> -- 
>> 2.56.0
>>
>>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-31 21:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-30 23:08 [PATCH] tests/unit/test-qga: only run tests for commands the host provides Brad Smith
2026-10-31 13:03 ` Roman Bogorodskiy
2026-10-31 21:20   ` Brad Smith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.