[LTP] [PATCH v1] du01.sh: Read the actual filesystem blocksize instead of pagesize
Andrea Cervesato
andrea.cervesato@suse.com
Thu Jul 3 16:06:52 CEST 2025
Hi!
On 7/3/25 8:01 PM, Wei Gao via ltp wrote:
> On PPC systems, the page size doesn't always equal the size of a symlink.
> Therefore, we need to update the test to read the actual filesystem blocksize
> instead of assuming it's equal to the page size.
>
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> testcases/commands/du/du01.sh | 10 ++++------
> 1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/testcases/commands/du/du01.sh b/testcases/commands/du/du01.sh
> index 7977fd461..68099de9e 100755
> --- a/testcases/commands/du/du01.sh
> +++ b/testcases/commands/du/du01.sh
> @@ -60,18 +60,16 @@ du_test()
> }
>
> block_size=512
> -page_size=$(tst_getconf PAGESIZE)
> -if [ "$page_size" -lt 1024 ]; then
> - tst_brk TBROK "Page size < 1024"
> -fi
> -page_size=$((page_size / 1024))
> +
> +FS_BLOCK_SIZE_BYTES=$(stat -f --format="%s" .)
> +FS_BLOCK_SIZE_KB=$((FS_BLOCK_SIZE_BYTES / 1024))
>
> # The output could be different in some systems, if we use du to
> # estimate file space usage with the same filesystem and the same size.
> # So we use the approximate value to check.
> check1="^10[2-3][0-9][0-9][[:space:]]\."
> check2="^10[2-3][0-9][0-9][[:space:]]testfile"
> -check3="^\(0\|${page_size}\)[[:space:]]\.\/testdir\/testsymlink"
> +check3="^\(0\|${FS_BLOCK_SIZE_KB}\)[[:space:]]\.\/testdir\/testsymlink"
> check5="^20[4-6][0-9][0-9][[:space:]]\."
> check7="^10[4-5][0-9][0-9]\{4\}[[:space:]]\."
> check9="^10[2-3][0-9][0-9][[:space:]]total"
we can just:
block_size_default=512
block_size=$(stat -f --format="%s" .)
block_size=$((block_size / 1024))
....
And then we use "block_size_default" inside do_test().
- Andrea
More information about the ltp
mailing list