#! /usr/bin/ksh
#--------------------------------------------------------------------------
# Summarize the Unit Test status.
#
# Usage: TestsSummary
#
# $Header: TestsSummary,v 78.1 96/01/03 16:17:44 ssa Exp $
#--------------------------------------------------------------------------
typeset dataF=/pd/$LOGNAME/doc/Tests

printf "PALLADIUM UNIT TEST STATUS: %s\n" "$( date )"
printf "                             IBM     Drop2   Drop4\n"

awk -F':' -v date="$(date)" '
    BEGIN\
    {
        t = 0; # Test Number
    }
    $1 ~ "^UNIT"\
    {
        t = t + 1;
        posUNIT = index( $0, "UNIT:"      )
        posIBM  = index( $0, "IBM:"       )
        posD2   = index( $0, "D2-STATUS:" )
        posD4   = index( $0, "D4-STATUS:" )
        posNAME = index( $0, "NAME:"      )

        unit[ t ] = substr( $0, posUNIT+ 5, posIBM  -posUNIT- 5 )
        split( unit[t], a, " " );  unit[t]=a[1]
        split( unit[t], a, "\t" ); unit[t]=a[1]

        ibm [ t ] = substr( $0, posIBM + 4, posD2   -posIBM - 3 )
        d2  [ t ] = substr( $0, posD2  +10, posD4   -posD2  -10 )
        d4  [ t ] = substr( $0, posD4  +10, posNAME -posD4  -10 )

        name[ t ] = substr( $0, posNAME+5 )
        split( name[t], a, " " );  name[t]=a[1]
        split( name[t], a, "\t" ); name[t]=a[1]

        if ( length( name[ t ] ) == 0 ) name[ t ] = "?";
    }
    END\
    {
        for ( i = 1; i <= t; i++ )
        {
            IB="";
            c=" "; if (ibm[i]~"build"||ibm[i]~"compiles")c="C"; IB=IB c;
            c=" "; if (ibm[i]~"exe"                    )c="L"; IB=IB c;
            c=" "; if (ibm[i]~"leak"                   )c="M"; IB=IB c;
            c=" "; if (ibm[i]~"core"                   )c="D"; IB=IB c;
            c=" "; if (ibm[i]~"pass"                   )c="P"; IB=IB c;
            if ( IB ~ "P" || D2 ~ "D" ) sub("^..","CL",IB)
            if ( IB ~ "L" ) sub("^.","C",IB)
            if ( IB ~ "C" ) CI=CI+1;
            if ( IB ~ "L" ) L4=LI+1;
            if ( IB ~ "M" ) M4=MI+1;
            if ( IB ~ "D" ) cI=cI+1;
            if ( IB ~ "P" ) PI=PI+1;
            D2="";
            c=" "; if (d2[i]~"build"||d2[i]~"compiles")c="C"; D2=D2 c;
            c=" "; if (d2[i]~"exe"                    )c="L"; D2=D2 c;
            c=" "; if (d2[i]~"leak"                   )c="M"; D2=D2 c;
            c=" "; if (d2[i]~"core"                   )c="D"; D2=D2 c;
            c=" "; if (d2[i]~"pass"                   )c="P"; D2=D2 c;
            if ( D2 ~ "P" || D2 ~ "D" ) sub("^..","CL",D2)
            if ( D2 ~ "L" ) sub("^.","C",D2)
            if ( D2 ~ "C" ) C2=C2+1;
            if ( D2 ~ "L" ) L2=L2+1;
            if ( D2 ~ "M" ) M2=M2+1;
            if ( D2 ~ "D" ) c2=c2+1;
            if ( D2 ~ "P" ) P2=P2+1;
            D4="";
            c=" "; if (d4[i]~"build"||d4[i]~"compiles")c="C"; D4=D4 c;
            c=" "; if (d4[i]~"exe"                    )c="L"; D4=D4 c;
            c=" "; if (d4[i]~"leak"                   )c="M"; D4=D4 c;
            c=" "; if (d4[i]~"core"                   )c="D"; D4=D4 c;
            c=" "; if (d4[i]~"pass"                   )c="P"; D4=D4 c;
            if ( D4 ~ "P" || D2 ~ "D" ) sub("^..","CL",D4)
            if ( D4 ~ "L" ) sub("^.","C",D4)
            if ( D4 ~ "C" ) C4=C4+1;
            if ( D4 ~ "L" ) L4=L4+1;
            if ( D4 ~ "M" ) M4=M4+1;
            if ( D4 ~ "D" ) c4=c4+1;
            if ( D4 ~ "P" ) P4=P4+1;
            printf( "%-9s %-17s [%s] [%s] [%s]\n",unit[i],name[i],IB,D2,D4);
        }
        printf "NOTE: (C)ompile, (L)ink, (M)em leak, core (D)ump, (P)ass\n"
        printf("+-------------------------------------------\n");
        printf("| PALLADIUM UNIT TEST STATUS SUMMARY\n", t );
        printf("|            IBM     Drop-2   Drop-4\n");
        printf("| Compile %3d %3.0f%% %3d %3.0f%% %3d %3.0f%%\n",CI,CI/t*100,C2,C2/t*100,C4,C4/t*100);
        printf("| Link    %3d %3.0f%% %3d %3.0f%% %3d %3.0f%%\n",LI,LI/t*100,L2,L2/t*100,L4,L4/t*100);
        printf("| Leak    %3d %3.0f%% %3d %3.0f%% %3d %3.0f%%\n",MI,MI/t/100,M2,M2/t*100,M4,M4/t*100);
        printf("| Core    %3d %3.0f%% %3d %3.0f%% %3d %3.0f%%\n",cI,cI/t*100,c2,c2/t*100,c4,c4/t*100);
        printf("| Pass    %3d %3.0f%% %3d %3.0f%% %3d %3.0f%%\n",PI,PI/t*100,P2,P2/t*100,P4,P4/t*100);
        printf("| TOTAL   %3d\n",t);
        printf("+-------------------------------------------\n");
    }
' <$dataF




