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

printf "PALLADIUM INTEGRATION TEST STATUS: %s\n" "$( date )"
printf "\n"
printf "No Testcase Name         Tester            Status\n"
printf "-- --------------------- ----------------- ---------------------\n"

awk -F':' -v date="$(date)" '
    BEGIN\
    {
        t = 0; # Test Number
        passed = 0; # Tests passed.
        na = 0; # Tests that are NOT APPLICABLE.
    }
    $1 ~ "^TESTCASE"\
    {
        t = t + 1;
        posTESTCASE = index( $0, "TESTCASE:" );
        posSTATUS   = index( $0, "STATUS:"   );
        posNAME     = index( $0, "NAME:"     );

        testcase[t] = substr( $0, posTESTCASE+9, posSTATUS-posTESTCASE-9 );
        split( testcase[t], a, " " );  testcase[t] = a[1];
        split( testcase[t], a, "\t" ); testcase[t] = a[1];

        status[t] = substr( $0, posSTATUS+7, posNAME-posSTATUS-7 );
        if ( status[t] ~ "[Pp]ass" ) passed = passed + 1;
        if ( status[t] ~ "NA@HP" ) na = na + 1;
        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++ ) 
        {
            printf( "%2d %-21s %-17s %s\n",
	        i, testcase[i], name[i], status[i] );
        }
        printf("\nNote: NA@HP = Not Applicable at HP\n\n");
        printf("+-------------------------------------------\n");
        printf("| PALLADIUM INTEGRATION TEST STATUS SUMMARY\n", t );
        printf("| %3.0f%%  (%d of %d) passed.\n",
                        passed/(t-na)*100,passed,t-na);
        printf("+-------------------------------------------\n");
    }
' <$dataF




