Commit fa14810e authored by Cedric Caffy's avatar Cedric Caffy
Browse files

[lto_rao] Corrected the readEndOfWrapPositionDataLongForm_t::getNbWrapsReturned()

parent cad4ea91
......@@ -1218,7 +1218,7 @@ namespace SCSI {
unsigned char reserved[2]; // Reserved
// bytes 4-n
struct {
struct WrapDescriptor {
unsigned char wrapNumber[2]; // Wrap number
unsigned char partition[2]; // The partition number of the above wrap
unsigned char reserved[2]; // Reserved
......@@ -1226,7 +1226,7 @@ namespace SCSI {
} wrapDescriptor[maxLTOTapeWraps]; // Array of wrap descriptiors
uint16_t getNbWrapsReturned(){
return (SCSI::Structures::toU16(responseDataLength) / sizeof(wrapDescriptor));
return ((SCSI::Structures::toU16(responseDataLength) - sizeof(reserved)) / sizeof(WrapDescriptor));
}
};
......
......@@ -971,8 +971,9 @@ namespace unitTests {
// Check proper initialization and location of struct members match the bit/byte locations defined in LTO-8 reference
ASSERT_EQ(0U, castor::tape::SCSI::Structures::toU16(readEndOfWrapPositionDataLongForm.responseDataLength));
buff[0] = 0x0A; buff[1] = 0xB0;
ASSERT_EQ(0xAB0, castor::tape::SCSI::Structures::toU16(readEndOfWrapPositionDataLongForm.responseDataLength));
//Assume we have maxLTOTapeWraps returned * 12 bytes = 3362 = 0x0D22
buff[0] = 0x0D; buff[1] = 0x22;
ASSERT_EQ(0x0D22, castor::tape::SCSI::Structures::toU16(readEndOfWrapPositionDataLongForm.responseDataLength));
for(unsigned int wrap = 0; wrap < castor::tape::SCSI::maxLTOTapeWraps; ++wrap) {
int offset = 4 + (wrap * 12);
......@@ -996,6 +997,8 @@ namespace unitTests {
buff[offset + 9] = 0x12; buff[offset + 10] = 0x34; buff[offset + 11] = 0x56;
ASSERT_EQ(0xABCDEF123456, castor::tape::SCSI::Structures::toU64(readEndOfWrapPositionDataLongForm.wrapDescriptor[wrap].logicalObjectIdentifier));
}
ASSERT_EQ(castor::tape::SCSI::maxLTOTapeWraps,readEndOfWrapPositionDataLongForm.getNbWrapsReturned());
}
TEST(castor_tape_SCSI_Structures, requestSenseCDB_t) {
......
......@@ -99,7 +99,13 @@ castor::tape::tapeserver::drive::physicalPositionInfo castor::tape::tapeserver::
}
std::vector<castor::tape::tapeserver::drive::endOfWrapPosition> castor::tape::tapeserver::drive::FakeDrive::getEndOfWrapPositions() {
return std::vector<castor::tape::tapeserver::drive::endOfWrapPosition>();
endOfWrapPosition eowp;
eowp.blockId = 1;
eowp.partition = 1;
eowp.wrapNumber = 1;
std::vector<endOfWrapPosition> ret;
ret.push_back(eowp);
return ret;
}
std::vector<uint16_t> castor::tape::tapeserver::drive::FakeDrive::getTapeAlertCodes() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment