diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-05-03 16:40:23 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-05-03 16:40:23 +0000 |
commit | 144f07e889ee91885eada92b668f0ead7ebdd0e4 (patch) | |
tree | b68609fa6a5329ffb3a3485aa9ecde3da40baa5e | |
parent | 12886edcafb16a221e273297ebf6ae806364f676 (diff) |
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@.
-rw-r--r-- | regress/usr.bin/fmt/fmt.sh | 32 |
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 |