Re: [PATCH 8/8] NTB: ntb_test: Fix bug when counting remote files

From: Serge Semin
Date: Fri Jun 15 2018 - 15:51:50 EST


On Fri, Jun 08, 2018 at 06:08:19PM -0600, Logan Gunthorpe <logang@xxxxxxxxxxxx> wrote:
> When remote files are counted in get_files_count, without using SSH,
> the code returns 0 because there is a colon prepended to $LOC. $VPATH
> should have been used instead of $LOC.
>

Good catch. Thanks for the patch. I discovered this problem myself a few days
before you sent this patchset. So was going to submit the fix, but you were
faster.

I also tested this script in the looped-back setup. It is the case when two
NTB-device ports are available at the same RootComplex. So the NTB can be
configured from the single executional context. In this case the REMOTE_HOST is left
empty, so the colon is left prepended to the corresponding paths and causes multiple
errors including the one fixed by this patch. In order to fix it, we need to discard
the colon for remote-less case, for instance, by the next patch:

@@ -482,7 +495,11 @@ function perf_test()
function ntb_tool_tests()
{
LOCAL_TOOL="$DEBUGFS/ntb_tool/$LOCAL_DEV"
- REMOTE_TOOL="$REMOTE_HOST:$DEBUGFS/ntb_tool/$REMOTE_DEV"
+ if [[ "${REMOTE_HOST}" != "" ]]; then
+ REMOTE_TOOL="$REMOTE_HOST:$DEBUGFS/ntb_tool/$REMOTE_DEV"
+ else
+ REMOTE_TOOL="$DEBUGFS/ntb_tool/$REMOTE_DEV"
+ fi

echo "Starting ntb_tool tests..."

And so on for REMOTE_PP and REMOTE_PERF. It is necessary for NTB devices, which ports
are looped-back to the same Root-Port. Would you be amenable if you resent this patch
together with the fix I suggested?

Regards,
-Sergey

> Fixes: 06bd0407d06c ("NTB: ntb_test: Update ntb_tool Scratchpad tests")
> Signed-off-by: Logan Gunthorpe <logang@xxxxxxxxxxxx>
> ---
> tools/testing/selftests/ntb/ntb_test.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/ntb/ntb_test.sh b/tools/testing/selftests/ntb/ntb_test.sh
> index 08cbfbbc7029..17ca36403d04 100755
> --- a/tools/testing/selftests/ntb/ntb_test.sh
> +++ b/tools/testing/selftests/ntb/ntb_test.sh
> @@ -250,7 +250,7 @@ function get_files_count()
> split_remote $LOC
>
> if [[ "$REMOTE" == "" ]]; then
> - echo $(ls -1 "$LOC"/${NAME}* 2>/dev/null | wc -l)
> + echo $(ls -1 "$VPATH"/${NAME}* 2>/dev/null | wc -l)
> else
> echo $(ssh "$REMOTE" "ls -1 \"$VPATH\"/${NAME}* | \
> wc -l" 2> /dev/null)
> --
> 2.11.0
>