From be324cc6659132ea50175ed8d341cb5f1175ce4d Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 29 Nov 2022 03:52:27 -0500 Subject: [PATCH] testsuite: Skip tests that miss charset support This came up when running the tests in a fresh toolbox missing the glibc-gconv-extra package. --- testsuite/css/data.c | 59 +++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 33 deletions(-) diff --git a/testsuite/css/data.c b/testsuite/css/data.c index 60cc2661cc..8022bcd96f 100644 --- a/testsuite/css/data.c +++ b/testsuite/css/data.c @@ -30,43 +30,22 @@ struct _Test const char *mimetype; const char *contents; gsize contents_len; + const char *charset; }; #define CONTENTS(data) (data), sizeof(data) - 1 Test tests[] = { - { "simple", - "data:,HelloWorld", - NULL, CONTENTS("HelloWorld") }, - { "nodata", - "data:,", - NULL, CONTENTS("") }, - { "case_sensitive", - "dATa:,HelloWorld", - NULL, CONTENTS("HelloWorld") }, - { "semicolon_after_comma", - "data:,;base64", - NULL, CONTENTS(";base64") }, - { "mimetype", - "data:image/png,nopng", - "image/png", CONTENTS("nopng") }, - { "charset", - "data:text/plain;charset=ISO-8859-1,Timm B\344der", - "text/plain", CONTENTS("Timm Bäder") }, - { "charset_escaped", - "data:text/plain;charset=ISO-8859-1,Timm%20B%E4der", - "text/plain", CONTENTS("Timm Bäder") }, - { "charset_base64", - "data:text/plain;charset=ISO-8859-5;base64,wOPh29DdILjW0ePb0OLe0g==", - "text/plain", CONTENTS("Руслан Ижбулатов") }, - { "wrong_scheme", - "duda:,Hello", - NULL, NULL, 0 }, - { "missing_comma", - "data:text/plain;charset=ISO-8859-1:bla", - NULL, NULL, 0 }, - { "bad_escape", - "data:,abc%00", - NULL, NULL, -1 }, + { "simple", "data:,HelloWorld", NULL, CONTENTS("HelloWorld"), NULL }, + { "nodata", "data:,", NULL, CONTENTS(""), NULL }, + { "case_sensitive", "dATa:,HelloWorld", NULL, CONTENTS("HelloWorld"), NULL }, + { "semicolon_after_comma", "data:,;base64", NULL, CONTENTS(";base64"), NULL }, + { "mimetype", "data:image/png,nopng", "image/png", CONTENTS("nopng"), NULL }, + { "charset", "data:text/plain;charset=ISO-8859-1,Timm B\344der", "text/plain", CONTENTS("Timm Bäder"), "ISO-8859-1" }, + { "charset_escaped", "data:text/plain;charset=ISO-8859-1,Timm%20B%E4der", "text/plain", CONTENTS("Timm Bäder"), "ISO-8859-1" }, + { "charset_base64", "data:text/plain;charset=ISO-8859-5;base64,wOPh29DdILjW0ePb0OLe0g==", "text/plain", CONTENTS("Руслан Ижбулатов"), "ISO-8859-5" }, + { "wrong_scheme", "duda:,Hello", NULL, NULL, 0, NULL }, + { "missing_comma", "data:text/plain;charset=ISO-8859-1:bla", NULL, NULL, 0, "ISO-8859-1" }, + { "bad_escape", "data:,abc%00", NULL, NULL, -1, NULL }, }; static void @@ -77,6 +56,20 @@ test_parse (gconstpointer data) char *mimetype = NULL; GBytes *bytes; + if (test->charset) + { + GIConv iconv; + + iconv = g_iconv_open ("UTF-8", test->charset); + if (iconv == (GIConv) -1) + { + g_test_skip_printf ("Conversion from %s to UTF-8 not supported", test->charset); + return; + } + + g_iconv_close (iconv); + } + bytes = gtk_css_data_url_parse (test->url, &mimetype, &error); if (test->contents)