Add support for READCAPACITY16

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2012-04-20 17:56:39 +10:00
parent 422bc32ce8
commit 86bf89aabf
11 changed files with 230 additions and 12 deletions

View File

@@ -0,0 +1,68 @@
/*
Copyright (C) 2012 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "iscsi.h"
#include "scsi-lowlevel.h"
#include "iscsi-test.h"
int T0160_readcapacity16_simple(const char *initiator, const char *url)
{
struct iscsi_context *iscsi;
struct scsi_task *task;
struct scsi_readcapacity16 *rc16;
int ret, lun;
ret = 0;
iscsi = iscsi_context_login(initiator, url, &lun);
if (iscsi == NULL) {
printf("Failed to login to target\n");
return -1;
}
printf("Test that Readcapacity10 is supported ... ");
task = iscsi_readcapacity16_sync(iscsi, lun);
if (task == NULL) {
printf("[FAILED]\n");
printf("Failed to send readcapacity16 command: %s\n", iscsi_get_error(iscsi));
ret = -1;
goto finished;
}
if (task->status != SCSI_STATUS_GOOD) {
printf("[FAILED]\n");
printf("Readcapacity command: failed with sense. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
rc16 = scsi_datain_unmarshall(task);
if (rc16 == NULL) {
printf("[FAILED]\n");
printf("failed to unmarshall readcapacity16 data. %s\n", iscsi_get_error(iscsi));
ret = -1;
scsi_free_scsi_task(task);
goto finished;
}
scsi_free_scsi_task(task);
printf("[OK]\n");
finished:
iscsi_logout_sync(iscsi);
iscsi_destroy_context(iscsi);
return ret;
}

View File

@@ -64,18 +64,22 @@ struct scsi_test tests[] = {
/* read16 */
{ "T0153_read16_rdprotect", T0153_read16_rdprotect },
/* readcapacity16*/
{ "T0160_readcapacity16_simple", T0160_readcapacity16_simple },
{ NULL, NULL }
};
void print_usage(void)
{
fprintf(stderr, "Usage: iscsi-inq [-?] [-?|--help] [--usage] [-i|--initiator-name=iqn-name]\n"
fprintf(stderr, "Usage: iscsi-test [-?] [-?|--help] [--usage] [-t|--test=<test>]\n"
"\t\t[-l|--list] [-i|--initiator-name=<iqn-name>]\n"
"\t\t<iscsi-url>\n");
}
void print_help(void)
{
fprintf(stderr, "Usage: iscsi-inq [OPTION...] <iscsi-url>\n");
fprintf(stderr, "Usage: iscsi-test [OPTION...] <iscsi-url>\n");
fprintf(stderr, " -i, --initiator-name=iqn-name Initiatorname to use\n");
fprintf(stderr, " -t, --test=test-name Which test to run. Default is to run all tests.\n");
fprintf(stderr, " -l, --list List all tests.\n");

View File

@@ -41,3 +41,5 @@ int T0132_verify10_mismatch_no_cmp(const char *initiator, const char *url);
int T0143_read12_rdprotect(const char *initiator, const char *url);
int T0153_read16_rdprotect(const char *initiator, const char *url);
int T0160_readcapacity16_simple(const char *initiator, const char *url);