]> xenbits.xensource.com Git - libvirt.git/commitdiff
tests: skip some unicode tests if expected output won't match
authorDaniel P. Berrangé <berrange@redhat.com>
Tue, 4 Sep 2018 10:26:03 +0000 (11:26 +0100)
committerDaniel P. Berrangé <berrange@redhat.com>
Tue, 4 Sep 2018 10:26:03 +0000 (11:26 +0100)
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é <berrange@redhat.com>
tests/vshtabletest.c

index 9e9c0452269b0c8a2d0dafb59e1f48d71fc7c9e3..1138e3416139a37e66e1d228e077d6f6f4480f71 100644 (file)
@@ -21,6 +21,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <locale.h>
+#include <wctype.h>
 
 #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)