#! /usr/bin/csh -f
#
# ident	"@(#)interconnect_test_cp	1.7	01/04/13 SMI"
#
# Copyright (c) 1996-2001 by Sun Microsystems, Inc.
# All rights reserved.
#

if( $#argv != 0 ) then
echo No arguments are allowed
echo Good-bye
exit 1
endif

set test_status = 0
set CSB_BRDS = "0 1"
set SYS_BRDS = "0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"

# Both centerplane support boards must be present _AND_ powered on.
foreach CSB_NUM (${CSB_BRDS})

	ring_test centerplane${CSB_NUM} jbc_internal -l > /dev/null
	if ( $status != 0 ) then
		echo "board centerplane${CSB_NUM} is not present."
		exit 1
	endif

	power -v -csb ${CSB_NUM}
	if ( $status != 0 ) then

		# If csb0 failed, check csb1 also before bailing out.
		if ( ${CSB_NUM} == 0) then
			power -v -csb 1
		endif

		echo "Both centerplane halves must be powered on to run this test."
		exit 1
	endif
end

# Now run the centerplane interconnect test
ict_test centerplane.1		|| set test_status = 1


# Run the sysboard connector interconnect test for each sysboard that is
# both present _AND_ powered on.
foreach SB_NUM (${SYS_BRDS})

	ring_test sysboard${SB_NUM} jbc_internal -l > /dev/null
	if( $status != 0 ) then
		echo "board sysboard${SB_NUM} is not present."
		continue
	endif

	power -v -q -sb ${SB_NUM}
	if ( $status != 0 ) then
		echo -n "board sysboard${SB_NUM} is powered off: "
		echo "skipping connector testing."
		continue
	endif

	ict_test sb${SB_NUM}_conn.1	|| set test_status = 1
end

# If any test failed then we FAILED
if( $test_status == 1 ) then
	echo "TEST FAILED"
else
	echo "TEST PASSED"
endif
exit $test_status
