nightly.sh 18.9 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
#!/bin/ksh -p
  
function setVariables {
	export ROOT=$WORKAREA
	export TOOLROOT=
	export ECS_ROOT=/ecad/ecs/ecs_2.4
	export PATH=.:/usr/sbin:/usr/bsd:/usr/bin:/bin:/etc:/usr/etc:/usr/local/bin:/usr/local/bin/ptools:$WORKAREA/PR/rspsim/vuregre/bin:$PATH
	export TMPDIR=$ROOT/tmp
	export PMAKE="-J 8"
	export SGI_ABI=-32
	export VCS_NETHOST=ubangi.asd
	export LD_LIBRARY_PATH=/ecad/vcs/vcs_2.2/sgi/lib
	export INSTOPTS="-t"

	LOGDIR=$WORKAREA/logs
	NIGHTLY_LOG=$LOGDIR/nightly.log
	NIGHTLY_RESULT=$LOGDIR/nightly.result
	CLOBBER_LOG=$LOGDIR/clobber.log
	UPDATE_LOG=$LOGDIR/update.log
	HEADERS_LOG=$LOGDIR/headers.log
	EXPORTS_LOG=$LOGDIR/exports.log
	RAWIDB_LOG=$LOGDIR/rawidb.log
	IMAGES_LOG=$LOGDIR/images.log
	RCP_LOG=$LOGDIR/rcp.log
	RTL_RDPUNIT_LOG=$LOGDIR/rtl_rdpunit.log
	RTL_RDPUNIT_RESULT=$LOGDIR/rtl_rdpunit.result
	SYN_RDPUNIT_LOG=$LOGDIR/syn_rdpunit.log
	SYN_RDPUNIT_RESULT=$LOGDIR/syn_rdpunit.result
	RTL_RIUNIT_LOG=$LOGDIR/rtl_riunit.log
	RTL_RIUNIT_RESULT=$LOGDIR/rtl_riunit.result
	SYN_RIUNIT_LOG=$LOGDIR/syn_riunit.log
	SYN_RIUNIT_RESULT=$LOGDIR/syn_riunit.result
	RSPTEST=$WORKAREA/rsptest
	AI_LOG=$LOGDIR/ai.log
	PI_LOG=$LOGDIR/pi.log
	SI_LOG=$LOGDIR/si.log
	SP_LOG=$LOGDIR/sp.log
	RD_LOG=$LOGDIR/rd.log
	EB_LOG=$LOGDIR/eb.log
	IORAND_LOG=$LOGDIR/iorand.log
	IORAND_VLOG=$LOGDIR/iorand.vlog
	HOSTNAME=`hostname`
}

function clobberTree {
	echo "*** clobber phase" >> $NIGHTLY_LOG
	cd $WORKAREA/PR
	p_check -w | xargs rm -f 1>> $CLOBBER_LOG 2>&1
}

function updateTree {
	echo "*** update phase" >> $NIGHTLY_LOG
	cd $WORKAREA/PR
	p_check -s | p_purge -yi 1>> $UPDATE_LOG 2>&1
	p_tupdate -v 2>&1 >> $UPDATE_LOG
}

function headersBuild {
	echo "*** make headers" >> $NIGHTLY_LOG
	
	cd $WORKAREA/PR
	make -ki headers 1>> $HEADERS_LOG 2>&1

	echo -n "(*) make headers build phase " >> $NIGHTLY_RESULT
        if (grep "^\*\*\* Error code" $HEADERS_LOG >/dev/null)
	then
		echo FAILED >> $NIGHTLY_RESULT
		echo "    (see" $HOSTNAME:$HEADERS_LOG")" >> $NIGHTLY_RESULT
	else
		echo SUCCEEDED >> $NIGHTLY_RESULT
	fi
}

function exportsBuild {
	echo "*** make exports" >> $NIGHTLY_LOG
	
	cd $WORKAREA/PR
	make -ki exports 1>> $EXPORTS_LOG 2>&1

	echo -n "(*) make exports build phase " >> $NIGHTLY_RESULT
        if (grep "^\*\*\* Error code" $EXPORTS_LOG >/dev/null)
	then
		echo FAILED >> $NIGHTLY_RESULT
		echo "    (see" $HOSTNAME:$EXPORTS_LOG")" >> $NIGHTLY_RESULT
	else
		echo SUCCEEDED >> $NIGHTLY_RESULT
	fi
}

