Esempio n. 1
0
int main(int argc, char** argv)
{
	// parse command line BEFORE InitGoogleTest
	bool useTersePrinter = true;	// ALWAYS true (for testing only)
	bool useTerseOutput = false;	// option for terse (true) or all (false)
	bool useColor = true;
	bool noClose = false;
	for (int i = 1; i < argc; i++)
	{
		if (strcmp(argv[i], "--terse_output") == 0 )
			useTerseOutput = true;
		else if (strcmp(argv[i], "--no_close") == 0 )
			noClose = true;
		else if (strcmp(argv[i], "--gtest_color=no") == 0 )
			useColor = false;
	}

	// do this after parsing the command line but before changing printer
	testing::InitGoogleTest(&argc, argv);

	// change to TersePrinter
	if (useTersePrinter)
	{
		UnitTest& unit_test = *UnitTest::GetInstance();
		TestEventListeners& listeners = unit_test.listeners();
		delete listeners.Release(listeners.default_result_printer());
		listeners.Append(new TersePrinter(useTerseOutput, useColor));
	}

	// run the tests
	int retval = RUN_ALL_TESTS();
	// Verify that all tests were run. This can occur if a source file
	// is missing from the project. The UnitTest reflection API in
	// example 9 will not work here because of user modifications.
	// Change the following value to the number of tests (within 20).
	if (useTersePrinter)
		TersePrinter::PrintTestTotals(260, __FILE__, __LINE__);
	else
		ColoredPrintf(COLOR_YELLOW, "\n* USING DEFAULT GTEST PRINTER *\n\n");
#ifdef __WIN32
	printf("%c", '\n');
#endif
	if (noClose)			// command line option
		SystemPause();

	return retval;
}
Esempio n. 2
0
void workFunctionDiagnostic(MODEL_TYPE modelType)
{
    std::string sFinalResult;

    if( TEST_BIT( nFunctionSelect, TIMER_16BIT_TEST))
    {
        SixteenBitTimerTest timerTest;
        timerTest.diagnostic();

        sFinalResult.append(timerTest.getResultString());
    }

    if( TEST_BIT(nFunctionSelect,  RANDOM_GEN_TEST))
    {
        RandomGeneratorTest randomTest;
        randomTest.diagnostic();

        sFinalResult.append(randomTest.getResultString());
    }


    if( TEST_BIT(nFunctionSelect,  CCTALK_TEST))
    {
        CCTalkTest ccTalkTest(modelType);
        ccTalkTest.diagnostic();

        sFinalResult.append(ccTalkTest.getResultString());
    }


    if( TEST_BIT(nFunctionSelect,  SAS_TEST))
    {
        SASTest sasTest;
        sasTest.diagnostic();


        sFinalResult.append(sasTest.getResultString());
    }

    if( TEST_BIT(nFunctionSelect,  SRAM_TEST))
    {
        //SRAMTest sramTest;
        //sramTest.diagnostic();

        //sFinalResult.append(sramTest.getResultString());
    }

    if( TEST_BIT(nFunctionSelect,  EEPROM_TEST))
    {
        EEPROMTest eepromTest(modelType);
        eepromTest.diagnostic();

        sFinalResult.append(eepromTest.getResultString());
    }


    if( TEST_BIT(nFunctionSelect,  GPO_TEST))
    {
        GPOTest gpoTest;
        gpoTest.diagnostic();

        sFinalResult.append(gpoTest.getResultString());
    }


    if( TEST_BIT(nFunctionSelect,  GPI_TEST))
    {
        GPITest gpiTest;
        gpiTest.diagnostic();

        sFinalResult.append(gpiTest.getResultString());
    }

    if( TEST_BIT(nFunctionSelect,  RTC_INSTURSION_TEST))
    {
        PICIntrusionTest picTest(modelType);
        picTest.diagnostic();

        sFinalResult.append(picTest.getResultString());
    }

    if( TEST_BIT(nFunctionSelect,  SPI_TEST))
    {
        SPITest spiTest;
        spiTest.diagnostic();

        sFinalResult.append(spiTest.getResultString());
    }

    ClearScreen();
    printf("Diagnostic Complete!\n\nResult:\n\n");
    printf("%s", sFinalResult.c_str());
    SystemPause();
}
Esempio n. 3
0
int test(int argc, char* argv[])
{
    string sInfo;	// show total version info
    char sAPIVer[128], sFPGADriverVer[128], sSMBusDriverVer[128], temp[64];
    int type;
    BYTE PICVer;
    FPGA_INFO fpgaInfo;
    SELECT_ACTION select_action;

#ifdef WINDOWS
    // resize console windows
    HWND console = GetConsoleWindow();

    int screenW = GetSystemMetrics(SM_CXSCREEN);
    int screenH = GetSystemMetrics(SM_CYSCREEN);

    MoveWindow(console, (screenW - 680)>>1, (screenH - 900)>>1, 800, 900, TRUE);

    // ignore Ctrl-C and Ctrl-Break signal
    signal(SIGINT, SIG_IGN);
    signal(SIGBREAK, SIG_IGN);
#endif

    // initial part

    // 1. open fpga
    FPGA_API_STATUS dwStatus = (FPGA_API_STATUS) FpgaPic_Init();

    if(dwStatus != FD_SUCCESS)
    {
        Error("main", "FpgaPic_Init", dwStatus);
        goto End;
    }

    // 2. get version
    #pragma region get version

    sInfo.assign(TEST_NAME);
    sInfo.append("\n=========================================================\n");
    sInfo.append("Detail info\n");
    sInfo.append("------------------------------\n");

    FD_GetFPGAVer(&fpgaInfo);

    type = fpgaInfo.hw_id & 0x0F;

    sprintf(temp, "Model : %s\n------------------------------\n",
            type < MAX_MODEL ? sModelName[type + 1].c_str() : sModelName[0].c_str());

    eModel = type < MAX_MODEL ? (MODEL_TYPE)type : UNKNOWN_MODEL;

    sInfo.append(temp);

    FD_GetAPIVersion(sAPIVer);
    sInfo += sAPIVer;
    sInfo += '\n';

    sprintf(temp, "FPGA version %d.%d.%d", (int)(fpgaInfo.version >>16) & 0xFF,
            (int)(fpgaInfo.version >>8) & 0xFF, (int)fpgaInfo.version & 0xFF);

    sInfo.append(temp);

    if(fpgaInfo.type == 0)
        sInfo.append(" standard\n");
    else
    {
        sprintf(temp, " customize %d\n", fpgaInfo.type);
        sInfo.append(temp);
    }

    FD_GetDriverVersion(sFPGADriverVer);
    sInfo += sFPGADriverVer;
    sInfo += '\n';

    FD_PIC_KernelVersion(sSMBusDriverVer);
    sInfo += sSMBusDriverVer;
    sInfo += '\n';

    PIC_GetVersion(&PICVer);

    sprintf(temp, "PIC version %d\n", PICVer);
    sInfo += temp;

    sInfo.append("------------------------------");

    #pragma endregion

    do
    {
        // 3. choice test operation selection
        #pragma region show menu of function selection

        select_action = TEST;
        select_action = TestSelectionMenu(sInfo, eTest_flow);

        if(eTest_flow == NONE)
        {
            printf("\nTo many times of input errors. Program will exit..\n");
            goto End;
        }
        else if(select_action == STOP)
        {
            break;
        }

        switch(eTest_flow)
        {
        case ALL_FUNCTION:
            nFunctionSelect = MAX_FUNCTION_VALUE;
            break;
        case SINGLE_FUNCTION:
            select_action = SingleFunctionMenu();
            break;
        case MULITI_FUNCTION:
            select_action = MultiFunctionMenu();
            break;
        }

        if(select_action == BACK)
        {
            fflush(stdin);
            continue;
        }
        else if(select_action == STOP)
        {
            break;
        }

        ClearScreen();
        printf("Test following function:\n\n");
        for(int i = TIMER_16BIT_TEST; i < MAX_TEST_FUNCTION_NUM ; i++)
        {
            if(eTest_flow == ALL_FUNCTION || (nFunctionSelect & 1<<i))
                printf("%s\n", sTestFunctionName[i].c_str());
        }

        #pragma endregion

        // 4. do test
#ifdef WINDOWS
        // disable close button, all testing finish will close window
        RemoveMenu(GetSystemMenu(console,FALSE), SC_CLOSE, MF_GRAYED);
        RemoveMenu(GetSystemMenu(console,FALSE), SC_MAXIMIZE, MF_GRAYED);
        DrawMenuBar(console);
#endif

        workFunctionDiagnostic(eModel);

    }
    while(1);

End:

    // 5. end and close
    dwStatus = (FPGA_API_STATUS) FpgaPic_Close();

    if(dwStatus != FD_SUCCESS)
    {
        printf("\nClose FPGA fail\n");
    }
    else
    {
        printf("\n");
    }

    SystemPause();

    return 0;
}