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# 28# This function creates the test archive for migration. 29# 30# Usage: 31# prepare srcdir cmd 32# 33# Return value: 0 on success 34# 1 on failure 35# 36# Where: 37# srcdir: is the directory where the testfile is 38# cmd: is the command to be executed. 39# E.g. 40# $TAR cf $TESTDIR/tar${TESTCASE_ID}.tar 41# 42function prepare #srcdir cmd 43{ 44 typeset srcdir=$1 45 typeset cmd=$2 46 typeset -i retval=0 47 48 cwd=$PWD 49 cd $srcdir 50 (( $? != 0 )) && return 1 51 52 $cmd 53 (( $? != 0 )) && return 1 54 55 cd $cwd 56 (( $? != 0 )) && return 1 57 58 return 0 59} 60 61# 62# This function executes a passed in command and then determines the chksum 63# of the resulting file. The chksum components are checked against the ones 64# passed in to determine if they are equal. If they are equal, 0 is returned 65# otherwise 1 is returned. 66# 67# Usage: 68# migrate destdir oldsuma oldsumb command_to_execute 69# 70# Return value: 0 on success 71# 1 on failure 72# 73# Where: 74# destdir: is the directory where the command is to be executed on 75# oldsuma: is the first part of the values returned by sum 76# oldsumb: is the second part of the values returned by sum 77# cmd: is the command to be executed; 78# E.g. 79# "$TAR xf $TESTDIR/tar${TESTCASE_ID}.tar" 80# 81function migrate #destdir oldsuma oldsumb cmd 82{ 83 typeset destdir=$1 84 typeset oldsuma=$2 85 typeset oldsumb=$3 86 typeset cmd=$4 87 typeset -i retval=0 88 89 cwd=$PWD 90 cd $destdir 91 (( $? != 0 )) && return 1 92 93 $cmd 94 (( $? != 0 )) && return 1 95 96 sumy=`$SUM ./$BNAME` 97 suma=`$ECHO $sumy | $AWK '{print $1}'` 98 sumb=`$ECHO $sumy | $AWK '{print $2}'` 99 100 if (( $oldsuma != $suma )); then 101 log_note "$SUM values are not the same" 102 retval=1 103 fi 104 105 if (( $oldsumb != $sumb )); then 106 log_note "$SUM values are not the same" 107 retval=1 108 fi 109 110 cd $cwd 111 (( $? != 0 )) && return 1 112 return $retval 113} 114 115function migrate_cpio 116{ 117 typeset destdir=$1 118 typeset archive=$2 119 typeset oldsuma=$3 120 typeset oldsumb=$4 121 typeset -i retval=0 122 123 cwd=$PWD 124 cd $destdir 125 (( $? != 0 )) && return 1 126 127 $CPIO -iv < $archive 128 (( $? != 0 )) && return 1 129 130 sumy=`$SUM ./$BNAME` 131 suma=`$ECHO $sumy | $AWK '{print $1}'` 132 sumb=`$ECHO $sumy | $AWK '{print $2}'` 133 134 if (( $oldsuma != $suma )); then 135 log_note "$SUM values are not the same" 136 retval=1 137 fi 138 139 if (( $oldsumb != $sumb )); then 140 log_note "$SUM values are not the same" 141 retval=1 142 fi 143 144 cd $cwd 145 (( $? != 0 )) && return 1 146 return $retval 147} 148