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
b667c7a4
Commit
b667c7a4
authored
Apr 28, 2020
by
Michael Davis
Committed by
Cedric Caffy
Sep 25, 2020
Browse files
[lto_rao] Adds unit test for 6-byte version of toU64()
parent
bd9fe8ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
tapeserver/castor/tape/tapeserver/SCSI/Structures.hpp
View file @
b667c7a4
...
...
@@ -122,7 +122,7 @@ namespace SCSI {
}
/**
* Helper function to deal with endianness
.
* Helper function to deal with endianness
: 6-byte version
*
* The REOWP SCSI command assigns 48 bits to store the LOGICAL OBJECT IDENTIFIER (although other
* commands use 64 bits or sometimes 32 bits). This function converts the 48-bit byte array
...
...
@@ -131,7 +131,7 @@ namespace SCSI {
* @param t byte array in SCSI order representing a 48-bit number
* @return 64-bit unsigned integer
*/
inline
uint64_t
toU4
8
(
const
unsigned
char
(
&
t
)[
6
])
inline
uint64_t
toU
6
4
(
const
unsigned
char
(
&
t
)[
6
])
{
/* Like network, SCSI is BigEndian */
return
(
uint64_t
)
ntohl
(
(
*
(
uint64_t
*
)
t
<<
32
)
>>
16
)
<<
32
|
ntohl
(
*
(
uint64_t
*
)
t
>>
16
);
...
...
tapeserver/castor/tape/tapeserver/SCSI/StructuresTest.cpp
View file @
b667c7a4
...
...
@@ -656,6 +656,11 @@ namespace unitTests {
ASSERT_EQ
(
-
433494437
,
castor
::
tape
::
SCSI
::
Structures
::
toS32
(
num
));
}
TEST
(
castor_tape_SCSI_Structures
,
toU64_6byte
)
{
unsigned
char
num
[
6
]
=
{
0xDE
,
0xAD
,
0xBE
,
0xEF
,
0xCA
,
0xFE
};
ASSERT_EQ
(
0xDEADBEEFCAFEULL
,
castor
::
tape
::
SCSI
::
Structures
::
toU64
(
num
));
}
TEST
(
castor_tape_SCSI_Structures
,
toU64
)
{
unsigned
char
num
[
8
]
=
{
0xDE
,
0xAD
,
0xBE
,
0xEF
,
0xCA
,
0xFE
,
0xFA
,
0xDE
};
ASSERT_EQ
(
0xDEADBEEFCAFEFADEULL
,
castor
::
tape
::
SCSI
::
Structures
::
toU64
(
num
));
...
...
@@ -952,9 +957,9 @@ namespace unitTests {
buff
[
2
]
=
0xFF
;
buff
[
3
]
=
0xFF
;
// In this record, the logical object identifier is 6 bytes (48 bits).
ASSERT_EQ
(
0U
,
castor
::
tape
::
SCSI
::
Structures
::
toU4
8
(
readEndOfWrapPositionDataShortForm
.
logicalObjectIdentifier
));
ASSERT_EQ
(
0U
,
castor
::
tape
::
SCSI
::
Structures
::
toU
6
4
(
readEndOfWrapPositionDataShortForm
.
logicalObjectIdentifier
));
buff
[
4
]
=
0xAB
;
buff
[
5
]
=
0xCD
;
buff
[
6
]
=
0xEF
;
buff
[
7
]
=
0x12
;
buff
[
8
]
=
0x34
;
buff
[
9
]
=
0x56
;
ASSERT_EQ
(
0xABCDEF123456
,
castor
::
tape
::
SCSI
::
Structures
::
toU4
8
(
readEndOfWrapPositionDataShortForm
.
logicalObjectIdentifier
));
ASSERT_EQ
(
0xABCDEF123456
,
castor
::
tape
::
SCSI
::
Structures
::
toU
6
4
(
readEndOfWrapPositionDataShortForm
.
logicalObjectIdentifier
));
}
TEST
(
castor_tape_SCSI_Structures
,
readEndOfWrapPositionDataLongForm_t
)
{
...
...
@@ -986,10 +991,10 @@ namespace unitTests {
buff
[
offset
+
4
]
=
0xFF
;
buff
[
offset
+
5
]
=
0xFF
;
// In this record, the logical object identifier is 6 bytes (48 bits).
ASSERT_EQ
(
0U
,
castor
::
tape
::
SCSI
::
Structures
::
toU4
8
(
readEndOfWrapPositionDataLongForm
.
wrapDescriptor
[
wrap
].
logicalObjectIdentifier
));
ASSERT_EQ
(
0U
,
castor
::
tape
::
SCSI
::
Structures
::
toU
6
4
(
readEndOfWrapPositionDataLongForm
.
wrapDescriptor
[
wrap
].
logicalObjectIdentifier
));
buff
[
offset
+
6
]
=
0xAB
;
buff
[
offset
+
7
]
=
0xCD
;
buff
[
offset
+
8
]
=
0xEF
;
buff
[
offset
+
9
]
=
0x12
;
buff
[
offset
+
10
]
=
0x34
;
buff
[
offset
+
11
]
=
0x56
;
ASSERT_EQ
(
0xABCDEF123456
,
castor
::
tape
::
SCSI
::
Structures
::
toU4
8
(
readEndOfWrapPositionDataLongForm
.
wrapDescriptor
[
wrap
].
logicalObjectIdentifier
));
ASSERT_EQ
(
0xABCDEF123456
,
castor
::
tape
::
SCSI
::
Structures
::
toU
6
4
(
readEndOfWrapPositionDataLongForm
.
wrapDescriptor
[
wrap
].
logicalObjectIdentifier
));
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment