Exemple #1
0
 void tdc::enableFIFO()
 {
   unsigned int DATA;  
   TestError(readData(ControlRegister, &DATA),"TDC: Enabling the FIFO");
   if (digit(DATA,8)==0) {
     DATA+=0x0100;}
   TestError(writeData(ControlRegister, &DATA),"TDC: Enabling the FIFO");
   if(vLevel(NORMAL))cout<<"FIFO enabled !"<<endl;
 }
Exemple #2
0
void FuzzyTester::runGit(const QStringList &arguments, QString *output)
{
    QProcess git;
    git.start("git", arguments);
    if (!git.waitForStarted())
        throw TestError("Failed to start git. It is expected to be in the PATH.");
    if (!git.waitForFinished(300000) || git.exitStatus() != QProcess::NormalExit) // 5 minutes ought to be enough for everyone
        throw TestError(QString::fromLatin1("git failed: %1").arg(git.errorString()));
    if (git.exitCode() != 0) {
        throw TestError(QString::fromLatin1("git failed: %1")
                        .arg(QString::fromLocal8Bit(git.readAllStandardError())));
    }
    if (output)
        *output = QString::fromLocal8Bit(git.readAllStandardOutput()).trimmed();
}
Exemple #3
0
void FuzzyTester::removeDir(const QString &dirPath)
{
    QDir dir(dirPath);
    if (!dir.removeRecursively()) {
        throw TestError(QString::fromLatin1("Failed to remove temporary dir '%1'.")
                        .arg(dir.absolutePath()));
    }
}
Exemple #4
0
void FuzzyTester::throwIncrementalBuildError(const QString &message,
                                             const QStringList &commitSequence)
{
    const QString commitSequenceString = commitSequence.join(QLatin1Char(','));
    throw TestError(QString::fromLatin1("Found qbs bug with incremental build!\n"
            "%1\n"
            "The sequence of commits was: %2.").arg(message, commitSequenceString));
}
Exemple #5
0
template <class HolderClass> bool verifyBranch(const char *testname, TTree *chain, const char *bname, int type = 0) {
   static HolderClass *gHolder = new HolderClass;
   HolderClass **add = 0;
   HolderClass *holder = 0;

   TBranch *branch = chain->GetBranch(bname);
   if (branch==0) {
      TestError("treeReading",Form("Missing branch: %s",bname));
      return false;
   }
   
   if (branch->InheritsFrom("TBranchObject")) {
      TLeafObject *tbo = dynamic_cast<TLeafObject*>(branch->GetListOfLeaves()->At(0));
      holder = (HolderClass*)(tbo->GetObject());

      if (holder==0) {
         TestError("treeReading",Form("BranchObject %s with holder == 0!",bname));
         return false;         
      }
   } else {
      add = (HolderClass**)branch->GetAddress();
      if (add==0) {
         TestError("treeReading",Form("Branch %s with add == 0!",bname));
         return false;
      }
      void **p;
      switch (type) {
         case 0: holder = *add; break;
         case 1: p = (void**) &(gHolder->fScalarPtr); *p = ((TBranchElement*)branch)->GetObject(); break;
         case 2: p = (void**) &(gHolder->fObjectPtr); *p = ((TBranchElement*)branch)->GetObject(); break;
         case 3: p = (void**) &(gHolder->fNestedPtr); *p = ((TBranchElement*)branch)->GetObject(); break;
      }
   }
   
   int splitlevel = branch->GetSplitLevel();

   switch (type) {
      case 0: return holder->Verify(chain->GetTree()->GetReadEntry(),Form("%s %s",testname,bname),splitlevel);
      case 1: return gHolder->VerifyScalarPtr(chain->GetTree()->GetReadEntry(),Form("%s %s",testname,bname),splitlevel);
      case 2: return gHolder->VerifyObjectPtr(chain->GetTree()->GetReadEntry(),Form("%s %s",testname,bname),splitlevel);
      case 3: return gHolder->VerifyNestedPtr(chain->GetTree()->GetReadEntry(),Form("%s %s",testname,bname),splitlevel);
      default: 
         TestError("treeReading",Form("Unknown type %d in verifyBranch",type));
         return false;
   }
}
Exemple #6
0
void tdc::Reset(){
    unsigned int DATA=0;
    int ADD = this->add +0x1014;
    for(int k = 0; k<3; k++){
        ADD+=2;
        TestError(writeData(ADD, &DATA),"Reset...");
    }
    if(vLevel(NORMAL))cout<< " Module Reset... " << endl << " Software Clear... " << endl <<  " Software Event Reset... " <<endl;
}
Exemple #7
0
void tdc::reset(){
    unsigned int DATA=0;
    int ADD = this->add +0x1014;
    for(int k = 0; k<3; k++){
        ADD+=2;
        TestError(writeData(ADD, &DATA),"Reset...");
    }
    if(vLevel(NORMAL))
        std::cout<< " Module Reset, Software clear and Software event reset." << std::endl;
}
Exemple #8
0
// Read the status with the
void tdc::ReadStatus(){
    unsigned int DATA=0;
    waitRead();
    TestError(readData(StatusRegister,&DATA),"TDC: read Status");
    if (DATA%2 > 0){ if(vLevel(NORMAL))cout << "Event Ready"<<endl;}
    else {if(vLevel(NORMAL))cout<< "No data ready"<<endl;}
    if (DATA%8 >3)  if(vLevel(NORMAL))cout<< " Output Buffer is Full"<< endl;
    else {if(vLevel(NORMAL))cout<< " Output Buffer is not full"<<endl;}
    
    if (DATA%16 >7 ){if(vLevel(NORMAL))cout<< " Operating Mode : Trigger "<<endl;}
    else{ if(vLevel(NORMAL))cout<< "Operating Mode : Continuous"<<endl;}
}
Exemple #9
0
int tdc::waitWrite(void)
{
    unsigned int DATA=0;
    int i=0;
	while(1){
			TestError(readData(this->MicroHandshake,&DATA,A32_U_DATA,D16),"TDC: wait_write");
			if(DATA%2==1){
			break;
			i++;
			}
	}
	return 0;
}
Exemple #10
0
int tdc::waitRead(void)
{
    unsigned int DATA=0;
    int i=0;
	while(1){
			TestError(readData(this->MicroHandshake,&DATA,A32_U_DATA,D16),"TDC: wait_read");
			if(DATA%4==3 || DATA%4==2){
			break;
			i++;
			}
	}
	return 0;
}
Exemple #11
0
int main()
{
	TestLong();
	TestString();
	TestWideString();
	TestBool();
	TestDate();
	TestVariant();
	TestInterface();
	TestSmartPointer();
	TestError();
	return 0;
}
Exemple #12
0
int tdc::waitDataReady(void)
{
    unsigned int DATA=0;
    int i=0;
	while(1){
			TestError(readData(this->StatusRegister,&DATA,A32_U_DATA,D16),"TDC: wait_write");
			if(DATA%2==1){
			break;
			i++;
			}
	}
	return 0;
}
Exemple #13
0
int tdc::getEvent(event &myEvent)
{
    //works only if FIFO enabled !
    
    this->waitDataReady(); 
    
    unsigned int DATA=0;
    TestError(readData(this->EventFIFO,&DATA,A32_U_DATA,D32),"TDC: read FIFO");
    unsigned int eventNumberFIFO=digit(DATA,31,16);
    unsigned int numberOfWords=digit(DATA,15,0);
    
    vector<unsigned int> dataOutputBuffer;
    for(unsigned int i=numberOfWords; i>0 ;i--)
    {
	TestError(readData(this->add,&DATA,A32_U_DATA,D32),"TDC: read buffer");
        dataOutputBuffer.vector::push_back(DATA);
    }
    
    if (!( eventNumberFIFO==digit(dataOutputBuffer[0],26,5) && digit(dataOutputBuffer[0],31,27)==8)) return -1;
    
    myEvent.eventNumber=eventNumberFIFO;
    
    hit temporaryHit;
    for(unsigned int i=0; i<numberOfWords-1 ;i++) // "-1" because last event is TRAILER
    {
	if (digit(dataOutputBuffer[i],31,27)==0 )
	{
	  temporaryHit.time=digit(dataOutputBuffer[i],18,0);
	  temporaryHit.channel=digit(dataOutputBuffer[i],25,19);
	  myEvent.measurements.vector::push_back(temporaryHit);
	}
    }
    
    time(&myEvent.time);
    return 0;
    
}
Exemple #14
0
int main( int argc, char *argv[] )
{
#ifdef __SW_BW
    FILE *my_stdout;
    my_stdout = freopen( "tmp.log", "a", stdout );
    if( my_stdout == NULL ) {
        fprintf( stderr, "Unable to redirect stdout\n" );
        exit( -1 );
    }
#endif
    /*** Initialize ***/
    strcpy( ProgramName, strlwr( argv[0] ) );   /* store filename */

    /*** Test various functions ***/
    TestCompare();                              /* compare stuff */
    TestMove();                                 /* moving data about */
    TestCase();                                 /* upper/lowercase stuff */
    TestSearch();                               /* searching stuff */
    TestSubstring();                            /* substring stuff */
    TestToken();                                /* tokenizing stuff */
    TestLocale();                               /* locale stuff */
    TestError();                                /* error string stuff */
    TestFormatted();                            /* formatted I/O stuff */
    TestBounded();                              /* bounded string stuff */
#ifdef __X86__
    TestCompareF();
    TestMoveF();
    TestCaseF();
    TestSearchF();
    TestSubstringF();
    TestTokenF();
#endif

    /*** Print a pass/fail message and quit ***/
    if( NumErrors != 0 ) {
        printf( "%s: FAILURE (%d errors).\n", ProgramName, NumErrors );
        return( EXIT_FAILURE );
    }
    printf( "Tests completed (%s).\n", strlwr( argv[0] ) );
#ifdef __SW_BW
    fprintf( stderr, "Tests completed (%s).\n", strlwr( argv[0] ) );
    fclose( my_stdout );
    _dwShutDown();
#endif
    return( 0 );
}
Exemple #15
0
bool FuzzyTester::runQbs(const QString &buildDir, const QString &command, QString *errorOutput)
{
    if (errorOutput)
        errorOutput->clear();
    QProcess qbs;
    QStringList commandLine = QStringList(command) << "-d" << buildDir;
    if (m_log) {
        commandLine << "-vv";
        const size_t maxLoggedCommits = 2;
        Q_ASSERT(m_commitsWithLogFiles.size() <= maxLoggedCommits + 1);
        if (m_commitsWithLogFiles.size() == maxLoggedCommits + 1) {
            static const QStringList allActivities = QStringList() << resolveIncrementalActivity()
                    << buildIncrementalActivity() << buildFromScratchActivity();
            const QString oldCommit = m_commitsWithLogFiles.front();
            m_commitsWithLogFiles.pop();
            for (const QString &a : allActivities)
                QFile::remove(logFilePath(oldCommit, a));
        }
        qbs.setStandardErrorFile(logFilePath(m_currentCommit, m_currentActivity));
        if (m_commitsWithLogFiles.empty() || m_commitsWithLogFiles.back() != m_currentCommit)
            m_commitsWithLogFiles.push(m_currentCommit);
    } else {
        commandLine << "-qq";
    }
    if (m_jobCount != 0)
        commandLine << "--jobs" << QString::number(m_jobCount);
    commandLine << ("profile:" + m_profile);
    qbs.start("qbs", commandLine);
    if (!qbs.waitForStarted()) {
        throw TestError(QString::fromLatin1("Failed to start qbs. It is expected to be "
                "in the PATH. QProcess error string: '%1'").arg(qbs.errorString()));
    }
    if (!qbs.waitForFinished(-1) || qbs.exitCode() != 0) {
        if (errorOutput)
            *errorOutput = QString::fromLocal8Bit(qbs.readAllStandardError());
        return false;
    }
    return true;
}
Exemple #16
0
event tdc::getEvent(){
    event e;
    int nWords = getNumberOfWords();
    if (nWords == 0) return (e);
    
    unsigned int DATA=0;
    bool inPayload = false;
    int lastWord = 0;
    for (int i=0; i<nWords; i++){
        lastWord = i;
        TestError(readData(this->add,&DATA,A32_U_DATA,D32),"TDC: read buffer");
        if (vLevel(DEBUG))
            std::cout<<"WORD "<<i<<(i<10?"  ":" ")<<": "<<show_hex(DATA,8)<<std::endl;
        short int wordType = DATA>>27;
        if (!inPayload){ //We are not in the payload yet (expecting header)
            if (wordType == 8){// Global header
                inPayload = true;
                e.eventNumber = (DATA>>5)%4194304;
            }
            else{
                e.errorCode = -2; // Sync loss error
            }
        }
Exemple #17
0
QString FuzzyTester::findWorkingStartCommit(const QString &startCommit)
{
    const QStringList allCommits = findAllCommits(startCommit);
    QString qbsError;
    m_currentActivity = buildFromScratchActivity();
    for (auto it = allCommits.crbegin(), end = allCommits.crend(); it != end; ++it) {
        m_currentCommit = *it;
        if (m_unbuildableCommits.contains(m_currentCommit)) {
            qDebug("Skipping known bad commit %s.", qPrintable(m_currentCommit));
            continue;
        }
        checkoutCommit(m_currentCommit);
        removeDir(defaultBuildDir());
        if (runQbs(defaultBuildDir(), QLatin1String("build"), &qbsError)) {
            m_buildableCommits << m_currentCommit;
            return m_currentCommit;
        }
        qDebug("Commit %s is not buildable.", qPrintable(m_currentCommit));
        m_unbuildableCommits << m_currentCommit;
    }
    throw TestError(QString::fromLatin1("Cannot run test: Failed to find a single commit that "
            "builds successfully with qbs. The last qbs error was: '%1'").arg(qbsError));
}
Exemple #18
0
int tdc::getNumberOfEvents(){
    unsigned int DATA = 0;
    TestError(readData(this->add+0x103C,&DATA,A32_U_DATA,D16),"TDC: get N events");
    return(DATA);
}
Exemple #19
0
int tdc::getNumberOfWords(){
    unsigned int DATA = 0;
    TestError(readData(this->add+0x1038,&DATA,A32_U_DATA,D32),"TDC: get N words");
    return(DATA%65536);
}
Exemple #20
0
	int GradientBoostingForest::Fit(InstancePool * pInstancepool)
	{
		m_pInstancePool = pInstancepool;
		m_pInstancePool->MakeBucket();
		if(NULL == m_pInstancePool)
		{
			Comm::LogErr("GradientBoostingForest::Fit pInstancepool is NULL");
			return -1;
		}
		int ret = -1;
		for(int i=0;i<m_pconfig->TreeNum;i++)
		{
			{
				//Comm::TimeStat stat("Residual");
				ret = Residual();
				printf("i = %d Residualed\n",i);
			}

			if(ret != 0)
			{
				Comm::LogErr("GradientBoostingForest::Fit fail! Residual fail!");
				return -1;
			}

			DecisionTree * pTree = new DecisionTree(m_pconfig);
			{
				//Comm::TimeStat stat("DecisionTree fit");
				ret = pTree->Fit(m_pInstancePool);
                //sleep(2);
			}
		//	printf("i = %d Fited pTree->FitError = %f\n",i,pTree->FitError());
			if(ret != 0)
			{
				Comm::LogErr("GradientBoostingForest::Fit fail! tree i = %d Fit fail!",i);
				return -1;
			}
			m_Forest.push_back(pTree);
			if(m_pconfig->LogLevel >= 3)printf("i = %d FitError = %f TestError = %f\n",i,FitError(),TestError());
		}
		ret = SaveResult();
		if(ret != 0)
		{
			Comm::LogErr("GradientBoostingForest::Fit fail ! SaveResult fail!");
			return -1;
		}
		if(m_pconfig->LogLevel >= 2)FeatureStat();
		return 0;
	}
Exemple #21
0
void tdc::writeOpcode(unsigned int &DATA)
{
  waitWrite();
  TestError(writeData(Opcode,&DATA),"TDC: writing OPCODE");
}
Exemple #22
0
template <class HolderClass> void write(const char *testname, int nEntry = 3) {
   bool testingTopLevelVectors = true;

   TString dirname = gROOT->GetVersion();
   dirname.ReplaceAll(".","-");
   dirname.ReplaceAll("/","-");

   gSystem->mkdir(dirname);
   gSystem->Unlink("latest");
   gSystem->Symlink(dirname,"latest");

   TString filename = gSystem->ConcatFileName(dirname, testname );
   filename += ".root";

   TFile *file = new TFile(filename,"RECREATE","stl test file",0);

   HolderClass *holder = new HolderClass( 0 );
   
   // Write(file,"scalar",holder->fScalar)
   // Write(file,"object",holder->fObject)
   // Write(file,"nested",holder->fNested)

   holder->Write("holder");

   TString classname = holder->IsA()->GetName();
   TTree *tree = new TTree("stltree","testing stl containers");
   tree->Branch("split_2.",classname,&holder,32000,-2);
   tree->Branch("split_1.",classname,&holder,32000,-1);
   tree->Branch("split0.",classname,&holder,32000,0);
   tree->Branch("split1.",classname,&holder,32000,1);
   tree->Branch("split2.",classname,&holder,32000,2);
   tree->Branch("split99.",classname,&holder,32000,99);

   if (testingTopLevelVectors) {
     TClass *cls = gROOT->GetClass(typeid(holder->fScalar));
     if (!cls) {
        TestError("TreeBuilding", Form("Writing holder class: Missing class for %s",
                                       typeid(holder->fScalar).name()));
     } else {
        tree->Branch("scalar0.",&(holder->fScalarPtr),32000,0);
        tree->Branch("scalar1.",&(holder->fScalarPtr),32000,1);
        tree->Branch("scalar2.",&(holder->fScalarPtr),32000,2);
        tree->Branch("scalar99.",&(holder->fScalarPtr),32000,99);
     }
 
     TClass *clo = gROOT->GetClass(typeid(holder->fObject));
     if (!clo) {
        TestError("TreeBuilding", Form("Writing holder class: Missing class for %s",
                  typeid(holder->fObject).name()));
     } else {
       tree->Branch("object0." ,&(holder->fObjectPtr),32000,0);
       tree->Branch("object1." ,&(holder->fObjectPtr),32000,1);
       tree->Branch("object2." ,&(holder->fObjectPtr),32000,2);
       tree->Branch("object99.",&(holder->fObjectPtr),32000,99);
     }

     TClass *cln = gROOT->GetClass(typeid(holder->fNested));
     if (!cln) {
        TestError("TreeBuilding", Form("Writing holder class: Missing class for %s",
                  typeid(holder->fNested).name()));
     } else {     
        tree->Branch("nested0." ,&(holder->fNestedPtr),32000,0);
        tree->Branch("nested1." ,&(holder->fNestedPtr),32000,1);
        tree->Branch("nested2." ,&(holder->fNestedPtr),32000,2);
        tree->Branch("nested99.",&(holder->fNestedPtr),32000,99);
     }
   }
   for(int i=0; i<nEntry; i++) {
      holder->Reset(i);
      tree->Fill();
   }
   file->Write();
   delete file;
}
Exemple #23
0
template <class HolderClass> bool read(const char *dirname, const char *testname, int nEntry, bool current) {
   HolderClass *holder = 0;
   bool result = true;
   bool testingTopLevelVectors = true; 

   TString filename = gSystem->ConcatFileName(dirname, testname );
   filename += ".root";

   if (!current && gSystem->AccessPathName(filename, kFileExists)) {
      // when reading old directory a missing files is not an error.
      // For example this happens if the run of roottest at the time was done
      // with FAST=yes
      return true;
   }

   TFile file(filename,"READ");

   if (file.IsZombie()) return false;

   holder = dynamic_cast<HolderClass*>( file.Get("holder") );
   if (!holder) {
      TestError("Reading",Form("Missing object: holder"));
      result = false;
   } else {
      result &= holder->Verify(0,Form("%s: write in dir",testname),0);
   }

   TTree *chain = dynamic_cast<TTree*>( file.Get("stltree") );

   if (!chain) {
      TestError("treeReading",Form("Missing TTree: stltree"));
      return false;
   }

   if (nEntry==0 || nEntry>chain->GetEntriesFast()) nEntry = (Int_t)chain->GetEntriesFast();
   for ( Int_t entryInChain = 0, entryInTree = chain->LoadTree(0);
         entryInTree >= 0 && entryInChain<nEntry;
         entryInChain++, entryInTree = chain->LoadTree(entryInChain)
         ) {

      if ( chain->GetEntry(entryInChain) == 0 ) {
         TestError("treeReading",Form("Nothing read for entry #%d",entryInChain));
         break;
      }

      result &= verifyBranch<HolderClass>(testname,chain,"split_2.");
      result &= verifyBranch<HolderClass>(testname,chain,"split_1.");
      result &= verifyBranch<HolderClass>(testname,chain,"split0.");
      result &= verifyBranch<HolderClass>(testname,chain,"split1.");
      result &= verifyBranch<HolderClass>(testname,chain,"split2.");
      result &= verifyBranch<HolderClass>(testname,chain,"split99.");

      if (testingTopLevelVectors) {
         // we know that they all fail! (missing dictionary)
         result &= verifyBranch<HolderClass>(testname,chain,"scalar0",1);
         result &= verifyBranch<HolderClass>(testname,chain,"scalar1",1);
         result &= verifyBranch<HolderClass>(testname,chain,"scalar2",1);
         result &= verifyBranch<HolderClass>(testname,chain,"scalar99",1);
         
         result &= verifyBranch<HolderClass>(testname,chain,"object0",2);
         result &= verifyBranch<HolderClass>(testname,chain,"object1",2);
         result &= verifyBranch<HolderClass>(testname,chain,"object2",2);
         result &= verifyBranch<HolderClass>(testname,chain,"object99",2);
         
         result &= verifyBranch<HolderClass>(testname,chain,"nested0",3);
         result &= verifyBranch<HolderClass>(testname,chain,"nested1",3);
         result &= verifyBranch<HolderClass>(testname,chain,"nested2",3);
         result &= verifyBranch<HolderClass>(testname,chain,"nested99",3);  
      }
   }
   return result;
}
static void TestExceptionHandling(CIMHandler* handler)
{
    CIMInstance indicationHandlerInstance;

    // Test "invalid IndicationHandlerSNMPMapper instance" exception
    CIMInstance indicationInstance(testClass1);
    indicationHandlerInstance = CreateHandlerInstance();
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "no required property TargetHostFormat" exception
    indicationInstance = CIMInstance(testClass1);
    indicationInstance.addProperty(CIMProperty(
       CIMName ("OidDataType"), String("OctetString")));
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "no required property SNMPVersion" exception
    indicationInstance = CIMInstance(testClass1);
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "unsupported snmp Version" exception
    indicationInstance = CIMInstance(testClass1);
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(5)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "invalid MappingStrings Syntax" exception
    indicationInstance = CIMInstance(testClass8);
    indicationInstance.addProperty(CIMProperty(
        CIMName ("OidDataType"), String("OctetString")));
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "invalid MappingStrings value" exception
    indicationInstance = CIMInstance(testClass2);
    indicationInstance.addProperty(CIMProperty(
        CIMName ("OidDataType"), String("OctetString")));
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "no MappingStrings qualifier" exception
    indicationInstance = CIMInstance(testClass3);
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "send trap failed" exception
    indicationInstance = CIMInstance(testClass4);
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPSecurityName"), String("t")));
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
    TestException(handler, indicationHandlerInstance, indicationInstance,
        CIM_ERR_FAILED);

    // Test "failed to add snmp variables to PDU",
    // Both a DiscardedData message and an error message
    // are logged to log file
    indicationInstance = CIMInstance(testClass5);
    indicationInstance.addProperty(CIMProperty(
        CIMName ("OidDataType"), String("OctetString")));
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPSecurityName"), String("t")));
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
    TestError(handler, indicationHandlerInstance, indicationInstance);

    // Test "convert enterprise OID from numeric form to a list of"
    // "subidentifiers failed".
    // Both a DiscardedData message and an error message
    // are logged to log file
    indicationInstance = CIMInstance(testClass5);
    indicationInstance.addProperty(CIMProperty(
        CIMName ("OidDataType"), String("OctetString")));
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPSecurityName"), String("t")));
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
    TestError(handler, indicationHandlerInstance, indicationInstance);

    // Test "convert property OID from numeric form to a list of"
    // "subidentifiers failed".
    // Both a DiscardedData message and an error message
    // are logged to log file
    indicationInstance = CIMInstance(testClass6);
    indicationInstance.addProperty(CIMProperty(
        CIMName ("OidDataType"), String("OctetString")));
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("OtherTargetHostFormat"), String("testOtherTargetHostFormat")));
    TestError(handler, indicationHandlerInstance, indicationInstance);

    // Test "unsupported SNMP data type for the CIM property"
    // Both a DiscardedData message and an error message
    // are logged to log file
    indicationInstance = CIMInstance(testClass7);
    indicationInstance.addProperty(CIMProperty(
        CIMName ("OidDataType"), String("test")));
    indicationHandlerInstance = CreateHandlerInstance();
    indicationHandlerInstance.addProperty(CIMProperty(
       CIMName("TargetHost"), String("15.13.140.120")));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("TargetHostFormat"), Uint16(3)));
    indicationHandlerInstance.addProperty(CIMProperty(
        CIMName("SNMPVersion"), Uint16(2)));
    TestError(handler, indicationHandlerInstance, indicationInstance);
}
Exemple #25
0
unsigned int tdc::getStatusWord(){
    unsigned int DATA;
    TestError(readData(StatusRegister,&DATA),"TDC: read Status");
    return(DATA);
}
Exemple #26
0
void tdc::readOpcode(unsigned int &DATA)
{
  waitRead();
  TestError(readData(Opcode,&DATA),"TDC: reading OPCODE");
}