[LTP] [COMMITTED][PATCH 1/6] lib/test_net.sh: add EXPECT_RHOST_PASS/FAIL functions

Subsystems: the rest

6 messages, 1 author, 2017-06-06 · open the first message on its own page

[LTP] [COMMITTED][PATCH 1/6] lib/test_net.sh: add EXPECT_RHOST_PASS/FAIL functions

From: Alexey Kodanev <hidden>
Date: 2017-06-06 11:21:56

Signed-off-by: Alexey Kodanev <redacted>
---
 testcases/lib/test_net.sh |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
index 753a061..9d6e6cb 100644
--- a/testcases/lib/test_net.sh
+++ b/testcases/lib/test_net.sh
@@ -113,6 +113,26 @@ tst_rhost_run()
 	return $ret
 }
 
+EXPECT_RHOST_PASS()
+{
+	tst_rhost_run -c "$*" > /dev/null
+	if [ $? -eq 0 ]; then
+		tst_resm TPASS "$* passed as expected"
+	else
+		tst_resm TFAIL "$* failed unexpectedly"
+	fi
+}
+
+EXPECT_RHOST_FAIL()
+{
+	tst_rhost_run -c "$* 2> /dev/null"
+	if [ $? -ne 0 ]; then
+		tst_resm TPASS "$* failed as expected"
+	else
+		tst_resm TFAIL "$* passed unexpectedly"
+	fi
+}
+
 # Get test interface names for local/remote host.
 # tst_get_ifaces [TYPE]
 # TYPE: { lhost | rhost }; Default value is 'lhost'.
-- 
1.7.1

[LTP] [COMMITTED][PATCH 2/6] net/rup01: convert to test_net.sh library

From: Alexey Kodanev <hidden>
Date: 2017-06-06 11:21:57

* remove broadcast test-cases, send requests to
  configured host only;

* don't start/stop rstatd and TCONF if rstatd not started;

Signed-off-by: Alexey Kodanev <redacted>
---
 testcases/network/rpc/basic_tests/rup/rup01 |  192 +++++----------------------
 1 files changed, 34 insertions(+), 158 deletions(-)
diff --git a/testcases/network/rpc/basic_tests/rup/rup01 b/testcases/network/rpc/basic_tests/rup/rup01
index ed99040..da944c6 100755
--- a/testcases/network/rpc/basic_tests/rup/rup01
+++ b/testcases/network/rpc/basic_tests/rup/rup01
@@ -1,174 +1,50 @@
 #!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2000
 #
+# 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 2 of
+# the License, or (at your option) any later version.
 #
-#   Copyright (c) International Business Machines  Corp., 2000
+# This program is distributed in the hope that it would 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.
 #
