Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tools/testing/selftests/ublk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ TEST_PROGS += test_loop_07.sh

TEST_PROGS += test_integrity_01.sh
TEST_PROGS += test_integrity_02.sh
TEST_PROGS += test_integrity_03.sh

TEST_PROGS += test_recover_01.sh
TEST_PROGS += test_recover_02.sh
Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/ublk/test_batch_01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dev_id=$(_add_ublk_dev -t loop -q 2 -b "${UBLK_BACKFILES[0]}")
_check_add_dev $TID $?

if ! _mkfs_mount_test /dev/ublkb"${dev_id}"; then
_cleanup_test "generic"
_cleanup_test
_show_result $TID 255
fi

Expand All @@ -27,5 +27,5 @@ _check_add_dev $TID $?
_mkfs_mount_test /dev/ublkb"${dev_id}"
ERR_CODE=$?

_cleanup_test "generic"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_batch_02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio --rw=readwrit
--iodepth=32 --size=100M --numjobs=4 > /dev/null 2>&1
ERR_CODE=$?

_cleanup_test "generic"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_batch_03.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio --rw=readwrit
--iodepth=32 --size=100M --numjobs=4 > /dev/null 2>&1
ERR_CODE=$?

_cleanup_test "generic"
_cleanup_test
_show_result $TID $ERR_CODE
4 changes: 2 additions & 2 deletions tools/testing/selftests/ublk/test_generic_02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ for _ in $(seq 100); do
done

if ! kill -0 "$btrace_pid" 2>/dev/null; then
_cleanup_test "null"
_cleanup_test
exit "$UBLK_SKIP_CODE"
fi

Expand All @@ -51,5 +51,5 @@ if grep -q "^out_of_order:" "$UBLK_TMP"; then
grep "^out_of_order:" "$UBLK_TMP"
ERR_CODE=255
fi
_cleanup_test "null"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_generic_03.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ fi
if [ "$max_segment_size" != "32768" ]; then
ERR_CODE=255
fi
_cleanup_test "null"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_generic_06.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ if [ $ELAPSED -ge 5 ]; then
ERR_CODE=255
fi

_cleanup_test "fault_inject"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_generic_07.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ if [ "$ERR_CODE" -eq 0 ]; then
ERR_CODE=$?
fi

_cleanup_test "generic"
_cleanup_test
_show_result $TID $ERR_CODE
4 changes: 2 additions & 2 deletions tools/testing/selftests/ublk/test_generic_08.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dev_id=$(_add_ublk_dev -t loop -q 2 --auto_zc "${UBLK_BACKFILES[0]}")
_check_add_dev $TID $?

if ! _mkfs_mount_test /dev/ublkb"${dev_id}"; then
_cleanup_test "generic"
_cleanup_test
_show_result $TID 255
fi

Expand All @@ -27,5 +27,5 @@ _check_add_dev $TID $?
_mkfs_mount_test /dev/ublkb"${dev_id}"
ERR_CODE=$?

_cleanup_test "generic"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_generic_09.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ _check_add_dev $TID $?
fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio --rw=readwrite --iodepth=32 --size=256M > /dev/null 2>&1
ERR_CODE=$?

_cleanup_test "null"
_cleanup_test

_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_generic_10.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ if [ "$new_size" != "$size" ]; then
ERR_CODE=255
fi

_cleanup_test "null"
_cleanup_test
_show_result $TID $ERR_CODE
4 changes: 2 additions & 2 deletions tools/testing/selftests/ublk/test_generic_12.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ btrace_pid=$!
sleep 2

if ! kill -0 "$btrace_pid" > /dev/null 2>&1; then
_cleanup_test "null"
_cleanup_test
exit "$UBLK_SKIP_CODE"
fi

Expand Down Expand Up @@ -54,5 +54,5 @@ if [[ $NR_THREADS_THAT_HANDLED_IO -ne $NTHREADS ]]; then
ERR_CODE=255
fi

_cleanup_test "null"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_generic_13.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ if ${UBLK_PROG} features | grep -q unknown; then
ERR_CODE=255
fi

_cleanup_test "null"
_cleanup_test
_show_result $TID $ERR_CODE
4 changes: 2 additions & 2 deletions tools/testing/selftests/ublk/test_generic_16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _prep_test "null" "stop --safe command"

