00001
00002
00004 #include "IoModules/test/IoInputModuleValidate.h"
00005 #include "MessageService/MsgService.h"
00006 #include "MessageService/MsgFormat.h"
00007 #include "MinosObjectMap/MomNavigator.h"
00008 #include "JobControl/JobCommand.h"
00009 #include "Persistency/Per.h"
00010
00011 using std::endl;
00012
00013 CVSID("$Id: IoInputModuleValidate.cxx,v 1.4 2006/06/28 04:30:23 rhatcher Exp $");
00014
00015
00016
00017 IoInputModuleValidate::IoInputModuleValidate(int nfiles,
00018 const char* const* files) :
00019 fNfiles(nfiles),fFileName(files)
00020 {
00021
00022
00023
00024
00025
00026
00027 MsgService::Instance() -> GetStream("Io") -> SetLogLevel(Msg::kVerbose);
00028 MsgService::Instance() -> GetStream("Per") -> SetLogLevel(Msg::kVerbose);
00029 fIoModule.Config(fIoModule.DefaultConfig());
00030 cout << "nfiles = " << fNfiles << endl;
00031
00032 }
00033
00034
00035
00036 IoInputModuleValidate::~IoInputModuleValidate() {}
00037
00038
00039
00040 bool IoInputModuleValidate::TestAdd()
00041 {
00042
00043
00044
00045
00046 MSG("Io",Msg::kDebug) << "TestAdd -- \n";
00047 MSG("Io",Msg::kDebug) << " Before:" << endl;
00048
00049 fIoModule.List();
00050 for (int i=0; i<fNfiles; ++i) {
00051 string s(fFileName[i]);
00052 fIoModule.AddFile(s.c_str());
00053 }
00054 MSG("Io",Msg::kDebug) << " After:" << endl;
00055 fIoModule.List();
00056 return true;
00057 }
00058
00059
00060
00061 bool IoInputModuleValidate::TestRemove()
00062 {
00063 MSG("Io",Msg::kDebug) << "TestRemove every other file -- \n";
00064 MSG("Io",Msg::kDebug) << " Before:" << endl;
00065 fIoModule.List();
00066 for (int i=1; i<fNfiles; i += 2) {
00067 string s(fFileName[i]);
00068 fIoModule.RemoveFile(s.c_str());
00069 }
00070 MSG("Io",Msg::kDebug) << " After:" << endl;
00071 fIoModule.List();
00072 return true;
00073 }
00074
00075
00076
00077 bool IoInputModuleValidate::TestNextFile()
00078 {
00079 MSG("Io",Msg::kDebug) << "Test NextFile by 3" << endl;
00080 fIoModule.NextFile(3);
00081 fIoModule.List();
00082 return true;
00083 }
00084
00085
00086
00087 bool IoInputModuleValidate::TestPrevFile()
00088 {
00089 MSG("Io",Msg::kDebug) << "Test PrevFile by 2" << endl;
00090 fIoModule.PrevFile(2);
00091 fIoModule.List();
00092 return true;
00093 }
00094
00095
00096
00097 bool IoInputModuleValidate::TestGoToFile()
00098 {
00099 MSG("Io",Msg::kDebug) << "Test GoToFile 2" << endl;
00100 fIoModule.GoToFile(2);
00101 fIoModule.List();
00102 return true;
00103 }
00104
00105
00106
00107 bool IoInputModuleValidate::TestNext()
00108 {
00109 MSG("Io",Msg::kDebug) << "Test Next by 10" << endl;
00110 fIoModule.Next(10);
00111 fIoModule.List();
00112 return true;
00113 }
00114
00115
00116
00117 bool IoInputModuleValidate::TestPrev()
00118 {
00119 MSG("Io",Msg::kDebug) << "Test Prev by 10" << endl;
00120 fIoModule.Prev(10);
00121 return true;
00122 }
00123
00124
00125
00126
00127 bool IoInputModuleValidate::TestStreams()
00128 {
00129 MSG("Io",Msg::kDebug) << "Test Streams" << endl;
00130 fIoModule.Set("Streams=DaqSnarl,LightInjection");
00131 fIoModule.List();
00132 return true;
00133 }
00134
00135
00136
00137 bool IoInputModuleValidate::TestGoToEOF()
00138 {
00139 MSG("Io",Msg::kDebug) << "Test GoToEOF" << endl;
00140 fIoModule.GoTo(Per::GetVldEnd());
00141 fIoModule.List();
00142 return true;
00143 }
00144
00145
00146
00147 bool IoInputModuleValidate::TestSetFormat()
00148 {
00149 return true;
00150 }
00151
00152 bool IoInputModuleValidate::TestGet()
00153 {
00154 MSG("Io",Msg::kDebug) << "Test Get" << endl;
00155 int i;
00156 MomNavigator mom;
00157 MsgFormat fmt("%4d");
00158 JobCResult r;
00159 for (i=0; r.EndOfInputStream() == false; ++i) {
00160 fIoModule.Get();
00161
00162 MSG("Io",Msg::kInfo) << fmt(i);
00163 if (i%15 == 14) MSG("Io",Msg::kInfo) << endl;
00164
00165 r = fIoModule.Next();
00166 }
00167 MSG("Io",Msg::kInfo) << endl;
00168 MSG("Io",Msg::kInfo) << "Read " << i << " events from file list" << endl;
00169 return true;
00170 }
00171
00172
00173
00174 bool IoInputModuleValidate::RunAllTests()
00175 {
00176 bool passed;
00177 MomNavigator* mom = new MomNavigator();
00178 fIoModule.SetMom(mom);
00179 passed = this->TestAdd();
00180 passed &= this->TestRemove();
00181 passed &= this->TestNextFile();
00182 passed &= this->TestPrevFile();
00183 passed &= this->TestGoToFile();
00184 passed &= this->TestStreams();
00185 passed &= this->TestNext();
00186 passed &= this->TestGoToEOF();
00187 passed &= this->TestPrev();
00188 passed &= this->TestGet();
00189 mom = fIoModule.GetMom();
00190 if ( mom ) delete mom; mom = 0;
00191
00192 return passed;
00193 }
00194