コード例 #1
0
ファイル: MockActualCall.cpp プロジェクト: rhertzog/cpputest
void MockCheckedActualCall::checkExpectations()
{
    if (state_ != CALL_IN_PROGRESS)
    {
        unfulfilledExpectations_.resetExpectations();
        return;
    }

    if (! unfulfilledExpectations_.hasUnfulfilledExpectations())
        FAIL("Actual call is in progress. Checking expectations. But no unfulfilled expectations. Cannot happen.") // LCOV_EXCL_LINE

    fulfilledExpectation_ = unfulfilledExpectations_.removeOneFulfilledExpectationWithIgnoredParameters();
    if (fulfilledExpectation_) {
        callHasSucceeded();
        unfulfilledExpectations_.resetExpectations();
        return;
    }

    if (unfulfilledExpectations_.hasUnfulfilledExpectationsBecauseOfMissingParameters()) {
        MockExpectedParameterDidntHappenFailure failure(getTest(), getName(), allExpectations_);
        failTest(failure);
    }
    else {
        MockExpectedObjectDidntHappenFailure failure(getTest(), getName(), allExpectations_);
        failTest(failure);
    }
}
コード例 #2
0
ファイル: random.cpp プロジェクト: IMCG/CDS
            virtual void test()
            {
                item_array& arr = getTest().m_Data ;
                for ( size_t nPass = 0; nPass < s_nPassPerThread; ) {
                    size_t nIdx = m_rndGen( size_t(0), s_nDataSize - 1 )  ;
                    Item & item = arr.at(nIdx)  ;
                    if ( item.m_access.tryLock() ) {
                        if ( item.m_pszBlock ) {
                            m_Alloc.deallocate( item.m_pszBlock, 1 )    ;
                            item.m_pszBlock = NULL ;
                        }
                        else {
                            size_t nSize ;
                            item.m_pszBlock = m_Alloc.allocate( nSize = m_rndGen(s_nMinBlockSize, s_nMaxBlockSize ), NULL )   ;

                            if ( nSize < 32 )
                                memset( item.m_pszBlock, 0, nSize )     ;
                            else {
                                memset( item.m_pszBlock, 0, 16 )     ;
                                memset( ((char *) item.m_pszBlock) + nSize * sizeof(*item.m_pszBlock) - 16, 0, 16 )     ;
                            }
                        }
                        item.m_access.unlock()  ;

                        ++nPass ;
                    }
                }
            }
コード例 #3
0
        virtual void test()
        {
            MAP& rMap = m_Map   ;

            m_nInsertSuccess =
                m_nInsertFailed = 0 ;
            key_array const& arr = getTest().m_arrValues    ;

            if ( m_nThreadNo & 1 ) {
                for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
                    for ( key_array::const_iterator it = arr.begin(), itEnd = arr.end(); it != itEnd; ++it ) {
                        if ( rMap.insert( *it, *it * 8 ) )
                            ++m_nInsertSuccess  ;
                        else
                            ++m_nInsertFailed   ;
                    }
                }
            }
            else {
                for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
                    for ( key_array::const_reverse_iterator it = arr.rbegin(), itEnd = arr.rend(); it != itEnd; ++it ) {
                        if ( rMap.insert( *it, *it * 8 ) )
                            ++m_nInsertSuccess  ;
                        else
                            ++m_nInsertFailed   ;
                    }
                }
            }
        }
