示例#1
0
void tipcTestServer(void)
{
	int test;	    /* this is the test passed from the Test Client process */
	int testIndex;	/* this is the index used to find the actual test we want to run*/
	int ntimes;	/* this is the number of times a test will be run */

	int res;	/* the return code from the recv() */
	int msgSize;	/* the size of the message */

	int sockfd_S;	/* the socket used to receive the test from the client */
	struct sockaddr_tipc addr; /* the TIPC address data structure */
	struct sockaddr_tipc from; /* the address data structure for the client */
	struct sockaddr_tipc self; /* the TIPC address data structure */
	socklen_t fromLen = sizeof(struct sockaddr_tipc); /* the length of the return address */
	socklen_t selfLen = sizeof(struct sockaddr_tipc); /* the length of the return address */
	__u32 domain;
	__u32 client_domain;

	debug("Starting Server\n");

	setServerAddr (&addr);
	msgSize = sizeof(test);

	while (1) {
		fflush (stdout);
		ntimes = TS_NUMTIMES;

		/* Get test identifier from client */

		sockfd_S = createSocketTIPC (SOCK_RDM);
		bindSocketTIPC (sockfd_S, &addr);
		sendSyncTIPC (TS_SYNC_WAITING_FOR_TEST_ID);
		res = recvfrom (sockfd_S, (char *)&test, msgSize, 0, (struct sockaddr *) &from, &fromLen);
		if (res > 0)
			test = (int)ntohl(test);
		else
			test = TS_INVALID_TEST;

		if (getsockname (sockfd_S, (struct sockaddr *) &self, &selfLen) != 0)
			failTest ("getsockname() error");
		domain = self.addr.id.node;
		client_domain= from.addr.id.node;
		client_in_same_cluster =
		        ((tipc_zone(domain) == tipc_zone(client_domain))
		         && (tipc_cluster(domain) == tipc_cluster(client_domain)));

		closeSocketTIPC (sockfd_S);

		/* Validate test identifier */

		if (test == TS_KILL_SERVER) {
			break;
		}
		if ((test >= ts_lastStressTest)
		                || ((test >= ts_lastSanityTest) && (test <TS_FIRST_STRESS_TEST))) {
			printf("TIPC Server: Invalid test number (%d)\n", test);
			killme(1);
		}

		/* Run the specified test */

		info("Server says test # %d\n", test);

		recvSyncTIPC (TS_SYNC_FINISHED_TEST_ID);

		for (testIndex = 0; testIndex <= TS_NUMBER_OF_TESTS; testIndex++) {
			if (serverList[testIndex].testNum == test)
				do {
					info("TIPC Server %s test...STARTED!\n",testName(test));
					serverList[testIndex].test();
					info("TIPC Server %s test...PASSED!\n\n",testName(test));
				} while ( --ntimes > 0 );
		}
	}

	printf("TIPC Server: Client told us to quit\n");
}
void NodeChildrenMainScene::updateProfilerName()
{
    snprintf(_profilerName, sizeof(_profilerName)-1, "%s(%d)", testName(), quantityOfNodes);
}
示例#3
0
void CTestTreeView::OnOpenTLS()
{

	CFileDialog   OpenTlsDlg(TRUE,NULL, NULL,OFN_HIDEREADONLY, _T("Test List File(*.mas)|*.mas"));//open   as 
	CString defPath;
	
	defPath.Format(_T("%smastertls\\"),CMConfigCenter::GetConfigCenter().GetLocalPath().c_str());
	OpenTlsDlg.m_ofn.lpstrInitialDir=defPath;

	if(OpenTlsDlg.DoModal()==IDOK) 
	{ 
		m_wndTestTreeView.DeleteAllItems();
		//FillTestTreeView(OpenTlsDlg.GetPathName());
	
	// 	CFileDialog   dlg(FALSE,NULL, "MyOrl.orl ",OFN_OVERWRITEPROMPT, "(*.orl)|*.orl| ");//save   as 
	// 	dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY, "AVI   files(*.avi)|*.avi| ")//open

		wstring tmp(OpenTlsDlg.GetPathName());
		string fileName= ws2s(tmp);
		m_TestTreeList.Init(fileName.c_str());

		HTREEITEM hRoot = m_wndTestTreeView.InsertItem(_T("Root"), 0, 0);
		HTREEITEM hCommon = m_wndTestTreeView.InsertItem(_T("Common"), 0, 0, hRoot);

		//HTREEITEM hTest = m_wndFileView.InsertItem(_T("Test"), 0, 0,hRoot);

		std::list<CTlsData*>* testData = m_TestTreeList.GetTestList();

		for (list<CTlsData*>::iterator testIt=testData->begin();testIt!=testData->end();testIt++)
		{
			switch ((*testIt)->GetType())
			{
			case COMMON:
				{
					STLSDATA_COMMON* pCommon = (*testIt)->GetDataCommon();
					CString commName (pCommon->commname.c_str());
					m_wndTestTreeView.SetItemText(hCommon,commName);
					m_wndTestTreeView.SetItemData(hCommon,(DWORD_PTR)(*testIt));
					break;
				}
			case SUBTEST:
				{
					if (!hCurrentTest)
					{
						break;
					}
					STLSDATA_SUBTEST* pSubTest = (*testIt)->GetDataSubtest();
					CString testName(pSubTest->subTestName.c_str());
					HTREEITEM hSubTest = m_wndTestTreeView.InsertItem(testName, 0, 0,hCurrentTest);
					m_wndTestTreeView.SetItemData(hSubTest,(DWORD_PTR)(*testIt));
					break;
				}
			case TEST:
				{
					STLSDATA_TEST* pTest = (*testIt)->GetDataTest();
					CString testName(pTest->testName.c_str());
					HTREEITEM hTest = m_wndTestTreeView.InsertItem(testName, 0, 0,hRoot);
					hCurrentTest = hTest;
					m_wndTestTreeView.SetItemData(hTest,(DWORD_PTR)(*testIt));
					break;
				}
			case ROOT:
				{
					STLSDATA_ROOT* pRoot = (*testIt)->GetDataRoot();
					CString rootName(pRoot->name.c_str());				
					m_wndTestTreeView.SetItemText(hRoot,rootName);
					m_wndTestTreeView.SetItemData(hRoot,(DWORD_PTR)(*testIt));
					break;
				}
			}

			m_wndTestTreeView.SetItemState(hRoot, TVIS_BOLD, TVIS_BOLD);

			m_wndTestTreeView.Expand(hRoot, TVE_EXPAND);
		}
		m_wndTestTreeView.Expand(hRoot, TVE_EXPAND);



	}
	OpenTlsDlg.DestroyWindow();


}
示例#4
0
string
Test::runSingleYearTest(TestResults& tResults)
{
    LOG_INFO << "\n --- Running runSingelYearTest() ---\n";
    string testName("Test-Single year 10K retrieval: ");

    T_Stock ts;
    O_Stock stock = ts.select( ts._ticker() == string("IBM")).front();
    T_Ep te;

    tResults.setStockTickerName( stock._ticker() );
    // extract to DB
    string filing = getMockFromDisk("IBM_2013_10k");
    if ( filing == "")
    {
        tResults.addFailure(testName + "Could not load mock 10k for testing");
        return tResults.getResultsSummary();
    }

    // Hard code 2013 to be used in all stocks in test
    int year = 2013;

    EdgarData edgar;
    edgar.extract10kToDisk( filing, stock, year);

    //Test results writen to DB
    if (te.select( te._stock_id() == stock._id() 
                   && te._quarter() == 0 ).empty())
    {
        tResults.addFailure(testName + "No record was added to DB");       
        return tResults.getResultsSummary();
    }
    O_Ep ibm2013 = te.select( te._stock_id() == stock._id() 
                              && te._quarter() == 0 ).front();

    if (ibm2013._year() != 2013)
        tResults.addFailure(testName + "Year should be: 2013, but is: "
                            + to_string(ibm2013._year()) );
    if (ibm2013._quarter() != 0)
        tResults.addFailure(testName + "Quarter (for 10k)  should be: 0, but is: " + to_string(ibm2013._quarter()) );

    if (ibm2013._revenue() != "99751000000")
        tResults.addFailure(testName + "Revenue should be: 99751000000, but is: " + ibm2013._revenue() );

    if (ibm2013._net_income() != "16483000000")   
        tResults.addFailure(testName + "Net Income should be: 16483000000, but is: " + ibm2013._net_income() );

    if (ibm2013._eps() != 14.94)   
        tResults.addFailure(testName + "(diluted) Eps should be: 14.94, but is: " + to_string(ibm2013._eps()) );

    if (ibm2013._shares() != "1103042156")   
        tResults.addFailure(testName + "Number of (diluted) shares should be: 1103042156, but is: " + ibm2013._shares() );
  
    // test clean up
    te.erase( te._id() == ibm2013._id());

    //BALANCE extraction test
    T_BalanceSheet tb;
    string balanceTestName = "BalanceTest";
    O_BalanceSheet b_ibm2013 = tb.select( tb._stock_id() == stock._id()
                              && tb._year() == year ).front();

    if (b_ibm2013._year() != 2013)
        tResults.addFailure(balanceTestName + "Year should be: 2013, but is: "
                            + to_string(b_ibm2013._year()) );

    if (b_ibm2013._current_assets() != "51350000000")
        tResults.addFailure(balanceTestName + "CA should be: 51350000000, but is: " + b_ibm2013._current_assets() );
    if (b_ibm2013._total_assets() != "126223000000")
        tResults.addFailure(balanceTestName + "TA should be: 126223000000, but is: " + b_ibm2013._total_assets() );
    if (b_ibm2013._current_liabilities() != "40154000000")
        tResults.addFailure(balanceTestName + "CL should be: 40154000000, but is: " + b_ibm2013._current_liabilities() );
    if (b_ibm2013._total_liabilities() != "103294000000")
        tResults.addFailure(balanceTestName + "TA should be: 103294000000, but is: " + b_ibm2013._total_liabilities() );
    if (b_ibm2013._long_term_debt() != "32856000000")
        tResults.addFailure(balanceTestName + "LTD should be: 32856000000, but is: " + b_ibm2013._long_term_debt() );
    if (stock._has_currant_ratio() != true)
        tResults.addFailure(balanceTestName + "Should Have current ratio. but is set to FALSE" );
   // if (b_ibm2013._book_value() != "99751000000")
     //   tResults.addFailure(balanceTestName + "Calculated Book value should be: 99751000000, but is: "
       //                     + b_ibm2013._book_value() );
    // test clean up
    tb.erase( tb._id() == b_ibm2013._id());

    // CVX
    stock = ts.select( ts._ticker() == string("CVX")).front();
    tResults.setStockTickerName( stock._ticker() );
    // extract to DB
    filing = getMockFromDisk("CVX_2013_10k.txt");
    if ( filing == ""){
        tResults.addFailure(testName + "Could not load mock 10k for testing");
        return tResults.getResultsSummary();
    }

    edgar.extract10kToDisk( filing, stock, year);

    //Test results writen to DB
    if (te.select( te._stock_id() == stock._id() 
                   && te._quarter() == 0 ).empty())
    {
        tResults.addFailure(testName + "No record was added to DB");       
        return tResults.getResultsSummary();
    }
    O_Ep cvx2013 = te.select( te._stock_id() == stock._id() 
                              && te._quarter() == 0 ).front();

    if (cvx2013._year() != year)
        tResults.addFailure(testName + "Year should be: 2013, but is: "
                            + to_string(cvx2013._year()) );
    if (cvx2013._quarter() != 0)
        tResults.addFailure(testName + "Quarter (for 10k)  should be: 0, but is: " + to_string(cvx2013._quarter()) );

    if (cvx2013._revenue() != "228848000000")
        tResults.addFailure(testName + "Revenue should be: 228848000000, but is: " + cvx2013._revenue() );

    if (cvx2013._net_income() != "21423000000")   
        tResults.addFailure(testName + "Net Income should be: 21423000000, but is: " + cvx2013._net_income() );

    if (cvx2013._eps() != 11.09)   
        tResults.addFailure(testName + "(diluted) Eps should be: 11.09, but is: " + to_string(cvx2013._eps()) );

//    if (cvx2013._shares() != "1103042156")   
    //      tResults.addFailure(testName + "Number of shares should be: 1103042156, but is: " + cvx2013._shares() );
  
    // test clean up
    te.erase( te._id() == cvx2013._id());

    //BALANCE extraction test
    O_BalanceSheet b_cvx2013 = tb.select( tb._stock_id() == stock._id()
                              && tb._year() == year ).front();
    if (b_cvx2013._year() != 2013)
        tResults.addFailure(balanceTestName + "Year should be: 2013, but is: "
                            + to_string(b_cvx2013._year()) );

    if (b_cvx2013._current_assets() != "50250000000")
        tResults.addFailure(balanceTestName + "CA should be: 50250000000, but is: " + b_cvx2013._current_assets() );
    if (b_cvx2013._total_assets() != "253753000000")
        tResults.addFailure(balanceTestName + "TA should be: 253753000000, but is: " + b_cvx2013._total_assets() );
    if (b_cvx2013._current_liabilities() != "33018000000")
        tResults.addFailure(balanceTestName + "CL should be: 33018000000, but is: " + b_cvx2013._current_liabilities() );
    if (b_cvx2013._total_liabilities() != "103326000000")
        tResults.addFailure(balanceTestName + "TA should be: 103326000000, but is: " + b_cvx2013._total_liabilities() );
    if (b_cvx2013._long_term_debt() != "19960000000")
        tResults.addFailure(balanceTestName + "LTD should be: 19960000000, but is: " + b_cvx2013._long_term_debt() );
    if (stock._has_currant_ratio() != true)
        tResults.addFailure(balanceTestName + "Should Have current ratio. but is set to FALSE" );
    // test clean up
    tb.erase( tb._id() == b_cvx2013._id());

    // GOOG
    stock = ts.select( ts._ticker() == string("GOOG")).front();
    tResults.setStockTickerName( stock._ticker() );
    // extract to DB
    filing = getMockFromDisk("GOOG_2013_10k.txt");
    if ( filing == ""){
        tResults.addFailure(testName + "Could not load mock 10k for testing");
        return tResults.getResultsSummary();
    }

    edgar.extract10kToDisk( filing, stock, year);

    //Test results writen to DB
    if (te.select( te._stock_id() == stock._id() 
                   && te._quarter() == 0 ).empty())
    {
        tResults.addFailure(testName + "No record was added to DB");       
        return tResults.getResultsSummary();
    }
    O_Ep goog2013 = te.select( te._stock_id() == stock._id() 
                              && te._quarter() == 0 ).front();
    if (goog2013._year() != year)
        tResults.addFailure(testName + "Year should be: 2013, but is: "
                            + to_string(goog2013._year()) );
    if (goog2013._quarter() != 0)
        tResults.addFailure(testName + "Quarter (for 10k)  should be: 0, but is: " + to_string(goog2013._quarter()) );

    if (goog2013._revenue() != "59825000000")
        tResults.addFailure(testName + "Revenue should be: 59825000000, but is: " + goog2013._revenue() );

    if (goog2013._net_income() != "12920000000")   
        tResults.addFailure(testName + "Net Income should be: 12920000000, but is: " + goog2013._net_income() );

    if (goog2013._eps() != 38.13)   
        tResults.addFailure(testName + "(diluted) Eps should be: 38.13, but is: " + to_string(goog2013._eps()) );

//    if (goog2013._shares() != "1103042156")   
    //      tResults.addFailure(testName + "Number of shares should be: 1103042156, but is: " + goog2013._shares() );
  
    // test clean up
    te.erase( te._id() == goog2013._id());

    //BALANCE extraction test
    O_BalanceSheet b_goog2013 = tb.select( tb._stock_id() == stock._id()
                              && tb._year() == year ).front();
    if (b_goog2013._year() != 2013)
        tResults.addFailure(balanceTestName + "Year should be: 2013, but is: "
                            + to_string(b_goog2013._year()) );

    if (b_goog2013._current_assets() != "72886000000")
        tResults.addFailure(balanceTestName + " CA should be: 72886000000, but is: " + b_goog2013._current_assets() );
    if (b_goog2013._total_assets() != "110920000000")
        tResults.addFailure(balanceTestName + " TA should be: 110920000000, but is: " + b_goog2013._total_assets() );
    if (b_goog2013._current_liabilities() != "15908000000")
        tResults.addFailure(balanceTestName + " CL should be: 15908000000, but is: " + b_goog2013._current_liabilities() );
    if (b_goog2013._book_value() != "87309000000")
        tResults.addFailure(balanceTestName + " BV should be: 87309000000, but is: " + b_goog2013._book_value() );

    if (b_goog2013._total_liabilities() != "23611000000")
        tResults.addFailure(balanceTestName + " TL should be: 23611000000, but is: " + b_goog2013._total_liabilities() );
    if (b_goog2013._long_term_debt() != "2236000000")
        tResults.addFailure(balanceTestName + " LTD should be: 2236000000, but is: " + b_goog2013._long_term_debt() );
    if (stock._has_currant_ratio() != true)
        tResults.addFailure(balanceTestName + "Should Have current ratio. but is set to FALSE" );
    // test clean up
    tb.erase( tb._id() == b_goog2013._id());


    // BDX
    stock = ts.select( ts._ticker() == string("BDX")).front();
    tResults.setStockTickerName( stock._ticker() );
    // extract to DB
    filing = getMockFromDisk("BDX_2013_10k.txt");
    if ( filing == ""){
        tResults.addFailure(testName + "Could not load mock 10k for testing");
        return tResults.getResultsSummary();
    }

    edgar.extract10kToDisk( filing, stock, year);

    //Test results writen to DB
    if (te.select( te._stock_id() == stock._id() 
                   && te._quarter() == 0 ).empty())
    {
        tResults.addFailure(testName + "No record was added to DB");       
        return tResults.getResultsSummary();
    }
    O_Ep bdx2013 = te.select( te._stock_id() == stock._id() 
                               && te._quarter() == 0 ).front();
    if (bdx2013._year() != year)
        tResults.addFailure(testName + "Year should be: 2013, but is: "
                            + to_string(bdx2013._year()) );
    if (bdx2013._quarter() != 0)
        tResults.addFailure(testName + "Quarter (for 10k)  should be: 0, but is: " + to_string(bdx2013._quarter()) );

    if (bdx2013._revenue() != "8054000000")
        tResults.addFailure(testName + "Revenue should be: 8054000000, but is: " + bdx2013._revenue() );

    if (bdx2013._net_income() != "1293000000")   
        tResults.addFailure(testName + "Net Income should be: 1293000000, but is: " + bdx2013._net_income() );

    if (bdx2013._eps() != 6.49)   
        tResults.addFailure(testName + "(diluted) Eps should be: 6.49, but is: " + to_string(bdx2013._eps()) );

    if (bdx2013._shares() != "194094466")   
      tResults.addFailure(testName + "Number of shares should be: 194094466, but is: " + bdx2013._shares() );

    // test clean up
    te.erase( te._id() == bdx2013._id());

    //BALANCE extraction test
    O_BalanceSheet b_bdx2013 = tb.select( tb._stock_id() == stock._id()
                              && tb._year() == year ).front();

    if (b_bdx2013._current_assets() != "5873000000")
        tResults.addFailure(balanceTestName + " CA should be: 5873000000, but is: " + b_bdx2013._current_assets() );
    if (b_bdx2013._total_assets() != "12149000000")
        tResults.addFailure(balanceTestName + " TA should be: 12149000000, but is: " + b_bdx2013._total_assets() );
    if (b_bdx2013._current_liabilities() != "2130000000")
        tResults.addFailure(balanceTestName + " CL should be: 2130000000, but is: " + b_bdx2013._current_liabilities() );
    if (b_bdx2013._book_value() != "5043000000")
        tResults.addFailure(balanceTestName + " BV should be: 5043000000, but is: " + b_bdx2013._book_value() );

    if (b_bdx2013._total_liabilities() != "7106000000")
        tResults.addFailure(balanceTestName + "TL should be: 7106000000, but is: " + b_bdx2013._total_liabilities() );
    if (b_bdx2013._long_term_debt() != "3763000000")
        tResults.addFailure(balanceTestName + "LTD should be: 3763000000, but is: " + b_bdx2013._long_term_debt() );
    if (stock._has_currant_ratio() != true)
        tResults.addFailure(balanceTestName + "Should Have current ratio. but is set to FALSE" );
    // test clean up
    tb.erase( tb._id() == b_bdx2013._id());


    // BRK.A
    stock = ts.select( ts._ticker() == string("BRK.A")).front();
    tResults.setStockTickerName( stock._ticker() );
    // extract to DB
    filing = getMockFromDisk("BRK_2013_10k.txt");
    if ( filing == ""){
        tResults.addFailure(testName + "Could not load mock 10k for testing");
        return tResults.getResultsSummary();
    }
    edgar.extract10kToDisk( filing, stock, year);

    //Test results writen to DB
    if (te.select( te._stock_id() == stock._id() 
                   && te._quarter() == 0 ).empty())
    {
        tResults.addFailure(testName + "No record was added to DB");       
        return tResults.getResultsSummary();
    }
    O_Ep brk2013 = te.select( te._stock_id() == stock._id() 
                              && te._quarter() == 0 ).front();
    if (brk2013._year() != 2013)
        tResults.addFailure(testName + "Year should be: 2013, but is: "
                            + to_string(brk2013._year()) );
    if (brk2013._quarter() != 0)
        tResults.addFailure(testName + "Quarter (for 10k)  should be: 0, but is: " + to_string(brk2013._quarter()) );

    if (brk2013._revenue() != "182150000000")
        tResults.addFailure(testName + "Revenue should be: 182150000000, but is: " + brk2013._revenue() );

    if (brk2013._net_income() != "19476000000")   
        tResults.addFailure(testName + "Net Income should be: 19476000000, but is: " + brk2013._net_income() );

    if (brk2013._eps() != 11850.0)   
        tResults.addFailure(testName + "(diluted) Eps should be: 11850.0, but is: " + to_string(brk2013._eps()) );

    // test clean up
    te.erase( te._id() == brk2013._id());

    //BALANCE extraction test
    O_BalanceSheet b_brk2013 = tb.select( tb._stock_id() == stock._id()
                              && tb._year() == year ).front();

    if (b_brk2013._current_assets() != "")
        tResults.addFailure(balanceTestName + " CA should be: , but is: " + b_brk2013._current_assets() );
    if (b_brk2013._total_assets() != "484931000000")
        tResults.addFailure(balanceTestName + " TA should be: 484931000000, but is: " + b_brk2013._total_assets() );
    if (b_brk2013._current_liabilities() != "")
        tResults.addFailure(balanceTestName + " CL should be: , but is: " + b_brk2013._current_liabilities() );
    if (b_brk2013._total_liabilities() != "260446000000")
        tResults.addFailure(balanceTestName + " TL should be: 260446000000, but is: " + b_brk2013._total_liabilities() );
//    if (b_brk2013._long_term_debt() != "")
//        tResults.addFailure(balanceTestName + " LTD should be: , but is: " + b_brk2013._long_term_debt() );
    if (b_brk2013._book_value() != "221890000000")
        tResults.addFailure(balanceTestName + " BV should be: 221890000000, but is: " + b_brk2013._book_value() );
    if (stock._has_currant_ratio() == true)
        tResults.addFailure(balanceTestName + "Should NOT Have current ratio. but is set to TRUE" );
    // test clean up
    tb.erase( tb._id() == b_brk2013._id());


    // DE
    stock = ts.select( ts._ticker() == string("DE")).front();
    tResults.setStockTickerName( stock._ticker() );
    // extract to DB
    filing = getMockFromDisk("DE_2013_10k.txt");
    if ( filing == ""){
        tResults.addFailure(testName + "Could not load mock 10k for testing");
        return tResults.getResultsSummary();
    }
    edgar.extract10kToDisk( filing, stock, year);

    //Test results writen to DB
    if (te.select( te._stock_id() == stock._id() 
                   && te._quarter() == 0 ).empty())
    {
        tResults.addFailure(testName + "No record was added to DB");       
        return tResults.getResultsSummary();
    }
    O_Ep de2013 = te.select( te._stock_id() == stock._id() 
                              && te._quarter() == 0 ).front();
    if (de2013._revenue() != "37795400000")
        tResults.addFailure(testName + "Revenue should be: 37795400000, but is: " + de2013._revenue() );
    if (de2013._net_income() != "3537300000")   
        tResults.addFailure(testName + "Net Income should be: 3537300000, but is: " + de2013._net_income() );
    if (de2013._eps() != 9.09)   
        tResults.addFailure(testName + "(diluted) Eps should be: 9.09, but is: " + to_string(de2013._eps()) );
    if (de2013._shares() != "389200000")   
        tResults.addFailure(testName + "Number of shares should be: 389200000, but is: " + de2013._shares() );
    // test clean up
    te.erase( te._id() == de2013._id());

    //BALANCE extraction test
    O_BalanceSheet b_de2013 = tb.select( tb._stock_id() == stock._id()
                              && tb._year() == year ).front();
    if (b_de2013._current_assets() != "")
        tResults.addFailure(balanceTestName + " CA should be: , but is: " + b_de2013._current_assets() );
    if (b_de2013._total_assets() != "59521300000")
        tResults.addFailure(balanceTestName + " TA should be: 59521300000, but is: " + b_de2013._total_assets() );
    if (b_de2013._current_liabilities() != "")
        tResults.addFailure(balanceTestName + " CL should be: , but is: " + b_de2013._current_liabilities() );
    if (b_de2013._total_liabilities() != "49253600000")
        tResults.addFailure(balanceTestName + " TL should be: 49253600000, but is: " + b_de2013._total_liabilities() );
    if (b_de2013._long_term_debt() != "21577700000")
        tResults.addFailure(balanceTestName + " LTD should be: 21577700000, but is: " + b_de2013._long_term_debt() );
    if (b_de2013._book_value() != "10265800000")
        tResults.addFailure(balanceTestName + " BV should be: 10265800000, but is: " + b_de2013._book_value() );
    if (stock._has_currant_ratio() == true)
        tResults.addFailure(balanceTestName + "Should NOT Have current ratio. but is set to TRUE" );
    // test clean up
    tb.erase( tb._id() == b_de2013._id());


    // INTC
    stock = ts.select( ts._ticker() == string("INTC")).front();
    tResults.setStockTickerName( stock._ticker() );
    // extract to DB
    filing = getMockFromDisk("INTC_2013_10k.txt");
    if ( filing == ""){
        tResults.addFailure(testName + "Could not load mock 10k for testing");
        return tResults.getResultsSummary();
    }
    edgar.extract10kToDisk( filing, stock, year);
    //Test results writen to DB
    if (te.select( te._stock_id() == stock._id() 
                   && te._quarter() == 0 ).empty())
    {
        tResults.addFailure(testName + "No record was added to DB");       
        return tResults.getResultsSummary();
    }
    O_Ep intc2013 = te.select( te._stock_id() == stock._id() 
                             && te._quarter() == 0 ).front();
    if (intc2013._revenue() != "52708000000")
        tResults.addFailure(testName + "Revenue should be: 52708000000, but is: " + intc2013._revenue() );
    if (intc2013._net_income() != "9620000000")   
        tResults.addFailure(testName + "Net Income should be: 9620000000, but is: " + intc2013._net_income() );
    if (intc2013._eps() != 1.89)   
        tResults.addFailure(testName + "(diluted) Eps should be: 1.89, but is: " + to_string(intc2013._eps()) );
    // test clean up
    te.erase( te._id() == intc2013._id());

    //BALANCE extraction test
    O_BalanceSheet b_intc2013 = tb.select( tb._stock_id() == stock._id()
                              && tb._year() == year ).front();
    if (b_intc2013._current_assets() != "32084000000")
        tResults.addFailure(balanceTestName + " CA should be: 32084000000, but is: " + b_intc2013._current_assets() );
    if (b_intc2013._total_assets() != "92358000000")
        tResults.addFailure(balanceTestName + " TA should be: 92358000000, but is: " + b_intc2013._total_assets() );
    if (b_intc2013._current_liabilities() != "13568000000")
        tResults.addFailure(balanceTestName + " CL should be: 13568000000, but is: " + b_intc2013._current_liabilities() );
    if (b_intc2013._total_liabilities() != "34102000000")
        tResults.addFailure(balanceTestName + " TL should be: 34102000000, but is: " + b_intc2013._total_liabilities() );
    if (b_intc2013._calculated_tl() == false)
        tResults.addFailure(balanceTestName + " TL NOT suplied, so calculated_tl should be NOT be false" );
    if (b_intc2013._long_term_debt() != "13165000000")
        tResults.addFailure(balanceTestName + " LTD should be: 13165000000, but is: " + b_intc2013._long_term_debt() );
    if (b_intc2013._book_value() != "58256000000")
        tResults.addFailure(balanceTestName + " BV should be: 58256000000, but is: " + b_intc2013._book_value() );
    // test clean up
    tb.erase( tb._id() == b_intc2013._id());


    // F
    stock = ts.select( ts._ticker() == string("F")).front();
    tResults.setStockTickerName( stock._ticker() );
    // extract to DB
    filing = getMockFromDisk("F_2013_10k.txt");
    if ( filing == ""){
        tResults.addFailure(testName + "Could not load mock 10k for testing");
        return tResults.getResultsSummary();
    }
    edgar.extract10kToDisk( filing, stock, year);
    //Test results writen to DB
    if (te.select( te._stock_id() == stock._id() 
                   && te._quarter() == 0 ).empty())
    {
        tResults.addFailure(testName + "No record was added to DB");       
        return tResults.getResultsSummary();
    }
    O_Ep f2013 = te.select( te._stock_id() == stock._id() 
                               && te._quarter() == 0 ).front();
    if (f2013._revenue() != "146917000000")
        tResults.addFailure(testName + "Revenue should be: 146917000000, but is: " + f2013._revenue() );
    if (f2013._net_income() != "7155000000")   
        tResults.addFailure(testName + "Net Income should be: 7155000000, but is: " + f2013._net_income() );
    if (f2013._eps() != 1.76)   
        tResults.addFailure(testName + "(diluted) Eps should be: 1.76, but is: " + to_string(f2013._eps()) );
    // test clean up
    te.erase( te._id() == f2013._id());

    //BALANCE extraction test
    O_BalanceSheet b_f2013 = tb.select( tb._stock_id() == stock._id()
                              && tb._year() == year ).front();
    if (b_f2013._current_assets() != "")
        tResults.addFailure(balanceTestName + " CA should be: , but is: " + b_f2013._current_assets() );
    if (b_f2013._total_assets() != "202026000000")
        tResults.addFailure(balanceTestName + " TA should be: 202026000000, but is: " + b_f2013._total_assets() );
    if (b_f2013._current_liabilities() != "")
        tResults.addFailure(balanceTestName + " CL should be: , but is: " + b_f2013._current_liabilities() );
    if (b_f2013._total_liabilities() != "175279000000")
        tResults.addFailure(balanceTestName + " TL should be: 175279000000, but is: " + b_f2013._total_liabilities() );
    if (stock._has_currant_ratio() == true)
        tResults.addFailure(balanceTestName + " NO current ratios, so stock._has_currant() should be false" );
    if (b_f2013._long_term_debt() != "114688000000")
        tResults.addFailure(balanceTestName + " LTD should be: 114688000000, but is: " + b_f2013._long_term_debt() );
    if (b_f2013._book_value() != "26383000000")
        tResults.addFailure(balanceTestName + " BV should be: 26383000000, but is: " + b_f2013._book_value() );
    // test clean up
    tb.erase( tb._id() == b_f2013._id());


    return tResults.getResultsSummary();
}
示例#5
0
bool 
Test::getReportsTest(O_Stock& stock, boost::filesystem::ofstream& outFile)
{
    LOG_INFO << "\n --- Testing retreval of reports for " << stock._ticker()
             << "  ---\n";
    
    // Ensure we switched to test DB
    bool rok(false);
    rok = db_setup();
    if(!rok)
    {
        LOG_ERROR << "Something wrong with TEST(probably with TEST DB setup)."
                  << "EXITING";
        cout << "An error uccored. exiting";
        exit(-1);
    }
    bool repFail(true);
    TestResults testRes;
    string testName(stock._ticker() + ": ");
    testRes.setTestName(testName);

    EdgarData edgar;
    /*
    Acn* acn = edgar.getLastYear10KAcn(stock);
    if (acn == NULL)
    {
        LOG_INFO << "Did not get acn for "<<stock._ticker() ;
        return false;
    }
    string filing = edgar.getEdgarFiling(stock,*acn);
    if (filing == "")
    {
        LOG_ERROR << "Failed to retrive filing for acn "<<acn->_acn<<"\n";
        return false;
    }
*/
    edgar.getSingleYear(stock,2013);
    auto reports = &edgar._reports;
    bool foreign = false;
    LOG_INFO << "Got "<<reports->size()<<" reports\n";
    ReportType reportType = ReportType::COVER;
    auto coverReportIt = reports->find(reportType);
    if( coverReportIt == reports->end())
    {
        testRes.addFailure("NO COVER REPORT");
        repFail =false;
    }
    reportType = ReportType::INCOME;
    auto incomeReportIt = reports->find(reportType);
    if( incomeReportIt == reports->end())
    {
        testRes.addFailure("NO INCOME REPORT");
        if ( (stock._country() != "") &&
             (stock._country() != "USA") )
            foreign = true;
        repFail =false;
    } else {
        T_Ep te;
        O_Ep earnings_data;
        bool inDB(true);
        if (te.select( te._stock_id() == stock._id() &&
                       te._year() == 2013).empty() )
        {       
            inDB = false;
            testRes.addFailure("No earnings record for 2013 retrieved from DB");
            earnings_data = edgar._ep;
        }
        else
            earnings_data = te.select( te._stock_id() == stock._id() &&
                                            te._year() == 2013).front();

        LOG_INFO << "\n Testing values extracted for eps record with id: "
             << to_string(earnings_data._id())<<", stock_id is: "<<
            to_string(earnings_data._stock_id())<<" year "<<
            to_string(earnings_data._year()) <<", revenue: "
             <<earnings_data._revenue() << ", income: "
             <<earnings_data._net_income()<<", and eps: "<<
            to_string(earnings_data._eps())<<"\n";

        if (earnings_data._revenue() == "")
            testRes.addFailure("No Revenue exracted from Income Statement");
        if (earnings_data._net_income() == "")
            testRes.addFailure("No Income exracted from Income Statement");
        if (withinPercent(earnings_data._eps(),0.01,0.0))
            testRes.addFailure("No Eps exracted from Income Statement");
        if (earnings_data._shares() == "")
            testRes.addFailure("No Share data exracted from Income Statement");
        
        if (inDB)
            te.erase( te._id() == earnings_data._id());
    }
    
//  balancereporttest:
    reportType = ReportType::BALANCE;
    auto balanceReportIt = reports->find(reportType);
    if( balanceReportIt == reports->end())
    {
        testRes.addFailure("NO BALANCE REPORT");
        repFail =false;
    }
    string resultSummary = testRes.getResultsSummary();
    if (testRes._numFails > 0)
    {
        if (foreign)
            outFile << stock._ticker() << " is foreign - " << stock._country();
        outFile << resultSummary;
        outFile.flush();
    }
    LOG_INFO << resultSummary;
    cout << "\n ---  TEST Results for "<<stock._ticker()<<" ---" <<resultSummary << endl;
    return repFail;
}
示例#6
0
string
Test::runSingleQarterTest(TestResults& tResults)
{
    LOG_INFO << "\n --- Running runSingleQarterTest() ---\n";
    string testName("Test-Single Quarter 10Q retrieval: ");

    //LOG_INFO << "single quarter test under restructuring\n";
    //return "";

    T_Stock ts;
    T_Ep te;
    O_Stock stock = ts.select( ts._ticker() == string("CVX")).front();
    tResults.setStockTickerName( stock._ticker() );

    string filing = getMockFromDisk("CVX_2014_1stQ.txt");
    if ( filing == "")
    {
        tResults.addFailure(testName + "Could not load mock 10q for testing");
        return tResults.getResultsSummary();
    }
    //cout << "Got filing " << filing.substr(0,300) << endl;
    EdgarData edgar;
    Acn acn( string("0000093410-14-000024"), date(2014,May,2), 1 );
    acn._year = 2014;

    //string cover_rep_mok = "";

    //string page = filing;

    Parser parser(stock);

    string cover_rep = parser.get_report_from_complete_filing(filing,ReportType::COVER);
    //check_report_year_and_date(cover_rep, *it);
    string income_rep = parser.get_report_from_complete_filing(filing,ReportType::INCOME);
    edgar.addIncomeStatmentToDB( income_rep, stock, acn._year, acn._quarter, cover_rep, to_iso_extended_string( acn._report_date) );

    //Test results writen to DB
    if (te.select( te._stock_id() == stock._id() &&
                   te._year() == 2014 && te._quarter() == 1).empty())
    {
        tResults.addFailure(testName + "No record was added to DB");       
        return tResults.getResultsSummary();
    }

    O_Ep cvx2013Q1 = te.select( te._stock_id() == stock._id() &&
                                te._year() == 2014 &&
                                te._quarter() == 1).front() ;
 
    if (cvx2013Q1._year() != 2014)
        tResults.addFailure(testName + "Year should be: 2014, but is: "
                            + to_string(cvx2013Q1._year()) );

    if (cvx2013Q1._quarter() != 1)
        tResults.addFailure(testName + "Quarter should be: 1, but is: " + to_string(cvx2013Q1._quarter()) );

    if (cvx2013Q1._revenue() != "53265000000")
        tResults.addFailure(testName + "Revenue should be: 53265000000, but is: " + cvx2013Q1._revenue() );

    if (cvx2013Q1._net_income() != "4512000000")   
        tResults.addFailure(testName + "Net Income should be: 4512000000, but is: " + cvx2013Q1._net_income() );

    if (cvx2013Q1._eps() != 2.36)   
        tResults.addFailure(testName + "(diluted) Eps should be: 2.36, but is: " + to_string(cvx2013Q1._eps()) );

    if (cvx2013Q1._shares() != "1909424000")   
        tResults.addFailure(testName + "Number of (diluted) shares should be: 1909424000, but is: " + cvx2013Q1._shares() );

    // erase record from DB
    te.erase( te._id() == cvx2013Q1._id());
    
    return tResults.getResultsSummary();
}
示例#7
0
void 
Test::runCompanyTest(string& ticker)
{
    // get record from REAL DB for 2013
    LOG_INFO << "\n --- Running Test for retreval of " << ticker 
             << "  ---\n";

    cout << "\n Switching to REAL DB--------------------" << endl;

    string realDB("graham_dev");
    string testDB("graham_test");
    if ( DBFace::instance()->switchDB( realDB ) )
        cout << "Switch to real db succeccful" << endl;

    size_t year = 2013;
    T_Stock rts;
    T_Ep rte;
    const O_Stock rstock = rts.select( rts._ticker() == ticker).front();
    const O_Ep real2013 = rte.select( rte._stock_id() == rstock._id() 
                               && rte._quarter() == 0
                               && rte._year() == year).front();
      
    cout << "\n Switching back to TEST DB--------------------" << endl;

    if (DBFace::instance()->switchDB( testDB ) )
        cout << "Switch to TEST db succeccful" << endl;
  
    // Switch back to TEST DB

    // Ensure we switched to test DB
    bool rok(false);
    rok = db_setup();
    if(!rok)
    {
        LOG_ERROR << "Something wrong with TEST(probably with TEST DB setup)."
                  << "EXITING";
        cout << "An error uccored. exiting";
        exit(-1);
    }
  
    TestResults testRes;
    T_Stock ts;
    T_Ep te;
    O_Stock stock;
    // CREATE Dummy stock in test DB!
    if ( ts.select( ts._ticker() == ticker).empty() )
    {
        stock._ticker() = ticker;
        stock._cik() = rstock._cik();
        stock.insert();

    }else{
        stock = ts.select( ts._ticker() == ticker).front();
    }
    string testName("Test-Company " + stock._ticker() + ": ");
    testRes.setTestName(testName);

    EdgarData edgar;
    if ( edgar.getSingleYear( stock, year) )
    {
        compareTest( rstock , real2013, testRes);
    }else{
        testRes.addFailure("Could Not get annual data for " + stock._ticker());
    }
    string resultSummary = testRes.getResultsSummary();
    cout << "\n ---  TEST Results  ---" <<resultSummary << endl;
}
示例#8
0
void TestResult::testOne() {
    SkPicture* pic = nullptr;
    {
    #if DEBUG_SHOW_TEST_NAME
        if (fTestStep == kCompareBits) {
            SkString testName(fFilename);
            const char http[] = "http";
            if (testName.startsWith(http)) {
                testName.remove(0, sizeof(http) - 1);
            }
            while (testName.startsWith("_")) {
                testName.remove(0, 1);
            }
            const char dotSkp[] = ".skp";
            if (testName.endsWith(dotSkp)) {
                size_t len = testName.size();
                testName.remove(len - (sizeof(dotSkp) - 1), sizeof(dotSkp) - 1);
            }
            testName.prepend("skp");
            testName.append("1");
            strncpy(DEBUG_FILENAME_STRING, testName.c_str(), DEBUG_FILENAME_STRING_LENGTH);
        } else if (fTestStep == kEncodeFiles) {
            strncpy(DEBUG_FILENAME_STRING, "", DEBUG_FILENAME_STRING_LENGTH);
        }
    #endif
        SkString path = get_in_path(fDirNo, fFilename);
        SkFILEStream stream(path.c_str());
        if (!stream.isValid()) {
            SkDebugf("invalid stream %s\n", path.c_str());
            goto finish;
        }
        pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory);
        if (!pic) {
            SkDebugf("unable to decode %s\n", fFilename);
            goto finish;
        }
        SkScalar width = pic->cullRect().width();
        SkScalar height = pic->cullRect().height();
        SkBitmap oldBitmap, opBitmap;
        fScale = 1;
        while (width / fScale > 32767 || height / fScale > 32767) {
            ++fScale;
        }
        do {
            int dimX = SkScalarCeilToInt(width / fScale);
            int dimY = SkScalarCeilToInt(height / fScale);
            if (oldBitmap.tryAllocN32Pixels(dimX, dimY) && opBitmap.tryAllocN32Pixels(dimX, dimY)) {
                break;
            }
            SkDebugf("-%d-", fScale);
        } while (++fScale < 256);
        if (fScale >= 256) {
            SkDebugf("unable to allocate bitmap for %s (w=%f h=%f)\n", fFilename,
                    width, height);
            goto finish;
        }
        oldBitmap.eraseColor(SK_ColorWHITE);
        SkCanvas oldCanvas(oldBitmap);
        oldCanvas.setAllowSimplifyClip(false);
        opBitmap.eraseColor(SK_ColorWHITE);
        SkCanvas opCanvas(opBitmap);
        opCanvas.setAllowSimplifyClip(true);
        drawPict(pic, &oldCanvas, fScale);
        drawPict(pic, &opCanvas, fScale);
        if (fTestStep == kCompareBits) {
            fPixelError = similarBits(oldBitmap, opBitmap);
            int oldTime = timePict(pic, &oldCanvas);
            int opTime = timePict(pic, &opCanvas);
            fTime = SkTMax(0, oldTime - opTime);
        } else if (fTestStep == kEncodeFiles) {
            SkString pngStr = make_png_name(fFilename);
            const char* pngName = pngStr.c_str();
            writePict(oldBitmap, outOldDir, pngName);
            writePict(opBitmap, outOpDir, pngName);
        }
    }
