3 # Copyright (c) International Business Machines Corp., 2000
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13 # the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this pronram; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 # PURPOSE: Copy files from server to client using the sendfile()
27 # SETUP: The home directory of root on the machine exported as "RHOST"
28 # MUST have a ".rhosts" file with the hostname of the client
29 # machine, where the test is executed.
32 # 06/09/2003 Manoj Iyer manjo@mail.utexas.edu
33 # - Modified to use LTP APIs, and added check to if commands used in test
35 # 03/01 Robbie Williamson (robbiew@us.ibm.com)
39 #***********************************************************************
43 #-----------------------------------------------------------------------
47 # DESCRIPTION: Check if required commands exits.
49 #-----------------------------------------------------------------------
54 RHOST
=${RHOST:-`hostname`}
55 TCdat
=${TCdat:-$LTPROOT/testcases/bin/datafiles}
56 TMPDIR
=${TMPDIR:-/tmp}
57 TCtmp
=${TCtmp:-$TMPDIR/$TC${EXEC_SUFFIX}$$}
58 CLIENT
="testsf_c${EXEC_SUFFIX}"
59 SERVER
="testsf_s${EXEC_SUFFIX}"
60 LTPROOT
=${LTPROOT:-../../../..}
61 FILES
=${FILES:-"ascii.sm ascii.med ascii.lg ascii.jmb"}
65 exists
awk diff gethost
grep rsh stat
67 IPADDR
=$
(gethost
$RHOST |
awk '/addresses:/ {print $2}')
72 #=============================================================================
73 # FUNCTION NAME: do_test
75 # FUNCTION DESCRIPTION: Perform the test
80 #=============================================================================
83 tst_resm TINFO
"Doing $0."
87 if ! rsh -l root
$IPADDR "$LTPROOT/testcases/bin/SF_Server $IPADDR $PORT $LTPROOT/testcases/bin"; then
88 end_testcase
"rsh failed to $IPADDR as root failed"
91 PID
=$
(rsh -l root
$IPADDR "ps -ef" |
awk "\$0 !~ /awk/ && /$SERVER/ && /$PORT/ {print \$1}")
92 [ -n "$PID" ] || end_testcase
"Could not start server"
94 for clnt_fname
in $FILES; do
95 serv_fname
=$TCdat/$clnt_fname
96 SIZE
=`stat -c '%s' $serv_fname`
97 tst_resm TINFO
"Starting $SERVER $IPADDR Client_filename Server_filename Size "
99 $CLIENT $IPADDR $PORT "$TCtmp/$clnt_fname" $serv_fname $SIZE
102 [ $RetVal -eq 0 ] || end_testcase
"$CLIENT returned error $RetVal"
104 diff $serv_fname $TCtmp/$clnt_fname
106 [ $DiffVal -gt 1 ] && end_testcase
"ERROR: Cannot compare files"
107 [ $DiffVal -eq 1 ] && end_testcase
"The file copied differs from the original"
112 #=============================================================================
113 # FUNCTION NAME: do_cleanup
115 # FUNCTION DESCRIPTION: Clean up
120 #=============================================================================
124 PID
=$
(rsh -n -l root
$RHOST "ps -ef" |
awk "\$0 !~ /awk/ && /$SERVER/ && /$PORT/ {print \$1}")
125 [ -n "$PID" ] && rsh -n -l root
$RHOST kill -9 $PID
129 #=============================================================================
131 #=============================================================================