xref: /titanic_51/usr/src/test/zfs-tests/tests/functional/holes/holes.shlib (revision 52244c0958bdf281ca42932b449f644b4decfdc2)
1*52244c09SJohn Wren Kennedy#
2*52244c09SJohn Wren Kennedy# This file and its contents are supplied under the terms of the
3*52244c09SJohn Wren Kennedy# Common Development and Distribution License ("CDDL"), version 1.0.
4*52244c09SJohn Wren Kennedy# You may only use this file in accordance with the terms of version
5*52244c09SJohn Wren Kennedy# 1.0 of the CDDL.
6*52244c09SJohn Wren Kennedy#
7*52244c09SJohn Wren Kennedy# A full copy of the text of the CDDL should have accompanied this
8*52244c09SJohn Wren Kennedy# source.  A copy of the CDDL is also available via the Internet at
9*52244c09SJohn Wren Kennedy# http://www.illumos.org/license/CDDL.
10*52244c09SJohn Wren Kennedy#
11*52244c09SJohn Wren Kennedy
12*52244c09SJohn Wren Kennedy#
13*52244c09SJohn Wren Kennedy# Copyright (c) 2014 by Delphix. All rights reserved.
14*52244c09SJohn Wren Kennedy#
15*52244c09SJohn Wren Kennedy
16*52244c09SJohn Wren Kennedy# testfile The file to examine.
17*52244c09SJohn Wren Kennedy# hole_blks The expected number of holes.
18*52244c09SJohn Wren Kennedy# data_blks The expected number of data blocks.
19*52244c09SJohn Wren Kennedyfunction verify_holes_and_data_blocks
20*52244c09SJohn Wren Kennedy{
21*52244c09SJohn Wren Kennedy	typeset testfile=$1
22*52244c09SJohn Wren Kennedy	typeset -i hole_blks=$2
23*52244c09SJohn Wren Kennedy	typeset -i data_blks=$3
24*52244c09SJohn Wren Kennedy	typeset -i failures=0
25*52244c09SJohn Wren Kennedy
26*52244c09SJohn Wren Kennedy	found_hole_blks=$($GETHOLES -h $testfile)
27*52244c09SJohn Wren Kennedy	found_data_blks=$($GETHOLES -d $testfile)
28*52244c09SJohn Wren Kennedy	if [[ $found_hole_blks -ne $hole_blks ]] then;
29*52244c09SJohn Wren Kennedy		log_note "Found $found_hole_blks, not $hole_blks hole blocks."
30*52244c09SJohn Wren Kennedy		((failures++))
31*52244c09SJohn Wren Kennedy	fi
32*52244c09SJohn Wren Kennedy
33*52244c09SJohn Wren Kennedy	if [[ $found_data_blks -ne $data_blks ]] then;
34*52244c09SJohn Wren Kennedy		log_note "Found $found_data_blks, not $data_blks data blocks."
35*52244c09SJohn Wren Kennedy		((failures++))
36*52244c09SJohn Wren Kennedy	fi
37*52244c09SJohn Wren Kennedy
38*52244c09SJohn Wren Kennedy	[[ $failures -eq 0 ]] || log_fail "Wrong number of data/hole blocks."
39*52244c09SJohn Wren Kennedy}
40