[PATCH blktests] nvme/053: do not use awk
Martin Wilck
martin.wilck at suse.com
Thu Jan 16 03:37:31 PST 2025
On Thu, 2025-01-16 at 16:17 +0900, Shin'ichiro Kawasaki wrote:
> Luis observed that the test case nvme/053 fails in his environment
> [1]
> due to the following awk error message:
>
> awk: ...rescan.awk:2: warning: The time extension is obsolete.
> Use the timex extension from gawkextlib
>
> To avoid the failure and reduce dependencies, do not use awk in the
> test
> case. Instead, introduce the bash function get_sleep_time() to
> calculate
> the sleep time. Also implement the controller rescan loop in bash,
> following Martin's original patch [2].
>
> [1]
> https://lore.kernel.org/linux-block/20241218111340.3912034-1-mcgrof@kernel.org/
> [2]
> https://lore.kernel.org/linux-nvme/20240822193814.106111-3-mwilck@suse.com/
>
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki at wdc.com>
LGTM
Reviewed-by: Martin Wilck <mwilck at suse.com>
> ---
> tests/nvme/053 | 34 ++++++++++++++--------------------
> 1 file changed, 14 insertions(+), 20 deletions(-)
>
> diff --git a/tests/nvme/053 b/tests/nvme/053
> index 3ade8d3..99dbd38 100755
> --- a/tests/nvme/053
> +++ b/tests/nvme/053
> @@ -12,8 +12,15 @@ DESCRIPTION="test controller rescan under I/O
> load"
> TIMED=1
> : "${TIMEOUT:=60}"
>
> +get_sleep_time() {
> + local duration=$((RANDOM % 50 + 1))
> +
> + echo "$((duration / 10)).$((duration % 10))"
> +}
> +
> rescan_controller() {
> - local path
> + local path finish
> +
> path="$1/rescan_controller"
>
> [[ -f "$path" ]] || {
> @@ -21,24 +28,12 @@ rescan_controller() {
> return 1
> }
>
> - awk -f "$TMPDIR/rescan.awk" \
> - -v path="$path" -v timeout="$TIMEOUT" -v seed="$2" &
> -}
> -
> -create_rescan_script() {
> - cat >"$TMPDIR/rescan.awk" <<EOF
> - at load "time"
> -
> -BEGIN {
> - srand(seed);
> - finish = gettimeofday() + strtonum(timeout);
> - while (gettimeofday() < finish) {
> - sleep(0.1 + 5 * rand());
> - printf("1\n") > path;
> - close(path);
> - }
> -}
> -EOF
> + finish=$(($(date +%s) + TIMEOUT))
> + while [[ $(date +%s) -le $finish ]]; do
> + # sleep interval between 0.1 and 5s
> + sleep "$(get_sleep_time)"
> + echo 1 >"$path"
> + done
> }
>
> test_device() {
> @@ -46,7 +41,6 @@ test_device() {
> local i st line
>
> echo "Running ${TEST_NAME}"
> - create_rescan_script
>
> while IFS= read -r line; do
> ctrls+=("$line")
More information about the Linux-nvme
mailing list