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

# This is $Revision: 1.8 $
#
# $Log: lib-tc.sh,v $
# Revision 1.8  2004/05/05 13:22:31  cyeoh
# lib64 should be used for s390x not ia64.
#
# Revision 1.7  2004/05/05 07:36:43  cyeoh
# 64 bit architectures look for libraries in /lib64 not /lib
#
# Revision 1.6  2002/04/26 14:57:25  ajosey
# update test 6 code to make it simpler
#
# Revision 1.5  2002/04/26 14:51:32  ajosey
# make test 6 conditional on a preprocessor being support, return a FIP otherwise
#
# Revision 1.4  2001/08/15 08:48:11  ajosey
# make libm test notinuse as not required by the FHS spec
#
# Revision 1.3  2001/08/14 14:24:48  ajosey
# update the assertion numbers for FHS2.2
#
# Revision 1.2  2001/07/19 12:23:46  ajosey
# add header, and update test cases for FHS2.2
#
#
# -- old cvs log below --
# This is 1.3
#
# lib-tc.sh,v
# Revision 1.3  2000/04/09 07:15:28  cyeoh
# Added CVS header information
#
#

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


tp1()
{
	tpstart "Reference 3.9-1(A)" 
	tet_infoline "The /lib directory exists and is searchable"
	lsb_test_dir_searchable /lib >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 3.9-2(C)"
	tet_infoline "If the implementation supports the subsystem"
	tet_infoline "the /lib/modules directory exists and is searchable"
	lsb_test_dir_searchable /lib/modules >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
		tet_infoline "This test result needs to be manually resolved, returning FIP result"
		tpresult FIP
		return
	fi
	tpresult			# set result code
}


tp3() 
{
	tpstart "Reference 3.9-3(A)"
	tet_infoline "The /lib directory contains an execution time linker/loader  /lib/ld*"
	FAIL=Y
	case `uname -m` in
			ppc64)
      LIB_PATH=/lib64
		  ;;

			s390x)
      LIB_PATH=/lib64
		  ;;

			x86_64)
		  LIB_PATH=/lib64
			;;

		  *)
			LIB_PATH=/lib
		  ;;
  esac

	for i in $LIB_PATH/ld*;
	do
 	  if test -e $i
	  then
	    FAIL=N
	  fi
	done
	tpresult			# set result code
}

tp4() 
{
	tpstart "Reference 3.9-4(A)"
	tet_infoline "The /lib directory contains the shared dynamic linker /lib/libc.so.*"
	FAIL=Y
	case `uname -m` in
			ppc64)
      LIB_PATH=/lib64
		  ;;

			s390x)
      LIB_PATH=/lib64
		  ;;

			x86_64)
		  LIB_PATH=/lib64
			;;

		  *)
			LIB_PATH=/lib
		  ;;
  esac
	for i in $LIB_PATH/libc.so.*;
	do
 	  if test -e $i
	  then
	    FAIL=N
	  fi
	done
	tpresult			# set result code
}

tp5() 
{
	tpstart "Reference 3.9-5(A)"
	tet_infoline "The /lib directory contains the shared dynamic linker /lib/libm.so.*"
	tet_infoline "Not in use since this requirement is no longer in the FHS"
#	FAIL=Y
#	for i in /lib/libm.so.*;
#	do
# 	  if test -e $i
#	  then
#	    FAIL=N
#	  fi
#	done
	tpresult NOTINUSE			# set result code
}

tp6() 
{
	tpstart "Reference 3.9-6(C)"
	tet_infoline "If the implementation provides a C preprocessor, /lib/cpp is a reference to it"
	if ! test -e /lib/cpp
	then
		tet_infoline "This test result needs to be manually resolved, returning FIP result"
		tpresult FIP
		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
