summaryrefslogtreecommitdiff
path: root/tests/xfs/058
blob: 8751a7acfd73cd169f7235bb462579dd845824ee (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2017, Oracle and/or its affiliates.  All Rights Reserved.
#
# FS QA Test No. 058
#
# Ensure that xfs_db fuzz command works as advertised.
#
. ./common/preamble
_begin_fstest auto quick fuzzers

# Import common functions.
. ./common/filter
. ./common/fuzzy

# real QA test starts here
_supported_fs xfs
_require_scratch_nocheck
_require_command "$XFS_DB_PROG" "xfs_db"
_require_xfs_db_command "fuzz"

rm -f "$seqres.full"

echo "Format"
_scratch_mkfs | _filter_mkfs 2>$tmp.mkfs >> "$seqres.full"
source $tmp.mkfs

do_xfs_db()
{
	local cmd=$1
	if [ $_fs_has_crcs -eq 0 ]; then
		echo "Allowing $cmd of corrupted data with good CRC"
	fi
	_scratch_xfs_db -x -c 'sb 0' -c "$*"
}

# Make sure that each fuzz verb works.  For the firstbit/middlebit/lastbit
# tests, we depend on 'ones' having set the field to all ones.
field="fdblocks"
do_xfs_db write -d ${field} 0
SCRATCH_XFS_LIST_FUZZ_VERBS= _scratch_xfs_list_fuzz_verbs | while read verb; do
	test "${verb}" = "random" && continue
	echo "Test verb ${verb}"
	do_xfs_db fuzz -d ${field} ${verb}
done

echo "Test verb random"
before="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
do_xfs_db fuzz -d ${field} random >> $seqres.full
after="$(_scratch_xfs_get_metadata_field "${field}" 'sb 0')"
test "${before}" != "${after}" && echo "${field} changed"

echo "Done"
# success, all done
status=0
exit