-#   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 2 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, write to the Free Software
-#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-#
-#
-#  FILE             : rup
-#
-#  TEST DESCRIPTION : Basic test for the `rup` command.
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the machine
-#         where the test is executed.
-#
-#  HISTORY:
-#    04/18/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#
-# CMD      FLAG      ARGS
-# rup
-# rup                rem_host
-# rup	    -d
-# rup       -h
-# rup       -t
-# rup       -l
-# rup                bogus_host
-# rup      -bogus_flag
-#***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-
-$trace_logic
-this_file=${0##*/}
-TC=rup01
-TCtmp=${TCtmp:=`pwd`}
-TCbin=${TCbin:=`pwd`}
-TCsrc=${TCsrc:=$TCbin}
-LUSER=${LUSER:=root}
-RHOST=${RHOST:=`hostname`}
-CLEANUP=${CLEANUP:="ON"}
-PID=0
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
-
-#=============================================================================
-# FUNCTION NAME:        do_test
-#
-# FUNCTION DESCRIPTION: Perform the test
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
-do_test()
-{
-$trace_logic
-
-echo "Checking for rstatd on $RHOST"
-
-rpcinfo -u $RHOST rstatd 3 > /dev/null 2>&1
-if [ $? -ne 0 ]; then
-  echo "Attempting to start rstatd on $RHOST"
-  rsh -n -l root $RHOST "/usr/sbin/rpc.rstatd &"
-  [ $? -eq 0 ] || end_testcase "rstatd is inactive on $RHOST"
-  PID=`rsh -n $RHOST ps -ewf | grep rstatd | awk '{print $2 }'`
-  echo "rstatd started on $RHOST"
-fi
-
-echo "Test rup with defaults....please be patient"
-# rusers with no options broadcasts over the net and reports
-# responses as it receives them. Time-out for responses is approx. 2 minutes.
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
-echo "rup"
-rup
-[ $? -eq 0 ] || end_testcase "rup with defaults - failed"
+TCID="rup01"
+TST_TOTAL=7
 
-echo "Test rusers with options set...please be patient"
-# Go through matrix of rup options:
+. test_net.sh
 
-echo "rup $RHOST"
-rup $RHOST
-[ $? -eq 0 ] || end_testcase "rup $RHOST - failed"
-
-echo "rup -d"
-rup -d
-[ $? -eq 0 ] || end_testcase "rup -d - failed"
-
-echo "rup -h"
-rup -h
-[ $? -eq 0 ] || end_testcase "rup -h - failed"
-
-echo "rup -l"
-rup -l
-[ $? -eq 0 ] || end_testcase "rup -l - failed"
-
-echo "rup -t"
-rup -t
-[ $? -eq 0 ] || end_testcase "rup -t - failed"
-
-echo "Test rusers with bad options"
-echo "rup <invalid hostname>"
-rup bogushost > /dev/null 2>&1
-[ $? -ne 0 ] || end_testcase "rup <invalid hostname> should fail"
-
-echo "rup -<invalid flag>"
-rup -bogusflag > /dev/null 2>&1
-[ $? -eq 1 ] || end_testcase "rup -<invalid flag> should fail"
+do_setup()
+{
+	tst_resm TINFO "Checking for rstatd on $(tst_ipaddr)"
+	tst_rhost_run -c "rpcinfo -u $(tst_ipaddr) rstatd 3" \
+		> /dev/null 2>&1 || \
+		tst_brkm TCONF "rstatd is inactive on $(tst_ipaddr)"
 }
 
-#=============================================================================
-# FUNCTION NAME:        do_cleanup
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
-do_cleanup()
+do_test()
 {
-    $trace_logic
+	tst_resm TINFO "Test rup with options set"
 
-    if [ "$PID" != 0 ]; then
-        # Kill rup on remote machine
-        rsh -n $RHOST kill -15 $PID
-        echo "rstatd daemon stopped on $RHOST"
-    fi
-}
+	EXPECT_RHOST_PASS rup $(tst_ipaddr)
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
+	local opts="-d -h -l -t"
+	for opt in $opts; do
+		EXPECT_RHOST_PASS rup $opt $(tst_ipaddr)
+	done
 
-end_testcase()
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-   if [ "$CLEANUP" = "ON" ]; then
-     do_cleanup
-   fi
-
-   [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+	tst_resm TINFO "Test rup with bad options"
+	EXPECT_RHOST_FAIL rup bogushost
+	EXPECT_RHOST_FAIL rup -bogusflag $(tst_ipaddr)
 }
 
-#=============================================================================
-# MAIN PROCEDURE
-#=============================================================================
-
+do_setup
 do_test
-end_testcase
+
+tst_exit
-- 
1.7.1

[LTP] [COMMITTED][PATCH 3/6] net/rusers01: convert to test_net.sh lib

From: Alexey Kodanev <hidden>
Date: 2017-06-06 11:21:58

* remove broadcast test-cases

* remove starting/stoping rusersd and TCONF if it's not started

Signed-off-by: Alexey Kodanev <redacted>
---
 testcases/network/rpc/basic_tests/rusers/rusers01 |  184 ++++-----------------
 1 files changed, 33 insertions(+), 151 deletions(-)
diff --git a/testcases/network/rpc/basic_tests/rusers/rusers01 b/testcases/network/rpc/basic_tests/rusers/rusers01
index 0b28c9e..a3f17c2 100755
--- a/testcases/network/rpc/basic_tests/rusers/rusers01
+++ b/testcases/network/rpc/basic_tests/rusers/rusers01
@@ -1,168 +1,50 @@
 #!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2000
 #
+# 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 2 of
+# the License, or (at your option) any later version.
 #
-#   Copyright (c) International Business Machines  Corp., 2000
+# This program is distributed in the hope that it would 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.
 #
-#   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 2 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, write to the Free Software
-#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-#
-#
-#  FILE             : rusers
-#
-#  TEST DESCRIPTION : Basic test for the `rusers` command.
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the machine
-#         where the test is executed.
-#
-#  HISTORY:
-#    04/18/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#
-# CMD      FLAG      ARGS
-# rusers
-# rusers             RHOST
-# rusers    -a
-# rusers    -a       RHOST
-# rusers    -l
-# rusers    -l       RHOST
-# rusers             bogus_host
-# rusers   -bogus_flag
-#***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
-$trace_logic
-this_file=${0##*/}
+TCID="rusers01"
+TST_TOTAL=5
 
-TC=rusers
-TCtmp=${TCtmp:=`pwd`}
-TCbin=${TCbin:=`pwd`}
-TCsrc=${TCsrc:=$TCbin}
-LUSER=${LUSER:=root}
-RHOST=${RHOST:=`hostname`}
-CLEANUP=${CLEANUP:="ON"}
-PID=0
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
+. test_net.sh
 
-#=============================================================================
-# FUNCTION NAME:        do_test
-#
-# FUNCTION DESCRIPTION: Perform the test
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
-do_test()
+do_setup()
 {
-$trace_logic
-
-echo "Checking for rusersd on $RHOST"
-
-rpcinfo -u $RHOST rusersd > /dev/null 2>&1
-if [ $? -ne 0 ]; then
-  echo "Attempting to start rusersd on $RHOST"
-  rsh -n -l root $RHOST "/usr/sbin/rpc.rusersd &"
-  [ $? -eq 0 ] || end_testcase "rusersd is inactive on $RHOST"
-  PID=`rsh -n $RHOST ps -ewf | grep rusersd | awk '{print $2 }'`
-  echo "ruserd started on $RHOST"
-fi
-
-#RHOST=`echo $RHOST | cut -d. -f1`   //The use is depriciated as it fails when RHOST is set to an IP address
-#                                    //Pointed out by "Ambar Seksena" <ambar.seksena@calsoftinc.com>
-
-echo "Test rusers with defaults...please be patient"
-# rusers with no options broadcasts over the net and reports
-# responses as it receives them. Time-out for responses is approx. 2 minutes.
-
-rusers > /dev/null
-[ $? -eq 0 ] || end_testcase "rusers with defaults - failed"
-
-echo "Test rusers with options set...please be patient"
-# Go through matrix of rusers options:
-
-rusers $RHOST > /dev/null
-[ $? -eq 0 ] || end_testcase "rusers $RHOST - failed"
-
-rusers -a $RHOST > /dev/null
-[ $? -eq 0 ] || end_testcase "rusers -a $RHOST - failed"
-
-rusers -l > /dev/null
-[ $? -eq 0 ] || end_testcase "rusers -l - failed"
-
-rusers -l $RHOST > /dev/null
-[ $? -eq 0 ] || end_testcase "rusers -l $RHOST - failed"
-
-echo "Test rusers with bad options"
-
-rusers bogushost > /dev/null 2>&1
-[ $? -eq 1 ] || end_testcase "rusers <invalid hostname> should fail"
-
-rusers -bogusflag > /dev/null 2>&1
-[ $? -eq 1 ] || end_testcase "rusers -<invalid flag> should fail"
+	tst_resm TINFO "Checking for rusersd on $(tst_ipaddr)"
+	tst_rhost_run -c "rpcinfo -u $(tst_ipaddr) rusersd" \
+		> /dev/null 2>&1 || \
+		tst_brkm TCONF "rusersd is inactive on $(tst_ipaddr)"
 }
 
-#=============================================================================
-# FUNCTION NAME:        do_cleanup
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
-do_cleanup()
+do_test()
 {
-    $trace_logic
+	tst_resm TINFO "Test rusers with options set"
 
-    if [ "$PID" != 0 ]; then
-        # Kill rusersd on remote machine
-        rsh -n $RHOST kill -9 $PID
-        echo "rusersd daemon stopped on $RHOST"
-    fi
-}
+	EXPECT_RHOST_PASS rusers $(tst_ipaddr)
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
+	local opts="-a -l"
+	for opt in $opts; do
+		EXPECT_RHOST_PASS rusers $opt $(tst_ipaddr)
+	done
 
-end_testcase()
-{
-   $trace_logic
-   echo "$this_file: doing $0."
-   if [ "$CLEANUP" = "ON" ]; then
-     do_cleanup
-   fi
-
-   [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+	tst_resm TINFO "Test rusers with bad options"
+	EXPECT_RHOST_FAIL rusers bogushost
+	EXPECT_RHOST_FAIL rusers -bogusflag $(tst_ipaddr)
 }
 
-#=============================================================================
-# MAIN PROCEDURE
-#=============================================================================
-
+do_setup
 do_test
-end_testcase
+
+tst_exit
-- 
1.7.1

[LTP] [COMMITTED][PATCH 4/6] net/rpcinfo01: convert to test_net.sh lib

From: Alexey Kodanev <hidden>
Date: 2017-06-06 11:21:59

* remove broadcast test-cases, and also with option '-d'
  which deletes registration

* TCONF if service not available or not started

Signed-off-by: Alexey Kodanev <redacted>
---
 .../network/rpc/basic_tests/rpcinfo/rpcinfo01      |  319 ++++----------------
 1 files changed, 60 insertions(+), 259 deletions(-)
diff --git a/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01 b/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01
index 512465b..afcf1b8 100755
--- a/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01
+++ b/testcases/network/rpc/basic_tests/rpcinfo/rpcinfo01
@@ -1,279 +1,80 @@
 #!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2000
 #
+# 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 2 of
+# the License, or (at your option) any later version.
 #
-#   Copyright (c) International Business Machines  Corp., 2000
+# This program is distributed in the hope that it would 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.
 #
-#   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 2 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, write to the Free Software
-#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-#
-#
-#  FILE             : rpcinfo
-#
-#  TEST DESCRIPTION : Basic test for the `rpcinfo` command.
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the machine
-#         where the test is executed.
-#
-#  HISTORY:
-#    04/20/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Written
-#    11/20/08 Aime Le Rouzic (aime.lerouzic@bull.net)
-#      - Adapt to rpcbind
-#
-# CMD      FLAG      ARGS
-# rpcinfo   -p
-# rpcinfo   -p       rem_host
-# rpcinfo   -b
-# rpcinfo   -d       prog_num   ver_num
-# rpcinfo   -t       rem_host   prog_num
-# rpcinfo   -t       rem_host   prog_num     ver_num
-# rpcinfo   -t       rem_host   prog_name
-# rpcinfo   -t       rem_host   prog_name    ver_num
-# rpcinfo   -u       rem_host   prog_num
-# rpcinfo   -u       rem_host   prog_num     ver_num
-# rpcinfo   -u       rem_host   prog_name
-# rpcinfo   -u       rem_host   prog_name    ver_num
-# rpcinfo
-# rpcinfo   -bogus_flag
-# rpcinfo   -u         rem_host
-# rpcinfo   -u         rem_host   bogus_prog   ver_num
-# rpcinfo   -u         rem_host   prog_num     bogus_num
-#***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
-$trace_logic
-this_file=${0##*/}
-TC=rpcinfo01
-TCtmp=${TCtmp:=`pwd`}
-TCbin=${TCbin:=`pwd`}
-TCsrc=${TCsrc:=$TCbin}
-LUSER=${LUSER:=root}
-RHOST=${RHOST:=`hostname`}
-CLEANUP=${CLEANUP:="ON"}
-PID=0
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
+TCID="rpcinfo01"
+TST_TOTAL=16
+TST_CLEANUP=tst_rmdir
 
-#=============================================================================
-# FUNCTION NAME:        do_test
-#
-# FUNCTION DESCRIPTION: Perform the test
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
-do_test()
+. test_net.sh
+
+do_setup()
 {
-$trace_logic
+	tst_resm TINFO "Checking for portmap or rpcbind"
 
-echo "Checking for portmap or rpcbind daemon on `hostname` and $RHOST"
-ps -ewf | grep portmap | grep -v grep > /dev/null
-if [ $? -eq 0 ]
-then
-	PORTMAPPER="portmap"
-else
-	ps -ewf | grep rpcbind | grep -v grep > /dev/null
-	if [ $? -eq 0 ]
-	then
-		PORTMAPPER="rpcbind"
+	if pgrep portmap > /dev/null; then
+		PORTMAPPER="portmap"
 	else
-		echo "The portmap or rpcbind daemon is NOT running"
+		pgrep rpcbind > /dev/null && PORTMAPPER="rpcbind" || \
+			tst_brkm TCONF "portmap or rpcbind is not running"
 	fi
-fi
-
-rsh -n $RHOST "ps -ewf" | grep portmap | grep -v grep > /dev/null
-[ $? -eq 0 ] || rsh -n $RHOST "ps -ewf" | grep rpcbind | grep -v grep > /dev/null
-[ $? -eq 0 ] || end_testcase "The portmap or rpcbind daemon is NOT running on $RHOST"
-
-echo "Test rpcinfo with default options"
-echo "rpcinfo -p"
-rpcinfo -p $RHOST | grep portmapper
-[ $? -eq 0 ] || end_testcase "rpcinfo -p failed"
-
-echo "Test rpcinfo with options"
-
-
-# Create file with 1 tcp and 1 udp line. Use for variable assignments.
-rpcinfo -p $RHOST | grep tcp | sed -n 2p > $TCtmp/rpc_out
-rpcinfo -p $RHOST | grep udp | sed -n 2p >> $TCtmp/rpc_out
-
-wc -l $TCtmp/rpc_out | grep "2" > /dev/null
-[ $? -eq 0 ] || end_testcase "Not enough programs registered on $RHOST for test"
-
-# Using "rpc_out" file created above, assign variables for rpcinfo options.
-TPNUM=`grep tcp $TCtmp/rpc_out | awk '{print $1}'`
-TVNUM=`grep tcp $TCtmp/rpc_out | awk '{print $2}'`
-TCPNAME=`grep tcp $TCtmp/rpc_out | awk '{print $5}'`
-UPNUM=`grep udp $TCtmp/rpc_out | awk '{print $1}'`
-UVNUM=`grep udp $TCtmp/rpc_out | awk '{print $2}'`
-UDPNAME=`grep udp $TCtmp/rpc_out | awk '{print $5}'`
-
-# Go through the matrix of remaining rpcinfo options
-# -d option
-ps -ewf | grep rusersd | grep -v grep
-if [ $? = 1 ]; then
-  /usr/sbin/rpc.rusersd
-  if [ $? = 0 ]; then
-    rpcinfo -p | grep 100002
-    echo "rpcinfo -d <prog num> <ver num>"
-    rpcinfo -d 100002 3
-    rpcinfo -p | grep 100002
-    rpcinfo -p | grep 100002 | wc -l | grep "1" > /dev/null
-    [ $? = 0 ] || end_testcase "rpcinfo -d <prog num> <ver num> - failed"
-    RUSERSD_PID=`ps -ewf | grep rusersd | grep -v grep | awk '{print $2}'`
-    kill -9 $RUSERSD_PID > /dev/null 2>&1
-  else
-    echo "Could not start rusersd daemon...skipping -d option test"
-  fi
-else
-  echo "rusersd is currently running, so may be used...skipping -d option test"
-fi
-
-# -t options
-echo "rpcinfo -t <hostname> <tcp prog num>"
-rpcinfo -t $RHOST $TPNUM
-[ $? -eq 0 ] || end_testcase "rpcinfo -t <hostname> <tcp prog num> - failed"
-
-echo "rpcinfo -t <hostname> <tcp prog num> <ver num>"
-rpcinfo -t $RHOST $TPNUM $TVNUM
-[ $? -eq 0 ] || end_testcase "rpcinfo -t <hostname> <tcp prog num> <ver num> - failed"
-
-echo "rpcinfo -t <hostname> <tcp prog name>"
-rpcinfo -t $RHOST $TCPNAME
-[ $? -eq 0 ] || end_testcase "rpcinfo -t <hostname> <tcp prog name> -  failed"
-
-echo "rpcinfo -t <hostname> <tcp prog name> <ver num>"
-rpcinfo -t $RHOST $TCPNAME $TVNUM
-[ $? -eq 0 ] || end_testcase "rpcinfo -t <hostname> <tcp prog name> <ver num> - failed"
 
-# -u options
-echo "rpcinfo -u <hostname> <udp prog num>"
-rpcinfo -u $RHOST 100000
-[ $? -eq 0 ] || end_testcase "rpcinfo -u <hostname> <udp prog num> - failed"
+	tst_tmpdir
 
-echo "rpcinfo -u <hostname> <udp prog num> <ver num>"
-rpcinfo -u $RHOST 100000 2
-[ $? -eq 0 ] || end_testcase "rpcinfo -u <hostname> <udp prog num> <ver num> - failed"
+	# Create file with 1 tcp and 1 udp line. Use for variable assignments.
+	tst_rhost_run -c "rpcinfo -p $thost | grep tcp | sed -n 2p" > rpc_out
+	tst_rhost_run -c "rpcinfo -p $thost | grep udp | sed -n 2p" >> rpc_out
 
-echo "rpcinfo -u <hostname> <udp prog name>"
-rpcinfo -u $RHOST portmapper
-[ $? -eq 0 ] || end_testcase "rpcinfo -u <hostname> <udp prog name> - failed"
+	wc -l rpc_out | grep "2" > /dev/null || \
+		tst_brkm TBROK "Not enough programs registered on $thost"
 
-echo "rpcinfo -u <hostname> <udp prog name> <ver num>"
-rpcinfo -u $RHOST portmapper 2
-[ $? -eq 0 ] || end_testcase "rpcinfo -u <hostname> <udp prog name> <ver num> - failed"
-
-echo "Test rpcinfo with missing or bad options"
-
-# Check the following: noflag, bogushost, bogusflag, no prog for -u or -t,
-# bogusprog, 99999 as versnum.
-
-echo "rpcinfo <no flags>"
-case $PORTMAPPER in
-	portmap)
-		rpcinfo
-		[ $? -eq 1 ] || end_testcase "rpcinfo <no flags> should fail"
-		;;
-	rpcbind)
-		rpcinfo
-		[ $? -eq 0 ]|| end_testcase "rpcinfo <no flags> should not fail"
-		;;
-	*)
-		echo " portmap or rpcbind not running"
-		exit 1
-		;;
-esac
-
-echo "rpcinfo -p <bad hostname>"
-rpcinfo -p bogushost
-[ $? -eq 1 ] || end_testcase "rpcinfo <bad hostname> should fail"
-
-echo "rpcinfo <bad flag>"
-rpcinfo -bogusflag
-[ $? -eq 1 ] || end_testcase "rpcinfo <bad flag> should fail"
-
-echo "rpcinfo -t <hostname> <no prognum>"
-rpcinfo -t $RHOST
-[ $? -eq 1 ] || end_testcase "rpcinfo -t <hostname> <no prognum> should fail"
-
-echo "rpcinfo -u <hostname> <no prognum>"
-rpcinfo -u $RHOST
-[ $? -eq 1 ] || end_testcase "rpcinfo -u <hostname> <no prognum> should fail"
-
-echo "rpcinfo -u <hostname> <bad prog name>"
-rpcinfo -u $RHOST bogusprog
-[ $? -eq 1 ] || end_testcase "rpcinfo -u <hostname> <invalid program name> should fail"
-
-echo "rpcinfo -u <hostname> <bad prog num>"
-rpcinfo -u $RHOST 11579
-[ $? -eq 1 ] || end_testcase "rpcinfo -u <hostname> 11579 should fail"
-
-echo "rpcinfo -u <hostname> <prog num> <bad ver num>"
-rpcinfo -u $RHOST 100000 5
-[ $? -eq 1 ] || end_testcase "rpcinfo -u <hostname> <prog num> <bad ver num> should fail"
+	# Using "rpc_out" file created above, assign variables for rpcinfo opts
+	TPNUM=`grep tcp rpc_out | awk '{print $1}'`
+	TVNUM=`grep tcp rpc_out | awk '{print $2}'`
+	TCPNAME=`grep tcp rpc_out | awk '{print $5}'`
+	UPNUM=`grep udp rpc_out | awk '{print $1}'`
+	UVNUM=`grep udp rpc_out | awk '{print $2}'`
+	UDPNAME=`grep udp rpc_out | awk '{print $5}'`
 }
 
-#=============================================================================
-# FUNCTION NAME:        do_cleanup
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           None.
-#
-# RETURNS:              None.
-#=============================================================================
-do_cleanup()
-{
-    $trace_logic
-
-    if [ "$PID" != 0 ]; then
-      kill -9 $PID
-    fi
-    rm -f $TCtmp/rpc_out
-}
-
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
+do_test()
 {
-   $trace_logic
-   echo "$this_file: doing $0."
-   if [ "$CLEANUP" = "ON" ]; then
-     do_cleanup
-   fi
-
-   [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+	local thost="$(tst_ipaddr)"
+
+	EXPECT_RHOST_PASS rpcinfo -p $thost | grep -q portmapper
+	EXPECT_RHOST_PASS rpcinfo -t $thost $TPNUM
+	EXPECT_RHOST_PASS rpcinfo -t $thost $TPNUM $TVNUM
+	EXPECT_RHOST_PASS rpcinfo -t $thost $TCPNAME
+	EXPECT_RHOST_PASS rpcinfo -t $thost $TCPNAME $TVNUM
+	EXPECT_RHOST_PASS rpcinfo -u $thost 100000
+	EXPECT_RHOST_PASS rpcinfo -u $thost 100000 2
+	EXPECT_RHOST_PASS rpcinfo -u $thost portmapper
+	EXPECT_RHOST_PASS rpcinfo -u $thost portmapper 2
+
+	tst_resm TINFO "Test rpcinfo with missing or bad options"
+	EXPECT_RHOST_FAIL rpcinfo -p bogushost
+	EXPECT_RHOST_FAIL rpcinfo -bogusflag
+	EXPECT_RHOST_FAIL rpcinfo -t $thost
+	EXPECT_RHOST_FAIL rpcinfo -u $thost
+	EXPECT_RHOST_FAIL rpcinfo -u $thost bogusprog
+	EXPECT_RHOST_FAIL rpcinfo -u $thost 11579
+	EXPECT_RHOST_FAIL rpcinfo -u $thost 100000 5
 }
 
-#=============================================================================
-# MAIN PROCEDURE
-#=============================================================================
-
+do_setup
 do_test
-end_testcase
+
+tst_exit
-- 
1.7.1

[LTP] [COMMITTED][PATCH 5/6] net/rpc01: convert to test_net.sh lib

From: Alexey Kodanev <hidden>
Date: 2017-06-06 11:22:00

Also wait for server to be registered with rpcinfo -T udp...

Signed-off-by: Alexey Kodanev <redacted>
---
 testcases/network/rpc/basic_tests/rpc01/rpc01 |  158 +++++++------------------
 1 files changed, 44 insertions(+), 114 deletions(-)
diff --git a/testcases/network/rpc/basic_tests/rpc01/rpc01 b/testcases/network/rpc/basic_tests/rpc01/rpc01
index 8ed69b0..fd8915a 100755
--- a/testcases/network/rpc/basic_tests/rpc01/rpc01
+++ b/testcases/network/rpc/basic_tests/rpc01/rpc01
@@ -1,132 +1,62 @@
 #!/bin/sh
+# Copyright (c) 2017 Oracle and/or its affiliates. All Rights Reserved.
+# Copyright (c) International Business Machines  Corp., 2000
 #
-#   Copyright (c) International Business Machines  Corp., 2000
+# 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 2 of
+# the License, or (at your option) any later version.
 #
-#   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 2 of the License, or
-#   (at your option) any later version.
+# This program is distributed in the hope that it would 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.
 #
-#   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, write to the Free Software
-#   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-#
-#
-#
-#  FILE             : rpc01
-#
-#  TEST DESCRIPTION : Test rpc using file transfers between a client & server
-#
-#  SETUP: The home directory of root on the machine exported as "RHOST"
-#         MUST have a ".rhosts" file with the hostname of the machine
-#         where the test is executed.
-#
-#  HISTORY:
-#    04/18/01 Robbie Williamson (robbiew@us.ibm.com)
-#      -Ported
-#
-#***********************************************************************
-#Uncomment line below for debug output.
-#trace_logic=${trace_logic:-"set -x"}
-$trace_logic
-this_file=${0##*/}
-TC=${TC:=rpc01}
-TCbin=${TCbin:=$LTPROOT/testcases/bin}
-TCdat=${TCdat:=$LTPROOT/testcases/data/rpc01}
-NUMLOOPS=${NUMLOOPS:=3}
-RHOST=${RHOST:=`hostname`}
-CLEANUP=${CLEANUP:="ON"}
-DATAFILES=${DATAFILES:="file.1 file.2"}
-export TCID=$TC
-export TST_TOTAL=1
-export TST_COUNT=1
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
 
-#=============================================================================
-# FUNCTION NAME:        do_test
-#
-# FUNCTION DESCRIPTION: Perform the test
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
-do_test()
-{
-    $trace_logic
+TCID="rpc01"
+TST_TOTAL=6
+TST_CLEANUP=do_cleanup
 
-    # Start server process
-    rsh -n $RHOST $TCbin/rpc_server
-    PID1=`rsh -n $RHOST ps -ewf | grep rpc_server | grep -v grep | awk '{print $2 }'`
-    echo "The rpc_server PID is $PID1"
-    # Start client process
-    echo "Starting $TC"
-    COUNT=1
-    while [ $COUNT -le $NUMLOOPS ]
-    do
-      for FILE in $DATAFILES
-      do
-	rpc1 -s $RHOST -f $TCdat/$FILE
-	[ $? -eq 0 ] || end_testcase "Fail on using $FILE"
-      done
-      COUNT=`expr $COUNT + 1`
-    done
-}
+. test_net.sh
 
+NUMLOOPS=${NUMLOOPS:=3}
+DATAFILES=${DATAFILES:="file.1 file.2"}
 
-#=============================================================================
-# FUNCTION NAME:        do_cleanup
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:   	None.
-#
-# RETURNS:      	None.
-#=============================================================================
 do_cleanup()
 {
-    $trace_logic
-
-    if [ "$CLEANUP" = "ON" ]; then
-	if [ -f $TMPDIR/core ]; then
-	   echo "Core file is saved in /tmp"
-	   mv $TMPDIR/core /tmp
-	fi
-
-	# Kill server
-        rsh -n $RHOST kill -9 $PID1
-    fi
+	pkill -9 rpc_server > /dev/null 2>&1
 }
 
-#=============================================================================
-# FUNCTION NAME:        end_testcase
-#
-# FUNCTION DESCRIPTION: Clean up
-#
-# PARAMETERS:           string, IF AND ONLY IF the testcase fails
-#
-# RETURNS:              None.
-#=============================================================================
-
-end_testcase()
+do_setup()
 {
-   $trace_logic
-   echo "$this_file: doing $0."
-
-   [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
-   tst_resm TFAIL "Test Failed: $@"
-   exit 1
+	tst_resm TINFO "start rpc_server"
+	rpc_server
+
+	tst_resm TINFO "wait for server to be registered"
+	for i in $(seq 1 30); do
+		rpcinfo -T udp $(tst_ipaddr) 2000333 10 >/dev/null 2>&1 && break
+		[ "$i" -eq 30 ] && tst_brkm TBROK "server not registered"
+		tst_sleep 100ms
+	done
 }
 
-#=============================================================================
-# MAIN PROCEDURE
-#=============================================================================
+do_test()
+{
+	local thost="$(tst_ipaddr)"
+
+	tst_resm TINFO "starting client process"
+	local cnt=1
+	while [ $cnt -le $NUMLOOPS ]; do
+		for f in $DATAFILES; do
+			EXPECT_RHOST_PASS rpc1 -s $thost -f $LTP_DATAROOT/$f
+		done
+		cnt=$(($cnt + 1))
+	done
+}
 
+do_setup
 do_test
-do_cleanup
-end_testcase
 
+tst_exit
-- 
1.7.1

[LTP] [COMMITTED][PATCH 6/6] net/rpc_test.sh: check if server is ready with rpcinfo

From: Alexey Kodanev <hidden>
Date: 2017-06-06 11:22:01

* remove 'sleep 1', usually server registered faster (<100ms)

* remove LTPROOT usage

Signed-off-by: Alexey Kodanev <redacted>
---
 testcases/network/rpc/rpc-tirpc/rpc_test.sh |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/testcases/network/rpc/rpc-tirpc/rpc_test.sh b/testcases/network/rpc/rpc-tirpc/rpc_test.sh
index e265725..54ea4fd 100755
--- a/testcases/network/rpc/rpc-tirpc/rpc_test.sh
+++ b/testcases/network/rpc/rpc-tirpc/rpc_test.sh
@@ -26,7 +26,6 @@ CLIENT_EXTRA_OPTS=""
 CLEANER=""
 # Program number to register the services to rpcbind
 PROGNUMNOSVC=536875000
-SERVER_STARTUP_SLEEP=1
 
 cleanup()
 {
@@ -57,7 +56,7 @@ EOF
 
 while getopts s:c:e:h arg; do
 	case $arg in
-		s) SERVER="$LTPROOT/testcases/bin/$OPTARG" ;;
+		s) SERVER="$OPTARG" ;;
 		c) CLIENT="$OPTARG" ;;
 		e) CLIENT_EXTRA_OPTS="$OPTARG" ;;
 		h) usage ;;
@@ -66,9 +65,9 @@ done
 
 if [ ! -z "$SERVER" ]; then
 	if `echo "$SERVER" | grep -e '^tirpc'`; then
-		CLEANER="$LTPROOT/testcases/bin/tirpc_cleaner"
+		CLEANER="tirpc_cleaner"
 	else
-		CLEANER="$LTPROOT/testcases/bin/rpc_cleaner"
+		CLEANER="rpc_cleaner"
 	fi
 fi
 
@@ -87,11 +86,14 @@ TST_CLEANUP=cleanup
 
 if [ ! -z "$SERVER" ]; then
 	$SERVER $PROGNUMNOSVC &
-	sleep "$SERVER_STARTUP_SLEEP"
-fi
 
-tst_rhost_run -sc "$CLIENT $(tst_ipaddr) $PROGNUMNOSVC $CLIENT_EXTRA_OPTS"
+	for i in $(seq 1 10); do
+		rpcinfo -p localhost | grep -q $PROGNUMNOSVC && break
+		[ "$i" -eq 30 ] && tst_brkm TBROK "server not registered"
+		tst_sleep 100ms
+	done
+fi
 
-tst_resm TPASS "Test passed"
+EXPECT_RHOST_PASS $CLIENT $(tst_ipaddr) $PROGNUMNOSVC $CLIENT_EXTRA_OPTS
 
 tst_exit
-- 
1.7.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help