fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 560
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test generic/560
6 #
7 # Iterate dedupe integrity test. Copy an original data0 several
8 # times (d0 -> d1, d1 -> d2, ... dn-1 -> dn), dedupe dataN everytime
9 # before copy. At last, verify dataN same with data0.
10 #
11 . ./common/preamble
12 _begin_fstest auto stress dedupe
13
14 # Import common functions.
15 . ./common/filter
16 . ./common/reflink
17
18 # real QA test starts here
19 _supported_fs generic
20 _require_scratch_duperemove
21
22 _scratch_mkfs > $seqres.full 2>&1
23 _scratch_mount >> $seqres.full 2>&1
24
25 function iterate_dedup_verify()
26 {
27         local src=$srcdir
28         local dest=$dupdir/1
29
30         for ((index = 1; index <= times; index++)); do
31                 cp -a $src $dest
32                 find $dest -type f -exec md5sum {} \; \
33                         > $md5file$index
34                 # Make some noise
35                 $FSSTRESS_PROG $fsstress_opts -d $noisedir \
36                                -n 200 -p $((5 * LOAD_FACTOR)) >/dev/null 2>&1
37                 # Too many output, so only save error output
38                 $DUPEREMOVE_PROG -dr --dedupe-options=same $dupdir \
39                         >/dev/null 2>$seqres.full
40                 md5sum -c --quiet $md5file$index
41                 src=$dest
42                 dest=$dupdir/$((index + 1))
43         done
44 }
45
46 srcdir=$SCRATCH_MNT/src
47 dupdir=$SCRATCH_MNT/dup
48 noisedir=$dupdir/noise
49 mkdir $srcdir $dupdir
50 mkdir $dupdir/noise
51
52 md5file=${tmp}.md5sum
53
54 fsstress_opts="-w -r"
55 # Create some files to be original data
56 $FSSTRESS_PROG $fsstress_opts -d $srcdir \
57                -n 500 -p $((5 * LOAD_FACTOR)) >/dev/null 2>&1
58
59 # Calculate how many test cycles will be run
60 src_size=`du -ks $srcdir | awk '{print $1}'`
61 free_size=`df -kP $SCRATCH_MNT | grep -v Filesystem | awk '{print $4}'`
62 times=$((free_size / src_size))
63 if [ $times -gt $((4 * TIME_FACTOR)) ]; then
64         times=$((4 * TIME_FACTOR))
65 fi
66
67 echo "= Do dedup and verify ="
68 iterate_dedup_verify
69
70 # Use the last checksum file to verify the original data
71 sed -e s#dup/$times#src#g $md5file$times > $md5file
72 echo "= Backwords verify ="
73 md5sum -c --quiet $md5file
74
75 # read from the disk also doesn't show mutations.
76 _scratch_cycle_mount
77 echo "= Verify after cycle mount ="
78 for ((index = 1; index <= times; index++)); do
79         md5sum -c --quiet $md5file$index
80 done
81
82 status=0
83 exit