Re: [PATCH v3 next 05/10] lib: Add tests for mul_u64_u64_div_u64_roundup()

From: Nicolas Pitre
Date: Tue Jun 17 2025 - 00:30:35 EST


On Sat, 14 Jun 2025, David Laight wrote:

> Replicate the existing mul_u64_u64_div_u64() test cases with round up.
> Update the shell script that verifies the table, remove the comment
> markers so that it can be directly pasted into a shell.
>
> Rename the divisor from 'c' to 'd' to match mul_u64_add_u64_div_u64().
>
> It any tests fail then fail the module load with -EINVAL.
>
> Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>

I must withdraw my Reviewed-by here.

> /*
> * The above table can be verified with the following shell script:
> - *
> - * #!/bin/sh
> - * sed -ne 's/^{ \+\(.*\), \+\(.*\), \+\(.*\), \+\(.*\) },$/\1 \2 \3 \4/p' \
> - * lib/math/test_mul_u64_u64_div_u64.c |
> - * while read a b c r; do
> - * expected=$( printf "obase=16; ibase=16; %X * %X / %X\n" $a $b $c | bc )
> - * given=$( printf "%X\n" $r )
> - * if [ "$expected" = "$given" ]; then
> - * echo "$a * $b / $c = $r OK"
> - * else
> - * echo "$a * $b / $c = $r is wrong" >&2
> - * echo "should be equivalent to 0x$expected" >&2
> - * exit 1
> - * fi
> - * done
> +
> +#!/bin/sh
> +sed -ne 's/^{ \+\(.*\), \+\(.*\), \+\(.*\), \+\(.*\), \+\(.*\) },$/\1 \2 \3 \4 \5/p' \
> + lib/math/test_mul_u64_u64_div_u64.c |
> +while read a b d r d; do

This "read a b d r d" is wrong and that breaks the script.


Nicolas