summaryrefslogtreecommitdiff
path: root/tests/generic/720
blob: 4db69c6921e49275470e829c9fe453d70d68676b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2022 Oracle.  All Rights Reserved.
#
# FS QA Test No. 720
#
# Stress testing with a lot of extents.

. ./common/preamble
_begin_fstest auto quick fiexchange swapext

# Override the default cleanup function.
_cleanup()
{
	cd /
	rm -r -f $tmp.* $dir
}

# Import common functions.
. ./common/filter

# real QA test starts here
_require_xfs_io_command swapext '-v exchrange'
_require_test_program punch-alternating
_require_test

dir=$TEST_DIR/test-$seq
mkdir -p $dir
blksz=$(_get_file_block_size $TEST_DIR)
nrblks=$((LOAD_FACTOR * 100000))

_require_fs_space $TEST_DIR $(( (2 * blksz * nrblks) / 1024 ))

# Create some big swiss cheese files to test swapext with a lot of extents
_pwrite_byte 0x58 0 $((blksz * nrblks)) $dir/a >> $seqres.full
$here/src/punch-alternating $dir/a
_pwrite_byte 0x59 0 $((blksz * nrblks)) $dir/b >> $seqres.full
$here/src/punch-alternating -o 1 $dir/b
filefrag -v $dir/a $dir/b >> $seqres.full

# Now try to swapext
md5_a="$(md5sum < $dir/a)"
md5_b="$(md5sum < $dir/b)"
date >> $seqres.full
$XFS_IO_PROG -c "swapext $dir/b" $dir/a
date >> $seqres.full

echo "md5_a=$md5_a" >> $seqres.full
echo "md5_b=$md5_b" >> $seqres.full
md5sum $dir/a $dir/b >> $seqres.full

test "$(md5sum < $dir/b)" = "$md5_a" || echo "file b does not match former a"
test "$(md5sum < $dir/a)" = "$md5_b" || echo "file a does not match former b"

echo "Silence is golden!"
# success, all done
status=0
exit