152244c09SJohn Wren Kennedy# 252244c09SJohn Wren Kennedy# This file and its contents are supplied under the terms of the 352244c09SJohn Wren Kennedy# Common Development and Distribution License ("CDDL"), version 1.0. 452244c09SJohn Wren Kennedy# You may only use this file in accordance with the terms of version 552244c09SJohn Wren Kennedy# 1.0 of the CDDL. 652244c09SJohn Wren Kennedy# 752244c09SJohn Wren Kennedy# A full copy of the text of the CDDL should have accompanied this 852244c09SJohn Wren Kennedy# source. A copy of the CDDL is also available via the Internet at 952244c09SJohn Wren Kennedy# http://www.illumos.org/license/CDDL. 1052244c09SJohn Wren Kennedy# 1152244c09SJohn Wren Kennedy 1252244c09SJohn Wren Kennedy# 13*1d32ba66SJohn Wren Kennedy# Copyright (c) 2014, 2016 by Delphix. All rights reserved. 1452244c09SJohn Wren Kennedy# 1552244c09SJohn Wren Kennedy 1652244c09SJohn Wren Kennedy# testfile The file to examine. 1752244c09SJohn Wren Kennedy# hole_blks The expected number of holes. 1852244c09SJohn Wren Kennedy# data_blks The expected number of data blocks. 1952244c09SJohn Wren Kennedyfunction verify_holes_and_data_blocks 2052244c09SJohn Wren Kennedy{ 2152244c09SJohn Wren Kennedy typeset testfile=$1 2252244c09SJohn Wren Kennedy typeset -i hole_blks=$2 2352244c09SJohn Wren Kennedy typeset -i data_blks=$3 2452244c09SJohn Wren Kennedy typeset -i failures=0 2552244c09SJohn Wren Kennedy 26*1d32ba66SJohn Wren Kennedy found_hole_blks=$(getholes -h $testfile) 27*1d32ba66SJohn Wren Kennedy found_data_blks=$(getholes -d $testfile) 2852244c09SJohn Wren Kennedy if [[ $found_hole_blks -ne $hole_blks ]] then; 2952244c09SJohn Wren Kennedy log_note "Found $found_hole_blks, not $hole_blks hole blocks." 3052244c09SJohn Wren Kennedy ((failures++)) 3152244c09SJohn Wren Kennedy fi 3252244c09SJohn Wren Kennedy 3352244c09SJohn Wren Kennedy if [[ $found_data_blks -ne $data_blks ]] then; 3452244c09SJohn Wren Kennedy log_note "Found $found_data_blks, not $data_blks data blocks." 3552244c09SJohn Wren Kennedy ((failures++)) 3652244c09SJohn Wren Kennedy fi 3752244c09SJohn Wren Kennedy 3852244c09SJohn Wren Kennedy [[ $failures -eq 0 ]] || log_fail "Wrong number of data/hole blocks." 3952244c09SJohn Wren Kennedy} 40