Skip to content

Commit 6327618

Browse files
calebsanderaxboe
authored andcommitted
selftests: ublk: add user copy test cases
The ublk selftests cover every data copy mode except user copy. Add tests for user copy based on the existing test suite: - generic_14 ("basic recover function verification (user copy)") based on generic_04 and generic_05 - null_03 ("basic IO test with user copy") based on null_01 and null_02 - loop_06 ("write and verify over user copy") based on loop_01 and loop_03 - loop_07 ("mkfs & mount & umount with user copy") based on loop_02 and loop_04 - stripe_05 ("write and verify test on user copy") based on stripe_03 - stripe_06 ("mkfs & mount & umount on user copy") based on stripe_02 and stripe_04 - stress_06 ("run IO and remove device (user copy)") based on stress_01 and stress_03 - stress_07 ("run IO and kill ublk server (user copy)") based on stress_02 and stress_04 Signed-off-by: Caleb Sander Mateos <csander@purestorage.com> Reviewed-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b9f0a94 commit 6327618

9 files changed

Lines changed: 243 additions & 0 deletions

File tree

tools/testing/selftests/ublk/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,32 @@ TEST_PROGS += test_generic_10.sh
2121
TEST_PROGS += test_generic_11.sh
2222
TEST_PROGS += test_generic_12.sh
2323
TEST_PROGS += test_generic_13.sh
24+
TEST_PROGS += test_generic_14.sh
2425

2526
TEST_PROGS += test_null_01.sh
2627
TEST_PROGS += test_null_02.sh
28+
TEST_PROGS += test_null_03.sh
2729
TEST_PROGS += test_loop_01.sh
2830
TEST_PROGS += test_loop_02.sh
2931
TEST_PROGS += test_loop_03.sh
3032
TEST_PROGS += test_loop_04.sh
3133
TEST_PROGS += test_loop_05.sh
34+
TEST_PROGS += test_loop_06.sh
35+
TEST_PROGS += test_loop_07.sh
3236
TEST_PROGS += test_stripe_01.sh
3337
TEST_PROGS += test_stripe_02.sh
3438
TEST_PROGS += test_stripe_03.sh
3539
TEST_PROGS += test_stripe_04.sh
40+
TEST_PROGS += test_stripe_05.sh
41+
TEST_PROGS += test_stripe_06.sh
3642

3743
TEST_PROGS += test_stress_01.sh
3844
TEST_PROGS += test_stress_02.sh
3945
TEST_PROGS += test_stress_03.sh
4046
TEST_PROGS += test_stress_04.sh
4147
TEST_PROGS += test_stress_05.sh
48+
TEST_PROGS += test_stress_06.sh
49+
TEST_PROGS += test_stress_07.sh
4250

