xrootd
CppUnitXrdHelpers.hh
Go to the documentation of this file.
00001 //------------------------------------------------------------------------------
00002 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
00003 // Author: Lukasz Janyst <ljanyst@cern.ch>
00004 //------------------------------------------------------------------------------
00005 // XRootD is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU Lesser General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // XRootD is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with XRootD.  If not, see <http://www.gnu.org/licenses/>.
00017 //------------------------------------------------------------------------------
00018 
00019 #ifndef __CPPUNIT_XRD_HELPERS_HH__
00020 #define __CPPUNIT_XRD_HELPERS_HH__
00021 
00022 #include <XrdCl/XrdClXRootDResponses.hh>
00023 #include <errno.h>
00024 #include <string.h>
00025 
00026 #define CPPUNIT_ASSERT_XRDST_NOTOK( x, err )         \
00027 {                                                    \
00028   XrdCl::XRootDStatus st = x;                        \
00029   std::string msg = "["; msg += #x; msg += "]: ";    \
00030   msg += st.ToStr();                                 \
00031   CPPUNIT_ASSERT_MESSAGE( msg, !st.IsOK() && st.code == err ); \
00032 }
00033 
00034 #define CPPUNIT_ASSERT_XRDST( x )                    \
00035 {                                                    \
00036   XrdCl::XRootDStatus st = x;                        \
00037   std::string msg = "["; msg += #x; msg += "]: ";    \
00038   msg += st.ToStr();                                 \
00039   CPPUNIT_ASSERT_MESSAGE( msg, st.IsOK() );          \
00040 }
00041 
00042 #define CPPUNIT_ASSERT_ERRNO( x )                    \
00043 {                                                    \
00044   std::string msg = "["; msg += #x; msg += "]: ";    \
00045   msg += strerror( errno );                          \
00046   CPPUNIT_ASSERT_MESSAGE( msg, x );                  \
00047 }
00048 
00049 #define CPPUNIT_ASSERT_PTHREAD( x )                  \
00050 {                                                    \
00051   errno = x;                                         \
00052   std::string msg = "["; msg += #x; msg += "]: ";    \
00053   msg += strerror( errno );                          \
00054   CPPUNIT_ASSERT_MESSAGE( msg, errno == 0 );         \
00055 }
00056 
00057 #endif // __CPPUNIT_XRD_HELPERS_HH__