function rawidbBuild {
	echo "*** make rawidb" >> $NIGHTLY_LOG
	
	cd $WORKAREA/PR
	make -ki rawidb 1>> $RAWIDB_LOG 2>&1
	
	echo -n "(*) make rawidb build phase " >> $NIGHTLY_RESULT
        if (grep "^\*\*\* Error code" $RAWIDB_LOG >/dev/null)
	then
		echo FAILED >> $NIGHTLY_RESULT
		echo "    (see" $HOSTNAME:$RAWIDB_LOG")" >> $NIGHTLY_RESULT
	else
		echo SUCCEEDED >> $NIGHTLY_RESULT
	fi
}

function imagesBuild {
	echo "*** make images" >> $NIGHTLY_LOG
	
	cd $WORKAREA/PR
	make -ki startversion 1>> $IMAGES_LOG 2>&1
	make -ki images 1>> $IMAGES_LOG 2>&1
	
	echo -n "(*) make images build phase " >> $NIGHTLY_RESULT
        if (grep "^ERROR:" $IMAGES_LOG >/dev/null ||
            grep "^\*\*\* Error code" $IMAGES_LOG >/dev/null)
	then
		echo FAILED >> $NIGHTLY_RESULT
		echo "    (see" $HOSTNAME:$IMAGES_LOG")" >> $NIGHTLY_RESULT
	else
		echo SUCCEEDED >> $NIGHTLY_RESULT
	fi
}

function rcpBuild {
	echo "*** make in $HW/chip/rcp/src" >> $NIGHTLY_LOG
	
	cd $WORKAREA/PR/$HW/chip/rcp/src
	
	echo -n "(*) rcp,v build " >> $NIGHTLY_RESULT
	if (make 1>> $NIGHTLY_LOG 2>&1)
	then
		echo SUCCEEDED >> $NIGHTLY_RESULT
	else
		echo FAILED >> $NIGHTLY_RESULT
		echo "    (see" $HOSTNAME:$NIGHTLY_LOG")" >> $NIGHTLY_RESULT
	fi
}

function simvIpcBuild {
	buildDir=$WORKAREA/PR/$HW/chip/sim
	echo "*** make ipc in $buildDir" >> $NIGHTLY_LOG
	cd $buildDir
	make -ki SIMVDIR=$buildDir ipc 1>> $NIGHTLY_LOG 2>&1
}

function iosimBuild {
	echo "*** make in iosim/src" >> $NIGHTLY_LOG
	cd $WORKAREA/PR/iosim/src
	make -ki 1>> $NIGHTLY_LOG 2>&1
}

function rtlRdpUnitTest {
	echo "*** make in rdpsim/test" >> $NIGHTLY_LOG
	cd $WORKAREA/PR/rdpsim/test
	make -ki 1>> $RTL_RDPUNIT_LOG 2>&1
	
	grep "^!!!" $RTL_RDPUNIT_LOG | sort +3 > $RTL_RDPUNIT_RESULT
	echo -n "(*) RTL RDP unit test " >> $NIGHTLY_RESULT
	if (cmp -s $RTL_RDPUNIT_RESULT $WORKAREA/PR/rdpsim/test/rtl_rdpunit.result)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$RTL_RDPUNIT_RESULT")" >> $NIGHTLY_RESULT
	    echo "    (and" $HOSTNAME:$RTL_RDPUNIT_LOG")" >> $NIGHTLY_RESULT
	fi
}

function synRdpUnitTest {
	echo "*** make stests in rdpsim/test" >> $NIGHTLY_LOG
	cd $WORKAREA/PR/rdpsim/test
	make -ki stests 1>> $SYN_RDPUNIT_LOG 2>&1
	
	grep "^!!!" $SYN_RDPUNIT_LOG | sort +3 > $SYN_RDPUNIT_RESULT
	echo -n "(*) Synthesized RDP unit test " >> $NIGHTLY_RESULT
	if (cmp -s $SYN_RDPUNIT_RESULT $WORKAREA/PR/rdpsim/test/syn_rdpunit.result)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$SYN_RDPUNIT_RESULT")" >> $NIGHTLY_RESULT
	    echo "    (and" $HOSTNAME:$SYN_RDPUNIT_LOG")" >> $NIGHTLY_RESULT
	fi
}

