From: Collin Funk Date: Fri, 31 Jul 2026 06:30:05 +0000 (-0700) Subject: tests: du: test --block-size with thousands separators X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e341208d065837719cb1c7d82e2f7a1e51c8768b;p=thirdparty%2Fcoreutils.git tests: du: test --block-size with thousands separators * tests/du/block-size.sh (test_unit): Test that the locales thousands separator is used if we can determine it. --- diff --git a/tests/du/block-size.sh b/tests/du/block-size.sh index 4d2b93b3b1..63f5da4361 100755 --- a/tests/du/block-size.sh +++ b/tests/du/block-size.sh @@ -56,16 +56,39 @@ test_unit () # When there is a prefix of 1, the unit is not printed. Setup a file # to compare to. sed 's/^\([0-9][0-9]*\)'"$upper"'/\1/g' exp1 || framework_failure_ - for opt in BLOCK_SIZE -B --block-size=; do - for c in $lower $upper; do - for prefix in '' 1; do - case $opt in - -*) env=; arg=$opt$prefix$c ;; - *) arg=; env=$opt=$prefix$c ;; - esac - env $env du -A $arg 1* >out 2>err || fail=1 - compare exp$prefix out || fail=1 - compare /dev/null err || fail=1 + for loc in C "$LOCALE_FR" "$LOCALE_FR_UTF8"; do + test -z "$loc" && continue + if test $loc != C; then + thousands_sep=$(LC_ALL=$loc locale thousands_sep) + grouping=$(LC_ALL=$loc locale grouping) + test -z "$thousands_sep" && continue + test "$grouping" != 3 && continue + fi + for f in exp exp1; do + LC_ALL=$loc \ + sed 's/^\([0-9][0-9]*\)\([0-9]\{3\}\)/\1'"$thousands_sep"'\2/g' $f \ + >$loc$f || framework_failure_ + done + for opt in BLOCK_SIZE -B --block-size=; do + for c in $lower $upper; do + for prefix1 in '' "'"; do + # Without the apostrophe thousands separators aren't used, + # regardless of locale. + if test $loc = C || test -z "$prefix1"; then + exp=exp + else + exp="$loc"exp + fi + for prefix2 in '' 1; do + case $opt in + -*) env=; arg=$opt$prefix1$prefix2$c ;; + *) arg=; env=$opt=$prefix1$prefix2$c ;; + esac + env LC_ALL=$loc $env du -A $arg 1* >out 2>err || fail=1 + compare $exp$prefix2 out || fail=1 + compare /dev/null err || fail=1 + done + done done done done