# Check if SAFE_STOP_DEV feature is supported
if ! _have_feature "SAFE_STOP_DEV"; then
_cleanup_test "null"
_cleanup_test
exit "$UBLK_SKIP_CODE"
fi

Expand Down Expand Up @@ -52,5 +52,5 @@ wait $dd_pid 2>/dev/null
_ublk_del_dev "${dev_id}"
udevadm settle

_cleanup_test "null"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_generic_17.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ fi
# time out here
_ublk_del_dev "${dev_id}"

_cleanup_test "fault_inject"
_cleanup_test
_show_result $TID $ERR_CODE
5 changes: 3 additions & 2 deletions tools/testing/selftests/ublk/test_integrity_02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ if ! _have_program fio; then
exit $UBLK_SKIP_CODE
fi

min_fio_version=fio-3.42
fio_version=$(fio --version)
if [[ "$fio_version" =~ fio-[0-9]+\.[0-9]+$ ]]; then
echo "Requires development fio version with https://github.com/axboe/fio/pull/1992"
if ! sort --version-sort --check=quiet <(printf "%s\n%s\n" "$min_fio_version" "$fio_version"); then
echo "Requires fio version with https://github.com/axboe/fio/pull/1992"
exit $UBLK_SKIP_CODE
fi

Expand Down
103 changes: 103 additions & 0 deletions tools/testing/selftests/ublk/test_integrity_03.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh

if ! _have_program fio; then
exit $UBLK_SKIP_CODE
fi

_test_fill_and_verify() {
fio --name fill --rw randwrite $fio_args > /dev/null
if [ $? != 0 ]; then
echo "fio fill failed"
ERR_CODE=255
return 1
fi

fio --name verify --rw randread $fio_args > /dev/null
if [ $? != 0 ]; then
echo "fio verify failed"
ERR_CODE=255
return 1
fi
}

_test_corrupted_reftag() {
local dd_reftag_args="bs=1 seek=58 count=6 oflag=dsync conv=notrunc status=none"

# Overwrite 6-byte reftag at offset 48 + 10 = 58
dd if=/dev/urandom "of=${UBLK_BACKFILES[1]}" $dd_reftag_args
if [ $? != 0 ]; then
echo "dd corrupted_reftag failed"
ERR_CODE=255
return 1
fi

if fio --name corrupted_reftag --rw randread $fio_args > /dev/null 2> "$fio_err"; then
echo "fio corrupted_reftag unexpectedly succeeded"
ERR_CODE=255
return 1
fi

if ! grep -q "$expected_err" "$fio_err"; then
echo "fio corrupted_reftag message not found: $expected_err"
ERR_CODE=255
return 1
fi

# Reset to 0
dd if=/dev/zero "of=${UBLK_BACKFILES[1]}" $dd_reftag_args
if [ $? != 0 ]; then
echo "dd restore corrupted_reftag failed"
ERR_CODE=255
return 1
fi
}

_test_corrupted_data() {
local dd_data_args="bs=512 count=1 oflag=direct,dsync conv=notrunc status=none"

dd if=/dev/zero "of=${UBLK_BACKFILES[0]}" $dd_data_args
if [ $? != 0 ]; then
echo "dd corrupted_data failed"
ERR_CODE=255
return 1
fi

if fio --name corrupted_data --rw randread $fio_args > /dev/null 2> "$fio_err"; then
echo "fio corrupted_data unexpectedly succeeded"
ERR_CODE=255
return 1
fi

if ! grep -q "$expected_err" "$fio_err"; then
echo "fio corrupted_data message not found: $expected_err"
ERR_CODE=255
return 1
fi
}

_prep_test "loop" "end-to-end auto integrity"

_create_backfile 0 256M
_create_backfile 1 32M # 256M * (64 integrity bytes / 512 data bytes)
integrity_params="--integrity_capable --integrity_reftag
--metadata_size 64 --pi_offset 48 --csum_type nvme"
dev_id=$(_add_ublk_dev -t loop -u $integrity_params "${UBLK_BACKFILES[@]}")
_check_add_dev "$TID" $?

fio_args="--ioengine libaio --direct 1 --bsrange 512-1M --iodepth 32
--filename /dev/ublkb$dev_id"
fio_err=$(mktemp "${UBLK_TEST_DIR}"/fio_err_XXXXX)
ERR_CODE=0

