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

Alexey Kodanev alexey.kodanev@oracle.com
Tue Jun 6 13:21:57 CEST 2017


* 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 <alexey.kodanev@oracle.com>
---
 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



More information about the ltp mailing list