Skip to content

Commit d836590

Browse files
Ming Leiaxboe
authored andcommitted
selftests: ublk: add two stress tests for zero copy feature
Add stress_03 & stress_04 for covering zero copy feature. Signed-off-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent bb2cabf commit d836590

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

tools/testing/selftests/ublk/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ TEST_PROGS += test_stripe_04.sh
2121

2222
TEST_PROGS += test_stress_01.sh
2323
TEST_PROGS += test_stress_02.sh
24+
TEST_PROGS += test_stress_03.sh
25+
TEST_PROGS += test_stress_04.sh
2426

2527
TEST_GEN_PROGS_EXTENDED = kublk
2628

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5+
TID="stress_03"
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+
if ! _have_feature "ZERO_COPY"; then
23+
exit "$UBLK_SKIP_CODE"
24+
fi
25+
26+
_prep_test "stress" "run IO and remove device(zero copy)"
27+
28+
_create_backfile 0 256M
29+
_create_backfile 1 128M
30+
_create_backfile 2 128M
31+
32+
ublk_io_and_remove 8G -t null -q 4 -z &
33+
ublk_io_and_remove 256M -t loop -q 4 -z "${UBLK_BACKFILES[0]}" &
34+
ublk_io_and_remove 256M -t stripe -q 4 -z "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
35+
wait
36+
37+
_cleanup_test "stress"
38+
_show_result $TID $ERR_CODE
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
. "$(cd "$(dirname "$0")" && pwd)"/test_common.sh
5+
TID="stress_04"
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+
if ! _have_feature "ZERO_COPY"; then
22+
exit "$UBLK_SKIP_CODE"
23+
fi
24+
25+
_prep_test "stress" "run IO and kill ublk server(zero copy)"
26+
27+
_create_backfile 0 256M
28+
_create_backfile 1 128M
29+
_create_backfile 2 128M
30+
31+
ublk_io_and_kill_daemon 8G -t null -q 4 -z &
32+
ublk_io_and_kill_daemon 256M -t loop -q 4 -z "${UBLK_BACKFILES[0]}" &
33+
ublk_io_and_kill_daemon 256M -t stripe -q 4 -z "${UBLK_BACKFILES[1]}" "${UBLK_BACKFILES[2]}" &
34+
wait
35+
36+
_cleanup_test "stress"
37+
_show_result $TID $ERR_CODE

0 commit comments

Comments
 (0)