function rtlRiUnitTest {
	echo "*** make in ritest" >> $NIGHTLY_LOG
	cd $WORKAREA/PR/ritest
	make -ki 1>> $RTL_RIUNIT_LOG 2>&1
	
	grep "^!!!" $RTL_RIUNIT_LOG | sort +3 > $RTL_RIUNIT_RESULT
	echo -n "(*) RTL RI unit test " >> $NIGHTLY_RESULT
	if (cmp -s $RTL_RIUNIT_RESULT $WORKAREA/PR/ritest/riunit.result)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$RTL_RIUNIT_RESULT")" >> $NIGHTLY_RESULT
	    echo "    (and" $HOSTNAME:$RTL_RIUNIT_LOG")" >> $NIGHTLY_RESULT
	fi
}

function synRiUnitTest {
	echo "*** make stests in ritest" >> $NIGHTLY_LOG
	cd $WORKAREA/PR/ritest
	make -ki stests 1>> $SYN_RIUNIT_LOG 2>&1
	
	grep "^!!!" $SYN_RIUNIT_LOG | sort +3 > $SYN_RIUNIT_RESULT
	echo -n "(*) Synthesized RI unit test " >> $NIGHTLY_RESULT
	if (cmp -s $SYN_RIUNIT_RESULT $WORKAREA/PR/ritest/riunit.result)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$SYN_RIUNIT_RESULT")" >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$SYN_RIUNIT_LOG")" >> $NIGHTLY_RESULT
	fi
}

function suTest {
	mkdir $RSPTEST/SU
	cd $RSPTEST/SU
	echo "*** RSP SU tests" >> $NIGHTLY_LOG
	rsp_regression +ctrace -SU 1>> $NIGHTLY_LOG 2>&1
}

function suTestResult {
	echo -n "(*) SU tests " >> $NIGHTLY_RESULT
        if (grep "Failed :0" $RSPTEST/SU/regression.log 1>/dev/null 2>&1)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    if [[ -a $RSPTEST/SU/regression.log ]]
	    then
		echo "    (see" $HOSTNAME:$RSPTEST/SU/regression.log")" >> \
		     $NIGHTLY_RESULT
	     else
		echo "    (log file not created)" >> $NIGHTLY_RESULT
	     fi
	fi
}
	
function vuTest {
	mkdir $RSPTEST/VU
	cd $RSPTEST/VU
	echo "*** RSP VU tests" >> $NIGHTLY_LOG
	rsp_regression +ctrace -VU 1>> $NIGHTLY_LOG 2>&1
}

function vuTestResult {
	echo -n "(*) VU tests " >> $NIGHTLY_RESULT
        if (grep "Failed :0" $RSPTEST/VU/regression.log 1>/dev/null 2>&1)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    if [[ -a $RSPTEST/VU/regression.log ]]
	    then
		echo "    (see" $HOSTNAME:$RSPTEST/VU/regression.log")" >> \
		     $NIGHTLY_RESULT
	     else
		echo "    (log file not created)" >> $NIGHTLY_RESULT
	     fi
	fi
}

function suSingleTest {
	mkdir $RSPTEST/SuSingle
	cd $RSPTEST/SuSingle
	echo "*** RSP SU single step tests" >> $NIGHTLY_LOG
	rsp_regression +ctrace +single_step -SU 1>> $NIGHTLY_LOG 2>&1
}

function suSingleTestResult {
	echo -n "(*) SU single step tests " >> $NIGHTLY_RESULT
        if (grep "Failed :0" $RSPTEST/SuSingle/regression.log 1>/dev/null 2>&1)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    if [[ -a $RSPTEST/SuSingle/regression.log ]]
	    then
		echo "    (see" $HOSTNAME:$RSPTEST/SuSingle/regression.log")" >> \
		     $NIGHTLY_RESULT
	     else
		echo "    (log file not created)" >> $NIGHTLY_RESULT
	     fi
	fi
}
	
