Skip to content

Commit 05b20c9

Browse files
committed
tests: Avoid check-subst failures in QEMU user-mode environments.
* Makefile.devel (GNULIB_MODULES): Add stdbool. (gnulib-imported-files): Copy also tests/qemu.h. * tests/is-native.c: New file. * tests/Makefile.in (is-native, is-native.@OBJEXT@): New targets. (clean): Remove the 'is-native' program. (SOURCE_FILES): Add is-native.c. (IMPORTED_FILES): Add qemu.h. * tests/check-subst: Invoke 'locale charmap' only in native environments.
1 parent 4d57c61 commit 05b20c9

File tree

6 files changed

+62
-8
lines changed

6 files changed

+62
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@
233233
/srcm4/wint_t.m4
234234
/srcm4/year2038.m4
235235
/srcm4/zzgnulib.m4
236+
/tests/qemu.h
236237
# Cached parameters of gnulib-tool:
237238
/srcm4/gnulib-cache.m4
238239

ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2021-09-19 Bruno Haible <bruno@clisp.org>
2+
3+
tests: Avoid check-subst failures in QEMU user-mode environments.
4+
* Makefile.devel (GNULIB_MODULES): Add stdbool.
5+
(gnulib-imported-files): Copy also tests/qemu.h.
6+
* tests/is-native.c: New file.
7+
* tests/Makefile.in (is-native, is-native.@OBJEXT@): New targets.
8+
(clean): Remove the 'is-native' program.
9+
(SOURCE_FILES): Add is-native.c.
10+
(IMPORTED_FILES): Add qemu.h.
11+
* tests/check-subst: Invoke 'locale charmap' only in native
12+
environments.
13+
114
2021-06-27 Bruno Haible <bruno@clisp.org>
215

316
README: Update.

Makefile.devel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ GNULIB_MODULES = \
5656
relocatable-prog \
5757
safe-read \
5858
sigpipe \
59+
stdbool \
5960
stdio \
6061
stdlib \
6162
strerror \
@@ -78,6 +79,7 @@ gnulib-imported-files : force
7879
$$GNULIB_TOOL --copy-file build-aux/$$file || exit $$?; \
7980
chmod a+x build-aux/$$file || exit $$?; \
8081
done; \
82+
$$GNULIB_TOOL --copy-file tests/qemu.h || exit $$?; \
8183
fi
8284

8385
srclib/Makefile.in : srclib/Makefile.am srclib/Makefile.gnulib aclocal.m4

tests/Makefile.in

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ top_builddir = ..
2828

2929
all :
3030

