On Tue, Sep 04, 2018 at 04:57:42PM +0200, Simon Kobyda wrote:
On Tue, 2018-09-04 at 11:30 +0100, Daniel P. Berrangé wrote:
> 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(a)redhat.com>
> ---
>
> Pushed as a build fix
>
> tests/vshtabletest.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> 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 <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;
Sidenote: This test case with zero-width characters would pass without
any problems if we implement environment variable
"gl_cv_func_wcwidth_works=no" as suggested here:
I don't really consider setting magic env vars before configure to
be a satisfactory solution, as it requires the person building
libvirt to somehow find out that they need this obscure env var.
We need to be success out of the box with a normal run of configure.
Regards,
Daniel
--
|:
https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|:
https://libvirt.org -o-
https://fstop138.berrange.com :|
|:
https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|