1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2021 SUSE LLC <mdoucha@suse.cz> 4# 5# DESCRIPTION: Create a large number of files and directories on NFS volume. 6# Then check whether they can be listed via NFS. 7 8FILE_COUNT=5000 9 10TST_OPTS="n:" 11TST_PARSE_ARGS=do_parse_args 12TST_TESTFUNC="do_test" 13TST_SETUP="do_setup" 14 15do_parse_args() 16{ 17 case "$1" in 18 n) FILE_COUNT="$2";; 19 esac 20} 21 22. nfs_lib.sh 23 24TST_USAGE="show_usage" 25 26show_usage() 27{ 28 nfs_usage 29 echo "-n x Create x files and x directories, default is 5000" 30} 31 32do_setup() 33{ 34 nfs_setup 35 36 local rpath=$(nfs_get_remote_path | sed -e 's/%/%%/g') 37 local file_fmt="$rpath/file%1.0f" 38 local dir_fmt="$rpath/dir%1.0f" 39 40 tst_rhost_run -s -c "touch \$(seq -f \"$file_fmt\" -s ' ' $FILE_COUNT)" 41 tst_rhost_run -s -c "mkdir \$(seq -f \"$dir_fmt\" -s ' ' $FILE_COUNT)" 42} 43 44do_test() 45{ 46 local count 47 48 # Pass the list of files through `sort -u` in case `ls` doesn't filter 49 # out potential duplicate filenames returned by buggy NFS 50 count=$(ls | grep '^file' | sort -u | wc -l) 51 52 if [ $count -ne $FILE_COUNT ]; then 53 tst_res TFAIL "Listing files failed: $count != $FILE_COUNT" 54 return 55 fi 56 57 count=$(ls | grep '^dir' | sort -u | wc -l) 58 59 if [ $count -ne $FILE_COUNT ]; then 60 tst_res TFAIL "Listing dirs failed: $count != $FILE_COUNT" 61 return 62 fi 63 64 tst_res TPASS "All files and directories were correctly listed" 65} 66 67tst_run 68