コード例 #4
0
ファイル: testmanager.cpp プロジェクト: Horsmir/hstest
bool TestManager::editTest(const QString &catName, const QString &testName, const quint32 numVis, const bool vis)
{
	if(!tests->editTest(catName, testName, numVis, vis))
		return false;
	
	Test test = getTest(catName, testName);
	test.setNumVis(numVis);
	if(vis)
		test.setVis();
	else
		test.setNoVis();
	
	QString testFileName = tests->getFileNameTest(catName, testName);
	
	QFile file(testsDir + "/" + testFileName);
	if(!file.open(QIODevice::WriteOnly))
	{
		qDebug() << "Can not open file " << (testsDir + "/" + testFileName) << " for writing. Error: " << file.errorString();
		return false;
	}
	
	QDataStream out(&file);
	out << quint32(magicNumber) << quint16(out.version());
	out << test;
	return true;
	
}
コード例 #5
0
ファイル: set_insdel_string.cpp プロジェクト: IMCG/CDS
            virtual void test()
            {
                Set& rSet = m_Set   ;

                m_nInsertSuccess =
                    m_nInsertFailed = 0 ;

                const std::vector<std::string>& arrString = *getTest().m_parrString    ;
                size_t nArrSize = arrString.size()  ;

                if ( m_nThreadNo & 1 ) {
                    for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
                        for ( size_t nItem = 0; nItem < c_nMapSize; ++nItem ) {
                            if ( rSet.insert( keyval_type(arrString[nItem % nArrSize], nItem * 8) ) )
                                ++m_nInsertSuccess  ;
                            else
                                ++m_nInsertFailed   ;
                        }
                    }
                }
                else {
                    for ( size_t nPass = 0; nPass < c_nThreadPassCount; ++nPass ) {
                        for ( size_t nItem = c_nMapSize; nItem > 0; --nItem ) {
                            if ( rSet.insert( keyval_type( arrString[nItem % nArrSize], nItem * 8) ) )
                                ++m_nInsertSuccess  ;
                            else
                                ++m_nInsertFailed   ;
                        }
                    }
                }
            }
コード例 #6
0
        virtual void test()
        {
            m_nPopEmpty = 0;
            m_nPopped = 0;
            m_nBadWriter = 0;
            const size_t nTotalWriters = s_nWriterThreadCount;
            Value v;

            m_fTime = m_Timer.duration();

            while ( true ) {
                if ( m_Queue.pop( v ) ) {
                    ++m_nPopped;
                    if ( /*v.nWriterNo >= 0 &&*/ v.nWriterNo < nTotalWriters )
                        m_WriterData[ v.nWriterNo ].push_back( v.nNo );
                    else
                        ++m_nBadWriter;
                }
                else
                    ++m_nPopEmpty;

                if ( m_Queue.empty() ) {
                    if ( getTest().m_nWriterDone.load() >= nTotalWriters ) {
                        if ( m_Queue.empty() )
                            break;
                    }
                }
            }

            m_fTime = m_Timer.duration() - m_fTime;
        }
コード例 #7
0
 void initPoppedData()
 {
     const size_t nWriterCount = s_nWriterThreadCount;
     const size_t nWriterPushCount = getTest().m_nThreadPushCount;
     m_WriterData.resize( nWriterCount );
     for ( size_t i = 0; i < nWriterCount; ++i )
         m_WriterData[i].reserve( nWriterPushCount );
 }
