4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
28 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
31 . $STF_SUITE/tests/functional/mv_files/mv_files.cfg
34 # Determine whether this version of the ksh being
35 # executed has a bug where the limit of background
38 function check_bg_procs_limit_num
40 echo "#!/bin/ksh" > $TEST_BASE_DIR/exitsZero.ksh
41 echo "exit 0" >> $TEST_BASE_DIR/exitsZero.ksh
42 chmod 777 $TEST_BASE_DIR/exitsZero.ksh
44 cat <<EOF > $TEST_BASE_DIR/testbackgprocs.ksh
47 # exitsZero.ksh is a one line script
48 # that exit with status of "0"
55 $TEST_BASE_DIR/exitsZero.ksh &
65 (( \$? == 127 )) && exit 1
70 ksh $TEST_BASE_DIR/testbackgprocs.ksh
71 if [[ $? -eq 1 ]]; then
73 # Current ksh being executed has a limit
74 # of 25 background processes.
87 create_pool $TESTPOOL "$disklist"
89 if ! is_global_zone ; then
93 rm -rf $TESTDIR || log_unresolved Could not remove $TESTDIR
94 mkdir -p $TESTDIR || log_unresolved Could not create $TESTDIR
96 rm -rf $TESTDIR_TGT || log_unresolved Could not remove $TESTDIR_TGT
97 mkdir -p $TESTDIR_TGT || log_unresolved Could not create $TESTDIR_TGT
99 log_must zfs create $TESTPOOL/$TESTFS
100 log_must zfs set mountpoint=$TESTDIR $TESTPOOL/$TESTFS
102 log_must zfs create $TESTPOOL/$TESTFS_TGT
103 log_must zfs set mountpoint=$TESTDIR_TGT $TESTPOOL/$TESTFS_TGT
105 mkdir -p $OLDDIR || log_unresolved Could not create $OLDDIR
106 mkdir -p $NEWDIR_IN_FS || log_unresolved Could not create $NEWDIR_IN_FS
107 mkdir -p $NEWDIR_ACROSS_FS || log_unresolved Could not create $NEWDIR_ACROSS_FS
112 # Generate given number files in a
113 # directory of zfs file system
114 # $1 - the directory holds the generated files
115 # $2 - number of to-be-generated files
118 function generate_files
121 typeset -i proc_num=0
123 if (( $2 == $MVNUMFILES )); then
129 while (( count <= $2 ))
131 cp /etc/passwd $1/file_$count \
134 (( proc_num = proc_num + 1 ))
136 if (( proc_num >= GANGPIDS )); then
141 (( count = count + 1 ))
148 # Move given number files from one directory to
149 # another directory in parallel
150 # $1 - source directory
151 # $2 - target directory
155 find $1 -type f -print | xargs -I "{}" \
156 mv {} $2 > /dev/null 2>&1
160 # Count the files number after moving, and
161 # compare it with the original number
162 # $1 - directory that to be operated
163 # $2 - original files number
168 file_num=`find $1 -type f -print | \
170 (( file_num != $2 )) && \
171 log_fail "The file number of target directory"\
172 "$2 is not equal to that of the source "\
178 # Running the 'mv' test
187 typeset -i inc_num=$(( MVNUMFILES + MVNUMINCR ))
190 for num in $MVNUMFILES $inc_num
192 generate_files $old $num
195 count_files $new $num
198 count_files $old $num
201 typeset dir=$(get_device_dir $DISKS)
202 verify_filesys "$TESTPOOL" "$TESTPOOL/$TESTFS" "$dir"