parsesuite 3.14 KB
#!/bin/perl

require "getopts.pl";

&Getopts('c:b:n:');
if ($opt_c)
{
    $CurrentGroup = $opt_c;
}
else
{
    $CurrentGroup = 1;
}

if ($opt_b)
{
    $BaseName = $opt_b;
}
else
{
    $BaseName = "gng";
}
if ($opt_n)
{
    $NUMFILESPERBLOCK = $opt_n;
}
else
{
    $NUMFILESPERBLOCK = 4;
}


open(TESTSUITE, "testsuite");
while(<TESTSUITE>)
{
    chop;
    if (/^SU/ || /^VU/)
    {
	s#^.*/##;

	$TestList[$TestNumber++] = $_;
    }
}

sub PrintWrapper
{
    printf("%s \n", "#"x80);
    printf("$BaseName$GroupNumber.vec: \$(ATTESTDIR)/$BaseName$GroupNumber.vec \n");
    printf(" \n");
    printf("\$(ATTESTDIR)/$BaseName$GroupNumber.vec: \$(BINDIR)/reality_rsp_regression \$(TESTDIR)/rsp_tests.list \\\n");

    for ($j = 0; $j < $NumSamples; $j++)
    {
	printf("	$Sample[$j] \\\n");
    }

    printf("	- cd \$(TESTDIR); \\\n");
    printf("	\$(BINDIR)/reality_rsp_regression -nocompile +rcp_attest_tab +attest_name=$BaseName$GroupNumber.vec \\\n");

    for ($j = 0; $j < $NumSamples; $j++)
    {    
	printf("	+diag=$Sample[$j] %s\n",
	$j  == $NumSamples - 1 ? "" : "\\");
    }

    printf("	sleep 200 \n");
    printf("	mv \$(TESTDIR)/$BaseName$GroupNumber.vec \$(ATTESTDIR)/$BaseName$GroupNumber.vec  \n");
    printf("	mv \$(TESTDIR)/,out \$(TESTDIR)/$BaseName$GroupNumber.out \n");
    printf("	mv \$(TESTDIR)/regression.log \$(TESTDIR)/$BaseName$GroupNumber.regression.log \n");
    printf(" \n");
    printf("$BaseName$GroupNumber.hp: \$(HPDIR)/$BaseName$GroupNumber.slf.Z  \n");
    printf(" \n");
    printf("\$(HPDIR)/$BaseName$GroupNumber.slf.Z: \$(TESTDPDS) ");

    for ($j = 0; $j < $NumSamples; $j++)
    {
	printf("$Sample[$j] ");
    }
    printf("\n");

    printf("	echo \"");
    for ($j = 0; $j < $NumSamples; $j++)
    {
	printf("+diag=$Sample[$j]");
    }
    printf("\" > $BaseName$GroupNumber.input \n");
    printf("	- rm -f \$(ROOT)/PR/hw2/chip/vector/rsp/$BaseName$GroupNumber.input \n");
    printf("	ln -s `pwd`/$BaseName$GroupNumber.input \$(ROOT)/PR/hw2/chip/vector/rsp \n");    
    printf("	\$(NHPEXECS:LIST=$BaseName$GroupNumber.input) \n");

    printf(" \n");    
}

printf("########################################################### \n");
printf("# \n");
printf("#  rules for extracting vectors from reality_rsp_regression \n");
printf("# \n");
printf("########################################################### \n");
printf(" \n");
printf("include ../rsprules \n");
printf(" \n");
printf("#################################################################################### \n");
printf("# Targets for generation of Fault Grading Vector files \n");
printf("#################################################################################### \n");
printf(" \n");

for ($i=0; $i < $TestNumber; $i+=$NUMFILESPERBLOCK)
{

    for ($j=0 ; $j<$NUMFILESPERBLOCK; $j++)
	{
	   $Sample[$j] = $TestList[$i+$j];
	}	

    if ($i+$NUMFILESPERBLOCK <= $TestNumber-1)
    {
	$NumSamples = $NUMFILESPERBLOCK;
    }
    else
    {
	$NumSamples = $TestNumber - $i;
    }

    $GroupNumber = sprintf("%.2d", $CurrentGroup++);

    &PrintWrapper();
}

printf("\n\n");
printf("default:\t");
for ($i=1; $i <= $GroupNumber; $i++)
{
    printf("$BaseName%.2d.hp ", $i);
}
printf("\n\n\n");