From: Daniel P. Berrangé Date: Tue, 4 Sep 2018 10:26:03 +0000 (+0100) Subject: tests: skip some unicode tests if expected output won't match X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7469aa0bc26d91ba3f32b4e10b47d47d9250be90;p=libvirt.git tests: skip some unicode tests if expected output won't match The expected output strings from the vshtabletest.c are created on a modern Linux host where unicode printing support is very good. On older Linux platforms, or non-Linux platforms, some unicode characters will not be considered printable. While the vsh table alignment code will stil do the right thing with escaping & aligning in this case, the result will not match the test's expected output. Since we know the code is working correctly, do a check with iswprint() to validate the platform's quality and skip the test if it fails. This fixes the test on FreeBSD platforms. Signed-off-by: Daniel P. Berrangé --- diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index 9e9c045226..1138e34161 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "internal.h" #include "testutils.h" @@ -158,6 +159,15 @@ testUnicodeArabic(const void *opaque ATTRIBUTE_UNUSED) " 1 ﻉﺪﻴﻟ ﺎﻠﺜﻘﻴﻟ ﻕﺎﻣ ﻊﻧ, ٣٠ ﻎﻴﻨﻳﺍ ﻮﺘﻧﺎﻤﺗ ﺎﻠﺛﺎﻠﺛ، ﺄﺳﺭ, ﺩﻮﻟ ﺩﻮﻟ. ﺄﻣﺎﻣ ﺍ ﺎﻧ ﻲﻜﻧ \n" " ﺺﻔﺣﺓ ﺖﻜﺘﻴﻛﺍً ﻊﻟ, ﺎﻠﺠﻧﻭﺩ ﻭﺎﻠﻌﺗﺍﺩ ﺵﺭ \n"; vshTablePtr table; + wchar_t wc; + + /* If this char is not classed as printable, the actual + * output won't match what this test expects. The code + * is still operating correctly, but we have different + * layout */ + mbrtowc(&wc, "،", MB_CUR_MAX, NULL); + if (!iswprint(wc)) + return EXIT_AM_SKIP; table = vshTableNew("ﻡﺍ ﻢﻣﺍ ﻕﺎﺌﻣﺓ", "ﺓ ﺎﻠﺼﻋ", "ﺍﻸﺜﻧﺎﻧ", NULL); if (!table) @@ -192,6 +202,15 @@ testUnicodeZeroWidthChar(const void *opaque ATTRIBUTE_UNUSED) " 1\u200B fedora28 run\u200Bning \n" " 2 rhel7.5 running \n"; char *act = NULL; + wchar_t wc; + + /* If this char is not classed as printable, the actual + * output won't match what this test expects. The code + * is still operating correctly, but we have different + * layout */ + mbrtowc(&wc, "\u200B", MB_CUR_MAX, NULL); + if (!iswprint(wc)) + return EXIT_AM_SKIP; table = vshTableNew("I\u200Bd", "Name", "\u200BStatus", NULL); if (!table)