function vuSingleTest {
	mkdir $RSPTEST/VuSingle
	cd $RSPTEST/VuSingle
	echo "*** RSP VU single step tests" >> $NIGHTLY_LOG
	rsp_regression +ctrace +single_step -VU 1>> $NIGHTLY_LOG 2>&1
}

function vuSingleTestResult {
	echo -n "(*) VU single step tests " >> $NIGHTLY_RESULT
        if (grep "Failed :0" $RSPTEST/VuSingle/regression.log 1>/dev/null 2>&1)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    if [[ -a $RSPTEST/VuSingle/regression.log ]]
	    then
		echo "    (see" $HOSTNAME:$RSPTEST/VuSingle/regression.log")" >> \
		     $NIGHTLY_RESULT
	     else
		echo "    (log file not created)" >> $NIGHTLY_RESULT
	     fi
	fi
}

function rspTest {
	suTest &
	vuTest &
	suSingleTest &
	vuSingleTest &
	wait
	suTestResult
	vuTestResult
	suSingleTestResult
	vuSingleTestResult
}

function pinRspSmallTest {
	mkdir $RSPTEST/pinRsp
	cd $RSPTEST/pinRsp
	echo "*** RSP pin level tests" >> $NIGHTLY_LOG
	reality_rsp_regression +ctrace -test_src=small_testsuite \
		1>> $NIGHTLY_LOG 2>&1
}

function pinRspSmallTestResult {
	echo -n "(*) RSP pin level tests " >> $NIGHTLY_RESULT
        if (grep "Failed :0" $RSPTEST/pinRsp/regression.log 1>/dev/null 2>&1)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    if [[ -a $RSPTEST/pinRsp/regression.log ]]
	    then
		echo "    (see" $HOSTNAME:$RSPTEST/pinRsp/regression.log")" >> \
		     $NIGHTLY_RESULT
	     else
		echo "    (log file not created)" >> $NIGHTLY_RESULT
	     fi
	fi
}

function pinRspSingleSmallTest {
	mkdir $RSPTEST/pinRspSingle
	cd $RSPTEST/pinRspSingle
	echo "*** RSP pin level single step tests" >> $NIGHTLY_LOG
	reality_rsp_regression +ctrace +single_step -test_src=small_testsuite \
		1>> $NIGHTLY_LOG 2>&1
}

function pinRspSingleSmallTestResult {
	echo -n "(*) RSP pin level single step tests " >> $NIGHTLY_RESULT
        if (grep "Failed :0" $RSPTEST/pinRspSingle/regression.log 1>/dev/null 2>&1)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    if [[ -a $RSPTEST/pinRspSingle/regression.log ]]
	    then
		echo "    (see" $HOSTNAME:$RSPTEST/pinRspSingle/regression.log")" >> \
		     $NIGHTLY_RESULT
	     else
		echo "    (log file not created)" >> $NIGHTLY_RESULT
	     fi
	fi
}

function dmaRspTest {
	mkdir $RSPTEST/dmaRsp
	cd $RSPTEST/dmaRsp
	echo "*** RSP DMA tests" >> $NIGHTLY_LOG
	reality_rsp_regression -DMA 1>> $NIGHTLY_LOG 2>&1
}

function dmaRspTestResult {
	echo -n "(*) RSP DMA tests " >> $NIGHTLY_RESULT
        if (grep "Failed :0" $RSPTEST/dmaRsp/regression.log 1>/dev/null 2>&1)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    if [[ -a $RSPTEST/dmaRsp/regression.log ]]
	    then
		echo "    (see" $HOSTNAME:$RSPTEST/dmaRsp/regression.log")" >> \
		     $NIGHTLY_RESULT
	     else
		echo "    (log file not created)" >> $NIGHTLY_RESULT
	     fi
	fi
}

