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