xrootd
CppUnitXrdHelpers.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // Copyright (c) 2011-2012 by European Organization for Nuclear Research (CERN)
3 // Author: Lukasz Janyst <ljanyst@cern.ch>
4 //------------------------------------------------------------------------------
5 // XRootD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // XRootD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
17 //------------------------------------------------------------------------------
18 
19 #ifndef __CPPUNIT_XRD_HELPERS_HH__
20 #define __CPPUNIT_XRD_HELPERS_HH__
21 
23 #include <errno.h>
24 #include <string.h>
25 
26 #define CPPUNIT_ASSERT_XRDST_NOTOK( x, err ) \
27 { \
28  XrdCl::XRootDStatus st = x; \
29  std::string msg = "["; msg += #x; msg += "]: "; \
30  msg += st.ToStr(); \
31  CPPUNIT_ASSERT_MESSAGE( msg, !st.IsOK() && st.code == err ); \
32 }
33 
34 #define CPPUNIT_ASSERT_XRDST( x ) \
35 { \
36  XrdCl::XRootDStatus st = x; \
37  std::string msg = "["; msg += #x; msg += "]: "; \
38  msg += st.ToStr(); \
39  CPPUNIT_ASSERT_MESSAGE( msg, st.IsOK() ); \
40 }
41 
42 #define CPPUNIT_ASSERT_ERRNO( x ) \
43 { \
44  std::string msg = "["; msg += #x; msg += "]: "; \
45  msg += strerror( errno ); \
46  CPPUNIT_ASSERT_MESSAGE( msg, x ); \
47 }
48 
49 #define CPPUNIT_ASSERT_PTHREAD( x ) \
50 { \
51  errno = x; \
52  std::string msg = "["; msg += #x; msg += "]: "; \
53  msg += strerror( errno ); \
54  CPPUNIT_ASSERT_MESSAGE( msg, errno == 0 ); \
55 }
56 
57 #endif // __CPPUNIT_XRD_HELPERS_HH__