[spice-server] test-codecs-parsing: On bad codec string spice_server_set_video_codecs can fail

Submitted by Frediano Ziglio on July 5, 2019, 1:09 p.m.

Details

Message ID 20190705130922.12132-1-fziglio@redhat.com
State Superseded
Headers show
Series "test-codecs-parsing: On bad codec string spice_server_set_video_codecs can fail" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio July 5, 2019, 1:09 p.m.
The 0 result means success however the function (correctly) could
report a failure if the string is incorrect.
This fixes the test after commit b4150de3cd0e56d4ce43a99ef5c3c5f5cbdfc4a3
("spice_server_set_video_codecs: fail when no codec can be installed").

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/tests/test-codecs-parsing.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/server/tests/test-codecs-parsing.c b/server/tests/test-codecs-parsing.c
index 7998501c9..08d83cc2b 100644
--- a/server/tests/test-codecs-parsing.c
+++ b/server/tests/test-codecs-parsing.c
@@ -140,7 +140,7 @@  static void codecs_bad(void)
         g_test_expect_message(G_LOG_DOMAIN, test_cases[i].log_level, test_cases[i].error_message);
         if (test_cases[i].default_err_message)
             g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "*Failed to set video codecs*");
-        g_assert_cmpint(spice_server_set_video_codecs(server, test_cases[i].codecs), ==, 0);
+        spice_server_set_video_codecs(server, test_cases[i].codecs);
         g_test_assert_expected_messages();
     }
 

Comments

Hi,

On 7/5/19 4:09 PM, Frediano Ziglio wrote:
> The 0 result means success however the function (correctly) could
> report a failure if the string is incorrect.
> This fixes the test after commit b4150de3cd0e56d4ce43a99ef5c3c5f5cbdfc4a3
> ("spice_server_set_video_codecs: fail when no codec can be installed").
>
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> ---
>   server/tests/test-codecs-parsing.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/server/tests/test-codecs-parsing.c b/server/tests/test-codecs-parsing.c
> index 7998501c9..08d83cc2b 100644
> --- a/server/tests/test-codecs-parsing.c
> +++ b/server/tests/test-codecs-parsing.c
> @@ -140,7 +140,7 @@ static void codecs_bad(void)
>           g_test_expect_message(G_LOG_DOMAIN, test_cases[i].log_level, test_cases[i].error_message);
>           if (test_cases[i].default_err_message)
>               g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "*Failed to set video codecs*");
> -        g_assert_cmpint(spice_server_set_video_codecs(server, test_cases[i].codecs), ==, 0);
> +        spice_server_set_video_codecs(server, test_cases[i].codecs);


Can't we assert forĀ  -1 now?

Snir.

>           g_test_assert_expected_messages();
>       }
>
> 
> Hi,
> 
> On 7/5/19 4:09 PM, Frediano Ziglio wrote:
> > The 0 result means success however the function (correctly) could
> > report a failure if the string is incorrect.
> > This fixes the test after commit b4150de3cd0e56d4ce43a99ef5c3c5f5cbdfc4a3
> > ("spice_server_set_video_codecs: fail when no codec can be installed").
> >
> > Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> > ---
> >   server/tests/test-codecs-parsing.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/server/tests/test-codecs-parsing.c
> > b/server/tests/test-codecs-parsing.c
> > index 7998501c9..08d83cc2b 100644
> > --- a/server/tests/test-codecs-parsing.c
> > +++ b/server/tests/test-codecs-parsing.c
> > @@ -140,7 +140,7 @@ static void codecs_bad(void)
> >           g_test_expect_message(G_LOG_DOMAIN, test_cases[i].log_level,
> >           test_cases[i].error_message);
> >           if (test_cases[i].default_err_message)
> >               g_test_expect_message(G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
> >               "*Failed to set video codecs*");
> > -        g_assert_cmpint(spice_server_set_video_codecs(server,
> > test_cases[i].codecs), ==, 0);
> > +        spice_server_set_video_codecs(server, test_cases[i].codecs);
> 
> 
> Can't we assert forĀ  -1 now?
> 
> Snir.
> 

Tested. Yes, they all returns currently -1. However -1 is returned only if
no codecs were set.
Also the usages test for != 0 so I would stick with this check, not == -1.

Frediano