#! /bin/csh -f

if (! $?QUARTUS_ROOTDIR) then
	setenv SCRIPT_PATH `dirname $0`

	if ("${SCRIPT_PATH}" == "") then
        # in case the dirname doesn't work, use "which" (slower)
		setenv SCRIPT_PATH `which $0 |& tail -1`
	endif

	if ("${SCRIPT_PATH}" == "." || "${SCRIPT_PATH}" == "") then
		setenv QUARTUS_ROOTDIR `dirname $cwd`
	else 
		setenv QUARTUS_ROOTDIR `dirname ${SCRIPT_PATH}`
	endif

	if ("${QUARTUS_ROOTDIR}" == "..") then
		setenv QUARTUS_ROOTDIR `dirname $cwd`
	endif
endif

source ${QUARTUS_ROOTDIR}/adm/qenv.csh

if ( $QUARTUS_PLATFORM == hp || $QUARTUS_PLATFORM == hp11 )
	set source_file=${QUARTUS_ROOTDIR}/${QUARTUS_PLATFORM}/quartus
else
	set source_file=${QUARTUS_ROOTDIR}/${QUARTUS_PLATFORM}/quartus
endif

set source_size=`ls -l $source_file | $AWK_CMD '{print $5}'`

echo "Testing transfer speed from Quartus II directory tree to local disk..."
/usr/bin/time cp $source_file /tmp/qtest$$ >& /tmp/qtest$$_time
set time=`cat /tmp/qtest$$_time | grep real | $AWK_CMD '{print $2}'`

echo "$time real seconds were spent copying $source_size bytes from $QUARTUS_ROOTDIR to /tmp."

rm -f /tmp/qtest$$*

exit 0
