#! /bin/bash
# hpc-testing
# Copyright (C) 2025 SUSE LLC
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

test_ibv_pingpong()
{
    local testname=$1

    local host1=$2
    local hca1=$3
    local ibport1=$4

    local host2=$5
    local hca2=$6
    local ibport2=$7

    tp $host2 "$testname -g 0 -d $hca2 -i $ibport2 $IBV_EXTRA_OPTS" &
    # Do a random sleep on the remote host so in case SSH is very slow we don't have
    # hardcoded sleep value
    tp $host2 "sleep 2"
    sleep 2
    tp $host1 "$testname -g 0 -d $hca1 -i $ibport1 $IBV_EXTRA_OPTS $host2"

    wait
}