function ioTest {
	echo "*** make in directed" >> $NIGHTLY_LOG
	cd $WORKAREA/PR/iosim/data/directed
	make -ki 1>> $NIGHTLY_LOG 2>&1

	echo "*** run test scripts in iosim/test" >> $NIGHTLY_LOG

	aiSocket=ai$$
	($WORKAREA/PR/iosim/src/iosim -f $WORKAREA/PR/iosim/test/ai.tst \
		-n $aiSocket -l $AI_LOG \
		-s "$SIMVDIR/$SIMVEXE" 1>>$NIGHTLY_LOG 2>&1)&

	piSocket=pi$$
	($WORKAREA/PR/iosim/src/iosim -f $WORKAREA/PR/iosim/test/pi.tst \
		-n $piSocket -l $PI_LOG \
		-s "$SIMVDIR/$SIMVEXE +load_rom +mmap_rdram=iosim" \
		1>>$NIGHTLY_LOG 2>&1)&

	siSocket=si$$
	($WORKAREA/PR/iosim/src/iosim -f $WORKAREA/PR/iosim/test/si.tst \
		-n $siSocket -l $SI_LOG \
		-s "$SIMVDIR/$SIMVEXE +load_pif" 1>>$NIGHTLY_LOG 2>&1)&

	spSocket=sp$$
	($WORKAREA/PR/iosim/src/iosim -f $WORKAREA/PR/iosim/test/sp.tst \
		-n $spSocket -l $SP_LOG \
		-s "$SIMVDIR/$SIMVEXE" 1>>$NIGHTLY_LOG 2>&1)&

	rdSocket=rd$$
	($WORKAREA/PR/iosim/src/iosim -f $WORKAREA/PR/iosim/test/rdramreg.tst \
		-n $rdSocket -l $RD_LOG \
		-s "$SIMVDIR/$SIMVEXE" 1>>$NIGHTLY_LOG 2>&1)&

	ebSocket=eb$$
	($WORKAREA/PR/iosim/src/iosim -f $WORKAREA/PR/iosim/test/ebus.tst \
		-n $ebSocket -l $EB_LOG \
		-s "$SIMVDIR/$SIMVEXE" 1>>$NIGHTLY_LOG 2>&1)&

	wait
	rm -fr	/tmp/$aiSocket /tmp/$piSocket /tmp/$siSocket /tmp/$spSocket \
		/tmp/$rdSocket

	echo -n "(*) AI unit test " >> $NIGHTLY_RESULT
        if (grep "total error = 0" $AI_LOG >/dev/null)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$AI_LOG")" >> $NIGHTLY_RESULT
	fi

	echo -n "(*) PI unit test " >> $NIGHTLY_RESULT
        if (grep "total error = 0" $PI_LOG >/dev/null)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$PI_LOG")" >> $NIGHTLY_RESULT
	fi

	echo -n "(*) SI unit test " >> $NIGHTLY_RESULT
        if (grep "total error = 0" $SI_LOG >/dev/null)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$SI_LOG")" >> $NIGHTLY_RESULT
	fi

	echo -n "(*) SP unit test " >> $NIGHTLY_RESULT
        if (grep "total error = 0" $SP_LOG >/dev/null)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$SP_LOG")" >> $NIGHTLY_RESULT
	fi

	echo -n "(*) RDRAM register read test " >> $NIGHTLY_RESULT
        if (grep "total error = 0" $RD_LOG >/dev/null)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$RD_LOG")" >> $NIGHTLY_RESULT
	fi

	echo -n "(*) EBUS test " >> $NIGHTLY_RESULT
        if (grep "total error = 0" $EB_LOG >/dev/null)
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$EB_LOG")" >> $NIGHTLY_RESULT
	fi
}

