1 #!/bin/sh 2 # Copyright (c) 2016 Oracle and/or its affiliates. All Rights Reserved. 3 # Copyright (c) International Business Machines Corp., 2000 4 # 5 # This program is free software; you can redistribute it and/or 6 # modify it under the terms of the GNU General Public License as 7 # published by the Free Software Foundation; either version 2 of 8 # the License, or (at your option) any later version. 9 # 10 # This program is distributed in the hope that it would be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 # 18 # PURPOSE: To test the basic functionality of the rwhod daemon using the 19 # `rwho` and `ruptime` commands. 20 # 21 22 TCID=rwho01 23 TST_TOTAL=25 24 TST_CLEANUP="do_cleanup" 25 26 . test_net.sh 27 28 LHOST_PID= 29 RHOST_PID= 30 31 do_setup() 32 { 33 tst_check_cmds cut hostname killall rwho ruptime 34 35 LHOST=$(hostname | cut -f1 -d.) 36 37 pgrep -x rwhod > /dev/null 38 if [ $? -ne 0 ]; then 39 tst_resm TINFO "Starting rwhod on $LHOST" 40 ROD rwhod 41 LHOST_PID=$(pgrep -x rwhod) 42 [ -z "$LHOST_PID" ] && \ 43 tst_brkm TBROK "Unable to start rwhod on $LHOST" 44 fi 45 46 tst_rhost_run -c "pgrep -x rwhod" > /dev/null 47 if [ $? -ne 0 ]; then 48 tst_resm TINFO "Starting rwhod on $RHOST" 49 tst_rhost_run -s -c "rwhod" 50 RHOST_PID=$(tst_rhost_run -c "pgrep -x rwhod") 51 [ -z "$RHOST_PID" ] && \ 52 tst_brkm TBROK "Unable to start rwhod on $RHOST" 53 fi 54 55 RHOSTNAME=$(tst_rhost_run -c "hostname | cut -f1 -d.") 56 [ "$RHOSTNAME" ] || tst_brkm TBROK "Unable to determine RHOSTNAME" 57 } 58 59 do_test() 60 { 61 rwho -a | grep -q $LHOST || \ 62 tst_brkm TFAIL "$LHOST isn't in rwho output" 63 rwho -a | grep -q $RHOSTNAME || \ 64 tst_brkm TFAIL "$RHOSTNAME isn't in rwho output" 65 ruptime -a | grep -q $LHOST || \ 66 tst_brkm TFAIL "$LHOST is not in ruptime outfile" 67 ruptime -a | grep -q $RHOSTNAME || \ 68 tst_brkm TFAIL "$RHOSTNAME is not in ruptime outfile" 69 } 70 71 do_cleanup() 72 { 73 if [ "$LHOST_PID" ]; then 74 tst_resm TINFO "Stopping rwhod on $LHOST" 75 killall rwhod 76 fi 77 78 if [ "$RHOST_PID" ]; then 79 tst_resm TINFO "Stopping rwhod on $RHOST" 80 tst_rhost_run -c "killall rwhod" 81 fi 82 } 83 84 do_setup 85 86 for i in $(seq 1 $TST_TOTAL); do 87 do_test 88 tst_resm TPASS "Test $i/$TST_COUNT complete" 89 done 90 91 tst_exit 92