TESTS: Allow inquiry data to contain padding IFF it is all zero
Some implementations may send oversized data coming back from Inquiry. Warn about this instead of failing the test but then perform additional checks that the padding MUST be zero or else fail the test. Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
@@ -83,13 +83,29 @@ test_inquiry_standard(void)
|
||||
CU_ASSERT_EQUAL(std_inq->response_data_format, 2);
|
||||
|
||||
logging(LOG_VERBOSE, "Verify additional-length is correct");
|
||||
if (std_inq->additional_length != task->datain.size - 5) {
|
||||
if (std_inq->additional_length > task->datain.size - 5) {
|
||||
logging(LOG_NORMAL, "[FAILED] Bad additional length "
|
||||
"returned. Should be %d but device returned %d.",
|
||||
task->datain.size - 5,
|
||||
std_inq->additional_length);
|
||||
logging(LOG_NORMAL, "[FAILED] Additional length points "
|
||||
"beyond end of data");
|
||||
CU_FAIL("Additional length points beyond end of data");
|
||||
}
|
||||
if (std_inq->additional_length < task->datain.size - 5) {
|
||||
logging(LOG_NORMAL, "[WARNING] Bad additional length "
|
||||
"returned. Should be %d but device returned %d. ",
|
||||
task->datain.size - 5,
|
||||
std_inq->additional_length);
|
||||
logging(LOG_VERBOSE, "Verify that all padding data is 0");
|
||||
for (i = std_inq->additional_length + 6; i < task->datain.size; i++) {
|
||||
if (!task->datain.data[i])
|
||||
continue;
|
||||
logging(LOG_NORMAL, "[FAILED] Padding data is not zero."
|
||||
" Are we leaking data?");
|
||||
CU_FAIL("Padding data is not zero. Leaking data?");
|
||||
}
|
||||
}
|
||||
CU_ASSERT_EQUAL(std_inq->additional_length, task->datain.size - 5);
|
||||
|
||||
logging(LOG_VERBOSE, "Verify VENDOR_IDENTIFICATION is in ASCII");
|
||||
for (i = 8; i < 16; i++) {
|
||||
|
||||
Reference in New Issue
Block a user