[LTP] [PATCH] tst_test.sh: Unset the locale concerned variables
Petr Vorel
pvorel@suse.cz
Thu Oct 13 14:24:07 CEST 2022
Hi Akihiko,
> network/tcp_cmds/tracepath/tracepath01.sh fails with LANG=ja_JP.UTF-8
> because it parses localized output.
it works for me:
# export LC_ALL=ja_JP.UTF-8 LANG=ja_JP.UTF-8
# PATH="/opt/ltp/testcases/bin:$PATH" LANG=ja_JP.UTF-8 tracepath01.sh
tracepath01 1 TINFO: initialize 'lhost' 'ltp_ns_veth2' interface
tracepath01 1 TINFO: add local addr 10.0.0.2/24
tracepath01 1 TINFO: add local addr fd00:1:1:1::2/64
tracepath01 1 TINFO: initialize 'rhost' 'ltp_ns_veth1' interface
tracepath01 1 TINFO: add remote addr 10.0.0.1/24
tracepath01 1 TINFO: add remote addr fd00:1:1:1::1/64
tracepath01 1 TINFO: Network config (local -- remote):
tracepath01 1 TINFO: ltp_ns_veth2 -- ltp_ns_veth1
tracepath01 1 TINFO: 10.0.0.2/24 -- 10.0.0.1/24
tracepath01 1 TINFO: fd00:1:1:1::2/64 -- fd00:1:1:1::1/64
tracepath01 1 TINFO: timeout per run is 0h 5m 0s
tracepath01 1 TINFO: traceroute version:
tracepath01 1 TINFO: tracepath from iputils 20211215
tracepath01 1 TINFO: test tracepath with 10.0.0.1, pmtu is 1280
tracepath01 1 TPASS: traced path to '10.0.0.1' in 1 hops
Summary:
passed 1
failed 0
broken 0
skipped 0
warnings 0
> To avoid such a problem, we can always unset the locale concerned
> variables. network/stress/ns-tools/check_envval does that, but it is
> limited to the network stress test. Add similar code to tst_test.sh
> so that it can cover more tests.
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> testcases/lib/tst_test.sh | 5 +++++
> 1 file changed, 5 insertions(+)
> diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh
> index 28b7d12ba..9a8b62f1e 100644
> --- a/testcases/lib/tst_test.sh
> +++ b/testcases/lib/tst_test.sh
> @@ -831,3 +831,8 @@ if [ -z "$TST_NO_DEFAULT_RUN" ]; then
> fi
> fi
> fi
> +
> +# Unset the locale cocerned variables
> +for env in $(locale | cut -f 1 -d =); do
> + unset $env
> +done
If we wanted to keep, we should also unset env, to not pollute the environment.
Instead of requiring locale being installed, prefer to follow kernel approach [1]
(well, they don't handle LANG)
unexport LC_ALL
LANG=C
LC_COLLATE=C
LC_NUMERIC=C
export LANG LC_COLLATE LC_NUMERIC
But as I wrote, is that really needed? Could you post your locale output?
Kind regards,
Petr
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile?h=v6.0
More information about the ltp
mailing list