summaryrefslogtreecommitdiffstats
path: root/regress
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2016-05-03 16:40:22 +0000
committerschwarze <schwarze@openbsd.org>2016-05-03 16:40:22 +0000
commitf53fac0527fe26fb68b8eaf9e7cd6335d65c2a46 (patch)
treef0d2ad5cd1a46584cf3c0da2b4495e35b980b48b /regress
parentRegression tests for fold(1). (diff)
downloadwireguard-openbsd-f53fac0527fe26fb68b8eaf9e7cd6335d65c2a46.tar.xz
wireguard-openbsd-f53fac0527fe26fb68b8eaf9e7cd6335d65c2a46.zip
These tests depended on whatever the user's locale was,
and the last one failed for LC_CTYPE=C. Instead, ignore the user's locale and run each test twice, once for UTF-8 and once for US-ASCII. Problem reported by deraadt@.
Diffstat (limited to 'regress')
-rw-r--r--regress/usr.bin/fmt/fmt.sh32
1 files changed, 26 insertions, 6 deletions
diff --git a/regress/usr.bin/fmt/fmt.sh b/regress/usr.bin/fmt/fmt.sh
index 5f36b374d30..1e9cea6190e 100644
--- a/regress/usr.bin/fmt/fmt.sh
+++ b/regress/usr.bin/fmt/fmt.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (c) 2015 Ingo Schwarze <schwarze@openbsd.org>
+# Copyright (c) 2015, 2016 Ingo Schwarze <schwarze@openbsd.org>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -16,10 +16,26 @@
test_fmt()
{
- expected=`echo -n "$3" ; echo .`
- result=`echo -n "$2" | fmt $1 2>&1 ; echo .`
- if [ "$result" != "$expected" ]; then
- echo "fmt $1 \"$2\": expected \"$expected\", got \"$result\""
+ expect=`echo -n "$3" ; echo .`
+ result=`echo -n "$2" | LC_ALL=en_US.UTF-8 fmt $1 2>&1 ; echo .`
+ if [ "$result" != "$expect" ]; then
+ echo "LC_ALL=en_US.UTF-8 fmt $1 \"$2\":"
+ echo -n "$2" | hexdump -C
+ echo "expect: $expect"
+ echo -n "$expect" | hexdump -C
+ echo "result: $result"
+ echo -n "$result" | hexdump -C
+ exit 1
+ fi
+ [ -n "$4" ] && expect=`echo -n "$4" ; echo .`
+ result=`echo -n "$2" | LC_ALL=C fmt $1 2>&1 ; echo .`
+ if [ "$result" != "$expect" ]; then
+ echo "LC_ALL=C fmt $1 \"$2\":"
+ echo -n "$2" | hexdump -C
+ echo "expect: $expect"
+ echo -n "$expect" | hexdump -C
+ echo "result: $result"
+ echo -n "$result" | hexdump -C
exit 1
fi
}
@@ -103,6 +119,10 @@ test_fmt "" "a \n" "a\n"
test_fmt "" "a\t\n" "a\n"
#utf-8
-test_fmt "14" "pöüöüöü üüp\n" "pöüöüöü üüp\n"
+test_fmt "14" \
+ "pöüöüöü üüp\n" \
+ "pöüöüöü üüp\n" \
+ "pöüöüöü\nüüp\n"
+
exit 0