20# include <ext/stdio_filebuf.h>
37 m_f1 =
"/etc/redhat-release";
43 m_fr2 =
"http://annwm.lbl.gov/~leggett/tuple2.rt";
44 m_fr3 =
"https://t-dpm.grid.sinica.edu.tw/dpm/grid.sinica.edu.tw/home/atlas/atlasppsscratchdisk/mc10_7TeV/AOD/"
45 "e574_s1110_s1100_r1655_r1700/"
46 "mc10_7TeV.105805.filtered_minbias6.merge.AOD.e574_s1110_s1100_r1655_r1700_tid261524_00/"
47 "AOD.261524._032551.pool.root.1";
59 error() <<
"unable to register POSIX file open action with FileMgr" <<
endmsg;
63 error() <<
"unable to register POSIX file open ERR action with FileMgr" <<
endmsg;
69 error() <<
"unable to register all Close action with FileMgr" <<
endmsg;
93 std::ofstream ofs{
m_f3 };
94 ofs <<
"initial line" << std::endl;
108 error() <<
"the following error is expected" <<
endmsg;
111 info() <<
"unable to open " <<
m_f2 <<
" for WRITE|CREATE|EXCL - expected as file already exists" <<
endmsg;
113 error() <<
"opened " <<
m_f2 <<
" for reading with FD: " << fd <<
" This should not occur!" <<
endmsg;
118 error() <<
"unable to open " <<
m_f1 <<
" again for reading" <<
endmsg;
156 for (
int j = 0; j < 2; ++j ) {
159 error() <<
"unable to open t6.txt for writing" <<
endmsg;
161 info() <<
"opened t6.txt for writing, fd: " << fd <<
" will now close" <<
endmsg;
182 __gnu_cxx::stdio_filebuf<char> fb(
fp_2, std::ios::out );
184 ofs.std::ios::rdbuf( &fb );
185 ofs <<
"Hello World!" << std::endl;
190 __gnu_cxx::stdio_filebuf<char> fb2(
fp_3, std::ios::out );
192 ofs2.std::ios::rdbuf( &fb2 );
193 ofs2 <<
"Hello World!" << std::endl;
203 std::vector<std::string> v;
204 std::vector<std::string>::const_iterator itr;
208 log <<
"listing all open files [" << i <<
"]" << std::endl;
209 for ( itr = v.begin(); itr != v.end(); ++itr ) { log <<
" " << *itr << std::endl; }
213 log <<
"listing ALL files [" << i <<
"]" << std::endl;
214 for ( itr = v.begin(); itr != v.end(); ++itr ) { log <<
" " << *itr << std::endl; }
217 std::vector<const Io::FileAttr*> v2;
218 std::vector<const Io::FileAttr*>::const_iterator it2;
220 log <<
"listing all POSIX files ever opened [" << i <<
"]" << std::endl;
221 for ( it2 = v2.begin(); it2 != v2.end(); ++it2 ) { log <<
" " << ( *it2 )->name() << std::endl; }
283 info() <<
"PosixOpenAction called by " << c <<
" for tech " << fa->
tech() <<
" on " << fa <<
endmsg;
304 info() <<
"AllCloseAction called by " << c <<
" for tech " << fa->
tech() <<
" on " << fa <<
endmsg;
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
an algorithm to test the FileMgr
StatusCode initialize() override
StatusCode execute() override
StatusCode finalize() override
ServiceHandle< IFileMgr > p_fileMgr
StatusCode allCloseAction(FILEMGR_CALLBACK_ARGS)
StatusCode PosixOpenAction(FILEMGR_CALLBACK_ARGS)
FileMgrTest(const std::string &name, ISvcLocator *pSvcLocator)
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
const std::string & name() const override
The identifying name of the algorithm object.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
This class is used for returning status codes from appropriate routines.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
std::function< StatusCode(FILEMGR_CALLBACK_ARGS)> bfcn_action_t