Skip to content

Commit 5c8fa81

Browse files
ikegami-tigaw
authored andcommitted
libnvme/test: add to test copy desc format 0h
The expected data is the data set the current nvme_init_copy_range. Signed-off-by: Tokunori Ikegami <[email protected]>
1 parent 270e812 commit 5c8fa81

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

libnvme/test/ioctl/misc.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define TEST_FD 0xFD
1212
#define TEST_NSID 0x12345678
1313
#define TEST_CSI NVME_CSI_KV
14+
#define TEST_COPY_NR 0x12
1415

1516
static struct nvme_transport_handle *test_hdl;
1617

@@ -980,12 +981,25 @@ static void test_dsm(void)
980981

981982
static void test_copy(void)
982983
{
983-
__u16 nr = 0x12, cev = 0, dspec = 0;
984+
__u16 nr = TEST_COPY_NR, cev = 0, dspec = 0;
984985
int copy_size = sizeof(struct nvme_copy_range) * nr, err;
985986
bool prinfor = false, prinfow = false, stcw = false,
986987
stcr = false, fua = false, lr = false;
987988
__u8 cetype = 0, dtype = 0, desfmt = 0xf;
988989
__u64 sdlba = 0xfffff;
990+
__u16 nlbs[TEST_COPY_NR] = { 0xa, 0xb, 0xc };
991+
__u64 slbas[TEST_COPY_NR] = { 0x1000, 0x20000000, 0x300040000000 };
992+
__u32 short_pi[TEST_COPY_NR] = { 0x1000, 0x20000000, 0x40000000 };
993+
__u32 elbatms[TEST_COPY_NR] = { 0x1ff, 0x3ff, 0x3ff };
994+
__u32 elbats[TEST_COPY_NR] = { 0x111, 0x222, 0x333 };
995+
__u8 expected_data[sizeof(struct nvme_copy_range) * TEST_COPY_NR] = {
996+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0, 0, 0, 0,
997+
0xa, 0, 0, 0, 0, 0, 0, 0, 0, 0x10, 0, 0, 0x11, 1, 0xff, 1,
998+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x20, 0, 0, 0, 0,
999+
0xb, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x20, 0x22, 2, 0xff, 3,
1000+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0, 0x30, 0, 0,
1001+
0xc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x40, 0x33, 3, 0xff, 3
1002+
};
9891003

9901004
_cleanup_free_ struct nvme_copy_range *copy = NULL;
9911005

@@ -1003,11 +1017,12 @@ static void test_copy(void)
10031017
((prinfow & 0xf) << 26) |
10041018
((fua & 0x1) << 30) | ((lr & 0x1) << 31),
10051019
.data_len = nr * sizeof(struct nvme_copy_range),
1006-
.in_data = copy,
1020+
.in_data = expected_data,
10071021
};
10081022
struct nvme_passthru_cmd cmd;
10091023

10101024
set_mock_io_cmds(&mock_io_cmd, 1);
1025+
nvme_init_copy_range(copy, nlbs, slbas, short_pi, elbatms, elbats, nr);
10111026
nvme_init_copy(&cmd, TEST_NSID, sdlba, nr, desfmt,
10121027
prinfor, prinfow, cetype, dtype, stcw, stcr,
10131028
fua, lr, cev, dspec, (void *)copy);

0 commit comments

Comments
 (0)