expected_err="Invalid or incomplete multibyte or wide character: read offset=0"
_test_fill_and_verify && \
_test_corrupted_reftag && \
_test_corrupted_data

rm -f "$fio_err"

_cleanup_test
_show_result "$TID" $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_loop_01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ _check_add_dev $TID $?
_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M
ERR_CODE=$?

_cleanup_test "loop"
_cleanup_test

_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_loop_02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ _check_add_dev $TID $?
_mkfs_mount_test /dev/ublkb"${dev_id}"
ERR_CODE=$?

_cleanup_test "loop"
_cleanup_test

_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_loop_03.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ _check_add_dev $TID $?
_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M
ERR_CODE=$?

_cleanup_test "loop"
_cleanup_test

_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_loop_04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ _check_add_dev $TID $?
_mkfs_mount_test /dev/ublkb"${dev_id}"
ERR_CODE=$?

_cleanup_test "loop"
_cleanup_test

_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_loop_05.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ _check_add_dev $TID $?
_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M
ERR_CODE=$?

_cleanup_test "loop"
_cleanup_test

_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_loop_06.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ _check_add_dev $TID $?
_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M
ERR_CODE=$?

_cleanup_test "loop"
_cleanup_test

_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_loop_07.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ _check_add_dev $TID $?
_mkfs_mount_test /dev/ublkb"${dev_id}"
ERR_CODE=$?

_cleanup_test "loop"
_cleanup_test

_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_null_01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ _check_add_dev $TID $?
fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio --rw=readwrite --iodepth=32 --size=256M > /dev/null 2>&1
ERR_CODE=$?

_cleanup_test "null"
_cleanup_test

_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_null_02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ _check_add_dev $TID $?
fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio --rw=readwrite --iodepth=32 --size=256M > /dev/null 2>&1
ERR_CODE=$?

_cleanup_test "null"
_cleanup_test

_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_null_03.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ _check_add_dev $TID $?
fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio --rw=readwrite --iodepth=32 --size=256M > /dev/null 2>&1
ERR_CODE=$?

_cleanup_test "null"
_cleanup_test

_show_result $TID $ERR_CODE
4 changes: 2 additions & 2 deletions tools/testing/selftests/ublk/test_part_01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fi
_prep_test "generic" "test UBLK_F_NO_AUTO_PART_SCAN"

if ! _have_feature "UBLK_F_NO_AUTO_PART_SCAN"; then
_cleanup_test "generic"
_cleanup_test
exit "$UBLK_SKIP_CODE"
fi

Expand All @@ -100,5 +100,5 @@ format_backing_file "${UBLK_BACKFILES[0]}"
[ "$ERR_CODE" -eq 0 ] && test_no_auto_part_scan "${UBLK_BACKFILES[0]}"
[ $? -ne 0 ] && ERR_CODE=255

_cleanup_test "generic"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_part_02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ _test_partition_scan_no_hang "no" "DEAD"
# Test 2: With recovery support - should transition to QUIESCED
_test_partition_scan_no_hang "yes" "QUIESCED"

_cleanup_test "partition_scan"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_recover_01.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ ublk_run_recover_test -t loop -q 2 -r 1 -i 1 "${UBLK_BACKFILES[0]}" &
ublk_run_recover_test -t stripe -q 2 -r 1 -i 1 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
wait

_cleanup_test "recover"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_recover_02.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ ublk_run_recover_test -t loop -q 2 -r 1 -z -i 1 "${UBLK_BACKFILES[0]}" &
ublk_run_recover_test -t stripe -q 2 -r 1 -z -i 1 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
wait

_cleanup_test "recover"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_recover_03.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@ ublk_run_quiesce_recover -t loop -q 2 -r 1 -i 1 "${UBLK_BACKFILES[0]}" &
ublk_run_quiesce_recover -t stripe -q 2 -r 1 -i 1 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
wait

_cleanup_test "quiesce"
_cleanup_test
_show_result $TID $ERR_CODE
2 changes: 1 addition & 1 deletion tools/testing/selftests/ublk/test_recover_04.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ ublk_run_recover_test -t loop -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[0]}" &
ublk_run_recover_test -t stripe -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
wait

_cleanup_test "recover"
_cleanup_test
_show_result $TID $ERR_CODE
Loading