function ioRandTest {
	echo "*** make in $IORANDDIR" >> $NIGHTLY_LOG
	cd $WORKAREA/PR/iosim/data/$IORANDDIR
	make -ki 1>> $NIGHTLY_LOG 2>&1

	echo "*** run iorand" >> $NIGHTLY_LOG
	ioRandSocket=io$$
	ioRandSeed=$RANDSEED

	($WORKAREA/PR/iosim/src/iorand -n $ioRandSocket \
		$ITERATION $RUNCOUNT $MEMSIZE \
	 	-t $TESTRANGE  -o $ioRandSeed -d 0x241 -l $IORAND_LOG \
		-s "$SIMVDIR/$SIMVEXE -l $IORAND_VLOG $DUMP +load_imem +load_dmem +load_pif +load_rom +mmap_rdram=iorand +vitab=vi.tab +adac_mon +mbus_mon +cbus_mon +rsp_mon +xbus_mon +spandata_mon +show_imem_on_r1" \
		1>>$NIGHTLY_LOG 2>&1)&
	wait
	rm -fr /tmp/$ioRandSocket
	echo -n "(*) IO random test " >> $NIGHTLY_RESULT
        if (grep "total error = 0" $IORAND_LOG >/dev/null &&
	    (! grep "Test   8" $IORAND_LOG > /dev/null ||
	     $ROOT/usr/sbin/checkaudio $IORAND_VLOG \
		golden.hex >> $NIGHTLY_LOG 2>&1) &&
	    (! grep "Test   9" $IORAND_LOG > /dev/null ||
	     $ROOT/usr/sbin/checkvideo vi.tab \
		goldenvideo.rgb >> $NIGHTLY_LOG 2>&1) &&
	    (! grep "Test  14" $IORAND_LOG > /dev/null ||
	     $ROOT/usr/sbin/checkimage $IORAND_VLOG iorand.rdram \
		golden.spandata golden.rgb golden.cov >> $NIGHTLY_LOG 2>&1))
	then
	    echo SUCCEEDED >> $NIGHTLY_RESULT
	else
	    echo FAILED >> $NIGHTLY_RESULT
	    echo "    (see" $HOSTNAME:$IORAND_LOG")" >> $NIGHTLY_RESULT
	fi
}

function pinRspTest {
	pinRspSmallTest &
	pinRspSingleSmallTest &
	dmaRspTest &
	wait
	pinRspSmallTestResult
	pinRspSingleSmallTestResult
	dmaRspTestResult
}