コード例 #8
0
status_t BnMcuService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
	ALOGI("BnMcuService::onTransact, code[%d]", code);
    switch (code) {
        case GET_TEST: {
            CHECK_INTERFACE(IMcuService, data, reply);
            int result = getTest();
            reply->writeInt32(result);
            return NO_ERROR;
        } break;
		case obtain_info: {
            CHECK_INTERFACE(IMcuService, data, reply);
			int domain = data.readInt32();
			int cmd = data.readInt32();
			Parcel out;
            bool res = obtainInfo(domain, cmd, out);
			reply->appendFrom(&out, 0, out.dataSize());
			reply->writeInt32(res?1:0);
			out.freeData();
            return NO_ERROR;
        } break;
		case send_info: {
            CHECK_INTERFACE(IMcuService, data, reply);
			int domain = data.readInt32();
			int cmd = data.readInt32();
			Parcel in;
			if(data.dataAvail() >0)
			{
				in.appendFrom(&data, data.dataPosition(), data.dataSize()-data.dataPosition());
				in.setDataPosition(0);
			}
			bool res = sendInfo(domain, cmd, in);
			reply->writeInt32(res?1:0);
			in.freeData();
            return NO_ERROR;
        } break;
		case regist_data_changed_listener: {
            CHECK_INTERFACE(IMcuService, data, reply);
			int domain = data.readInt32();
           	sp<IDataChangedListener> client = interface_cast<IDataChangedListener>(data.readStrongBinder());
            bool res = registDataChanagedListener(domain, client);
            reply->writeInt32((res?1:0));
            return NO_ERROR;
        } break; 
		case unregist_data_changed_listener: {
            CHECK_INTERFACE(IMcuService, data, reply);
			int domain = data.readInt32();
           	sp<IDataChangedListener> client = interface_cast<IDataChangedListener>(data.readStrongBinder());
            bool res = unregistDataChanagedListener(domain, client);
            reply->writeInt32((res?1:0));
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
コード例 #9
0
            virtual void test()
            {
                size_t nPushCount = getTest().m_nThreadPushCount;
                Value v;

                for (size_t i = 0; i < nPushCount; i++)
                    while (! m_Queue.pop( v ) )
                      ;
            }
コード例 #10
0
            virtual void test()
            {
                size_t nPushCount = getTest().m_nThreadPushCount;
                Value v;

                for (v.nNo = 0; v.nNo < nPushCount; ++v.nNo)
                    while (! m_Queue.push( v ))
                        ;
            }
コード例 #11
0
ファイル: jniLibrary.c プロジェクト: rootlogin/MDProject
JNIEXPORT jstring JNICALL
Java_com_gohon_material_jnisample_Library_getString(JNIEnv *env, jobject instance) {

    // TODO

   jstring *jstr =(*env)->NewStringUTF(env, "users");


    return getTest(env);
}
コード例 #12
0
        virtual void test()
        {
            size_t nPushCount = getTest().m_nThreadPushCount;
            Value v;
            v.nWriterNo = m_nThreadNo;
            v.nNo = 0;
            m_nPushFailed = 0;

            m_fTime = m_Timer.duration();

            while ( v.nNo < nPushCount ) {
                if ( m_Queue.push( v ))
                    ++v.nNo;
                else
                    ++m_nPushFailed;
            }

            m_fTime = m_Timer.duration() - m_fTime;
            getTest().m_nWriterDone.fetch_add( 1 );
        }
コード例 #13
0
ファイル: push_pop.cpp プロジェクト: 3Hren/libcds
            virtual void test()
            {
                m_nPushError = 0;

                for ( array_type::const_iterator it = m_arr.begin(); it != m_arr.end(); ++it ) {
                    if ( !m_Queue.push( SimpleValue( *it ) ))
                        ++m_nPushError;
                }

                getTest().end_pusher();
            }
コード例 #14
0
      bool MeasurementFunctorNVPM::callOnInit()
      {
        DP_ASSERT( dynamic_cast<TestRender*>( getTest() ) );

        if ( !m_nvPerfMon.get() )
        {
          m_nvPerfMon.reset( new NVPerfMon( m_counterFilters ) );
        }
        DP_ASSERT( m_nvPerfMon.get() );
        return( m_nvPerfMon->init() && MeasurementFunctor::callOnInit() );
      }
コード例 #15
0
            virtual void test()
            {
                size_t nPushCount = getTest().m_nThreadPushCount;
                Cacheline v;

                for (v.nNo = 0; v.nNo < nPushCount; ++v.nNo) {
                    m_Bag.add( v );
#if _DEBUG
                    // Just so writer and reader have approximate "computation"
                    CPPUNIT_MSG( "Added " << v.nNo );
#endif
                }
            }
コード例 #16
0
ファイル: MockActualCall.cpp プロジェクト: rhertzog/cpputest
MockActualCall& MockCheckedActualCall::withParameterOfType(const SimpleString& type, const SimpleString& name, const void* value)
{
    MockNamedValue actualParameter(name);
    actualParameter.setObjectPointer(type, value);

    if (actualParameter.getComparator() == NULL) {
        MockNoWayToCompareCustomTypeFailure failure(getTest(), type);
        failTest(failure);
        return *this;
    }
    checkInputParameter(actualParameter);
    return *this;
}
コード例 #17
0
void MockCheckedActualCall::checkOutputParameter(const MockNamedValue& outputParameter)
{
	unfulfilledExpectations_.onlyKeepUnfulfilledExpectationsWithOutputParameter(outputParameter);

	if (unfulfilledExpectations_.isEmpty()) {
		MockUnexpectedOutputParameterFailure failure(getTest(), getName(), outputParameter, allExpectations_);
		failTest(failure);
		return;
	}

	unfulfilledExpectations_.outputParameterWasPassed(outputParameter.getName());
	finalizeCallWhenFulfilled();
}
コード例 #18
0
MockFunctionCall& MockActualFunctionCall::withParameterOfType(const SimpleString& type, const SimpleString& name, void* value)
{
	if (getComparatorForType(type) == NULL) {
		MockNoWayToCompareCustomTypeFailure failure(getTest(), type);
		failTest(failure);
		return *this;
	}
	MockNamedValue actualParameter(name);
	actualParameter.setObjectPointer(type, value);
	actualParameter.setComparator(getComparatorForType(type));
	checkActualParameter(actualParameter);
	return *this;
}
コード例 #19
0
void MockActualFunctionCall::checkActualParameter(const MockNamedValue& actualParameter)
{
	unfulfilledExpectations_.onlyKeepUnfulfilledExpectationsWithParameter(actualParameter);

	if (unfulfilledExpectations_.isEmpty()) {
		MockUnexpectedParameterFailure failure(getTest(), getName(), actualParameter, allExpectations_);
		failTest(failure);
		return;
	}

	unfulfilledExpectations_.parameterWasPassed(actualParameter.getName());
	finnalizeCallWhenFulfilled();
}
コード例 #20
0
ファイル: push_pop.cpp プロジェクト: 3Hren/libcds
            virtual void test()
            {
                m_nPopSuccess = 0;
                m_nPopFailed = 0;

                SimpleValue val;
                while ( getTest().pushing() || !m_Queue.empty() ) {
                    if ( m_Queue.pop( val ))
                        ++m_nPopSuccess;
                    else
                        ++m_nPopFailed;
                }
            }
コード例 #21
0
      bool MeasurementFunctorNVPM::callOnRun( unsigned int i )
      {
        DP_ASSERT( m_nvPerfMon.get() );

        bool ok = true;
        while ( ok && !m_nvPerfMon->finishedExperiment() )
        {
          m_nvPerfMon->beginPass();
          ok = MeasurementFunctor::callOnRun( i );
          static_cast<TestRender*>(getTest())->getBackend()->finish();
          m_nvPerfMon->endPass();
        }
        return( ok );
      }
コード例 #22
0
            virtual void test()
            {
                Map& rMap = m_Map   ;

                m_nDeleteSuccess =
                    m_nDeleteFailed = 0 ;

                std::vector<size_t>& arrData = getTest().m_arrData ;
                if ( m_nThreadNo & 1 ) {
                    for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
                        for ( size_t i = 0; i < arrData.size(); ++i ) {
                            if ( arrData[i] & 1 ) {
                                if ( rMap.erase_with( arrData[i], key_less() ))
                                    ++m_nDeleteSuccess  ;
                                else
                                    ++m_nDeleteFailed   ;
                            }
                        }
                        if ( getTest().m_nInsThreadCount.load( CDS_ATOMIC::memory_order_acquire ) == 0 )
                            break;
                    }
                }
                else {
                    for ( size_t k = 0; k < c_nInsThreadCount; ++k ) {
                        for ( size_t i = arrData.size() - 1; i > 0; --i ) {
                            if ( arrData[i] & 1 ) {
                                if ( rMap.erase_with( arrData[i], key_less() ))
                                    ++m_nDeleteSuccess  ;
                                else
                                    ++m_nDeleteFailed   ;
                            }
                        }
                        if ( getTest().m_nInsThreadCount.load( CDS_ATOMIC::memory_order_acquire ) == 0 )
                            break;
                    }
                }
            }
コード例 #23
0
      bool MeasurementFunctorGoldImage::saveImages()
      {
        bool foundFile = true;
        bool success = true;

        const std::string& name = getCurTestName();

        unsigned int nShots = dp::util::checked_cast<unsigned int>(m_screenshots.size());
        for(unsigned int i = 0; i < nShots; i++)
        {
          std::string goldImageName(m_filenamePrefix + name + "_" + getTest()->getDescriptionOnRunInit(i) + m_filenameSuffix + util::to_string(".png"));

          if( m_gold )
          {

            std::string filename( m_goldDir + "\\" + goldImageName );
            dp::util::imageToFile( retrieveScreenshot(i), filename );
            std::cerr << "Saved gold image: " << goldImageName + "\n";
          }
          else
          { 
            util::SmartImage gold = util::imageFromFile(m_goldDir + "\\" + goldImageName);
            if( !gold )
            {
              if(foundFile)
              {
                std::cerr << "Could not find the following gold images\n";
                foundFile = false;
              }
              std::cerr << goldImageName << "\n";
              continue;
            }


            if( *retrieveScreenshot(i) != *gold )
            {
              std::cerr << "Gold image comparison failed for " << goldImageName << "\n";
              success = false;
            }

            std::string filename( m_imageDir + "\\" + goldImageName );
            dp::util::imageToFile(retrieveScreenshot(i), filename);
          }
        }

        m_screenshots.clear();

        return foundFile && success;
      }
コード例 #24
0
MockFunctionCall& MockActualFunctionCall::onObject(void* objectPtr)
{
	unfulfilledExpectations_.onlyKeepUnfulfilledExpectationsOnObject(objectPtr);

	if (unfulfilledExpectations_.isEmpty()) {
		MockUnexpectedObjectFailure failure(getTest(), getName(), objectPtr, allExpectations_);
		failTest(failure);
		return *this;
	}

	unfulfilledExpectations_.wasPassedToObject();

	finnalizeCallWhenFulfilled();
	return *this;
}
コード例 #25
0
            virtual void test()
            {
                Map& rMap = m_Map   ;

                m_nInsertSuccess =
                    m_nInsertFailed = 0 ;

                std::vector<size_t>& arrData = getTest().m_arrData ;
                for ( size_t i = 0; i < arrData.size(); ++i ) {
                    if ( rMap.insert( key_type( arrData[i], m_nThreadNo )))
                        ++m_nInsertSuccess ;
                    else
                        ++m_nInsertFailed ;
                }

                ensure_func f ;
                for ( size_t i = arrData.size() - 1; i > 0; --i ) {
                    if ( arrData[i] & 1 ) {
                        rMap.ensure( key_type( arrData[i], m_nThreadNo ), f ) ;
                    }
                }

                getTest().m_nInsThreadCount.fetch_sub( 1, CDS_ATOMIC::memory_order_acquire ) ;
            }
コード例 #26
0
      DPTCORE_API void MeasurementFunctorNVPM::OutputPlotDataCSV()
      {
        Test * test = getTest();
        DP_ASSERT( test );
        std::string fileName = m_resultsDir + "//" + m_resultsFilenamePrefix + getCurTestName() + m_resultsFilenameSuffix + "_run.csv";
        std::ofstream of( fileName.c_str() );
        if ( of.fail() )
        {
          std::cerr << "Warning: Could not open file <" << fileName << "> !!\n";
        }
        else
        {
          of << "# Generated by dp::testfw::core::MeasurementFunctorNVPM for test <" << test->getDescriptionOnInit() << ">\n\n";
          of << "CounterName";
          unsigned int nResults = checked_cast<unsigned int>(m_counterResults.size());
          for ( unsigned int i=0 ; i<nResults ; i++ )
          {
            of << ";" << test->getDescriptionOnRunInit( i );
          }
          of << std::endl;

          const vector<NVPMCounterID> & counterIDs = m_nvPerfMon->getCounterIDs();
          const NVPerfMon::CounterIDToSpecMap & counterToSpecMap = m_nvPerfMon->getCounterIDToSpecMap();
          for ( size_t i=0 ; i<counterIDs.size() ; i++ )
          {
            NVPerfMon::CounterIDToSpecMap::const_iterator it = counterToSpecMap.find( counterIDs[i] );
            DP_ASSERT( it != counterToSpecMap.end() );
            of << it->second.name;
            if ( it->second.percentage )
            {
              of << " (%)";
              for ( unsigned int j=0 ; j<nResults ; j++ )
              {
                of << ";" << m_counterResults[j][i].percent;
              }
            }
            else
            {
              for ( unsigned int j=0 ; j<nResults ; j++ )
              {
                of << ";" << m_counterResults[j][i].count;
              }
            }
            of << std::endl;
          }
        }
      }
コード例 #27
0
            virtual void test()
            {
                size_t nPushCount = getTest().m_nThreadPushCount;
                Cacheline v;

                for (size_t i = 0; i < nPushCount; i++) {
                    while (! m_Bag.tryRemoveAny( v ) )
                        ;
#ifdef _DEBUG
                    CPPUNIT_MSG( "Removed " << v.nNo );
#endif
                }

#ifdef _DEBUG
                    CPPUNIT_MSG( "Consumer finished." );
#endif
            }
コード例 #28
0
ファイル: MockActualCall.cpp プロジェクト: rhertzog/cpputest
MockActualCall& MockCheckedActualCall::onObject(const void* objectPtr)
{
    callIsInProgress();

    unfulfilledExpectations_.onlyKeepExpectationsOnObject(objectPtr);

    if (unfulfilledExpectations_.isEmpty()) {
        MockUnexpectedObjectFailure failure(getTest(), getName(), objectPtr, allExpectations_);
        failTest(failure);
        return *this;
    }

    unfulfilledExpectations_.wasPassedToObject();

    finalizeCallWhenFulfilled();
    return *this;
}
コード例 #29
0
            virtual void test()
            {
                ValueVector& arr = getTest().m_Arr  ;
                //size_t nSize = arr.size()   ;

                MAP& rMap = m_Map   ;
                for ( size_t nPass = 0; nPass < c_nPassCount; ++nPass ) {
                    if ( m_nThreadNo & 1 ) {
                        ValueVector::const_iterator itEnd = arr.end()   ;
                        for ( ValueVector::const_iterator it = arr.begin(); it != itEnd; ++it ) {
                            bool bFound = rMap.find( *(it->pKey) ) ;
                            if ( it->bExists ) {
                                if ( bFound )
                                    ++m_KeyExists.nSuccess  ;
                                else
                                    ++m_KeyExists.nFailed   ;
                            }
                            else {
                                if ( bFound )
                                    ++m_KeyNotExists.nFailed    ;
                                else
                                    ++m_KeyNotExists.nSuccess   ;
                            }
                        }
                    }
                    else {
                        ValueVector::const_reverse_iterator itEnd = arr.rend()   ;
                        for ( ValueVector::const_reverse_iterator it = arr.rbegin(); it != itEnd; ++it ) {
                            bool bFound = rMap.find( *(it->pKey) ) ;
                            if ( it->bExists ) {
                                if ( bFound )
                                    ++m_KeyExists.nSuccess  ;
                                else
                                    ++m_KeyExists.nFailed   ;
                            }
                            else {
                                if ( bFound )
                                    ++m_KeyNotExists.nFailed    ;
                                else
                                    ++m_KeyNotExists.nSuccess   ;
                            }
                        }
                    }
                }
            }
コード例 #30
0
MockFunctionCall& MockActualFunctionCall::withName(const SimpleString& name)
{
	setName(name);
	setState(CALL_IN_PROGESS);

	unfulfilledExpectations_.onlyKeepUnfulfilledExpectationsRelatedTo(name);
	if (unfulfilledExpectations_.isEmpty()) {
		MockUnexpectedCallHappenedFailure failure(getTest(), name, allExpectations_);
		failTest(failure);
		return *this;
	}

	unfulfilledExpectations_.callWasMade(callOrder_);

	finnalizeCallWhenFulfilled();

	return *this;
}