#!/bin/sh
# bin-tc.sh : test case for /bin directory

##########################################################################
# (C) Copyright 1998-2001 The Open Group
#
# All rights reserved.  No part of this source code may be reproduced,
# stored in a retrieval system, or transmitted, in any form or by any
# means, electronic, mechanical, photocopying, recording or otherwise,
# except as stated in the end-user licence agreement, without the prior
# permission of the copyright owners.
#
# X/Open and the 'X' symbol are trademarks of X/Open Company Limited in
# the UK and other countries.
#
#	PROJECT:	LSB-FHS
#	PRODUCT:	LSB.fhs/root/bin/bin-tc.sh
#	AUTHOR:		Andrew Josey, The Open Group
#	DATE CREATED:	21 Dec 1998
##########################################################################

# This is $Revision: 1.20 $
#
# $Log: bin-tc.sh,v $
# Revision 1.20  2004/02/20 13:12:33  ajosey
# update tp49 strategy as failed on Mandrake cooker,also correct tet_infoline
#
# Revision 1.19  2004/02/12 13:15:08  ajosey
# update tp13,tp44 for FHS2.3/LSB2.0, change result codes to UNSUPPORTED
#
# Revision 1.18  2002/12/19 21:45:51  mwichmann
# Bugfix for 656515: save inum of zcat in _zcat_serial, which is used
# in the subsequent test, instead of in _gunzip_serial.
#
# Revision 1.17  2002/09/17 12:25:59  ajosey
# update tp37 for PR.0015
#
# Revision 1.16  2002/09/05 10:50:59  cyeoh
# Fix syntax errors in test code
#
# Revision 1.15  2002/07/11 15:39:46  ajosey
# correct tp47,tp48 to allow either hard or symlinks
#
# Revision 1.14  2002/07/11 15:06:51  ajosey
# correct error mesg in tp47
#
# Revision 1.13  2002/05/18 06:16:50  ajosey
# Change ping test to match specauth ruling that it does not need to be executable by all users
#
# Revision 1.12  2001/08/14 14:25:42  ajosey
# update the assertion numbers for FHS2.2
#
# Revision 1.11  2001/07/25 08:46:09  ajosey
# update tp49, tp50, and add tp52
#
# Revision 1.10  2001/07/19 11:19:30  ajosey
# add FAIL=N for FIP cases
#
# Revision 1.9  2001/07/19 11:16:58  ajosey
# FIP result codes added for option cases
#
# Revision 1.8  2001/07/19 09:58:17  ajosey
# update ping  test case to cope with unexpected output on stderr
#
# Revision 1.7  2001/07/17 16:36:47  ajosey
# add tests tp49 thru 51, new for FHS2.2
#
# Revision 1.6  2001/07/17 15:04:58  ajosey
# update tp42 and tp44 for FHS2.2
#
# Revision 1.5  2001/07/17 15:02:08  ajosey
# update tp38 and tp39 for FHS2.2
#
# Revision 1.4  2001/07/17 14:59:46  ajosey
# update tp29 for FHS2.2, now returns NOTINUSE result
#
# Revision 1.3  2001/07/17 14:56:19  ajosey
# update tp13 for FHS2.2, and put back in revision log
#
# Revision 1.2  2001/07/17 14:54:55  ajosey
# add in copyright notice
#
# -- note previous revision history out of date
#
# Revision 1.4  2000/04/17 07:07:35  ajosey
# add tests 46-48
#
# Revision 1.3  2000/04/14 09:08:18  ajosey
# update 3.4-29 for FHS2.1, if /bin/setserial does not exist then fail
#
# Revision 1.2  2000/04/09 07:15:19  cyeoh
# Added CVS header information
#
#

