Message ID | 20191023173954.29291-1-kamalheib1@gmail.com (mailing list archive) |
---|---|
State | Changes Requested |
Headers | show |
Series | [for-next] selftests: rdma: Add rdma tests | expand |
On Wed, Oct 23, 2019 at 08:39:54PM +0300, Kamal Heib wrote: > Add a new directory to house the rdma specific tests and add the first > rdma_dev.sh test that checks the renaming and setting of adaptive > moderation using the rdma tool for the available RDMA devices in the > system. What is this actually testing? rdmatool? This seems like a very strange kselftest to me. Jason
On Wed, Oct 23, 2019 at 02:42:19PM -0300, Jason Gunthorpe wrote: > On Wed, Oct 23, 2019 at 08:39:54PM +0300, Kamal Heib wrote: > > Add a new directory to house the rdma specific tests and add the first > > rdma_dev.sh test that checks the renaming and setting of adaptive > > moderation using the rdma tool for the available RDMA devices in the > > system. > > What is this actually testing? rdmatool? > This is a very basic test that uses the rdmatool for checking two of the RDMA devices functionalities. > This seems like a very strange kselftest to me. > Basically, you can take a look into other subsystems selftests (e.g. net) to see that it not that strange :-). Yes, the first test is very basic, but the idea behind it is to utilize the kernel selftests infrastructure to test the rdma subsystem, I plan to introduce more tests in the near future, hopefully other folks from the community will join me too. Thanks, Kamal > Jason
On Wed, Oct 23, 2019 at 11:10:08PM +0300, Kamal Heib wrote: > On Wed, Oct 23, 2019 at 02:42:19PM -0300, Jason Gunthorpe wrote: > > On Wed, Oct 23, 2019 at 08:39:54PM +0300, Kamal Heib wrote: > > > Add a new directory to house the rdma specific tests and add the first > > > rdma_dev.sh test that checks the renaming and setting of adaptive > > > moderation using the rdma tool for the available RDMA devices in the > > > system. > > > > What is this actually testing? rdmatool? > > > > This is a very basic test that uses the rdmatool for checking two of the > RDMA devices functionalities. > > > This seems like a very strange kselftest to me. > > > > Basically, you can take a look into other subsystems selftests (e.g. > net) to see that it not that strange :-). Yeah, selftests is in-kernel dumpster, everything goes in. It doesn't mean we should follow this path too. The in-kernel tests are great to check interfaces and not external tools. > > Yes, the first test is very basic, but the idea behind it is to utilize > the kernel selftests infrastructure to test the rdma subsystem, I plan to > introduce more tests in the near future, hopefully other folks from the > community will join me too. You don't have any version checks, the idea that you can test latest kernel features with installed "rdmatool" in distro is a little bit over optimistic. > > Thanks, > Kamal > > > Jason
On 10/23/2019 1:39 PM, Kamal Heib wrote: > + > +rdma dev show 2>/dev/null >/dev/null > +check_and_skip $? "Can not run the test without rdma tool" > + I like the idea of some self tests in theory, actually really like the idea. However I do not think it is a good idea to be tied to a user tool that may or may not be available. Also I think we need to ask ourselves, what are we actually testing. The kernel and it's interfaces, or the HW? Not so sure the latter is what we want. -Denny
On Thu, Oct 24, 2019 at 09:39:09AM +0300, Leon Romanovsky wrote: > On Wed, Oct 23, 2019 at 11:10:08PM +0300, Kamal Heib wrote: > > On Wed, Oct 23, 2019 at 02:42:19PM -0300, Jason Gunthorpe wrote: > > > On Wed, Oct 23, 2019 at 08:39:54PM +0300, Kamal Heib wrote: > > > > Add a new directory to house the rdma specific tests and add the first > > > > rdma_dev.sh test that checks the renaming and setting of adaptive > > > > moderation using the rdma tool for the available RDMA devices in the > > > > system. > > > > > > What is this actually testing? rdmatool? > > > > > > > This is a very basic test that uses the rdmatool for checking two of the > > RDMA devices functionalities. > > > > > This seems like a very strange kselftest to me. > > > > > > > Basically, you can take a look into other subsystems selftests (e.g. > > net) to see that it not that strange :-). > > Yeah, selftests is in-kernel dumpster, everything goes in. It doesn't > mean we should follow this path too. The in-kernel tests are great to > check interfaces and not external tools. > OK, I see that you don't like the idea of using external/Userspace tools. So, what do you suggest?! > > > > Yes, the first test is very basic, but the idea behind it is to utilize > > the kernel selftests infrastructure to test the rdma subsystem, I plan to > > introduce more tests in the near future, hopefully other folks from the > > community will join me too. > > You don't have any version checks, the idea that you can test latest > kernel features with installed "rdmatool" in distro is a little bit over > optimistic. > > > > > Thanks, > > Kamal > > > > > Jason
On Thu, Oct 24, 2019 at 04:39:44PM +0300, Kamal Heib wrote: > On Thu, Oct 24, 2019 at 09:39:09AM +0300, Leon Romanovsky wrote: > > On Wed, Oct 23, 2019 at 11:10:08PM +0300, Kamal Heib wrote: > > > On Wed, Oct 23, 2019 at 02:42:19PM -0300, Jason Gunthorpe wrote: > > > > On Wed, Oct 23, 2019 at 08:39:54PM +0300, Kamal Heib wrote: > > > > > Add a new directory to house the rdma specific tests and add the first > > > > > rdma_dev.sh test that checks the renaming and setting of adaptive > > > > > moderation using the rdma tool for the available RDMA devices in the > > > > > system. > > > > > > > > What is this actually testing? rdmatool? > > > > > > > > > > This is a very basic test that uses the rdmatool for checking two of the > > > RDMA devices functionalities. > > > > > > > This seems like a very strange kselftest to me. > > > > > > > > > > Basically, you can take a look into other subsystems selftests (e.g. > > > net) to see that it not that strange :-). > > > > Yeah, selftests is in-kernel dumpster, everything goes in. It doesn't > > mean we should follow this path too. The in-kernel tests are great to > > check interfaces and not external tools. > > > > OK, I see that you don't like the idea of using external/Userspace tools. > > So, what do you suggest?! You need to decide WHAT do you want to test. For rdma-core APIs, we have pyverbs, see this PR https://github.com/linux-rdma/rdma-core/pull/567 For sysfs API, shell scripts in selftest is a good place. For netlink/verbs API, you will need to write C-programs. <-- don't recommend this path. > > > > > > > Yes, the first test is very basic, but the idea behind it is to utilize > > > the kernel selftests infrastructure to test the rdma subsystem, I plan to > > > introduce more tests in the near future, hopefully other folks from the > > > community will join me too. > > > > You don't have any version checks, the idea that you can test latest > > kernel features with installed "rdmatool" in distro is a little bit over > > optimistic. > > > > > > > > Thanks, > > > Kamal > > > > > > > Jason
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index c3feccb99ff5..870b9d0c36c9 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -37,6 +37,7 @@ TARGETS += powerpc TARGETS += proc TARGETS += pstore TARGETS += ptrace +TARGETS += rdma TARGETS += rseq TARGETS += rtc TARGETS += seccomp diff --git a/tools/testing/selftests/rdma/Makefile b/tools/testing/selftests/rdma/Makefile new file mode 100644 index 000000000000..56df64b9b5d9 --- /dev/null +++ b/tools/testing/selftests/rdma/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0 +# Makefile for rdma selftests + +TEST_PROGS := rdma_dev.sh + +include ../lib.mk diff --git a/tools/testing/selftests/rdma/lib.sh b/tools/testing/selftests/rdma/lib.sh new file mode 100644 index 000000000000..5f1cc08bc6b2 --- /dev/null +++ b/tools/testing/selftests/rdma/lib.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +EXIT_STATUS=0 +RET=0 +#Kselftest framework requirement - SKIP code is 4 +ksft_skip=4 + +check_and_skip() +{ + local rc=$1 + local msg=$2 + + if [ $rc -ne 0 ]; then + echo "SKIP: $msg" + exit $ksft_skip + fi +} + +check_ret_val() +{ + local rc=$1 + local msg=$2 + + if [[ $RET -eq 0 && $rc -ne 0 ]]; then + RET=$rc + retmsg=$msg + fi +} + +print_results() +{ + local test_name=$1 + + if [[ $RET -ne 0 ]]; then + EXIT_STATUS=1 + printf "TEST: %-60s [FAIL]\n" "$test_name" + if [[ ! -z "$retmsg" ]]; then + printf "\t%s\n" "$retmsg" + fi + return 1 + fi + + printf "TEST: %-60s [OK]\n" "$test_name" + return 0 +} + +run_tests() +{ + local cur_test + + for cur_test in ${ALL_TESTS}; do + $cur_test + done +} diff --git a/tools/testing/selftests/rdma/rdma_dev.sh b/tools/testing/selftests/rdma/rdma_dev.sh new file mode 100755 index 000000000000..ca3ae7ddac9b --- /dev/null +++ b/tools/testing/selftests/rdma/rdma_dev.sh @@ -0,0 +1,83 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 + +lib=$(dirname $0)/lib.sh +source $lib + +ALL_TESTS=" + test_rename + test_adaptive_moderation +" + +test_rename() +{ + local dev=$RDMA_DEV + + rdma dev set $dev name "tmp_$dev" + check_ret_val $? "Failed to rename $dev to tmp_$dev" + + rdma dev set tmp_$dev name $dev + check_ret_val $? "Failed to restore $dev name" + + print_results "$dev: Rename" +} + +test_adaptive_moderation() +{ + local dev=$RDMA_DEV + + rdma dev show $dev -d | grep -qE "adaptive-moderation" + check_and_skip $? "Setting adaptive-moderation is not supported" + + rdma dev show $dev -d | grep -qE "adaptive-moderation off" + if [ $? -ne 0 ]; then + rdma dev set $dev adaptive-moderation off + check_ret_val $? "$dev: Failed to set adaptive-moderation to on" + + rdma dev set $dev adaptive-moderation on + check_ret_val $? "$dev: Failed to restroe adaptive-moderation to off" + else + rdma dev set $dev adaptive-moderation on + check_ret_val $? "$dev: Failed to set adaptive-moderation to on" + + rdma dev set $dev adaptive-moderation off + check_ret_val $? "$dev: Failed to restroe adaptive-moderation to off" + fi + + print_results "$dev: Setting adaptive-moderation" +} + +prepare() +{ + TMP_LIST_RDMADEV="$(mktemp)" + if [ ! -e $TMP_LIST_RDMADEV ]; then + echo "FAIL: Failed to create temp file to hold rdma devices" + exit 1 + fi +} + +cleanup() +{ + rm $TMP_LIST_RDMADEV +} + +trap cleanup EXIT + +check_and_skip $(id -u) "Need root privileges" + +rdma dev show 2>/dev/null >/dev/null +check_and_skip $? "Can not run the test without rdma tool" + +prepare + +rdma dev show | grep '^[0-9]' | cut -d" " -f 2 | cut -d: -f1> "$TMP_LIST_RDMADEV" +test -s "$TMP_LIST_RDMADEV" +check_and_skip $? "No RDMA devices available" + +while read rdma_dev +do + RDMA_DEV=$rdma_dev + run_tests +done < $TMP_LIST_RDMADEV + +exit $EXIT_STATUS
Add a new directory to house the rdma specific tests and add the first rdma_dev.sh test that checks the renaming and setting of adaptive moderation using the rdma tool for the available RDMA devices in the system. Signed-off-by: Kamal Heib <kamalheib1@gmail.com> --- tools/testing/selftests/Makefile | 1 + tools/testing/selftests/rdma/Makefile | 6 ++ tools/testing/selftests/rdma/lib.sh | 55 ++++++++++++++++ tools/testing/selftests/rdma/rdma_dev.sh | 83 ++++++++++++++++++++++++ 4 files changed, 145 insertions(+) create mode 100644 tools/testing/selftests/rdma/Makefile create mode 100644 tools/testing/selftests/rdma/lib.sh create mode 100755 tools/testing/selftests/rdma/rdma_dev.sh