Skip to content

Commit 2181300

Browse files
committed
nvme/065: add nvme format test with supported LBA format
Link: https://lore.kernel.org/linux-nvme/20250611055432.2401372-1-hch@lst.de/ Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
1 parent 401420a commit 2181300

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

tests/nvme/065

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-3.0+
3+
# Copyright (C) 2025 Yi Zhang <yi.zhang@redhat.com>
4+
#
5+
# Test nvme format NVMe disk with supported LBA format
6+
#
7+
8+
. tests/nvme/rc
9+
10+
DESCRIPTION="Test nvme format NVMe disk with supported LBA format"
11+
QUICK=1
12+
13+
requires() {
14+
_nvme_requires
15+
_have_program jq
16+
}
17+
18+
test_device() {
19+
echo "Running ${TEST_NAME}"
20+
21+
local flbas nlbaf lbaf clbaf
22+
local iteration=10 i=0
23+
24+
flbas=$(nvme id-ns --output-format=json "$TEST_DEV" | jq '.flbas')
25+
nlbaf=$(nvme id-ns --output-format=json "$TEST_DEV" | jq '.nlbaf')
26+
27+
for lbaf in $(seq 0 "$nlbaf"); do
28+
nvme format --lbaf="$lbaf" --force "$TEST_DEV" >> "${FULL}"
29+
while (( i < iteration )); do
30+
if [ ! -b "$TEST_DEV" ]; then
31+
sleep 0.2
32+
((i++))
33+
continue
34+
else
35+
clbaf=$(nvme id-ns --output-format=json "$TEST_DEV" | jq '.flbas')
36+
if [ "$clbaf" -ne "$lbaf" ]; then
37+
echo "$TEST_DEV formatted to lbaf:$clbaf, expected:$lbaf"
38+
break
39+
fi
40+
fi
41+
done
42+
done
43+
44+
# Restore to the original lbaf
45+
nvme format --lbaf="$flbas" --force "$TEST_DEV" >> "${FULL}"
46+
47+
udevadm settle
48+
49+
echo "Test complete"
50+
}

tests/nvme/065.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Running nvme/065
2+
Test complete

0 commit comments

Comments
 (0)