]> git.proxmox.com Git - mirror_zfs-debian.git/blob - tests/zfs-tests/tests/functional/cp_files/cp_files_001_pos.ksh
New upstream version 0.7.11
[mirror_zfs-debian.git] / tests / zfs-tests / tests / functional / cp_files / cp_files_001_pos.ksh
1 #! /bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright (c) 2018 by Nutanix. All rights reserved.
25 #
26
27 . $STF_SUITE/include/libtest.shlib
28
29 #
30 # DESCRIPTION:
31 # Copy a large number of files between 2 directories
32 # within a zfs filesystem works without errors.
33 # This make sure zap upgrading and expanding works.
34 #
35 # STRATEGY:
36 #
37 # 1. Create NR_FILES files in directory src
38 # 2. Check the number of files is correct
39 # 3. Copy files from src to dst in readdir order
40 # 4. Check the number of files is correct
41 #
42
43 verify_runnable "global"
44
45 function cleanup
46 {
47 rm -rf $TESTDIR/src $TESTDIR/dst
48 }
49
50 log_assert "Copy a large number of files between 2 directories" \
51 "within a zfs filesystem works without errors"
52
53 log_onexit cleanup
54
55 NR_FILES=60000
56 BATCH=1000
57
58 log_must mkdir $TESTDIR/src
59 log_must mkdir $TESTDIR/dst
60
61 WD=$(pwd)
62 cd $TESTDIR/src
63 # create NR_FILES in BATCH at a time to prevent overflowing argument buffer
64 for i in $(seq $(($NR_FILES/$BATCH))); do touch $(seq $((($i-1)*$BATCH+1)) $(($i*$BATCH))); done
65 cd $WD
66
67 log_must test $NR_FILES -eq $(ls -U $TESTDIR/src | wc -l)
68
69 # copy files from src to dst, use cp_files to make sure we copy in readdir order
70 log_must $STF_SUITE/tests/functional/cp_files/cp_files $TESTDIR/src $TESTDIR/dst
71
72 log_must test $NR_FILES -eq $(ls -U $TESTDIR/dst | wc -l)
73
74 log_pass