5767 fix several problems with zfs test suite
[unleashed.git] / usr / src / test / zfs-tests / tests / functional / holes / holes.shlib
blob9420c8212063f33b06c57eabcc699e7b4398d4f1
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.
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.
13 # Copyright (c) 2014 by Delphix. All rights reserved.
16 # testfile The file to examine.
17 # hole_blks The expected number of holes.
18 # data_blks The expected number of data blocks.
19 function verify_holes_and_data_blocks
21         typeset testfile=$1
22         typeset -i hole_blks=$2
23         typeset -i data_blks=$3
24         typeset -i failures=0
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
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
38         [[ $failures -eq 0 ]] || log_fail "Wrong number of data/hole blocks."