tet_startup="startup"			# startup function
tet_cleanup="cleanup"			# cleanup function
iclist="ic1 ic2 ic3 ic4 ic5 ic6 ic7 ic8 ic9 ic10 ic11 ic12 ic13 ic14 ic15 ic16 ic17 ic18 ic19 ic20 ic21 ic22 ic23 ic24 ic25 ic26 ic27 ic28 ic29 ic30 ic31 ic32 ic33 ic34 ic35 ic36 ic37 ic38 ic39 ic40 ic41 ic42 ic43 ic44 ic45 ic46 ic47 ic48 ic49 ic50 ic51 ic52"	
# list invocable components
ic1="tp1"
ic2="tp2"
ic3="tp3"
ic4="tp4"
ic5="tp5"
ic6="tp6"
ic7="tp7"
ic8="tp8"
ic9="tp9"
ic10="tp10"
ic11="tp11"
ic12="tp12"
ic13="tp13"
ic14="tp14"
ic15="tp15"
ic16="tp16"
ic17="tp17"
ic18="tp18"
ic19="tp19"
ic20="tp20"
ic21="tp21"
ic22="tp22"
ic23="tp23"
ic24="tp24"
ic25="tp25"
ic26="tp26"
ic27="tp27"
ic28="tp28"
ic29="tp29"
ic30="tp30"
ic31="tp31"
ic32="tp32"
ic33="tp33"
ic34="tp34"
ic35="tp35"
ic36="tp36"
ic37="tp37"
ic38="tp38"
ic39="tp39"
ic40="tp40"
ic41="tp41"
ic42="tp42"
ic43="tp43"
ic44="tp44"
ic45="tp45"
ic46="tp46"
ic47="tp47"
ic48="tp48"
ic49="tp49"
ic50="tp50"
ic51="tp51"
ic52="tp52"


tp1()
{
    tpstart "Reference 3.4-1(A), The /bin directory exists and is searchable"

    lsb_test_dir_searchable /bin >out.stdout  2>out.stderr
    check_exit_value $? 0		# should be zero
    check_nostdout			# should be stdout
    check_nostderr			# should be no stderr
    tpresult				# set result code
}

tp2() 
{
    tpstart "Reference 3.4-2(A)"
    tet_infoline "The implementation provides no subdirectories wthin /bin"

    ls -al /bin|grep "^d" >out.stdout 2>out.stderr
    # allow . and .. to exist as directory entries
    cat out.stdout |grep -v "\.\.$"|grep -v "\.$" >out.dir
    set `wc -l out.dir`
    if ! test  $1 -eq 0 
    then
	tet_infoline "The /bin directory contains the following directories:"
	infofile out.dir
        FAIL=Y
    fi
    rm out.dir
    check_nostderr			# should be no stderr
    tpresult				# set result code
}

