strengthen AliHLT_C_Component_WrapperInterface unit test
authorrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 28 Jul 2008 12:53:06 +0000 (12:53 +0000)
committerrichterm <richterm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 28 Jul 2008 12:53:06 +0000 (12:53 +0000)
HLT/BASE/test/testAliHLT_C_Component_WrapperInterface.C

index 6b4a8c6..8fe6099 100644 (file)
@@ -51,18 +51,35 @@ public:
   AliHLTComponent* Spawn() {return new TestProcessor;}
 private:
   int DoInit( int argc, const char** argv ) {
+    if (fState!=kCreated) {
+      HLTError("wrong state (%d): component already initialized", fState);
+      return -EBUSY;
+    }
+
     if (argc>0 && argv) {
     }
     gRunNo=GetRunNo();
     gChainId=GetChainId();
+
+    fState=kInitialized;
     return 0;
   }
   int DoDeinit() {
+    if (fState!=kInitialized) {
+      HLTError("wrong state (%d): required %d kInitialized", fState, kInitialized);
+      return -ENODEV;
+    }
+
     return 0;
   }
 
   int DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) {
     int iResult=0;
+    if (fState!=kInitialized) {
+      HLTError("wrong state (%d): component not initialized", fState);
+      return -ENODEV;
+    }
+
     HLTInfo("processing event");
     for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock();
         pBlock!=NULL; 
@@ -73,12 +90,24 @@ private:
       iResult=PushBack(pBlock->fPtr, pBlock->fSize/2, dt, ~pBlock->fSpecification);
       Forward();
     }
+
     return iResult;
   }
+
+  enum {
+    kCreated =0,
+    kInitialized,
+    kProcessing,
+  };
+
+  int fState; //!transient
 };
 
 TestProcessor::TestProcessor()
-  : AliHLTProcessor() 
+  : 
+  AliHLTProcessor(),
+  fState(kCreated)
 {
 }