Source

illumos-stc / usr / src / suites / storage / ndmp / zfs / src / lib / ksh / common.ksh

Full commit
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#

#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
#


LOGDIR=${LOGDIR:=/var/tmp/cmd_log}

. ${CTI_SUITE}/lib/unix_cmd
. ${CTI_SUITE}/lib/init
. ${CTI_SUITE}/lib/run_cmd
. ${CTI_SUITE}/lib/fs
. ${CTI_SUITE}/lib/osb

#
# NAME
#	print_test_case
#
# DESCRIPTION
#	Print the test case name to the results formatted to fit with
#	60 characters.
# 
# RETURN
#	void
#
function print_test_case
{
	unset ptc_short_info
	ptc_info="Test case $*"

	cti_report "==================================================="

	if [ `echo $ptc_info | $WC -c` -gt 60 ]
	then
		#
		# Split the line
		#
		ptc_ltrcnt=0
		for ptc_word in $ptc_info
		do
			if [ "$ptc_word" = "\n" ]
			then
				cti_report "$ptc_short_info"
				ptc_short_info=""
				ptc_ltrcnt=0
				continue
			fi

			ptc_wordsz=`echo $ptc_word | $WC -c`
			ptc_ltrcnt=`$EXPR $ptc_ltrcnt + $ptc_wordsz + 1`
			if [ $ptc_ltrcnt -gt 60 ]
			then
				cti_report "$ptc_short_info"
				ptc_short_info=" $ptc_word"
				ptc_ltrcnt=`$EXPR $ptc_wordsz`
			else
				ptc_short_info="$ptc_short_info $ptc_word"
			fi
		done
		if [ $ptc_ltrcnt -gt 0 ]
		then
			cti_report "$ptc_short_info"
		fi
	else
		cti_report "$ptc_info"
	fi

	cti_report "==================================================="
}