selftests: add ublk selftests
Subsystems (3)
cover selftests: add ublk selftests
Hello Guys,
The 1st patch adds one ublk utility and one entry test.
The 2nd patch adds test over file backed ublk.
The 3rd patch adds test for ublk zero copy.
How to run:
- make install
- make headers_install INSTALL_HDR_PATH=/usr
- reboot
- make -C tools/testing/selftests TARGETS=ublk run_test
Thanks,
Ming Lei (3):
selftests: ublk: add kernel selftests for ublk
selftests: ublk: add file backed ublk
selftests: ublk: add ublk zero copy test
MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/ublk/.gitignore | 3 + tools/testing/selftests/ublk/Makefile | 14 + tools/testing/selftests/ublk/config | 1 + tools/testing/selftests/ublk/kublk.c | 1671 ++++++++++++++++++ tools/testing/selftests/ublk/test_common.sh | 112 ++ tools/testing/selftests/ublk/test_loop_01.sh | 30 + tools/testing/selftests/ublk/test_loop_02.sh | 21 + tools/testing/selftests/ublk/test_loop_03.sh | 32 + tools/testing/selftests/ublk/test_null_01.sh | 18 + 11 files changed, 1904 insertions(+) create mode 100644 tools/testing/selftests/ublk/.gitignore create mode 100644 tools/testing/selftests/ublk/Makefile create mode 100644 tools/testing/selftests/ublk/config create mode 100644 tools/testing/selftests/ublk/kublk.c create mode 100755 tools/testing/selftests/ublk/test_common.sh create mode 100755 tools/testing/selftests/ublk/test_loop_01.sh create mode 100755 tools/testing/selftests/ublk/test_loop_02.sh create mode 100755 tools/testing/selftests/ublk/test_loop_03.sh create mode 100755 tools/testing/selftests/ublk/test_null_01.sh
Signature · 1 line
2.47.0
PATCH 1/3 selftests: ublk: add kernel selftests for ublk
Both ublk driver and userspace heavily depends on io_uring subsystem, and tools/testing/selftests/ should be the best place for holding this cross-subsystem tests.
Add basic read/write IO test over this ublk null disk, and make sure ublk working.
More tests will be added.
--- MAINTAINERS | 1 + tools/testing/selftests/Makefile | 1 + tools/testing/selftests/ublk/.gitignore | 3 + tools/testing/selftests/ublk/Makefile | 11 + tools/testing/selftests/ublk/config | 1 + tools/testing/selftests/ublk/kublk.c | 1347 ++++++++++++++++++ tools/testing/selftests/ublk/test_common.sh | 57 + tools/testing/selftests/ublk/test_null_01.sh | 18 + 8 files changed, 1439 insertions(+) create mode 100644 tools/testing/selftests/ublk/.gitignore create mode 100644 tools/testing/selftests/ublk/Makefile create mode 100644 tools/testing/selftests/ublk/config create mode 100644 tools/testing/selftests/ublk/kublk.c create mode 100755 tools/testing/selftests/ublk/test_common.sh create mode 100755 tools/testing/selftests/ublk/test_null_01.sh
MAINTAINERS +1 -0
@@ -24237,6 +24237,7 @@ S: Maintained F: Documentation/block/ublk.rst F: drivers/block/ublk_drv.c F: include/uapi/linux/ublk_cmd.h +F: tools/testing/selftests/ublk/ UBSAN M: Kees Cook <[email protected]>
tools/testing/selftests/Makefile +1 -0
@@ -113,6 +113,7 @@ endif TARGETS += tmpfs TARGETS += tpm2 TARGETS += tty +TARGETS += ublk TARGETS += uevent TARGETS += user_events TARGETS += vDSO
tools/testing/selftests/ublk/.gitignore new file +3 -0
@@ -0,0 +1,3 @@ +kublk +/tools +*-verify.state
tools/testing/selftests/ublk/Makefile new file +11 -0
@@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0 + +CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir) +LDLIBS += -lpthread -lm -luring + +TEST_PROGS := test_null_01.sh + +# Order correspond to 'make run_tests' order +TEST_GEN_PROGS_EXTENDED = kublk + +include ../lib.mk
tools/testing/selftests/ublk/config new file +1 -0
@@ -0,0 +1 @@ +CONFIG_BLK_DEV_UBLK=m
tools/testing/selftests/ublk/kublk.c new file +1347 -0
1,347 lines not on this page · raw message
tools/testing/selftests/ublk/test_common.sh new file +57 -0
57 lines not on this page · raw message
tools/testing/selftests/ublk/test_null_01.sh new file +18 -0
@@ -0,0 +1,18 @@ +#!/bin/bash + +. test_common.sh + +TID="null_01" +ERR_CODE=0 + +_prep_test "null" "basic IO test" + +dev_id=`_add_ublk_dev -t null` + +# run fio over the two disks +fio --name=job1 --filename=/dev/ublkb${dev_id} --ioengine=libaio --rw=readwrite --iodepth=32 --size=256M > /dev/null 2>&1 +ERR_CODE=$? + +_cleanup_test ${dev_id} "null" + +_show_result $TID $ERR_CODE
Signature · 1 line
2.47.0
PATCH 2/3 selftests: ublk: add file backed ublk
In reply to Ming LeiAdd file backed ublk and IO verify test.
--- tools/testing/selftests/ublk/Makefile | 2 + tools/testing/selftests/ublk/kublk.c | 172 ++++++++++++++++++- tools/testing/selftests/ublk/test_common.sh | 47 +++++ tools/testing/selftests/ublk/test_loop_01.sh | 30 ++++ tools/testing/selftests/ublk/test_loop_02.sh | 21 +++ 5 files changed, 268 insertions(+), 4 deletions(-) create mode 100755 tools/testing/selftests/ublk/test_loop_01.sh create mode 100755 tools/testing/selftests/ublk/test_loop_02.sh
tools/testing/selftests/ublk/Makefile +2 -0
@@ -4,6 +4,8 @@ CFLAGS += -O3 -Wl,-no-as-needed -Wall -I $(top_srcdir) LDLIBS += -lpthread -lm -luring TEST_PROGS := test_null_01.sh +TEST_PROGS += test_loop_01.sh +TEST_PROGS += test_loop_02.sh # Order correspond to 'make run_tests' order TEST_GEN_PROGS_EXTENDED = kublk
tools/testing/selftests/ublk/kublk.c +168 -4
214 lines not on this page · raw message
tools/testing/selftests/ublk/test_common.sh +47 -0
52 lines not on this page · raw message
tools/testing/selftests/ublk/test_loop_01.sh new file +30 -0
@@ -0,0 +1,30 @@ +#!/bin/bash + +. test_common.sh + +TID="loop_01" +ERR_CODE=0 + +_prep_test "loop" "write and verify test" + +backfile_0=`_create_backfile 256M` + +dev_id=`_add_ublk_dev -t loop $backfile_0` + +# run fio over the ublk disk +fio --name=write_and_verify \ + --filename=/dev/ublkb${dev_id} \ + --ioengine=libaio --iodepth=16 \ + --rw=write \ + --size=256M \ + --direct=1 \ + --verify=crc32c \ + --do_verify=1 \ + --bs=4k > /dev/null 2>&1 +ERR_CODE=$? + +_cleanup_test ${dev_id} "loop" + +_remove_backfile $backfile_0 + +_show_result $TID $ERR_CODE
tools/testing/selftests/ublk/test_loop_02.sh new file +21 -0
@@ -0,0 +1,21 @@ +#!/bin/bash + +. test_common.sh + +TID="loop_02" +ERR_CODE=0 + +_prep_test "loop" "mkfs & mount & umount" + +backfile_0=`_create_backfile 256M` + +dev_id=`_add_ublk_dev -t loop $backfile_0` + +_mkfs_mount_test /dev/ublkb${dev_id} +ERR_CODE=$? + +_cleanup_test ${dev_id} "loop" + +_remove_backfile $backfile_0 + +_show_result $TID $ERR_CODE
Signature · 1 line
2.47.0
PATCH 3/3 selftests: ublk: add ublk zero copy test
In reply to Ming LeiAdd selftests for covering ublk zero copy feature.
--- tools/testing/selftests/ublk/Makefile | 1 + tools/testing/selftests/ublk/kublk.c | 204 +++++++++++++++++-- tools/testing/selftests/ublk/test_common.sh | 8 + tools/testing/selftests/ublk/test_loop_03.sh | 32 +++ 4 files changed, 223 insertions(+), 22 deletions(-) create mode 100755 tools/testing/selftests/ublk/test_loop_03.sh
tools/testing/selftests/ublk/Makefile +1 -0
@@ -6,6 +6,7 @@ LDLIBS += -lpthread -lm -luring TEST_PROGS := test_null_01.sh TEST_PROGS += test_loop_01.sh TEST_PROGS += test_loop_02.sh +TEST_PROGS += test_loop_03.sh # Order correspond to 'make run_tests' order TEST_GEN_PROGS_EXTENDED = kublk
tools/testing/selftests/ublk/kublk.c +182 -22
315 lines not on this page · raw message
tools/testing/selftests/ublk/test_common.sh +8 -0
@@ -101,4 +101,12 @@ _add_ublk_dev() { echo ${dev_id} } +_have_feature() +{ + if $UBLK_PROG "features" | grep $1 > /dev/null 2>&1; then + return 0 + fi + return 1 +} + export UBLK_PROG=$(pwd)/kublk
tools/testing/selftests/ublk/test_loop_03.sh new file +32 -0
@@ -0,0 +1,32 @@ +#!/bin/bash + +. test_common.sh + +TID="loop_03" +ERR_CODE=0 + +_have_feature "ZERO_COPY" || exit 4 + +_prep_test "loop" "write and verify over zero copy" + +backfile_0=`_create_backfile 256M` + +dev_id=`_add_ublk_dev -t loop $backfile_0 -z` + +# run fio over the ublk disk +fio --name=write_and_verify \ + --filename=/dev/ublkb${dev_id} \ + --ioengine=libaio --iodepth=64 \ + --rw=write \ + --size=256M \ + --direct=1 \ + --verify=crc32c \ + --do_verify=1 \ + --bs=4k > /dev/null 2>&1 +ERR_CODE=$? + +_cleanup_test ${dev_id} "loop" + +_remove_backfile $backfile_0 + +_show_result $TID $ERR_CODE
Signature · 1 line
2.47.0