rsp_cregression 5.14 KB
#!/usr/local/bin/perl

if ($ENV{"ROOT"}) {
   $ROOT = $ENV{"ROOT"};
  }
else {
  die "ROOT env not set. Plaase set ROOT environment first \n";
  }

$VUREGRES =  $ROOT."/PR/rspsim/vuregre";
$SUREGRES =  $ROOT."/PR/rspsim/suregre";
$VUSRC =  $VUREGRES."/src";
$SUSRC =  $SUREGRES."/ready";
$TOOL =   $VUREGRES."/bin";
$RSPASM = $ROOT."/PR/rspasm";
$RSPSIM = $ROOT."/PR/rspsim";

$WORKDIR = `pwd`;
chop($WORKDIR);
$TESTDIR = $WORKDIR;
$TESTDIR_VU = $TESTDIR."/csim_vu";
$TESTDIR_SU = $WORKDIR."/csim_su";


$ALL_DIAGS = 1;

while ($#ARGV >= 0) {

    if ($ARGV[0] =~ /^\+su=/) {
      ($TEMP,$DIAG) = split(/=/,shift(@ARGV));
      $PlusArgs = push(@PlusArgs,$DIAG);
      $ALL_DIAGS = 0;
     }
    elsif ($ARGV[0] eq '-h') {
      shift (@ARGV);
    }
    else {
    die "Illigal option provided \n";
    }

} #while ($#ARGV >= 0)


if (!(-e $TESTDIR_VU && -d $TESTDIR_VU)) {
     mkdir ($TESTDIR_VU,0777) || die "Cant make $TESTDIR_VU \n";
   }
if (!(-e $TESTDIR_SU && -d $TESTDIR_SU)) {
     mkdir ($TESTDIR_SU,0777) || die "Cant make $TESTDIR_SU \n";
   }

