From cee3800c56d544dd6203c1d2de98a14e6d6328d8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20P=C3=ADsa=C5=99?= Date: Mon, 22 Apr 2019 17:27:39 +0200 Subject: [PATCH] test: Skip tests in offline/utf82locale if a locale is not available To test a conversion to a UTF-8 locale, we need to have a UTF-8 locale supported by the standard library. We tried en_US.UTF-8 that is widely available and then cs_CZ.UTF-8. However, some distributions started to remove en_US.UTF-8 from their build infrastructure and use C.UTF-8 instead. This patch skips the inapplicable tests. --- test/offline/utf82locale.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/test/offline/utf82locale.c b/test/offline/utf82locale.c index 415e1bb..217f4ae 100644 --- a/test/offline/utf82locale.c +++ b/test/offline/utf82locale.c @@ -34,21 +34,23 @@ static int test_utf82locale(const void *input, const void *correct) { int main(void) { INIT_TEST("utf8locale"); - if (prepare_locale(1)) - ABORT_UNIT("Could not set any UTF-8 locale"); - - TEST("NULL input", test_utf82locale, NULL, NULL); - TEST("Empty string", test_utf82locale, "", ""); - TEST("ASCII text", test_utf82locale, "lazy fox", "lazy fox"); - TEST("non-ASCII text in UTF-8 locale", test_utf82locale, "Šíleně žluťoučký", - "Šíleně žluťoučký"); - TEST("OTP message in UTF-8 locale", test_utf82locale, - "Jednorázový kód odeslán.", "Jednorázový kód odeslán."); - - if (prepare_locale(0)) - ABORT_UNIT("Could not set C locale"); + if (prepare_locale(1)) { + SKIP_TESTS(5, "Could not set any UTF-8 locale"); + } else { + TEST("NULL input", test_utf82locale, NULL, NULL); + TEST("Empty string", test_utf82locale, "", ""); + TEST("ASCII text", test_utf82locale, "lazy fox", "lazy fox"); + TEST("non-ASCII text in UTF-8 locale", test_utf82locale, "Šíleně žluťoučký", + "Šíleně žluťoučký"); + TEST("OTP message in UTF-8 locale", test_utf82locale, + "Jednorázový kód odeslán.", "Jednorázový kód odeslán."); + } - TEST("non-ASCII text in C locale", test_utf82locale, "Šíleně žluťoučký", NULL); + if (prepare_locale(0)) { + SKIP_TESTS(1, "Could not set C locale"); + } else { + TEST("non-ASCII text in C locale", test_utf82locale, "Šíleně žluťoučký", NULL); + } SUM_TEST(); } -- 2.11.4.GIT