Skip to content

Commit 80efbd3

Browse files
MaisenbacherDigaw
authored andcommitted
test: add missing tests for identify functions
Tests for nvme_identify_ns_csi_user_data_format() and nvme_identify_iocs_ns_csi_user_data_format() were previously omitted. Those identify commands are specified in the command set specification. Signed-off-by: Dennis Maisenbacher <[email protected]>
1 parent 0454a99 commit 80efbd3

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

test/ioctl/identify.c

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#define TEST_CNTID 0x4321
1717
#define TEST_DOMID 0xFEDC
1818
#define TEST_ENDGID 0x0123
19+
#define TEST_FIDX 0xF
1920
#define TEST_SC NVME_SC_INVALID_FIELD
2021

2122
static void test_ns(void)
@@ -531,6 +532,53 @@ static void test_kernel_error(void)
531532
check(errno == EIO, "unexpected error %m");
532533
}
533534

535+
static void test_identify_ns_csi_user_data_format(void)
536+
{
537+
struct nvme_id_ns expected_id, id = {};
538+
struct mock_cmd mock_admin_cmd = {
539+
.opcode = nvme_admin_identify,
540+
.nsid = NVME_NSID_NONE,
541+
.data_len = sizeof(expected_id),
542+
.cdw10 = NVME_IDENTIFY_CNS_NS_USER_DATA_FORMAT,
543+
//TEST_CSI=NVME_CSI_KV does not implement this command
544+
.cdw11 = (TEST_FIDX << 0) | (NVME_CSI_NVM << 24),
545+
.cdw14 = TEST_UUID,
546+
.out_data = &expected_id,
547+
};
548+
int err;
549+
550+
arbitrary(&expected_id, sizeof(expected_id));
551+
set_mock_admin_cmds(&mock_admin_cmd, 1);
552+
err = nvme_identify_ns_csi_user_data_format(
553+
TEST_FD, TEST_FIDX, TEST_UUID, NVME_CSI_NVM, &id);
554+
end_mock_cmds();
555+
check(err == 0, "identify returned error %d, errno %m", err);
556+
cmp(&id, &expected_id, sizeof(id), "incorrect identify data");
557+
}
558+
559+
static void test_identify_iocs_ns_csi_user_data_format(void)
560+
{
561+
struct nvme_id_ns expected_id, id = {};
562+
struct mock_cmd mock_admin_cmd = {
563+
.opcode = nvme_admin_identify,
564+
.nsid = NVME_NSID_NONE,
565+
.data_len = sizeof(expected_id),
566+
.cdw10 = NVME_IDENTIFY_CNS_CSI_NS_USER_DATA_FORMAT,
567+
.cdw11 = (TEST_FIDX << 0) | (TEST_CSI << 24),
568+
.cdw14 = TEST_UUID,
569+
.out_data = &expected_id,
570+
};
571+
int err;
572+
573+
arbitrary(&expected_id, sizeof(expected_id));
574+
set_mock_admin_cmds(&mock_admin_cmd, 1);
575+
err = nvme_identify_iocs_ns_csi_user_data_format(
576+
TEST_FD, TEST_FIDX, TEST_UUID, TEST_CSI, &id);
577+
end_mock_cmds();
578+
check(err == 0, "identify returned error %d, errno %m", err);
579+
cmp(&id, &expected_id, sizeof(id), "incorrect identify data");
580+
}
581+
534582
static void run_test(const char *test_name, void (*test_fn)(void))
535583
{
536584
printf("Running test %s...", test_name);
@@ -569,4 +617,6 @@ int main(void)
569617
RUN_TEST(iocs);
570618
RUN_TEST(status_code_error);
571619
RUN_TEST(kernel_error);
620+
RUN_TEST(identify_ns_csi_user_data_format);
621+
RUN_TEST(identify_iocs_ns_csi_user_data_format);
572622
}

0 commit comments

Comments
 (0)