4351
TEST_GEN_PROGS_EXTENDED = kublk
4452

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5+
6+
TID="generic_14"
7+
ERR_CODE=0
8+
9+
ublk_run_recover_test()
10+
{
11+
run_io_and_recover 256M "kill_daemon" "$@"
12+
ERR_CODE=$?
13+
if [ ${ERR_CODE} -ne 0 ]; then
14+
echo "$TID failure: $*"
15+
_show_result $TID $ERR_CODE
16+
fi
17+
}
18+
19+
if ! _have_program fio; then
20+
exit "$UBLK_SKIP_CODE"
21+
fi
22+
23+
_prep_test "recover" "basic recover function verification (user copy)"
24+
25+
_create_backfile 0 256M
26+
_create_backfile 1 128M
27+
_create_backfile 2 128M
28+
29+
ublk_run_recover_test -t null -q 2 -r 1 -u &
30+
ublk_run_recover_test -t loop -q 2 -r 1 -u "${UBLK_BACKFILES[0]}" &
31+
ublk_run_recover_test -t stripe -q 2 -r 1 -u "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
32+
wait
33+
34+
ublk_run_recover_test -t null -q 2 -r 1 -u -i 1 &
35+
ublk_run_recover_test -t loop -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[0]}" &
36+
ublk_run_recover_test -t stripe -q 2 -r 1 -u -i 1 "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
37+
wait
38+
39+
_cleanup_test "recover"
40+
_show_result $TID $ERR_CODE
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5+
6+
TID="loop_06"
7+
ERR_CODE=0
8+
9+
if ! _have_program fio; then
10+
exit "$UBLK_SKIP_CODE"
11+
fi
12+
13+
_prep_test "loop" "write and verify over user copy"
14+
15+
_create_backfile 0 256M
16+
dev_id=$(_add_ublk_dev -t loop -u "${UBLK_BACKFILES[0]}")
17+
_check_add_dev $TID $?
18+
19+
# run fio over the ublk disk
20+
_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=256M
21+
ERR_CODE=$?
22+
23+
_cleanup_test "loop"
24+
25+
_show_result $TID $ERR_CODE
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5+
6+
TID="loop_07"
7+
ERR_CODE=0
8+
9+
_prep_test "loop" "mkfs & mount & umount with user copy"
10+
11+
_create_backfile 0 256M
12+
13+
dev_id=$(_add_ublk_dev -t loop -u "${UBLK_BACKFILES[0]}")
14+
_check_add_dev $TID $?
15+
16+
_mkfs_mount_test /dev/ublkb"${dev_id}"
17+
ERR_CODE=$?
18+
19+
_cleanup_test "loop"
20+
21+
_show_result $TID $ERR_CODE
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5+
6+
TID="null_03"
7+
ERR_CODE=0
8+
9+
if ! _have_program fio; then
10+
exit "$UBLK_SKIP_CODE"
11+
fi
12+
13+
_prep_test "null" "basic IO test with user copy"
14+
15+
dev_id=$(_add_ublk_dev -t null -u)
16+
_check_add_dev $TID $?
17+
18+
# run fio over the two disks
19+
fio --name=job1 --filename=/dev/ublkb"${dev_id}" --ioengine=libaio --rw=readwrite --iodepth=32 --size=256M > /dev/null 2>&1
20+
ERR_CODE=$?
21+
22+
_cleanup_test "null"
23+
24+
_show_result $TID $ERR_CODE
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5+
TID="stress_06"
6+
ERR_CODE=0
7+
8+
ublk_io_and_remove()
9+
{
10+
run_io_and_remove "$@"
11+
ERR_CODE=$?
12+
if [ ${ERR_CODE} -ne 0 ]; then
13+
echo "$TID failure: $*"
14+
_show_result $TID $ERR_CODE
15+
fi
16+
}
17+
18+
if ! _have_program fio; then
19+
exit "$UBLK_SKIP_CODE"
20+
fi
21+
22+
_prep_test "stress" "run IO and remove device (user copy)"
23+
24+
_create_backfile 0 256M
25+
_create_backfile 1 128M
26+
_create_backfile 2 128M
27+
28+
ublk_io_and_remove 8G -t null -q 4 -u &
29+
ublk_io_and_remove 256M -t loop -q 4 -u "${UBLK_BACKFILES[0]}" &
30+
ublk_io_and_remove 256M -t stripe -q 4 -u "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
31+
wait
32+
33+
ublk_io_and_remove 8G -t null -q 4 -u --nthreads 8 --per_io_tasks &
34+
ublk_io_and_remove 256M -t loop -q 4 -u --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" &
35+
ublk_io_and_remove 256M -t stripe -q 4 -u --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
36+
wait
37+
38+
_cleanup_test "stress"
39+
_show_result $TID $ERR_CODE
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5+
TID="stress_07"
6+
ERR_CODE=0
7+
8+
ublk_io_and_kill_daemon()
9+
{
10+
run_io_and_kill_daemon "$@"
11+
ERR_CODE=$?
12+
if [ ${ERR_CODE} -ne 0 ]; then
13+
echo "$TID failure: $*"
14+
_show_result $TID $ERR_CODE
15+
fi
16+
}
17+
18+
if ! _have_program fio; then
19+
exit "$UBLK_SKIP_CODE"
20+
fi
21+
22+
_prep_test "stress" "run IO and kill ublk server (user copy)"
23+
24+
_create_backfile 0 256M
25+
_create_backfile 1 128M
26+
_create_backfile 2 128M
27+
28+
ublk_io_and_kill_daemon 8G -t null -q 4 -u --no_ublk_fixed_fd &
29+
ublk_io_and_kill_daemon 256M -t loop -q 4 -u --no_ublk_fixed_fd "${UBLK_BACKFILES[0]}" &
30+
ublk_io_and_kill_daemon 256M -t stripe -q 4 -u "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
31+
wait
32+
33+
ublk_io_and_kill_daemon 8G -t null -q 4 -u --nthreads 8 --per_io_tasks &
34+
ublk_io_and_kill_daemon 256M -t loop -q 4 -u --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[0]}" &
35+
ublk_io_and_kill_daemon 256M -t stripe -q 4 -u --nthreads 8 --per_io_tasks "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
36+
wait
37+
38+
_cleanup_test "stress"
39+
_show_result $TID $ERR_CODE
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5+
6+
TID="stripe_05"
7+
ERR_CODE=0
8+
9+
if ! _have_program fio; then
10+
exit "$UBLK_SKIP_CODE"
11+
fi
12+
13+
_prep_test "stripe" "write and verify test on user copy"
14+
15+
_create_backfile 0 256M
16+
_create_backfile 1 256M
17+
18+
dev_id=$(_add_ublk_dev -t stripe -q 2 -u "${UBLK_BACKFILES[0]}" "${UBLK_BACKFILES[1]}")
19+
_check_add_dev $TID $?
20+
21+
# run fio over the ublk disk
22+
_run_fio_verify_io --filename=/dev/ublkb"${dev_id}" --size=512M
23+
ERR_CODE=$?
24+
25+
_cleanup_test "stripe"
26+
_show_result $TID $ERR_CODE
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5+
6+
TID="stripe_06"
7+
ERR_CODE=0
8+
9+
_prep_test "stripe" "mkfs & mount & umount on user copy"
10+
11+
_create_backfile 0 256M
12+
_create_backfile 1 256M
13+
14+
dev_id=$(_add_ublk_dev -t stripe -u -q 2 "${UBLK_BACKFILES[0]}" "${UBLK_BACKFILES[1]}")
15+
_check_add_dev $TID $?
16+
17+
_mkfs_mount_test /dev/ublkb"${dev_id}"
18+
ERR_CODE=$?
19+
20+
_cleanup_test "stripe"
21+
_show_result $TID $ERR_CODE

0 commit comments

Comments
 (0)