1# 2# CDDL HEADER START 3# 4# The contents of this file are subject to the terms of the 5# Common Development and Distribution License (the "License"). 6# You may not use this file except in compliance with the License. 7# 8# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9# or https://opensource.org/licenses/CDDL-1.0. 10# See the License for the specific language governing permissions 11# and limitations under the License. 12# 13# When distributing Covered Code, include this CDDL HEADER in each 14# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15# If applicable, add the following below this CDDL HEADER, with the 16# fields enclosed by brackets "[]" replaced with your own identifying 17# information: Portions Copyright [yyyy] [name of copyright owner] 18# 19# CDDL HEADER END 20# 21 22# 23# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24# Use is subject to license terms. 25# 26 27# 28# Copyright (c) 2016 by Delphix. All rights reserved. 29# 30 31. $STF_SUITE/include/libtest.shlib 32 33# 34# Compare the checksum of target files with the original file 35# 36 37function compare_cksum #<orig_data> <target_data1>...<target_datan> 38{ 39 typeset orig_data=$1 40 typeset orig_sum=$(cksum < $orig_data) 41 typeset target_sum="" 42 typeset bad_data_list="" 43 typeset -i bad_count=0 44 45 shift 46 for data in $@; do 47 if [[ ! -e $data ]]; then 48 bad_data_list="$bad_data_list $data" 49 (( bad_count +=1 )) 50 continue 51 fi 52 53 target_sum=$(cksum < $data) 54 if [[ $target_sum != $orig_sum ]]; then 55 bad_data_list="$bad_data_list $data" 56 (( bad_count +=1 )) 57 fi 58 done 59 60 [[ $bad_data_list != "" ]] && \ 61 log_fail "Data corruptions appear during send->receive." \ 62 "There are total $bad_count corruptions. They are:\n"\ 63 "$bad_data_list" 64} 65 66# 67# Check the received dataset exists or not 68# 69function receive_check #<dataset1>...<datasetn> 70{ 71 typeset bad_rst_tgts="" 72 73 for dataset in $@; do 74 ! datasetexists $dataset && \ 75 bad_rst_tgts="$bad_rst_tgts $dataset" 76 done 77 78 if [[ $bad_rst_tgts != "" ]]; then 79 log_fail "Restoring fails. The specified datasets"\ 80 "$bad_rst_tgts are not being received." 81 fi 82} 83