31-
check : all table-from table-to ../src/iconv_no_i18n test-shiftseq test-to-wchar
31+
check : all table-from table-to ../src/iconv_no_i18n is-native test-shiftseq test-to-wchar
3232
$(SHELL) $(srcdir)/check-stateless $(srcdir) ASCII
3333
# /* General multi-byte encodings */
3434
$(CC) $(LDFLAGS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(srcdir)/genutf8.c ../srclib/libicrt.a -o genutf8 && \
@@ -218,6 +218,12 @@ table-to : table-to.@OBJEXT@ ../lib/libiconv.la
218218
table-to.@OBJEXT@ : $(srcdir)/table-to.c
219219
$(CC) -c $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(srcdir)/table-to.c
220220

221+
is-native : is-native.@OBJEXT@
222+
$(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(CFLAGS) is-native.@OBJEXT@ ../srclib/libicrt.a -o $@
223+
224+
is-native.@OBJEXT@ : $(srcdir)/is-native.c
225+
$(CC) -c $(INCLUDES) $(CFLAGS) $(CPPFLAGS) $(srcdir)/is-native.c
226+
221227
test-shiftseq : test-shiftseq.@OBJEXT@ ../lib/libiconv.la
222228
$(LIBTOOL_LINK) $(CC) $(LDFLAGS) $(CFLAGS) test-shiftseq.@OBJEXT@ ../srclib/libicrt.a ../lib/libiconv.la -o $@
223229

@@ -237,7 +243,7 @@ test-to-wchar.@OBJEXT@ : $(srcdir)/test-to-wchar.c
237243
mostlyclean : clean
238244

239245
clean : force
240-
$(RM) *.@OBJEXT@ *.lo table-from table-from@EXEEXT@ table-to table-to@EXEEXT@ test-shiftseq test-shiftseq@EXEEXT@ test-to-wchar test-to-wchar@EXEEXT@ tmp-* genutf8 genutf8@EXEEXT@ UTF-8.TXT gengb18030z gengb18030z@EXEEXT@ GB18030.TXT core *.stackdump
246+
$(RM) *.@OBJEXT@ *.lo table-from table-from@EXEEXT@ table-to table-to@EXEEXT@ is-native is-native@EXEEXT@ test-shiftseq test-shiftseq@EXEEXT@ test-to-wchar test-to-wchar@EXEEXT@ tmp-* genutf8 genutf8@EXEEXT@ UTF-8.TXT gengb18030z gengb18030z@EXEEXT@ GB18030.TXT core *.stackdump
241247
$(RM) -r .libs _libs
242248

243249
distclean : clean
@@ -363,6 +369,7 @@ SOURCE_FILES = \
363369
Quotes.UTF-8 Quotes.ISO-8859-1 Quotes.ASCII \
364370
Translit1.ISO-8859-1 Translit1.ASCII \
365371
TranslitFail1.ISO-8859-1 \
372+
is-native.c \
366373
check-subst \
367374
test-shiftseq.c \
368375
test-to-wchar.c \
@@ -399,7 +406,8 @@ SOURCE_FILES = \
399406
ATARIST.TXT \
400407
RISCOS-LATIN1.TXT
401408
# List of distributed files imported from other packages.
402-
IMPORTED_FILES =
409+
IMPORTED_FILES = \
410+
qemu.h
403411
# List of distributed files generated by autotools or Makefile.devel.
404412
GENERATED_FILES =
405413
# List of distributed files generated by "make".

tests/check-subst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ cmp tmp-out tmp-ok
1919

2020
# Test of --byte-subst with a non-ASCII substitution.
2121

22-
if test "`(locale charmap) 2>/dev/null`" = UTF-8; then
22+
if ./is-native && test "`(locale charmap) 2>/dev/null`" = UTF-8; then
2323
cat > tmp-in <<\EOF
2424
Böse Bübchen
2525
EOF
@@ -30,7 +30,7 @@ EOF
3030
cmp tmp-out tmp-ok
3131
fi
3232

33-
if test "`(locale charmap) 2>/dev/null`" = UTF-8; then
33+
if ./is-native && test "`(locale charmap) 2>/dev/null`" = UTF-8; then
3434
cat > tmp-in <<\EOF
3535
Böse Bübchen
3636
EOF
@@ -77,7 +77,7 @@ cmp tmp-out tmp-ok
7777

7878
# Test of --unicode-subst with a non-ASCII substitution.
7979

80-
if test "`(locale charmap) 2>/dev/null`" = UTF-8; then
80+
if ./is-native && test "`(locale charmap) 2>/dev/null`" = UTF-8; then
8181
cat > tmp-in <<\EOF
8282
Russian (Русский)
8383
EOF
@@ -116,7 +116,7 @@ fi
116116
# wcrtomb() doesn't exist on FreeBSD 4.0 and is broken on MacOS X 10.3.
117117
# So far this has been tested only on a glibc system with !__STDC_ISO_10646__.
118118

119-
if false && test "`(locale charmap) 2>/dev/null`" = UTF-8; then
119+
if false && ./is-native && test "`(locale charmap) 2>/dev/null`" = UTF-8; then
120120
cat > tmp-in <<\EOF
121121
Russian (Русский)
122122
EOF
@@ -128,7 +128,7 @@ Russian (<00000420><00000443><00000441><00000441><0000043a><00000438><00000439>)
128128
EOF
129129
cmp tmp-out1 tmp-ok
130130
cmp tmp-out2 tmp-ok
131-
if test "`(LC_ALL=de_DE.ISO-8859-1 locale charmap) 2>/dev/null`" = ISO-8859-1; then
131+
if ./is-native && test "`(LC_ALL=de_DE.ISO-8859-1 locale charmap) 2>/dev/null`" = ISO-8859-1; then
132132
options_latin1=`echo " $options_utf8" | $iconv -f UTF-8 -t ISO-8859-1`
133133
LC_ALL=de_DE.ISO-8859-1 $iconv $options_latin1 -f wchar_t -t UTF-8 < tmp-inw > tmp-out1
134134
cat > tmp-ok <<\EOF

tests/is-native.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* Copyright (C) 2021 Free Software Foundation, Inc.
2+
This file is part of the GNU LIBICONV Library.
3+
4+
The GNU LIBICONV Library is free software; you can redistribute it
5+
and/or modify it under the terms of the GNU Lesser General Public
6+
License as published by the Free Software Foundation; either version 2.1
7+
of the License, or (at your option) any later version.
8+
9+
The GNU LIBICONV Library is distributed in the hope that it will be
10+
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
Lesser General Public License for more details.
13+
14+
You should have received a copy of the GNU Lesser General Public
15+
License along with the GNU LIBICONV Library; see the file COPYING.LIB.
16+
If not, see <https://www.gnu.org/licenses/>. */
17+
18+
#include "config.h"
19+
20+
#include "qemu.h"
21+
22+
/* Returns 0 (success) in a native environment.
23+
Returns 1 (failure) in a cross-executing environment, that is, in an
24+
environment where compiled programs use a different libc than the system's
25+
libc. Currently, only QEMU user-mode environments are recognized. */
26+
27+
int main ()
28+
{
29+
return is_running_under_qemu_user () ? 1 : 0;
30+
}

0 commit comments

Comments
 (0)