[Libosinfo] [PATCH 2/2] tests: ignore transient failures in media/tree URI tests

Fabiano Fidêncio fidencio at redhat.com
Mon Nov 19 12:27:42 UTC 2018


On Mon, 2018-11-19 at 11:43 +0000, Daniel P. Berrangé wrote:
> Some times the media/tree URI tests will fail with a timeout trying
> to connect to the server. Treat this as non-fatal since it will
> usually just indicate a transient network or server failure.
> 
> Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
> ---
>  tests/test-mediauris.c | 13 +++++++++----
>  tests/test-treeuris.c  | 13 +++++++++----
>  2 files changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/tests/test-mediauris.c b/tests/test-mediauris.c
> index c906f08..220dfb8 100644
> --- a/tests/test-mediauris.c
> +++ b/tests/test-mediauris.c
> @@ -46,11 +46,16 @@ static void test_media(OsinfoMediaList
> *medialist, GError **error, CURL *curl)
>          curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE,
> &response_code);
>  
>          g_test_message("res=%d, %s; code=%ld", res,
> curl_easy_strerror(res), response_code);
> -        if (res != CURLE_OK) {
> -            g_printerr("Failed URI %s res=%d (%s) code=%ld\n",
> -                       url, res, curl_easy_strerror(res),
> response_code);
> +
> +        if (res == CURLE_OPERATION_TIMEDOUT) {
> +            g_printerr("Ignoring network timeout failure for %s\n",
> url);
> +        } else {
> +            if (res != CURLE_OK) {
> +                g_printerr("Failed URI %s res=%d (%s) code=%ld\n",
> +                           url, res, curl_easy_strerror(res),
> response_code);
> +            }
> +            g_assert_cmpint(res, ==, CURLE_OK);
>          }
> -        g_assert_cmpint(res, ==, CURLE_OK);
>  
>          tmp = tmp->next;
>      }
> diff --git a/tests/test-treeuris.c b/tests/test-treeuris.c
> index b0cddbf..26c949b 100644
> --- a/tests/test-treeuris.c
> +++ b/tests/test-treeuris.c
> @@ -46,11 +46,16 @@ static void test_tree(OsinfoTreeList *treelist,
> GError **error, CURL *curl)
>          curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE,
> &response_code);
>  
>          g_test_message("res=%d, %s; code=%ld", res,
> curl_easy_strerror(res), response_code);
> -        if (res != CURLE_OK) {
> -            g_printerr("Failed URI %s res=%d (%s) code=%ld\n",
> -                       url, res, curl_easy_strerror(res),
> response_code);
> +
> +        if (res == CURLE_OPERATION_TIMEDOUT) {
> +            g_printerr("Ignoring network timeout failure for %s\n",
> url);
> +        } else {
> +            if (res != CURLE_OK) {
> +                g_printerr("Failed URI %s res=%d (%s) code=%ld\n",
> +                           url, res, curl_easy_strerror(res),
> response_code);
> +            }
> +            g_assert_cmpint(res, ==, CURLE_OK);
>          }
> -        g_assert_cmpint(res, ==, CURLE_OK);
>  
>          tmp = tmp->next;
>      }

The comments done in the previous patch about g_printerr() apply here
as well.

Best Regards,
-- 
Fabiano Fidêncio




More information about the Libosinfo mailing list