tp3() 
{
	tpstart "Reference 3.4-3 (A)"
	tet_infoline "The implementation provides an exec-able version of the cat"
	tet_infoline "utility in the /bin directory. "
	echo "test" >tfile
	lsb_test_exec /bin/cat  tfile >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile >/dev/null 2>&1
	check_stdout			# should be output on stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp4() 
{
	tpstart "Reference 3.4-4 (A)"
	tet_infoline "The implementation provides an exec-able version of the chgrp"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	lsb_test_exec /bin/chgrp vsxg0 tfile >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp5() 
{
	tpstart "Reference 3.4-5 (A)"
	tet_infoline "The implementation provides an exec-able version of the chmod"
	tet_infoline "utility in the /bin directory. "
	echo "test" >tfile
	lsb_test_exec /bin/chmod a+w tfile >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp6() 
{
	tpstart "Reference 3.4-6 (A)"
	tet_infoline "The implementation provides an exec-able version of the chown"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	lsb_test_exec /bin/chown vsx0 tfile >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}


tp7() 
{
	tpstart "Reference 3.4-7 (A)"
	tet_infoline "The implementation provides an exec-able version of the cp"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	lsb_test_exec /bin/cp tfile tfile2 >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile tfile2 >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp8() 
{
	tpstart "Reference 3.4-8 (A)"
	tet_infoline "The implementation provides an exec-able version of the date"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/date >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_stdout			# should be output on stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}


tp9() 
{
	tpstart "Reference 3.4-9 (A)"
	tet_infoline "The implementation provides an exec-able version of the dd"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	lsb_test_exec /bin/dd if=tfile of=/dev/null >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile >/dev/null 2>&1
	check_nostdout
	check_stderr			# should be output on stderr
	tpresult			# set result code
}

tp10() 
{
	tpstart "Reference 3.4-10 (A)"
	tet_infoline "The implementation provides an exec-able version of the df"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/df >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_stdout			# should be output on stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp11() 
{
	tpstart "Reference 3.4-11 (A)"
	tet_infoline "The implementation provides an exec-able version of the dmesg"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/dmesg >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_stdout			# should be output on stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp12() 
{
	tpstart "Reference 3.4-12 (A)"
	tet_infoline "The implementation provides an exec-able version of the echo"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/echo hello >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp13() 
{
	tpstart "Reference 3.4-13 (A)"
	tet_infoline "The implementation provides an exec-able version of the ed"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	lsb_test_exec /bin/ed -s tfile >out.stdout 2>out.stderr  <<!!EOF
q
!!EOF
	check_exit_value $? 0		# should be zero
	rm -f tfile >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
# update for FHS 2.2. the ed utility is now optional.
# update for LSB2.0/FHS 2.3 make result code UNSUPPORTED
	if [ $FAIL = Y ]
	then
		tet_infoline "/bin/ed not found"
		tet_infoline "/bin/ed is optional in FHS 2.2"
		FAIL=N
		tpresult UNSUPPORTED
		return
	fi
	tpresult			# set result code
}

tp14() 
{
	tpstart "Reference 3.4-14 (A)"
	tet_infoline "The implementation provides an exec-able version of the false"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/false >out.stdout 2>out.stderr 
	check_exit_value $? 1		# should be non-zero
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp15() 
{
	tpstart "Reference 3.4-15 (A)"
	tet_infoline "The implementation provides an exec-able version of the kill"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/kill -l >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_stdout KILL		# check that KILL is listed on stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp16() 
{
	tpstart "Reference 3.4-16 (A)"
	tet_infoline "The implementation provides an exec-able version of the ln"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	lsb_test_exec /bin/ln tfile tfile2 >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f  tfile tfile2 >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp17() 
{
	tpstart "Reference 3.4-17 (A)"
	tet_infoline "The implementation provides an exec-able version of the login"
	tet_infoline "utility in the /bin directory. "
	if ! test -x /bin/login
	then
		FAIL=Y
	fi
	tpresult			# set result code
}

tp18() 
{
	tpstart "Reference 3.4-18 (A)"
	tet_infoline "The implementation provides an exec-able version of the ls"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	lsb_test_exec /bin/ls tfile >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f  tfile >/dev/null 2>&1
	check_stdout tfile		# should be stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp19() 
{
	tpstart "Reference 3.4-19 (A)"
	tet_infoline "The implementation provides an exec-able version of the mkdir"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/mkdir tdir >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rmdir tdir >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp20() 
{
	tpstart "Reference 3.4-20 (A)"
	tet_infoline "The implementation provides an exec-able version of the mknod"
	tet_infoline "utility in the /bin directory. "

	rm -f pfile >/dev/null 2>&1 	# delete pfile just in case
	lsb_test_exec /bin/mknod pfile p >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f pfile >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp21() 
{
	tpstart "Reference 3.4-21 (A)"
	tet_infoline "The implementation provides an exec-able version of the more"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	lsb_test_exec /bin/more tfile >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile >/dev/null 2>&1
	check_stdout test		# should be stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp22() 
{
	tpstart "Reference 3.4-22 (A)"
	tet_infoline "The implementation provides an exec-able version of the mount"
	tet_infoline "utility in the /bin directory. "
	echo "test" >tfile
	if ! test -x /bin/mount
	then
		FAIL=Y
	fi
	tpresult			# set result code
}

tp23() 
{
	tpstart "Reference 3.4-23 (A)"
	tet_infoline "The implementation provides an exec-able version of the mv"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	lsb_test_exec /bin/mv tfile tfile2 >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile tfile2 >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp24() 
{
	tpstart "Reference 3.4-24 (A)"
	tet_infoline "The implementation provides an exec-able version of the ps"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	lsb_test_exec /bin/ps >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_stdout			# should be stdout 
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp25() 
{
	tpstart "Reference 3.4-25 (A)"
	tet_infoline "The implementation provides an exec-able version of the pwd"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/pwd >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_stdout LSB.fhs		# should be stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp26() 
{
	tpstart "Reference 3.4-26 (A)"
	tet_infoline "The implementation provides an exec-able version of the rm"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	lsb_test_exec /bin/rm tfile >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp27() 
{
	tpstart "Reference 3.4-27 (A)"
	tet_infoline "The implementation provides an exec-able version of the rmdir"
	tet_infoline "utility in the /bin directory. "

	mkdir tdir
	lsb_test_exec /bin/rmdir tdir >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rmdir tdir >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp28() 
{
	tpstart "Reference 3.4-28 (A)"
	tet_infoline "The implementation provides an exec-able version of the sed"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	echo "s/test/foo/g" >sedfile
	lsb_test_exec /bin/sed -f sedfile tfile >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f sedfile tfile >/dev/null 2>&1
	check_stdout foo		# should be stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp29() 
{
	tpstart "Reference 3.4-29 (A)"
	tet_infoline "The implementation provides an exec-able version of the setserial"
	tet_infoline "utility in the /bin directory. "
	tet_infoline "Note: this requirement is removed in FHS 2.2."
	tpresult NOTINUSE		# set result code

# original test code commented out.
#	lsb_test_exec /bin/setserial >out.stdout 2>out.stderr 
#	check_exit_value $? 1		# should be non-zero
#	check_nostdout			# should be no stdout
#	check_stderr			# should be stderr
#	if [ $FAIL = Y ]
#	then
#		tet_infoline "/bin/setserial not found"
#		if [ "$LSB_FHS_TEST_MODE" = "2.0" ]
#		then 
#			tet_infoline "This appears to be an issue with the FHS2.0 specification"
#			tet_infoline "as setserial does not appear on many non x86 platforms"
#			FAIL=N			# need different result code
#			tpresult WARNING	# set to warning
#		else
#			tpresult FAIL
#		fi
#	else
#
#		tpresult		# set result code
#	fi
}

tp30() 
{
	tpstart "Reference 3.4-30 (A)"
	tet_infoline "The implementation provides an exec-able version of the sh"
	tet_infoline "utility in the /bin directory. "

	echo "exit 0" >tfile
	lsb_test_exec /bin/sh tfile >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp31() 
{
	tpstart "Reference 3.4-31 (A)"
	tet_infoline "The implementation provides an exec-able version of the stty"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/stty -a >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_stdout			# should be stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp32() 
{
	tpstart "Reference 3.4-32 (A)"
	tet_infoline "The implementation provides an exec-able version of the su"
	tet_infoline "utility in the /bin directory. "

	if ! test -x /bin/su
	then
		FAIL=Y
	fi
	tpresult			# set result code
}

tp33() 
{
	tpstart "Reference 3.4-33 (A)"
	tet_infoline "The implementation provides an exec-able version of the sync"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/sync >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp34() 
{
	tpstart "Reference 3.4-34 (A)"
	tet_infoline "The implementation provides an exec-able version of the true"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/true >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp35() 
{
	tpstart "Reference 3.4-35 (A)"
	tet_infoline "The implementation provides an exec-able version of the umount"
	tet_infoline "utility in the /bin directory. "

	if ! test -x /bin/umount
	then
		FAIL=Y
	fi
	tpresult			# set result code
}

tp36() 
{
	tpstart "Reference 3.4-36 (A)"
	tet_infoline "The implementation provides an exec-able version of the uname"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/uname >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_stdout Linux		# should be stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp37() 
{
	tpstart "Reference 3.4-37 (C)"
	tet_infoline "If the implementation supports a C Shell or equivalent (tcsh):"
        tet_infoline "	The path name of the C Shell shall be /bin/csh."

	if test -z $LSB_C_SHELL_SUPP
	then
		tpresult UNSUPPORTED
		return
	fi

#	echo "#" >tfile
#	lsb_test_exec /bin/csh tfile >out.stdout 2>out.stderr 
#	check_exit_value $? 0		# should be zero
#	rm -f tfile >/dev/null 2>&1
#	check_nostdout			# should be no stdout
#	check_nostderr			# should be no stderr
# PR.0015, can only check whether executable.
	if [ ! -x /bin/csh ]
        then
		FAIL=Y
		tet_infoline "/bin/csh is not executable"
	fi
	tpresult			# set result code
}

# According to the UNIX 98 specification for tar, output from cvf should appear
# on stderr, although many systems do put output on stdout
# i.e. Solaris 2.6, UnixWare 2.1.2, GNU tar, AIX 4.3.1
tp38() 
{
	tpstart "Reference 3.4-38 (A)"
	tet_infoline "The implementation provides an exec-able version of the tar"
	tet_infoline "utility in the /bin directory. "
	tet_infoline "Note: although optional in FHS 2.2 , this is mandatory in the LSB specification. "

	echo "test" >tfile
	lsb_test_exec /bin/tar cvf tfile.tar tfile  >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile.tar tfile >/dev/null 2>&1
# these checks are commented out as the tar behaviour seems to vary between
# systems on whether output should appear on stdout or stderr
#	check_nostdout			# should be no stdout
#	check_stderr			# should be no stderr
	tpresult			# set result code
}

tp39() 
{
	tpstart "Reference 3.4-39 (A)"
	tet_infoline "The implementation provides an exec-able version of the gzip"
	tet_infoline "utility in the /bin directory. "
	tet_infoline "Note: although optional in FHS 2.2 , this is mandatory in the LSB specification. "

	echo "test" >tfile
	lsb_test_exec /bin/gzip tfile  >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile.gz tfile >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp40() 
{
	tpstart "Reference 3.4-40 (A)"
	tet_infoline "The implementation provides an exec-able version of the gunzip"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	/bin/gzip tfile >/dev/null 2>&1
	check_prep_exit_value gzip $? 0

	lsb_test_exec /bin/gunzip tfile.gz  >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile.gz tfile >/dev/null 2>&1
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp41() 
{
	tpstart "Reference 3.4-41 (A)"
	tet_infoline "The implementation provides an exec-able version of the zcat"
	tet_infoline "utility in the /bin directory. "

	echo "test" >tfile
	/bin/gzip tfile >/dev/null 2>&1
	check_prep_exit_value /bin/gzip $? 0

	lsb_test_exec /bin/zcat tfile.gz  >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	rm -f tfile.gz tfile >/dev/null 2>&1
	check_stdout test		# should be stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp42() 
{
	tpstart "Reference 3.4-42 (A)"
	tet_infoline "The implementation provides an exec-able version of the domainname"
	tet_infoline "utility in the /bin directory. "
	tet_infoline "Note: This requirement is withdrawn in FHS2.2. "
	tpresult NOTINUSE			# set result code

#	lsb_test_exec /bin/domainname  >out.stdout 2>out.stderr 
#	check_exit_value $? 0		# should be zero
#	check_stdout			# should be stdout
#	check_nostderr			# should be no stderr
#	tpresult			# set result code
}

tp43() 
{
	tpstart "Reference 3.4-43 (A)"
	tet_infoline "The implementation provides an exec-able version of the hostname"
	tet_infoline "utility in the /bin directory. "

	lsb_test_exec /bin/hostname  >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_stdout			# should be stdout
	check_nostderr			# should be no stderr
	tpresult			# set result code
}

tp44() 
{
	tpstart "Reference 3.4-44 (C)"
	tet_infoline "The implementation provides an exec-able version of the netstat"
	tet_infoline "utility in the /bin directory. "
	tet_infoline "Note: this is now optional in FHS2.2. "

	lsb_test_exec /bin/netstat  >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_stdout			# should be stdout
	check_nostderr			# should be no stderr
# update for LSB2.0/FHS2.3 make result code UNSUPPORTED
	if [ $FAIL = Y ]
        then
		FAIL=N
		tpresult UNSUPPORTED
		return
	fi
	tpresult			# set result code
}

tp45() 
{
	tpstart "Reference 3.4-45 (A)"
	tet_infoline "The implementation provides an exec-able version of the ping"
	tet_infoline "utility in the /bin directory. "
#	lsb_test_exec /bin/ping -c 2 localhost  >out.stdout 2>out.stderr 
#	check_exit_value $? 0		# should be zero
#	check_stdout ping		# should be stdout
# Spec authority ruled 17 May 2002 that ping need not be executable
# by non root users, so we can only check its executable and not
# run the utility - AJ
	if [ ! -x /bin/ping ]
        then
		FAIL=Y
		tet_infoline "/bin/ping is not executable"
	fi
	if [ $FAIL = Y ]
	then
		FAIL=N
		tet_infoline "This test result needs to be manually resolved, returning FIP result code"
		tpresult FIP
		return
	fi
	tpresult			# set result code
}

tp46() 
{
	tpstart "Reference 3.4-46 (A)"
	tet_infoline "If /bin/sh is bash, then /bin/sh shall be a symbolic"
	tet_infoline "or hard link to /bin/bash"
	tet_infoline "(See the LSB_BIN_SHELL_BASH parameter)"
# driven off a new parameter
	if test -z $LSB_BIN_SHELL_BASH
	then
		tet_infoline "LSB_BIN_SHELL_BASH parameter not set"
		tpresult UNSUPPORTED
		return
	fi
# is it a symlink
	lsb_test_symlink /bin/sh /bin/bash  >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_nostdout 		        # should be stdout
	check_nostderr			# should be no stderr
# if not a symlink, check for a hard link
	if [ $FAIL = Y ]
	then
	    set `ls -i /bin/bash` 2>out.stderr
	    check_exit_value $? 0		# should be zero
	    check_nostderr			# should be no stderr
	    _bash_serial=$1
	    set `ls -i /bin/sh` 2>out.stderr
	    check_exit_value $? 0		# should be zero
	    check_nostderr			# should be no stderr
	    _sh_serial=$1
	    if [ $_sh_serial -ne $_bash_serial ]
	    then
	        tet_infoline "The sh utility is not a hard link to bash"
	        FAIL=Y
	    else
	        FAIL=N
	    fi
	fi
	tpresult			# set result code
}

tp47() 
{
	tpstart "Reference 3.4-47 (A)"
	tet_infoline "The gunzip utility shall be a hard link or symlink to the gzip utility"

	set `ls -i /bin/gunzip` 2>out.stderr
	check_exit_value $? 0		# should be zero
	check_nostderr			# should be no stderr
	_gunzip_serial=$1
	set `ls -i /bin/gzip` 2>out.stderr
	check_exit_value $? 0		# should be zero
	check_nostderr			# should be no stderr
	_gzip_serial=$1
	if [ $_gzip_serial -ne $_gunzip_serial ]
	then
	    tet_infoline "The gunzip utility is not a hard link to gzip"
	    FAIL=N
# is it a symlink
	    lsb_test_symlink /bin/gunzip /bin/gzip  >out.stdout 2>out.stderr
	    _gunzip_sym=$?
	    #not fatal if shell wrapper
	    #check_exit_value $? 0		# should be zero
	    #check_nostdout 		        # should be stdout
	    check_nostderr			# should be no stderr
	    if [ $_gunzip_sym -ne 0 ]
	    # not a symlink either, shell wrapper? (bug 1668)
	    then
	        tet_infoline "The gunzip utility is not a symlink to gzip"
		FAIL=N
		grep -q 'exec gzip' /bin/gunzip >out.stdout 2>out.stderr
	        check_exit_value $? 0
		check_nostdout
		check_nostderr
	    else
		FAIL=N
	    fi
	fi
	tpresult			# set result code
}

tp48() 
{
	tpstart "Reference 3.4-48 (A)"
	tet_infoline "The zcat utility shall be a hard link or symlink to the gzip utility"

	set `ls -i /bin/zcat` 2>out.stderr
	check_exit_value $? 0		# should be zero
	check_nostderr			# should be no stderr
	_zcat_serial=$1
	set `ls -i /bin/gzip` 2>out.stderr
	check_exit_value $? 0		# should be zero
	check_nostderr			# should be no stderr
	_gzip_serial=$1
	if [ $_gzip_serial -ne $_zcat_serial ]
	then
	    tet_infoline "The zcat utility is not a hard link to gzip"
	    FAIL=N
# is it a symlink
	    lsb_test_symlink /bin/zcat /bin/gzip  >out.stdout 2>out.stderr
	    _zcat_sym=$? 
	    #not fatal if shell wrapper
	    #check_exit_value $? 0		# should be zero
	    #check_nostdout 		        # should be stdout
	    check_nostderr			# should be no stderr
	    if [ $_zcat_sym != 0 ]
	    # not a symlink either, shell wrapper? (bug 1668)
	    then
	        tet_infoline "The zcat utility is not a symlink to gzip"
		FAIL=N
		grep -q 'exec gzip' /bin/zcat >out.stdout 2>out.stderr
	        check_exit_value $? 0
		check_nostdout
		check_nostderr
	    else
		FAIL=N
	    fi
	fi
	tpresult			# set result code
}

# added for FHS2.2
tp49()
{
        tpstart "Reference 3.4-49 (A)"
        tet_infoline "The implementation provides an exec-able version of the ["
        tet_infoline "utility in the /bin or /usr/bin directory. "
	if ! test -x /bin/[
	then
		FAIL=Y
	fi
        if [ $FAIL = Y ]
        then
                tet_infoline "Not found in /bin, checking /usr/bin"
                FAIL=N
                if ! test -x /usr/bin/[
                then
                        FAIL=Y
                fi
        fi
        if [ $FAIL = Y ]
        then
                tet_infoline "Not found in /bin or /usr/bin"
	fi

        tpresult                        # set result code
}


tp50() 
{
	tpstart "Reference 3.4-50 (A)"
	tet_infoline "The implementation provides an exec-able version of the test" 
	tet_infoline "utility in the /bin or /usr/bin directory. "
	lsb_test_exec /bin/test true  >out.stdout 2>out.stderr 
	check_exit_value $? 0		# should be zero
	check_nostdout 			# should be no stdout
	check_nostderr			# should be no stderr
	if [ $FAIL = Y ]
	then
		tet_infoline "Not found in /bin, checking /usr/bin"
		FAIL=N
		lsb_test_exec /usr/bin/test true  >out.stdout 2>out.stderr 
		check_exit_value $? 0		# should be zero
		check_nostdout 			# should be no stdout
		check_nostderr			# should be no stderr
	fi
	tpresult			# set result code
}

tp51() 
{
	tpstart "Reference 3.4-51 (A)"
	tet_infoline "The implementation provides an exec-able version of the cpio" 
	tet_infoline "utility in the /bin directory. "
	if [ ! -x /bin/cpio ]
        then
		FAIL=Y
		tet_infoline "/bin/cpio is not executable"
	fi
	tpresult			# set result code
}

tp52() 
{
	tpstart "Reference 3.4-52 (A)"
	tet_infoline "The implementation provides an exec-able version of the test and [ utilities" 
	tet_infoline "in the same directory, either /bin or /usr/bin directory. "
	if [ -x /bin/test ]
	then
		tet_infoline "/bin/test exists"
		if [ -x /bin/[ ]
		then
			FAIL=N
		else
			FAIL=Y
		fi
	fi
	if [ $FAIL = Y ]
	then
		if [ -x /usr/bin/test ]
		then
			tet_infoline "/usr/bin/test exists"
			if [ -x /usr/bin/[ ]
			then
				FAIL=N
			else
				FAIL=Y
			fi
		else
		tet_infoline "The utilities were not found , or not executable in either /bin or /usr/bin"
		FAIL=Y
		fi
	fi
	tpresult			# set result code
}


startup() # startup function
{
     rm -f out.stdout out.stderr out.experr >/dev/null 2>&1
}


cleanup() # clean-up function
{
     rm -f out.stdout out.stderr out.experr >/dev/null 2>&1
}

# source common shell functions

. $TET_EXECUTE/LIB/shfuncs.sh
. $TET_EXECUTE/LIB/lsbfuncs.sh

# execute shell test case manager - must be last line
. $TET_ROOT/lib/xpg3sh/tcm.sh