finish:
    if (pic) {
        pic->unref();
    }
}
示例#9
0
Status TestDriver::runTests()
{
    cout << "\nRunning " << testName() << " tests...\n";


    // Kill anything that might be hanging around.

    char* newdbpath;
    char* newlogpath;
   
	char remove_logcmd[50];
	char remove_dbcmd[50];

    newdbpath = new char[ strlen(dbpath) + 20];
    newlogpath = new char[ strlen(logpath) + 20];
    strcpy(newdbpath,dbpath); 
    strcpy(newlogpath, logpath);

#ifdef MULTIUSER
	pwd = getpwuid(getuid());
	sprintf(remove_dbcmd, "/bin/rm -rf %s-%s", dbpath, pwd->pw_name);
	sprintf(remove_logcmd, "/bin/rm -rf %s-%s", logpath, pwd->pw_name);
#else
	sprintf(remove_logcmd, "/bin/rm -rf %s", logpath);
	sprintf(remove_dbcmd, "/bin/rm -rf %s", dbpath);
#endif
	
	system(remove_logcmd);
	system(remove_dbcmd);

#ifdef MULTIUSER
  if ( (pwd = getpwuid(getuid())) != NULL) {
	  sprintf( newdbpath, "%s-%s", dbpath, pwd->pw_name );
  	  sprintf( newlogpath, "%s-%s", logpath, pwd->pw_name );
  }
#else
  sprintf(newdbpath, "%s", dbpath);
  sprintf(newlogpath, "%s", logpath);
#endif


    unlink( newdbpath );
    unlink( newlogpath );

    minibase_errors.clear_errors();


      // Run the tests.
    Status answer = runAllTests();


      // Clean up.
    unlink( newdbpath );
    unlink( newlogpath );
    minibase_errors.clear_errors();

    cout << "\n..." << testName() << " tests "
         << (answer == OK ? "completed successfully" : "failed")
         << ".\n\n";

    delete newdbpath; delete newlogpath;

    return answer;
}
void StaticOctreeTest:: run()
{
  preciceTrace ( "run()" );
  int sizeRanks = utils::Parallel::getCommunicatorSize();
  bool evenTasks = false;
  bool oddTasks = false;
  if (sizeRanks > 1){
    if (utils::Parallel::getProcessRank() == 0){
      evenTasks = true;
    }
    else if (utils::Parallel::getProcessRank() == 1){
      oddTasks = true;
    }
  }
  else {
    evenTasks = true;
    oddTasks = true;
  }
  if (evenTasks || oddTasks){
    std::string testName("StaticOctreeTest");
    StaticOctreeFactory factory;
    SpacetreeTestScenarios testScenarios(testName, factory);

    if (evenTasks){
      preciceDebug ( "test search position" );
      testScenarios.testSearchPosition();
    }

    if (oddTasks){
      preciceDebug ( "test search distance" );
      testScenarios.testSearchDistance();
    }

    if (evenTasks){
      preciceDebug ( "test neighbor search" );
      testScenarios.testNeighborSearch();
    }

    if (oddTasks){
      preciceDebug ( "test search content vertices" );
      testScenarios.testSearchContentVertices();
    }

    if (evenTasks){
      preciceDebug ( "test search content edges" );
      testScenarios.testSearchContentEdges();
    }

    if (oddTasks){
      preciceDebug ( "test search content triangles" );
      testScenarios.testSearchContentTriangles();
    }

    if (evenTasks){
      preciceDebug ( "test search voxel position" );
      testScenarios.testVoxelPosition();
    }

    if (oddTasks){
      preciceDebug ( "test splitting voxels" );
      testScenarios.testSplittingVoxels();
    }
    validate(testScenarios.getNumberOfErrors() == 0);
  }
}
void PerformceAllocScene::updateProfilerName()
{
    kdSnprintf(_profilerName, sizeof(_profilerName)-1, "%s(%d)", testName(), quantityOfNodes);
}
void PerformanceContainerScene::updateProfilerName()
{
    snprintf(_profilerName, sizeof(_profilerName)-1, "%s(%d)", testName(), quantityOfNodes);
}
示例#13
0
void ChibiTest::testDebug(const QString string)
{
    emit testMessage(testName(), debugMessage, 0, string);
}
示例#14
0
void ChibiTest::testError(const QString string)
{
    emit testMessage(testName(), errorMessage, 0, string);
}
示例#15
0
void ChibiTest::testInfo(const QString string)
{
    emit testMessage(testName(), infoMessage, 0, string);
}
示例#16
0
void Question::RunTest() const {
	std::string testName (typeid(*this).name());
	std::cout << "***** Start test: " << testName.c_str() << "****" << std::endl;
	this->RunTestImpl();
	std::cout << "***** End test: " << testName.c_str() << "****" << std::endl;
}