Ejemplo n.º 1
0
void DisplayStatistics(const RECT& rect, const Stats& stats, HDC& hdc) {
	int xpos = rect.left + 1;
	int ypos = rect.top + 1;
	DisplayElapsedTime(stats.ElapsedTransferTime(), hdc, xpos, ypos);
	DisplaySendProtocolEfficiency(stats.SendProtocolEfficiency(), hdc, xpos, ypos);
	DisplayReceiveProtocolEfficiency(stats.ReceiveProtocolEfficiency(), hdc, xpos, ypos);
	DisplayEffectiveSendBPS(stats.EffectiveSendBPS(), hdc, xpos, ypos);
	DisplayEffectiveReceiveBPS(stats.EffectiveReceiveBPS(), hdc, xpos, ypos);
	DisplayNumPacketsSent(stats.NumPacketsSent(), hdc, xpos, ypos);
	DisplayBitErrorRate(stats.BitErrorRate(), hdc, xpos, ypos);
	//DisplayNumACKs(stats.NumACKs(), hdc, xpos, ypos);
	//DisplayNumNAKs(stats.NumNAKs(), hdc, xpos, ypos);
	DisplayTotalBitsSent(stats.TotalBitsSent(), hdc, xpos, ypos);
	DisplayTotalBitsReceived(stats.TotalBitsReceived(), hdc, xpos, ypos);
	DisplayResponseTime(stats.ResponseTime(), hdc, xpos, ypos);
	DisplayTotalTimeouts(stats.TotalTimeouts(), hdc, xpos, ypos);
	DisplayTotalRequests(stats.TotalRequests(), hdc, xpos, ypos);
	DisplayAverageSendPadding(stats.AverageSendPadding(), hdc, xpos, ypos);
	DisplayAverageReceivePadding(stats.AverageReceivePadding(), hdc, xpos, ypos);
	DisplayPacketsSentPerSecond(stats.PacketsSentPerSecond(), hdc, xpos, ypos);
	DisplayPacketsReceivedPerSecond(stats.PacketsReceivedPerSecond(), hdc, xpos, ypos);
}
Ejemplo n.º 2
0
int main( int argc, char* argv[] )
{
    DisplayCopyrightNotice();

    std::string configFile = "hh.cfg";
    std::string batchBuildId = "";

    CTimeSpan totalTimeSpan;

    enum RunOption
    {
        ApproveUnitTest,
        ExecuteUnitTests,
        ExecuteUnitTestsInBatchBuildMode,
        GenerateConfigFile,
        ViewUnitTestFailures,
        EditUnitTest
    };

    RunOption runOption = ExecuteUnitTests;
    bool verbose = false;

    try
    {
        for ( ;; )
        {
            int c = getopt( argc, argv, "ac:b:gefv?" );
            if (c == -1)
            {
                break;
            }
     
            switch ( c )
            {
                case 'a':
                    runOption = ApproveUnitTest;
                    break;

                case 'c':
                    configFile = optarg;
                    break;

                case 'b':
                    runOption = ExecuteUnitTestsInBatchBuildMode;
                    batchBuildId = optarg;
                    break;

                case 'g':
                    runOption = GenerateConfigFile;
                    break;

                case 'e':
                    runOption = EditUnitTest;
                    break;

                case 'f':
                    runOption = ViewUnitTestFailures;
                    break;

                case 'v':
                    verbose = true;
                    break;

                case '?':
                    DisplayUsage( argv[0] );
                    return RESULT_SUCCESS;
            }
        }
    }
    catch ( HH_CommandLineError& ex )
    {
        std::cout << ex.AsString() << std::endl;
        std::cout << std::endl;
        DisplayUsage( argv[0] );
        return RESULT_ERROR;
    }

    try
    {
        HH_CommandLineNotifier  commandLineNotifier( verbose );

        switch( runOption )
        {
        case ExecuteUnitTests:
            {
                HH_Runtime  runtime( GetIniFile( verbose ), configFile, commandLineNotifier );
                DisplayParameters( runtime, verbose );
                totalTimeSpan = runtime.ExecuteUnitTest( batchBuildId );
                DisplayElapsedTime( totalTimeSpan, verbose );
            }
            break;

        case ExecuteUnitTestsInBatchBuildMode:
            {
                HH_Runtime  runtime( GetIniFile( verbose ), configFile, commandLineNotifier );
                DisplayParameters( runtime, verbose );
                totalTimeSpan = runtime.ExecuteUnitTest( batchBuildId );
                DisplayElapsedTime( totalTimeSpan, verbose );
            }
            break;

        case ApproveUnitTest:
            {
                HH_Runtime  runtime( GetIniFile( verbose ), configFile, commandLineNotifier );
                DisplayParameters( runtime, verbose );
                runtime.ApproveUnitTest();
            }
            break;

        case GenerateConfigFile:
            HH_Runtime::GenerateConfigFile( commandLineNotifier );
            break;

        case ViewUnitTestFailures:
            {
                HH_Runtime  runtime( GetIniFile( verbose ), configFile, commandLineNotifier );
                DisplayParameters( runtime, verbose );
                runtime.ViewUnitTestFailures();
            }
            break;

        case EditUnitTest:
            {
                HH_Runtime  runtime( GetIniFile( verbose ), configFile, commandLineNotifier );
                DisplayParameters( runtime, verbose );
                runtime.EditDotInFile();
            }
            break;
        }
    }
    catch ( HH_Exception& ex )
    {
        HH_UnitTest::LogException( ex );
        DisplayElapsedTime( totalTimeSpan, verbose );
        return RESULT_ERROR;
    }

    return RESULT_SUCCESS;
}