if (!(-r "testsuite")){
   print "Getting file $VUREGRES/regression/testsuite \n";
   system("cp $VUREGRES/regression/testsuite $WORKDIR")==0
    || die " System Call interrupt";
   chmod(0666,$WORKDIR."/testsuite");
 }

  open(TESTSUITE,"testsuite") || die "Cant open testsuite \n";
  open(TESTSKIPPED,">ctests.skipped") || die "Cant open ctests.skipped \n";
  open(LOG,">cregression.log") || die "Cant open cregression.log \n";

  $test_num=0;

  while ($_= <TESTSUITE>) {

     split;

     $INTYPE = 0; $STYPE = 0;
     $VUTEST = 0; $SUTEST = 0;

     $TEST_TYPE = $_[0]; #VU,SU
     $TEST =      $_[1]; #test

     if ($TEST_TYPE eq "VU" || $TEST_TYPE eq "SU") {

        if ($TEST_TYPE eq "VU") {
	   $VUTEST = 1;
   	   $TESTNAME_FULL = $ROOT."/".$TEST;
	   $TESTDIR = $TESTDIR_VU;
           open(MAKEFILE,">$TESTDIR/Makefile") || die "Cant open $TESTDIR/Makefile \n";
         }
	else { 
	   $SUTEST = 1; 
	   $TESTNAME_FULL = $ROOT."/".$TEST;
	   $TESTDIR = $TESTDIR_SU;
           open(MAKEFILE,">$TESTDIR/Makefile") || die "Cant open $TESTDIR/Makefile \n";
	  }

	$TEST = `basename $TESTNAME_FULL`;
	chop($TEST);

	print "test is $TEST \n";
	
	($TEST,$FILE_TYPE) = split(/\./,$TEST);

        if ($FILE_TYPE eq "in") { 
	   $INTYPE = 1; 
          }
	else { 
	   $STYPE = 1; 
	  }

	if (-r $TESTNAME_FULL) {

	    chdir ($TESTDIR) || die "Cant go to $TESTDIR \n";
            
	    print MAKEFILE "\n";
	    print MAKEFILE "TARGET1 = $TEST.$FILE_TYPE\n";
	    print MAKEFILE "TARGET2 = $TEST.out \n";
	    print MAKEFILE "TOOL = $RSPASM/rspasm $TOOL/d2asm $TOOL/make_rtsk\n";
	    print MAKEFILE "INCLUDE = VU_AVP.h  suregre.h\n";
	    print MAKEFILE "\n";
	    print MAKEFILE "\$(TARGET2): $TEST.$FILE_TYPE \$(TOOL) \$(INCLUDE)\n";
	    print MAKEFILE "\ttouch a.out\n";
	    print MAKEFILE "\trm a.out*\n";
	    if ($FILE_TYPE eq "in") {
	           print MAKEFILE "\t$TOOL/d2asm $TEST.in $TEST.s $TEST.inlst\n";
		  }
	    print MAKEFILE "\t$RSPASM/rspasm -b 0 $TEST.s\n";
	    print MAKEFILE "\tmv a.out $TEST.out\n";
	    print MAKEFILE "\tmv a.out.lst $TEST.lst\n";
	    print MAKEFILE "\tmv a.out.dat $TEST.dat\n";
	    if ($TEST_TYPE eq "SU") {
	          print MAKEFILE "\t$TOOL/make_rtsk $TEST 1\n";
		  }
            else {
	          print MAKEFILE "\t$TOOL/make_rtsk $TEST 31\n";
		  }
	    print MAKEFILE "\t$RSPSIM/rsp -n $TEST.rtsk> $TEST.simlog \n";
	    print MAKEFILE "\n";
	    print MAKEFILE "\$(TARGET1): $TESTNAME_FULL\n";
	    print MAKEFILE "\tcp $TESTNAME_FULL $TEST.$FILE_TYPE\n";
	    print MAKEFILE "\tchmod +w $TEST.$FILE_TYPE\n";
            print MAKEFILE "\n";
            print MAKEFILE "\suregre.h: $SUREGRES/csrc/suregre.h \n";
            print MAKEFILE "\tcp $SUREGRES/csrc/suregre.h suregre.h\n";
            print MAKEFILE "\tchmod +w suregre.h\n";
            print MAKEFILE "\n";
            print MAKEFILE "\VU_AVP.h: $VUREGRES/src/include/VU_AVP.h \n";
            print MAKEFILE "\tcp $VUREGRES/src/include/VU_AVP.h VU_AVP.h\n";
            print MAKEFILE "\tchmod +w VU_AVP.h\n";
	    close(MAKEFILE);
		
            if (system("make")==0) {
		$CMPSTR = "";
		if (-r $TEST.".simlog") {
		  if ($TEST_TYPE eq "SU") {
		      $CMPSTR = `grep "r1 = " $TEST.simlog`;
		      chop($CMPSTR);
		      if ($CMPSTR =~ /0xfeed0000/) {
			 print LOG "($TEST_TYPE test) $TEST.$FILE_TYPE passed\n"; 
			}
		      else {
			 print LOG "($TEST_TYPE test) $TEST.$FILE_TYPE .......failed ($CMPSTR) \n"; 
			}
		   }
		  elsif ($TEST_TYPE eq "VU") {
		      $CMPSTR = `grep "r31 = " $TEST.simlog`;
		      chop($CMPSTR);
		      if ($CMPSTR =~ /0xfeed0000/) {
			 print LOG "($TEST_TYPE test) $TEST.$FILE_TYPE passed\n"; 
			}
		      else {
			 print LOG "($TEST_TYPE test) $TEST.$FILE_TYPE .......failed($CMPSTR)\n"; 
			}
		   }
		 }

	       }
	    else {
	       print "\n\n****ERROR:asm steps: test skipped\n\n";
	       print TESTSKIPPED "($TEST_TYPE test) $TEST.$FILE_TYPE skipped due to Error\n";
	       }
	 } #if (-r $TESTNAME_FULL)
	

	chdir ($WORKDIR) || die "Cant go to parent \n";


      }
  } #while

close(TESTSKIPPED);
close(LOG);
if (-z $WORKDIR."/tests.skipped") {
   system("rm $WORKDIR/tests.skipped")==0 || die "System Interrupt";
   }