Skip to content
Closed
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
4 changes: 3 additions & 1 deletion tools/testing/selftests/ublk/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ endif

LDLIBS += -lpthread -lm -luring

TEST_PROGS := test_generic_02.sh
TEST_PROGS := test_cli_01.sh

TEST_PROGS += test_generic_02.sh
TEST_PROGS += test_generic_03.sh
TEST_PROGS += test_generic_06.sh
TEST_PROGS += test_generic_07.sh
Expand Down
5 changes: 5 additions & 0 deletions tools/testing/selftests/ublk/kublk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2525,6 +2525,11 @@ int main(int argc, char *argv[])
while (i < argc && ctx.nr_files < MAX_BACK_FILES) {
ctx.files[ctx.nr_files++] = argv[i++];
}
if (i < argc) {
fprintf(stderr, "too many backing files (maximum is %d)\n",
MAX_BACK_FILES);
return -EINVAL;
}

ops = ublk_find_tgt(ctx.tgt_type);
if (ops && ops->parse_cmd_line) {
Expand Down
15 changes: 15 additions & 0 deletions tools/testing/selftests/ublk/test_cli_01.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0

UBLK_PROG="$(dirname "$0")/kublk"
expected="too many backing files (maximum is 4)"

if output=$("${UBLK_PROG}" add -t stripe a b c d e 2>&1); then
echo "kublk accepted more than four backing files"
exit 1
fi

if [ "${output}" != "${expected}" ]; then
echo "unexpected error: ${output}"
exit 1
fi