function videoTest {

	buildDir=$WORKAREA/PR/$HW/chip/sim
	for v in mln1 mln2 mlp1 mhn1 mhf2 dth2;
	do
	    echo "*** make ${v}test in $buildDir" >> $NIGHTLY_LOG
	    make -ki SIMVDIR=$buildDir ${v}test 1>> $NIGHTLY_LOG 2>&1

	    echo "*** make ${v}test.rgb in $HW/chip/sim" >> $NIGHTLY_LOG
	    make ${v}test.rgb 1>> $NIGHTLY_LOG 2>&1

	    echo -n "(*) Video test $v " >> $NIGHTLY_RESULT
            if (grep "total error = 0" io-${v}.log >/dev/null &&
	        make ${v}test.rgb 1>> $NIGHTLY_LOG 2>&1)
	    then
		echo SUCCEEDED >> $NIGHTLY_RESULT
	    else
		echo FAILED >> $NIGHTLY_RESULT
		echo "    (see" $HOSTNAME:$WORKAREA/$HW/chip/sim/io-${v}.log")" \
			>> $NIGHTLY_RESULT
		echo "    (and" $HOSTNAME:$NIGHTLY_LOG")" >> $NIGHTLY_RESULT
	    fi
	done
}

	doClobber=FALSE
	doUpdate=FALSE
	doHeaders=FALSE
	doExports=FALSE
	doRawidb=FALSE
	doImages=FALSE
	doRcp=FALSE
	doRtlRdp=FALSE
	doSynRdp=FALSE
	doRsp=FALSE
	doPinRsp=FALSE
	doRtlRi=FALSE
	doSynRi=FALSE
	doSimvIpcBuild=FALSE
	doIosimBuild=FALSE
	doIo=FALSE
	doIoRand=FALSE
	doVideo=FALSE

	HW=hw2
	SIMVDIR=$WORKAREA/PR/$HW/chip/sim
	SIMVEXE=simv2.ipc

	RANDSEED=`date +%M%S`
	IORANDDIR=dma80
	TESTRANGE=1-14

	while getopts a:d:e:f:h:i:m:p:r:s:t:v:w: c
	do
		case $c in
		a)	export HW_FLAGS=$OPTARG;;
		d)	IORANDDIR=$OPTARG;;
		e)	SIMVEXE=$OPTARG;;
		f)	SIMVDIR=$OPTARG;;
		h)	HW=$OPTARG;;
		i)	ITERATION="-i $OPTARG";;
		m)	MEMSIZE="-m $OPTARG";;
		p)	export PRODUCT=$OPTARG;;
		r)	RUNCOUNT="-r $OPTARG";;
		s)	RANDSEED=$OPTARG;;
		t)	TESTRANGE=$OPTARG;;
		w)	export WORKAREA=$OPTARG;;
		\?)	echo "usage: nightly.script [-d <iorand data directory>]"
			echo "                      [-e <simv executable>]"
			echo "                      [-f <simv directory>]"
			echo "                      [-h <hw/hw2 directory>]"
			echo "                      [-i <iorand iteration count>]"
			echo "                      [-m <memory size>]"
			echo "                      [-r <iorand min run count>]"
			echo "                      [-s <iorand random seed>]"
			echo "                      [-t <iorand test range>]"
			echo "                      [-w <workarea directory>]"
			echo "                      [-a <define HW_FLAGS env var>]"
			echo "                      [tests]"
			exit 1;;
		esac
	done
	shift `expr $OPTIND - 1`

	setVariables

	for i in $*;
	do
		case $i in
		clobber)	doClobber=TRUE;;
		update)		doUpdate=TRUE;;
		headers)	doHeaders=TRUE;;
		exports)	doExports=TRUE;;
		rawidb)		doRawidb=TRUE;;
		images)		doImages=TRUE;;
		rcp)		doRcp=TRUE;;
		rtlrdp)		doRtlRdp=TRUE;;
		synrdp)		doSynRdp=TRUE;;
		rsp)		doRsp=TRUE;;
		pinrsp)		doPinRsp=TRUE;;
		rtlri)		doRtlRi=TRUE;;
		synri)		doSynRi=TRUE;;
		simvbuild)	doSimvIpcBuild=TRUE;;
		iobuild)	doIosimBuild=TRUE;;
		io)		doIo=TRUE;;
		iorand)		doIoRand=TRUE;;
		video)		doVideo=TRUE;;
		esac
	done

	rm -fr	$LOGDIR.old $RSPTEST $TMPDIR
	mv -f	$LOGDIR $LOGDIR.old
	mkdir	$LOGDIR $RSPTEST $TMPDIR

	echo -n "*** Regression begins at " >> $NIGHTLY_LOG
	date >> $NIGHTLY_LOG
	
	$ECS_ROOT/bin/makeini
	
	if [ $doClobber = TRUE ];	 then clobberTree;	fi
	if [ $doUpdate = TRUE ];	 then updateTree;	fi
	if [ $doHeaders = TRUE ];	 then headersBuild;	fi
	if [ $doExports = TRUE ];	 then exportsBuild;	fi
	if [ $doRawidb = TRUE ];	 then rawidbBuild;	fi
	if [ $doImages = TRUE ];	 then imagesBuild;	fi
	if [ $doRcp = TRUE ];		 then rcpBuild;		fi
	if [ $doRtlRdp = TRUE ];	 then rtlRdpUnitTest;	fi
	if [ $doSynRdp = TRUE ];	 then synRdpUnitTest;	fi
	if [ $doRtlRi = TRUE ];		 then rtlRiUnitTest;	fi
	if [ $doSynRi = TRUE ];		 then synRiUnitTest;	fi
	if [ $doRsp = TRUE ];		 then rspTest;		fi
	if [ $doPinRsp = TRUE ];	 then pinRspTest;	fi
	if [ $doSimvIpcBuild = TRUE ];	 then simvIpcBuild;	fi
	if [ $doIosimBuild = TRUE ];	 then iosimBuild;	fi
	if [ $doIo = TRUE ];		 then ioTest;		fi
	if [ $doIoRand = TRUE ];	 then ioRandTest;	fi
	if [ $doVideo = TRUE ];		 then videoTest;	fi
	
	echo -n "*** Nightly regression finished at " >> $NIGHTLY_LOG
	date >> $NIGHTLY_LOG