[PATCH] tests/qtest/test-hmp: Improve the check for verbose mode

Thomas Huth posted 1 patch 1 year, 4 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230109101306.271444-1-thuth@redhat.com
Maintainers: "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Thomas Huth <thuth@redhat.com>, Laurent Vivier <lvivier@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>
tests/qtest/test-hmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] tests/qtest/test-hmp: Improve the check for verbose mode
Posted by Thomas Huth 1 year, 4 months ago
Running the test-hmp with V=2 up to V=9 runs the test in verbose mode,
but running for example with V=10 falls back to non-verbose mode ...
Improve this oddity by properly treating the argument as a number.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 tests/qtest/test-hmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/qtest/test-hmp.c b/tests/qtest/test-hmp.c
index f8b22abe4c..b4a920df89 100644
--- a/tests/qtest/test-hmp.c
+++ b/tests/qtest/test-hmp.c
@@ -151,7 +151,7 @@ int main(int argc, char **argv)
 {
     char *v_env = getenv("V");
 
-    if (v_env && *v_env >= '2') {
+    if (v_env && atoi(v_env) >= 2) {
         verbose = true;
     }
 
-- 
2.31.1
Re: [PATCH] tests/qtest/test-hmp: Improve the check for verbose mode
Posted by Laurent Vivier 1 year, 4 months ago
Le 09/01/2023 à 11:13, Thomas Huth a écrit :
> Running the test-hmp with V=2 up to V=9 runs the test in verbose mode,
> but running for example with V=10 falls back to non-verbose mode ...
> Improve this oddity by properly treating the argument as a number.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   tests/qtest/test-hmp.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tests/qtest/test-hmp.c b/tests/qtest/test-hmp.c
> index f8b22abe4c..b4a920df89 100644
> --- a/tests/qtest/test-hmp.c
> +++ b/tests/qtest/test-hmp.c
> @@ -151,7 +151,7 @@ int main(int argc, char **argv)
>   {
>       char *v_env = getenv("V");
>   
> -    if (v_env && *v_env >= '2') {
> +    if (v_env && atoi(v_env) >= 2) {
>           verbose = true;
>       }
>   

Applied to my trivial-patches branch.

Thanks,
Laurent



Re: [PATCH] tests/qtest/test-hmp: Improve the check for verbose mode
Posted by Philippe Mathieu-Daudé 1 year, 4 months ago
On 9/1/23 11:13, Thomas Huth wrote:
> Running the test-hmp with V=2 up to V=9 runs the test in verbose mode,
> but running for example with V=10 falls back to non-verbose mode ...
> Improve this oddity by properly treating the argument as a number.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   tests/qtest/test-hmp.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>