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