On Wed, Sep 09, 2026 at 06:44:59PM -0300, Fabiano Rosas wrote:
> The following patches will change how parameters are set and shown in
> HMP, add a test for it.
> 
> The test issues HMP migrate_set_parameters for each of the existing
> migration parameters and queries them back with the info command. A
> list is kept with the expected strings. A substring match function
> inspired by glib's g_str_match_string is implemented for this test so
> the test can produce a decent error output instead of just assert
> failure. E.g:
> 
>  # HMP output mismatch for entry at line 55:
>  # expected vs. found:
>  #
>  # max-bandwidth: 10356305952768 bytes/hour
>  # ---
>  # max-bandwidth: 10356305952768 bytes/second
> 
> (note that line 55 above is the source line where the test case for
> max-bandwith is, which helps find the failing test in the list)
> 
> Usage:
> QTEST_QEMU_BINARY=./qemu-system-x86_64 \
> ./tests/qtest/migration-test --full -p /x86_64/migration/hmp/parameters
> 
> Signed-off-by: Fabiano Rosas <[email protected]>

I didn't read into details, but it's a nice good test case, let's ship it..

Acked-by: Peter Xu <[email protected]>

One thing to mention below, no need to change but maybe for future if that
makes sense..

> ---
>  tests/qtest/migration/misc-tests.c | 201 +++++++++++++++++++++++++++++
>  1 file changed, 201 insertions(+)
> 
> diff --git a/tests/qtest/migration/misc-tests.c 
> b/tests/qtest/migration/misc-tests.c
> index 4e0deb7f18..533cf3d55d 100644
> --- a/tests/qtest/migration/misc-tests.c
> +++ b/tests/qtest/migration/misc-tests.c
> @@ -22,6 +22,203 @@
>  
>  static char *tmpfs;
>  
> +#ifdef CONFIG_HMP
> +static int test_case_line;
> +
> +#define TEST(i1, i2, e) { i1, i2, e , .line = __LINE__, }
> +#define SKIP(i1, i2, e) { i1, i2, e , .skip = true, }
> +#define BG_SNAP_MSG ("Error: Background-snapshot is not compatible with " \
> +                     "currently set capabilities")
> +
> +typedef struct HMPTestData {
> +    const char *input1;
> +    const char *input2;
> +    const char *output1;
> +    bool skip;
> +    int line;
> +} HMPTestData;
> +
> +/*
> + * .input1: string to be used as parameter name
> + * .input2: string to be used as parameter value
> + * .output1: expected output of migrate_set_parameters
> + * E.g:
> + * (qemu) migrate_set_parameters .input1 .input2
> + * .output1

This comment doesn't seem to be accurate, because the code seems to treat
success and failure cases differently based on the initial chars.

Since SKIP existed, we could also do SUCCESS() and FAIL() with another
bool, maybe.

-- 
Peter Xu


Reply via email to