[LTP] [PATCH 3/3] Add test for NFS directory listing regression

Petr Vorel pvorel@suse.cz
Tue Nov 23 10:49:16 CET 2021


Hi Martin,

Cc: Alexey
...
> +++ b/testcases/network/nfs/nfs_stress/Makefile
> @@ -15,6 +15,7 @@ INSTALL_TARGETS		:= nfs_lib.sh \
>  			   nfs03 \
>  			   nfs04 \
>  			   nfs05 \
> -			   nfs06
> +			   nfs06 \
> +			   nfs07.sh
+ 1 for .sh name, we should later add it to the rest of NFS shell scripts.

>  include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/network/nfs/nfs_stress/nfs07.sh b/testcases/network/nfs/nfs_stress/nfs07.sh
> new file mode 100755
> index 000000000..d8e482751
> --- /dev/null
> +++ b/testcases/network/nfs/nfs_stress/nfs07.sh
> @@ -0,0 +1,56 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2021 SUSE LLC <mdoucha@suse.cz>
> +#
> +#  DESCRIPTION: Create a large number of files and directories on NFS volume.
> +#  Then check whether they can be listed via NFS.
> +
> +FILE_COUNT=5000
> +
> +TST_OPTS="n:"
> +TST_PARSE_ARGS=do_parse_args
> +TST_TESTFUNC="do_test"
> +TST_SETUP="do_setup"
> +
> +do_parse_args()
> +{
> +	case "$1" in
> +	n) FILE_COUNT="$2";;
> +	esac
nit: nfs07.sh -h does not list this, would you care to add TST_USAGE?

> +}
> +
> +. nfs_lib.sh
> +
> +do_setup()
> +{
> +	nfs_setup
> +
> +	local rpath=$(nfs_get_remote_path)
> +	tst_rhost_run -s -c "touch $rpath/file{1..$FILE_COUNT}"
> +	tst_rhost_run -s -c "mkdir $rpath/dir{1..$FILE_COUNT}"
Unfortunately {1..$FILE_COUNT} is bashism (not work at least on dash).
Could you please rewrite it to using for cycle and seq?
It might be reasonably slower on bash, but working everywhere.

The rest LGTM, good idea to add this test.

Kind regards,
Petr

> +}
> +
> +do_test()
> +{
> +	local count
> +
> +	# Pass the list of files through `sort -u` in case `ls` doesn't fitler
> +	# out potential duplicate filenames returned by buggy NFS
> +	count=`ls | grep '^file' | sort -u | wc -l`
> +
> +	if [ $count -ne $FILE_COUNT ]; then
> +		tst_res TFAIL "Listing files failed: $count != $FILE_COUNT"
> +		return
> +	fi
> +
> +	count=`ls | grep '^dir' | sort -u | wc -l`
> +
> +	if [ $count -ne $FILE_COUNT ]; then
> +		tst_res TFAIL "Listing dirs failed: $count != $FILE_COUNT"
> +		return
> +	fi
> +
> +	tst_res TPASS "All files and directories were correctly listed"
> +}
> +
> +tst_run


More information about the ltp mailing list