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