test-tool/OverwriteReserved: override driver queue_pdu() callback
In preparation for removing the test-tool iscsi_queue_pdu() dlsym overload hack, convert this test to use the regular transport driver callback for this purpose. Signed-off-by: David Disseldorp <ddiss@suse.de>
This commit is contained in:
@@ -26,8 +26,9 @@
|
|||||||
#include "iscsi-test-cu.h"
|
#include "iscsi-test-cu.h"
|
||||||
|
|
||||||
static int change_num;
|
static int change_num;
|
||||||
|
static struct iscsi_transport iscsi_drv_orig;
|
||||||
|
|
||||||
static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu *pdu)
|
static int my_iscsi_queue_pdu(struct iscsi_context *iscsi, struct iscsi_pdu *pdu)
|
||||||
{
|
{
|
||||||
switch (change_num) {
|
switch (change_num) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -45,7 +46,7 @@ static int my_iscsi_queue_pdu(struct iscsi_context *iscsi _U_, struct iscsi_pdu
|
|||||||
}
|
}
|
||||||
|
|
||||||
change_num = 0;
|
change_num = 0;
|
||||||
return 0;
|
return iscsi_drv_orig.queue_pdu(iscsi, pdu);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_sanitize_overwrite_reserved(void)
|
void test_sanitize_overwrite_reserved(void)
|
||||||
@@ -75,7 +76,9 @@ void test_sanitize_overwrite_reserved(void)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
local_iscsi_queue_pdu = my_iscsi_queue_pdu;
|
/* override transport queue_pdu callback for PDU manipulation */
|
||||||
|
iscsi_drv_orig = *sd->iscsi_ctx->drv;
|
||||||
|
sd->iscsi_ctx->drv->queue_pdu = my_iscsi_queue_pdu;
|
||||||
|
|
||||||
logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
|
logging(LOG_VERBOSE, "Send SANITIZE command with the reserved "
|
||||||
"bit in byte 1 set to 1");
|
"bit in byte 1 set to 1");
|
||||||
@@ -91,4 +94,7 @@ void test_sanitize_overwrite_reserved(void)
|
|||||||
SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
|
SANITIZE(sd, 0, 0, SCSI_SANITIZE_OVERWRITE, data.size, &data,
|
||||||
EXPECT_INVALID_FIELD_IN_CDB);
|
EXPECT_INVALID_FIELD_IN_CDB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* restore transport callbacks */
|
||||||
|
*(sd->iscsi_ctx->drv) = iscsi_drv_orig;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user