Make tests detect UTF-8 locale with a helper executable
This uses the same utility function that mosh-client/mosh-server do. This resolves portability issues with the 'locale' command. This fixes OpenBSD 6.0 and probably Haiku builds.
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
/encrypt-decrypt
|
/encrypt-decrypt
|
||||||
/nonce-incr
|
/nonce-incr
|
||||||
/inpty
|
/inpty
|
||||||
|
/is-utf8-locale
|
||||||
/*.d/
|
/*.d/
|
||||||
*.log
|
*.log
|
||||||
*.trs
|
*.trs
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ displaytests = \
|
|||||||
unicode-later-combining.test \
|
unicode-later-combining.test \
|
||||||
window-resize.test
|
window-resize.test
|
||||||
|
|
||||||
check_PROGRAMS = ocb-aes encrypt-decrypt base64 nonce-incr inpty
|
check_PROGRAMS = ocb-aes encrypt-decrypt base64 nonce-incr inpty is-utf8-locale
|
||||||
TESTS = ocb-aes encrypt-decrypt base64 nonce-incr local.test $(displaytests)
|
TESTS = ocb-aes encrypt-decrypt base64 nonce-incr local.test $(displaytests)
|
||||||
XFAIL_TESTS = \
|
XFAIL_TESTS = \
|
||||||
e2e-failure.test \
|
e2e-failure.test \
|
||||||
@@ -65,6 +65,10 @@ inpty_SOURCES = inpty.cc
|
|||||||
inpty_CPPFLAGS = -I$(srcdir)/../util
|
inpty_CPPFLAGS = -I$(srcdir)/../util
|
||||||
inpty_LDADD = ../util/libmoshutil.a $(LIBUTIL)
|
inpty_LDADD = ../util/libmoshutil.a $(LIBUTIL)
|
||||||
|
|
||||||
|
is_utf8_locale_SOURCES = is-utf8-locale.cc
|
||||||
|
is_utf8_locale_CPPFLAGS = -I$(srcdir)/../util
|
||||||
|
is_utf8_locale_LDADD = ../util/libmoshutil.a $(LIBUTIL)
|
||||||
|
|
||||||
clean-local: clean-local-check
|
clean-local: clean-local-check
|
||||||
.PHONY: clean-local-check
|
.PHONY: clean-local-check
|
||||||
clean-local-check:
|
clean-local-check:
|
||||||
|
|||||||
+9
-8
@@ -108,10 +108,6 @@ mosh_server()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# main
|
# main
|
||||||
if ! set_locale; then
|
|
||||||
test_error "e2e-test: no usable locale\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Set up environment
|
# Set up environment
|
||||||
if [ -z "$srcdir" ]; then
|
if [ -z "$srcdir" ]; then
|
||||||
export srcdir=$PWD
|
export srcdir=$PWD
|
||||||
@@ -137,10 +133,6 @@ case "$(basename "$0")" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if ! tmux_check; then
|
|
||||||
test_skipped "tmux unavailable\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $# -lt 2 ]; then
|
if [ $# -lt 2 ]; then
|
||||||
test_error "not enough args\n"
|
test_error "not enough args\n"
|
||||||
fi
|
fi
|
||||||
@@ -153,6 +145,15 @@ test_args=$@
|
|||||||
test_dir=$(basename "${test_name}").d
|
test_dir=$(basename "${test_name}").d
|
||||||
test_script="${test_name}"
|
test_script="${test_name}"
|
||||||
|
|
||||||
|
tests_dir=$(dirname "${test_name}")
|
||||||
|
if ! set_locale "${tests_dir}"; then
|
||||||
|
test_error "e2e-test: no usable locale\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! tmux_check; then
|
||||||
|
test_skipped "tmux unavailable\n"
|
||||||
|
fi
|
||||||
|
|
||||||
rm -rf "${test_dir}"
|
rm -rf "${test_dir}"
|
||||||
mkdir "${test_dir}"
|
mkdir "${test_dir}"
|
||||||
|
|
||||||
|
|||||||
@@ -60,14 +60,12 @@ chr()
|
|||||||
set_locale()
|
set_locale()
|
||||||
{
|
{
|
||||||
# Test for a usable locale.
|
# Test for a usable locale.
|
||||||
map=$(locale charmap 2>/dev/null)
|
if ./is-utf8-locale 2> /dev/null; then
|
||||||
if [ "$map" = "utf-8" ] || [ "$map" = "UTF-8" ]; then
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
# Attempt to find/set a usable locale.
|
# Attempt to find/set a usable locale.
|
||||||
for i in en_US.UTF-8 en_US.utf8 C.UTF-8; do
|
for i in en_US.UTF-8 en_US.utf8 C.UTF-8; do
|
||||||
map="$(env LANG=$i locale charmap 2>/dev/null)"
|
if env LANG=$i ./is-utf8-locale 2> /dev/null; then
|
||||||
if [ "$map" = "utf-8" ] || [ "$map" = "UTF-8" ]; then
|
|
||||||
export LANG=$i LC_ALL=''
|
export LANG=$i LC_ALL=''
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
Mosh: the mobile shell
|
||||||
|
Copyright 2012 Keith Winstein
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
In addition, as a special exception, the copyright holders give
|
||||||
|
permission to link the code of portions of this program with the
|
||||||
|
OpenSSL library under certain conditions as described in each
|
||||||
|
individual source file, and distribute linked combinations including
|
||||||
|
the two.
|
||||||
|
|
||||||
|
You must obey the GNU General Public License in all respects for all
|
||||||
|
of the code used other than OpenSSL. If you modify file(s) with this
|
||||||
|
exception, you may extend this exception to your version of the
|
||||||
|
file(s), but you are not obligated to do so. If you do not wish to do
|
||||||
|
so, delete this exception statement from your version. If you delete
|
||||||
|
this exception statement from all source files in the program, then
|
||||||
|
also delete it here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "locale_utils.h"
|
||||||
|
|
||||||
|
int main( int argc __attribute__(( unused )), char **argv __attribute__(( unused )))
|
||||||
|
{
|
||||||
|
set_native_locale();
|
||||||
|
if ( !is_utf8_locale() ) {
|
||||||
|
fprintf( stderr, "not a UTF-8 locale\n" );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user