All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] tst_test.sh: Unset the locale concerned variables
@ 2022-10-13  5:58 Akihiko Odaki
  2022-10-13 12:24 ` Petr Vorel
  0 siblings, 1 reply; 2+ messages in thread
From: Akihiko Odaki @ 2022-10-13  5:58 UTC (permalink / raw)
  To: ltp; +Cc: Yan Vugenfirer, Yuri Benditovich

network/tcp_cmds/tracepath/tracepath01.sh fails with LANG=ja_JP.UTF-8
because it parses localized output.

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
-- 
2.37.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] [PATCH] tst_test.sh: Unset the locale concerned variables
  2022-10-13  5:58 [LTP] [PATCH] tst_test.sh: Unset the locale concerned variables Akihiko Odaki
@ 2022-10-13 12:24 ` Petr Vorel
  0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2022-10-13 12:24 UTC (permalink / raw)
  To: Akihiko Odaki; +Cc: Yan Vugenfirer, Yuri Benditovich, ltp

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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-13 12:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-13  5:58 [LTP] [PATCH] tst_test.sh: Unset the locale concerned variables Akihiko Odaki
2022-10-13 12:24 ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.