#!/bin/sh
# bin-tc.sh : test case for /usr/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/usr/bin/bin-tc.sh
#	AUTHOR:		Andrew Josey, The Open Group
#	DATE CREATED:	21 Dec 1998
##########################################################################

# This is $Revision: 1.10 $
#
# $Log: bin-tc.sh,v $
# Revision 1.10  2004/02/13 11:38:43  ajosey
# change FIP results to UNSUPPORTED for category C assertions
#
# Revision 1.9  2001/08/14 14:37:30  ajosey
# update the assertion numbers for FHS2.2
#
# Revision 1.8  2001/07/27 14:16:59  ajosey
# missing FAIL=N for FIP cases
#
# Revision 1.7  2001/07/20 12:16:00  ajosey
# add new tests tp6 and tp7 for FHS2.2
#
# Revision 1.6  2001/07/20 12:10:42  ajosey
# fix tclsh test
#
# Revision 1.5  2001/07/20 10:58:52  ajosey
# update UNSUPPORTED to FIP result codes
#
# Revision 1.4  2001/07/19 09:36:47  ajosey
# update tclsh test case to ensure it exits
#
# Revision 1.3  2001/07/19 08:36:56  ajosey
# update tp5 for FHS2.2 alignment
#
# Revision 1.2  2001/07/18 15:41:18  ajosey
# add header, cvs info, and initial changes for FHS2.2
#
#
# -- old cvs info below --
#
# This is 1.4
#
# bin-tc.sh,v
# Revision 1.4  2000/04/14 10:30:53  ajosey
# add in 4.5-5, test existence of /usr/bin/mh directory
#
# Revision 1.3  2000/04/14 10:26:19  ajosey
# renumber the assertions for FHS2.1
#
# Revision 1.2  2000/04/09 07:15:34  cyeoh
# Added CVS header information
#
#

tet_startup="startup"			# startup function
tet_cleanup="cleanup"			# cleanup function
iclist="ic1 ic2 ic3 ic4 ic5 ic6 ic7"
ic1="tp1"
ic2="tp2"
ic3="tp3"
ic4="tp4"
ic5="tp5"
ic6="tp6"
ic7="tp7"


tp1()
{
	tpstart "Reference 4.5-1(A)"
	tet_infoline "The /usr/bin directory exists and is searchable"
	lsb_test_dir_searchable /usr/bin >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
}

tp2()
{
	tpstart "Reference 4.5-2(C)"
	tet_infoline "The implementation may provide a perl interpreter that can be referenced as /usr/bin/perl"
	(/usr/bin/perl -e 'exit 0') >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
		FAIL=N
		tpresult UNSUPPORTED
		return
	fi
	tpresult 			# set result code
}

tp3()
{
	tpstart "Reference 4.5-3(C)"
	tet_infoline "The implementation may provide a python interpreter that can be referenced as /usr/bin/python"
	(/usr/bin/python --help ) >out.stdout 2>out.stderr
	lsb_res=$?
	case $lsb_res in
	2) FAIL=N ;;
	*) tet_infoline "Return=$lsb_res"
	   if test -s out.stderr
	   then
		infofile out.stderr "stderr:"
	   fi
	   FAIL=Y ;;
	esac
	check_nostdout			# should be no stdout
	check_stderr			# should be stderr
	if [ $FAIL = Y ]
	then
		FAIL=N
		tpresult UNSUPPORTED
		return
	fi
	tpresult 			# set result code
}

tp4()
{
	tpstart "Reference 4.5-4(C)"
# /usr/bin/tcl changed to /usr/bin/tclsh in FHS2.2
	tet_infoline "The implementation provides a tcl interpreter that can be referenced as /usr/bin/tclsh"
	(echo "exit 1" | /usr/bin/tclsh ) >out.stdout 2>out.stderr
	lsb_res=$?
	case $lsb_res in
	1) FAIL=N ;;
	*) tet_infoline "Return=$lsb_res"
	   if test -s out.stderr
	   then
		infofile out.stderr "stderr:"
	   fi
	   FAIL=Y ;;
	esac
	check_nostdout			# should be no stdout
	check_nostderr			# should be no stderr
	if [ $FAIL = Y ]
	then
		FAIL=N
		tpresult UNSUPPORTED
		return
	fi
	tpresult 			# set result code
}

tp5()
{
# now optional in FHS2.2
	tpstart "Reference 4.5-5(C)"
	tet_infoline "If the subsystem is supported"
	tet_infoline "The /usr/bin/mh directory exists and is searchable"
	lsb_test_dir_searchable /usr/bin/mh >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
		FAIL=N
		tpresult UNSUPPORTED
		return
	fi
	tpresult				# set result code
}

# new in FHS 2.2
tp6()
{
	tpstart "Reference 4.5-6(C)"
	tet_infoline "The implementation may provide a simple tcl/tk windowing shell that can be referenced as /usr/bin/wish"
	if [ ! -x  /usr/bin/wish ]
	then
		FAIL=N
		tet_infoline "/usr/bin/wish: does not exist or is not executable"
		tpresult UNSUPPORTED
		return
	fi
	tpresult 			# set result code
}
# new in FHS 2.2
tp7()
{
	tpstart "Reference 4.5-7(C)"
	tet_infoline "The implementation may provide a program for interactive dialog that can be referenced as /usr/bin/expect"
	if [ ! -x  /usr/bin/expect ]
	then
		FAIL=N
		tet_infoline "/usr/bin/expect: does not exist or is not executable"
		tpresult UNSUPPORTED
		return
	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
