Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
06fd6ced
Commit
06fd6ced
authored
Nov 26, 2013
by
Eric Cano
Browse files
Renamed unit tests for easier location.
Lowercased/Upercased some namespace/class names for homogeneity.
parent
ccab13ab
Changes
16
Hide whitespace changes
Inline
Side-by-side
castor/tape/tapeserver/Daemon/tapeserverd.cpp
View file @
06fd6ced
...
...
@@ -68,14 +68,14 @@ throw (castor::tape::Exception)
break
;
case
':'
:
{
castor
::
tape
::
E
xceptions
::
InvalidArgument
ex
(
std
::
string
(
"The -"
)
+
(
char
)
optopt
+
" option requires a parameter"
);
castor
::
tape
::
e
xceptions
::
InvalidArgument
ex
(
std
::
string
(
"The -"
)
+
(
char
)
optopt
+
" option requires a parameter"
);
throw
ex
;
}
case
'?'
:
{
std
::
stringstream
err
(
"Unknown command-line option"
);
if
(
optopt
)
err
<<
std
::
string
(
": -"
)
<<
optopt
;
castor
::
tape
::
E
xceptions
::
InvalidArgument
ex
(
err
.
str
().
c_str
());
castor
::
tape
::
e
xceptions
::
InvalidArgument
ex
(
err
.
str
().
c_str
());
throw
ex
;
}
default:
...
...
@@ -83,7 +83,7 @@ throw (castor::tape::Exception)
std
::
stringstream
err
;
err
<<
"getopt_long returned the following unknown value: 0x"
<<
std
::
hex
<<
(
int
)
c
;
castor
::
tape
::
E
xceptions
::
InvalidArgument
ex
(
err
.
str
().
c_str
());
castor
::
tape
::
e
xceptions
::
InvalidArgument
ex
(
err
.
str
().
c_str
());
throw
ex
;
}
}
...
...
@@ -101,7 +101,7 @@ void castor::tape::Server::Daemon::daemonize()
/* Fork off the parent process */
pid
=
fork
();
if
(
pid
<
0
)
{
castor
::
tape
::
E
xceptions
::
Errnum
e
(
"Failed to fork in castor::tape::Server::Daemon::daemonize"
);
castor
::
tape
::
e
xceptions
::
Errnum
e
(
"Failed to fork in castor::tape::Server::Daemon::daemonize"
);
throw
e
;
}
/* If we got a good PID, then we can exit the parent process. */
...
...
@@ -115,7 +115,7 @@ void castor::tape::Server::Daemon::daemonize()
/* Create a new session for the child process */
sid
=
setsid
();
if
(
sid
<
0
)
{
castor
::
tape
::
E
xceptions
::
Errnum
e
(
"Failed to create new session in castor::tape::Server::Daemon::daemonize"
);
castor
::
tape
::
e
xceptions
::
Errnum
e
(
"Failed to create new session in castor::tape::Server::Daemon::daemonize"
);
throw
e
;
}
...
...
@@ -130,7 +130,7 @@ void castor::tape::Server::Daemon::daemonize()
if
((
chdir
(
m_options
.
runDirectory
.
c_str
()))
<
0
)
{
std
::
stringstream
err
(
"Failed to chdir in castor::tape::Server::Daemon::daemonize"
);
err
<<
" ( destination directory: "
<<
m_options
.
runDirectory
<<
")"
;
castor
::
tape
::
E
xceptions
::
Errnum
e
(
err
.
str
());
castor
::
tape
::
e
xceptions
::
Errnum
e
(
err
.
str
());
throw
e
;
}
...
...
castor/tape/tapeserver/Drive/CMakeLists.txt
View file @
06fd6ced
...
...
@@ -6,5 +6,5 @@ set_property(SOURCE Drive.cpp
add_executable
(
TapeDriveReadWriteTest TapeDriveReadWriteTest.cpp
)
target_link_libraries
(
TapeDriveReadWriteTest TapeDrive Exception SCSI System Utils castorcommon
${
GTEST_LIBRARY
}
gmock pthread
)
install
(
TARGETS TapeDriveReadWriteTest
RUNTIME DESTINATION bin
)
#
install(TARGETS TapeDriveReadWriteTest
#
RUNTIME DESTINATION bin)
castor/tape/tapeserver/Drive/Drive.cpp
View file @
06fd6ced
...
...
@@ -34,10 +34,10 @@ m_tapeFD(-1), m_sysWrapper(sw) {
*/
m_tapeFD
=
m_sysWrapper
.
open
(
m_SCSIInfo
.
nst_dev
.
c_str
(),
O_RDWR
|
O_NONBLOCK
);
if
(
-
1
==
m_tapeFD
)
throw
E
xceptions
::
Errnum
(
std
::
string
(
"Could not open device file: "
+
m_SCSIInfo
.
nst_dev
));
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Could not open device file: "
+
m_SCSIInfo
.
nst_dev
));
/* Read drive status */
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCGET
,
&
m_mtInfo
))
throw
E
xceptions
::
Errnum
(
std
::
string
(
"Could not read drive status: "
+
m_SCSIInfo
.
nst_dev
));
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Could not read drive status: "
+
m_SCSIInfo
.
nst_dev
));
}
/**
...
...
@@ -59,7 +59,7 @@ void drives::DriveGeneric::clearCompressionStats() throw (Exception) {
/* Manage both system error and SCSI errors. */
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
SCSI
::
ExceptionLauncher
(
sgh
,
"SCSI error in clearCompressionStats:"
);
}
...
...
@@ -81,7 +81,7 @@ drives::deviceInfo drives::DriveGeneric::getDeviceInfo() throw (Exception) {
/* Manage both system error and SCSI errors. */
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
SCSI
::
ExceptionLauncher
(
sgh
,
std
::
string
(
"SCSI error in getDeviceInfo: "
)
+
SCSI
::
statusToString
(
sgh
.
status
));
...
...
@@ -115,7 +115,7 @@ std::string drives::DriveGeneric::getSerialNumber() throw (Exception) {
/* Manage both system error and SCSI errors. */
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
SCSI
::
ExceptionLauncher
(
sgh
,
std
::
string
(
"SCSI error in getSerialNumber: "
)
+
SCSI
::
statusToString
(
sgh
.
status
));
std
::
string
serialNumber
;
...
...
@@ -148,7 +148,7 @@ throw (Exception) {
/* Manage both system error and SCSI errors. */
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
SCSI
::
ExceptionLauncher
(
sgh
,
"SCSI error in positionToLogicalObject:"
);
}
...
...
@@ -174,7 +174,7 @@ throw (Exception) {
/* Manage both system error and SCSI errors. */
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
SCSI
::
ExceptionLauncher
(
sgh
,
std
::
string
(
"SCSI error in getPositionInfo: "
)
+
SCSI
::
statusToString
(
sgh
.
status
));
...
...
@@ -219,7 +219,7 @@ std::vector<std::string> drives::DriveGeneric::getTapeAlerts() throw (Exception)
sgh
.
dxfer_direction
=
SG_DXFER_FROM_DEV
;
/* Manage both system error and SCSI errors. */
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
SCSI
::
ExceptionLauncher
(
sgh
,
std
::
string
(
"SCSI error in getTapeAlerts: "
)
+
SCSI
::
statusToString
(
sgh
.
status
));
/* Return the ACTIVE tape alerts (this is indicated by "flag" (see
...
...
@@ -265,7 +265,7 @@ void drives::DriveGeneric::setDensityAndCompression(unsigned char densityCode,
/* Manage both system error and SCSI errors. */
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
SCSI
::
ExceptionLauncher
(
sgh
,
std
::
string
(
"SCSI error in setDensityAndCompression: "
)
+
SCSI
::
statusToString
(
sgh
.
status
));
...
...
@@ -291,7 +291,7 @@ void drives::DriveGeneric::setDensityAndCompression(unsigned char densityCode,
/* Manage both system error and SCSI errors. */
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
SCSI
::
ExceptionLauncher
(
sgh
,
std
::
string
(
"SCSI error in setDensityAndCompression: "
)
+
SCSI
::
statusToString
(
sgh
.
status
));
...
...
@@ -309,7 +309,7 @@ void drives::DriveGeneric::setSTBufferWrite(bool bufWrite) throw (Exception) {
m_mtCmd
.
mt_op
=
MTSETDRVBUFFER
;
m_mtCmd
.
mt_count
=
bufWrite
?
(
MT_ST_SETBOOLEANS
|
MT_ST_BUFFER_WRITES
)
:
(
MT_ST_CLEARBOOLEANS
|
MT_ST_BUFFER_WRITES
);
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTSETDRVBUFFER)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTSETDRVBUFFER)"
);
}
/**
...
...
@@ -326,7 +326,7 @@ void drives::DriveGeneric::spaceToEOM(void) throw (Exception) {
m_mtCmd
.
mt_op
=
MTEOM
;
m_mtCmd
.
mt_count
=
1
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTEOM)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTEOM)"
);
}
/**
...
...
@@ -340,7 +340,7 @@ void drives::DriveGeneric::setSTFastMTEOM(bool fastMTEOM) throw (Exception) {
m_mtCmd
.
mt_op
=
MTSETDRVBUFFER
;
m_mtCmd
.
mt_count
=
fastMTEOM
?
(
MT_ST_SETBOOLEANS
|
MT_ST_FAST_MTEOM
)
:
(
MT_ST_CLEARBOOLEANS
|
MT_ST_FAST_MTEOM
);
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTSETDRVBUFFER)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTSETDRVBUFFER)"
);
}
/**
...
...
@@ -353,7 +353,7 @@ void drives::DriveGeneric::fastSpaceToEOM(void) throw (Exception) {
m_mtCmd
.
mt_op
=
MTEOM
;
m_mtCmd
.
mt_count
=
1
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTEOM)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTEOM)"
);
}
/**
...
...
@@ -364,7 +364,7 @@ void drives::DriveGeneric::rewind(void) throw (Exception) {
m_mtCmd
.
mt_op
=
MTREW
;
m_mtCmd
.
mt_count
=
1
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTREW)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTREW)"
);
}
/**
...
...
@@ -376,7 +376,7 @@ void drives::DriveGeneric::spaceFileMarksBackwards(size_t count) throw (Exceptio
m_mtCmd
.
mt_op
=
MTBSF
;
m_mtCmd
.
mt_count
=
(
int
)
count
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTBSF)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTBSF)"
);
}
/**
...
...
@@ -388,7 +388,7 @@ void drives::DriveGeneric::spaceFileMarksForward(size_t count) throw (Exception)
m_mtCmd
.
mt_op
=
MTFSF
;
m_mtCmd
.
mt_count
=
(
int
)
count
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTFSF)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTFSF)"
);
}
/**
...
...
@@ -403,7 +403,7 @@ void drives::DriveGeneric::spaceBlocksBackwards(size_t count) throw (Exception)
m_mtCmd
.
mt_op
=
MTBSR
;
m_mtCmd
.
mt_count
=
(
int
)
count
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTBSR)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTBSR)"
);
}
/**
...
...
@@ -418,7 +418,7 @@ void drives::DriveGeneric::spaceBlocksForward(size_t count) throw (Exception) {
m_mtCmd
.
mt_op
=
MTFSR
;
m_mtCmd
.
mt_count
=
(
int
)
count
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTFSR)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTFSR)"
);
}
/**
...
...
@@ -429,7 +429,7 @@ void drives::DriveGeneric::unloadTape(void) throw (Exception) {
m_mtCmd
.
mt_op
=
MTUNLOAD
;
m_mtCmd
.
mt_count
=
1
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTUNLOAD)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTUNLOAD)"
);
}
/**
...
...
@@ -441,7 +441,7 @@ void drives::DriveGeneric::sync(void) throw (Exception) {
m_mtCmd
.
mt_op
=
MTNOP
;
//The side effect of the no-op is to actually flush the driver's buffer to tape (see "man st").
m_mtCmd
.
mt_count
=
1
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTNOP)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTNOP)"
);
}
/**
...
...
@@ -454,7 +454,7 @@ void drives::DriveGeneric::writeSyncFileMarks(size_t count) throw (Exception) {
m_mtCmd
.
mt_op
=
MTWEOF
;
m_mtCmd
.
mt_count
=
(
int
)
count
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTWEOF)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTWEOF)"
);
}
/**
...
...
@@ -467,7 +467,7 @@ void drives::DriveGeneric::writeImmediateFileMarks(size_t count) throw (Exceptio
m_mtCmd
.
mt_op
=
MTWEOFI
;
//Undocumented in "man st" needs the mtio_add.hh header file (see above)
m_mtCmd
.
mt_count
=
(
int
)
count
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
m_tapeFD
,
MTIOCTOP
,
&
m_mtCmd
))
throw
E
xceptions
::
Errnum
(
"Failed ST ioctl (MTWEOFI)"
);
throw
e
xceptions
::
Errnum
(
"Failed ST ioctl (MTWEOFI)"
);
}
/**
...
...
@@ -477,7 +477,7 @@ void drives::DriveGeneric::writeImmediateFileMarks(size_t count) throw (Exceptio
*/
void
drives
::
DriveGeneric
::
writeBlock
(
const
unsigned
char
*
data
,
size_t
count
)
throw
(
Exception
)
{
if
(
-
1
==
m_sysWrapper
.
write
(
m_tapeFD
,
data
,
count
))
throw
E
xceptions
::
Errnum
(
"Failed ST write"
);
throw
e
xceptions
::
Errnum
(
"Failed ST write"
);
}
/**
...
...
@@ -487,7 +487,7 @@ void drives::DriveGeneric::writeBlock(const unsigned char * data, size_t count)
*/
void
drives
::
DriveGeneric
::
readBlock
(
unsigned
char
*
data
,
size_t
count
)
throw
(
Exception
)
{
if
(
-
1
==
m_sysWrapper
.
read
(
m_tapeFD
,
data
,
count
))
throw
E
xceptions
::
Errnum
(
"Failed ST read"
);
throw
e
xceptions
::
Errnum
(
"Failed ST read"
);
}
void
drives
::
DriveGeneric
::
SCSI_inquiry
()
{
...
...
@@ -514,7 +514,7 @@ void drives::DriveGeneric::SCSI_inquiry(int fd) {
sgh
.
dxfer_len
=
sizeof
(
dataBuff
);
sgh
.
timeout
=
30000
;
if
(
-
1
==
m_sysWrapper
.
ioctl
(
fd
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
std
::
cout
<<
"INQUIRY result: "
<<
std
::
endl
<<
"sgh.dxfer_len="
<<
sgh
.
dxfer_len
<<
" sgh.sb_len_wr="
<<
((
int
)
sgh
.
sb_len_wr
)
...
...
@@ -547,7 +547,7 @@ drives::compressionStats drives::DriveT10000::getCompression() throw (Exception)
/* Manage both system error and SCSI errors. */
if
(
-
1
==
this
->
m_sysWrapper
.
ioctl
(
this
->
m_tapeFD
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
SCSI
::
ExceptionLauncher
(
sgh
,
std
::
string
(
"SCSI error in getCompression: "
)
+
SCSI
::
statusToString
(
sgh
.
status
));
...
...
@@ -604,7 +604,7 @@ drives::compressionStats drives::DriveLTO::getCompression() throw (Exception) {
/* Manage both system error and SCSI errors. */
if
(
-
1
==
this
->
m_sysWrapper
.
ioctl
(
this
->
m_tapeFD
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
SCSI
::
ExceptionLauncher
(
sgh
,
std
::
string
(
"SCSI error in getCompression: "
)
+
SCSI
::
statusToString
(
sgh
.
status
));
...
...
@@ -679,7 +679,7 @@ drives::compressionStats drives::DriveIBM3592::getCompression() throw (Exception
/* Manage both system error and SCSI errors. */
if
(
-
1
==
this
->
m_sysWrapper
.
ioctl
(
this
->
m_tapeFD
,
SG_IO
,
&
sgh
))
throw
E
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
throw
e
xceptions
::
Errnum
(
"Failed SG_IO ioctl"
);
SCSI
::
ExceptionLauncher
(
sgh
,
std
::
string
(
"SCSI error in getCompression: "
)
+
SCSI
::
statusToString
(
sgh
.
status
));
...
...
castor/tape/tapeserver/Drive/DriveTest.cpp
View file @
06fd6ced
...
...
@@ -35,7 +35,7 @@ using ::testing::An;
namespace
UnitTests
{
TEST
(
Tape
Drive
,
OpensCorrectly
)
{
TEST
(
castor_tape_drives_
Drive
,
OpensCorrectly
)
{
/* Prepare the test harness */
castor
::
tape
::
System
::
mockWrapper
sysWrapper
;
sysWrapper
.
fake
.
setupSLC5
();
...
...
@@ -64,7 +64,7 @@ TEST(TapeDrive, OpensCorrectly) {
}
}
TEST
(
Tape
Drive
,
getPositionInfoAndPositionToLogicalObject
)
{
TEST
(
castor_tape_drives_
Drive
,
getPositionInfoAndPositionToLogicalObject
)
{
/* Prepare the test harness */
castor
::
tape
::
System
::
mockWrapper
sysWrapper
;
sysWrapper
.
fake
.
setupSLC5
();
...
...
@@ -115,7 +115,7 @@ TEST(TapeDrive, getPositionInfoAndPositionToLogicalObject) {
}
}
}
TEST
(
Tape
Drive
,
setDensityAndCompression
)
{
TEST
(
castor_tape_drives_
Drive
,
setDensityAndCompression
)
{
/* Prepare the test harness */
castor
::
tape
::
System
::
mockWrapper
sysWrapper
;
sysWrapper
.
fake
.
setupSLC5
();
...
...
@@ -162,7 +162,7 @@ TEST(TapeDrive, setDensityAndCompression) {
}
}
TEST
(
Tape
Drive
,
setStDriverOptions
)
{
TEST
(
castor_tape_drives_
Drive
,
setStDriverOptions
)
{
/* Prepare the test harness */
castor
::
tape
::
System
::
mockWrapper
sysWrapper
;
sysWrapper
.
fake
.
setupSLC5
();
...
...
@@ -199,7 +199,7 @@ TEST(TapeDrive, setStDriverOptions) {
}
}
TEST
(
Tape
Drive
,
getDeviceInfo
)
{
TEST
(
castor_tape_drives_
Drive
,
getDeviceInfo
)
{
/* Prepare the test harness */
castor
::
tape
::
System
::
mockWrapper
sysWrapper
;
sysWrapper
.
fake
.
setupSLC5
();
...
...
@@ -240,7 +240,7 @@ TEST(TapeDrive, getDeviceInfo) {
}
}
TEST
(
Tape
Drive
,
getCompressionAndClearCompressionStats
)
{
TEST
(
castor_tape_drives_
Drive
,
getCompressionAndClearCompressionStats
)
{
/* Prepare the test harness */
castor
::
tape
::
System
::
mockWrapper
sysWrapper
;
sysWrapper
.
fake
.
setupSLC5
();
...
...
@@ -337,7 +337,7 @@ TEST(TapeDrive, getCompressionAndClearCompressionStats) {
}
}
TEST
(
Tape
Drive
,
getTapeAlerts
)
{
TEST
(
castor_tape_drives_
Drive
,
getTapeAlerts
)
{
/**
* "Local function" allowing the test to be run twice (for SLC5 and then for
...
...
castor/tape/tapeserver/Exception/Exception.cpp
View file @
06fd6ced
...
...
@@ -46,7 +46,7 @@ Exception::Exception(const Exception &ex): castor::exception::Exception(0) {
m_backtrace
=
ex
.
m_backtrace
;
}
E
xceptions
::
Errnum
::
Errnum
(
std
::
string
what
)
:
Exception
(
""
)
{
e
xceptions
::
Errnum
::
Errnum
(
std
::
string
what
)
:
Exception
(
""
)
{
m_errnum
=
errno
;
char
s
[
1000
];
/* _XOPEN_SOURCE seems not to work. */
...
...
castor/tape/tapeserver/Exception/Exception.hpp
View file @
06fd6ced
...
...
@@ -39,7 +39,7 @@ namespace tape {
void
setWhat
(
const
std
::
string
&
w
);
};
namespace
E
xceptions
{
namespace
e
xceptions
{
class
Errnum
:
public
Exception
{
public:
Errnum
(
std
::
string
what
=
""
);
...
...
castor/tape/tapeserver/Exception/ExceptionTest.cpp
View file @
06fd6ced
...
...
@@ -52,7 +52,7 @@ namespace UnitTests {
f2
();
}
TEST
(
E
xceptions
,
stacktrace_with_demangling
)
{
TEST
(
castor_tape_e
xceptions
,
stacktrace_with_demangling
)
{
try
{
Nested
x
;
}
catch
(
castor
::
tape
::
Exception
&
e
)
{
...
...
@@ -65,11 +65,11 @@ namespace UnitTests {
}
}
TEST
(
E
xceptions
,
errnum_throwing
)
{
TEST
(
castor_tape_e
xceptions
,
errnum_throwing
)
{
/* Mickey Mouse test as we had trouble which throwing Errnum (with errno=ENOENT)*/
errno
=
ENOENT
;
try
{
throw
castor
::
tape
::
E
xceptions
::
Errnum
(
"Test ENOENT"
);
throw
castor
::
tape
::
e
xceptions
::
Errnum
(
"Test ENOENT"
);
}
catch
(
std
::
exception
&
e
)
{
std
::
string
temp
=
e
.
what
();
temp
+=
" "
;
...
...
castor/tape/tapeserver/File/Structures.cpp
View file @
06fd6ced
...
...
@@ -38,29 +38,29 @@ void AULFile::VOL1::fill(std::string vsn) {
void
AULFile
::
VOL1
::
verify
()
{
if
(
cmpString
(
label
,
"VOL1"
))
throw
E
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the VOL1: "
)
+
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the VOL1: "
)
+
AULFile
::
toString
(
label
));
if
(
!
cmpString
(
VSN
,
""
))
throw
E
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the VSN: "
)
+
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the VSN: "
)
+
AULFile
::
toString
(
VSN
));
if
(
cmpString
(
lblStandard
,
"3"
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the label standard: "
)
+
AULFile
::
toString
(
lblStandard
));
if
(
cmpString
(
ownerID
,
"CASTOR"
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the ownerID: "
)
+
AULFile
::
toString
(
ownerID
));
/* now we verify all other fields which must be spaces */
if
(
cmpString
(
accessibility
,
""
))
throw
E
xceptions
::
Errnum
(
"accessibility is not empty"
);
throw
e
xceptions
::
Errnum
(
"accessibility is not empty"
);
if
(
cmpString
(
reserved1
,
""
))
throw
E
xceptions
::
Errnum
(
"reserved1 is not empty"
);
throw
e
xceptions
::
Errnum
(
"reserved1 is not empty"
);
if
(
cmpString
(
implID
,
""
))
throw
E
xceptions
::
Errnum
(
"implID is not empty"
);
throw
e
xceptions
::
Errnum
(
"implID is not empty"
);
if
(
cmpString
(
reserved2
,
""
))
throw
E
xceptions
::
Errnum
(
"reserved2 is not empty"
);
throw
e
xceptions
::
Errnum
(
"reserved2 is not empty"
);
}
void
AULFile
::
HDR1EOF1
::
fillCommon
(
...
...
@@ -86,47 +86,47 @@ void AULFile::HDR1EOF1::fillCommon(
}
void
AULFile
::
HDR1EOF1
::
verifyCommon
()
const
throw
(
E
xceptions
::
Errnum
)
{
const
throw
(
e
xceptions
::
Errnum
)
{
if
(
!
cmpString
(
fileId
,
""
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the fileId: "
)
+
AULFile
::
toString
(
fileId
));
if
(
!
cmpString
(
VSN
,
""
))
throw
E
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the VSN: "
)
+
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the VSN: "
)
+
AULFile
::
toString
(
VSN
));
if
(
cmpString
(
fSec
,
"0001"
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the fSec: "
)
+
AULFile
::
toString
(
fSec
));
if
(
!
cmpString
(
fSeq
,
""
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the fSeq: "
)
+
AULFile
::
toString
(
fSeq
));
if
(
cmpString
(
genNum
,
"0001"
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the genNum: "
)
+
AULFile
::
toString
(
genNum
));
if
(
cmpString
(
verNumOfGen
,
"00"
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the verNumOfGen: "
)
+
AULFile
::
toString
(
verNumOfGen
));
if
(
!
cmpString
(
creationDate
,
""
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the creationDate: "
)
+
AULFile
::
toString
(
creationDate
));
if
(
!
cmpString
(
expirationDate
,
""
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the expirationDate: "
)
+
AULFile
::
toString
(
expirationDate
));
if
(
cmpString
(
accessibility
,
""
))
throw
E
xceptions
::
Errnum
(
"accessibility is not empty"
);
throw
e
xceptions
::
Errnum
(
"accessibility is not empty"
);
if
(
!
cmpString
(
sysCode
,
""
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the sysCode: "
)
+
AULFile
::
toString
(
sysCode
));
if
(
cmpString
(
reserved
,
""
))
throw
E
xceptions
::
Errnum
(
"reserved is not empty"
);
throw
e
xceptions
::
Errnum
(
"reserved is not empty"
);
}
void
AULFile
::
HDR1
::
fill
(
...
...
@@ -140,12 +140,12 @@ void AULFile::HDR1::fill(
fillCommon
(
_fileId
,
_VSN
,
_fSeq
);
}
void
AULFile
::
HDR1
::
verify
()
const
throw
(
E
xceptions
::
Errnum
)
{
void
AULFile
::
HDR1
::
verify
()
const
throw
(
e
xceptions
::
Errnum
)
{
if
(
cmpString
(
label
,
"HDR1"
))
throw
E
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the HDR1: "
)
+
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the HDR1: "
)
+
AULFile
::
toString
(
label
));
if
(
cmpString
(
blockCount
,
"000000"
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the blockCount: "
)
+
AULFile
::
toString
(
blockCount
));
...
...
@@ -160,17 +160,17 @@ void AULFile::HDR1PRELABEL::fill(std::string _VSN) {
}
void
AULFile
::
HDR1PRELABEL
::
verify
()
const
throw
(
E
xceptions
::
Errnum
)
{
const
throw
(
e
xceptions
::
Errnum
)
{
if
(
cmpString
(
label
,
"HDR1"
))
throw
E
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the HDR1: "
)
+
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the HDR1: "
)
+
AULFile
::
toString
(
label
));
if
(
cmpString
(
blockCount
,
"000000"
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the blockCount: "
)
+
AULFile
::
toString
(
blockCount
));
if
(
cmpString
(
fileId
,
"PRELABEL"
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the PRELABEL: "
)
+
AULFile
::
toString
(
fileId
));
...
...
@@ -186,12 +186,12 @@ void AULFile::EOF1::fill(
fillCommon
(
_fileId
,
_VSN
,
_fSeq
);
}
void
AULFile
::
EOF1
::
verify
()
const
throw
(
E
xceptions
::
Errnum
)
{
void
AULFile
::
EOF1
::
verify
()
const
throw
(
e
xceptions
::
Errnum
)
{
if
(
cmpString
(
label
,
"EOF1"
))
throw
E
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the EOF1: "
)
+
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the EOF1: "
)
+
AULFile
::
toString
(
label
));
if
(
!
cmpString
(
blockCount
,
""
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the blockCount: "
)
+
AULFile
::
toString
(
blockCount
));
...
...
@@ -212,30 +212,30 @@ void AULFile::HDR2EOF2::fillCommon(int _blockLength, bool driveHasCompression) {
}
void
AULFile
::
HDR2EOF2
::
verifyCommon
()
const
throw
(
E
xceptions
::
Errnum
)
{
const
throw
(
e
xceptions
::
Errnum
)
{
if
(
cmpString
(
recordFormat
,
"F"
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the recordFormat: "
)
+
AULFile
::
toString
(
recordFormat
));
if
(
!
cmpString
(
blockLength
,
""
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the blockLength: "
)
+
AULFile
::
toString
(
blockLength
));
if
(
!
cmpString
(
recordLength
,
""
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the recordLength: "
)
+
AULFile
::
toString
(
recordLength
));
if
(
cmpString
(
aulId
,
"00"
))
throw
E
xceptions
::
Errnum
(
throw
e
xceptions
::
Errnum
(
std
::
string
(
"Failed verify for the aulId: "
)
+
AULFile
::
toString
(
aulId
));
if
(
cmpString
(
reserved1
,
""
))
throw
E
xceptions
::
Errnum
(
"reserved1 is not empty"
);
throw
e
xceptions
::
Errnum
(
"reserved1 is not empty"
);
if
(
cmpString
(
reserved2
,
""
))
throw
E
xceptions
::
Errnum
(
"reserved2 is not empty"
);
throw
e
xceptions
::
Errnum
(
"reserved2 is not empty"
);
if
(
cmpString
(
reserved3
,
""
))
throw
E
xceptions
::
Errnum
(
"reserved2 is not empty"
);
throw
e
xceptions
::
Errnum
(
"reserved2 is not empty"
);
}
void
AULFile
::
HDR2
::
fill
(
int
_blockLength
,
bool
driveHasCompression
)
{
...
...
@@ -243,9 +243,9 @@ void AULFile::HDR2::fill(int _blockLength, bool driveHasCompression) {