1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2022 Akihiko Odaki <[email protected]> 4# Copyright (c) 2003 Manoj Iyer <[email protected]> 5# Copyright (c) 2001 Robbie Williamson <[email protected]> 6 7TST_TESTFUNC=do_test 8TST_CNT=4 9TST_NEEDS_CMDS='awk ftp' 10TST_NEEDS_TMPDIR=1 11 12RUSER="${RUSER:-root}" 13RHOST="${RHOST:-localhost}" 14 15do_test() 16{ 17 case $1 in 18 1) test_get binary;; 19 2) test_get ascii;; 20 3) test_put binary;; 21 4) test_put ascii;; 22 esac 23} 24 25list_files() 26{ 27 case $1 in 28 ascii) echo 'ascii.sm ascii.med ascii.lg ascii.jmb';; 29 binary) echo 'bin.sm bin.med bin.lg bin.jmb';; 30 esac 31} 32 33test_get() 34{ 35 local file sum1 sum2 36 37 for file in $(list_files $1); do 38 { 39 echo user $RUSER $PASSWD 40 echo $1 41 echo cd $TST_NET_DATAROOT 42 echo get $file 43 echo quit 44 } | ftp -nv $RHOST 45 46 sum1="$(ls -l $file | awk '{print $5}')" 47 sum2="$(ls -l $TST_NET_DATAROOT/$file | awk '{print $5}')" 48 rm -f $file 49 EXPECT_PASS "[ '$sum1' = '$sum2' ]" 50 done 51} 52 53test_put() 54{ 55 local file sum1 sum2 56 57 for file in $(list_files $1); do 58 { 59 echo user $RUSER $PASSWD 60 echo lcd $TST_NET_DATAROOT 61 echo $1 62 echo cd $TST_TMPDIR 63 echo put $file 64 echo quit 65 } | ftp -nv $RHOST 66 67 sum1="$(tst_rhost_run -c "sum $TST_TMPDIR/$file" -s | awk '{print $1}')" 68 sum2="$(sum $TST_NET_DATAROOT/$file | awk '{print $1}')" 69 tst_rhost_run -c "rm -f $TST_TMPDIR/$file" 70 EXPECT_PASS "[ '$sum1' = '$sum2' ]" 71 done 72} 73 74. tst_net.sh 75tst_run 76