1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0-or-later 3# Copyright (c) 2020 Petr Vorel <pvorel@suse.cz> 4# Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved. 5# Copyright (c) Linux Test Project, 2001-2013 6# Copyright (c) Manoj Iyer <manjo@mail.utexas.edu> 2003 7# Copyright (c) Robbie Williamson <robbiew@us.ibm.com> 2002-2003 8# Copyright (c) International Business Machines Corp., 2000 9 10TST_SETUP=do_setup 11TST_CLEANUP=do_cleanup 12TST_TESTFUNC=do_test 13TST_NEEDS_TMPDIR=1 14TST_NEEDS_CMDS="diff ss stat" 15 16do_setup() 17{ 18 19 tst_res TINFO "copy files from server to client using the sendfile() on IPv$TST_IPVER" 20 21 client="testsf_c${TST_IPV6}" 22 server="testsf_s${TST_IPV6}" 23 24 port=$(tst_rhost_run -s -c "tst_get_unused_port ipv$TST_IPVER stream") 25 [ -z "$port" ] && tst_brk TBROK "failed to get unused port" 26 27 tst_rhost_run -s -b -c "$server $(tst_ipaddr rhost) $port" 28 server_started=1 29 tst_res TINFO "wait for the server to start" 30 TST_RETRY_FUNC "tst_rhost_run -c 'ss -ltp' | grep -q '$port.*testsf'" 0 31} 32 33do_test() 34{ 35 local file lfile size 36 37 for file in $(ls $TST_NET_DATAROOT/ascii.*); do 38 lfile="$(basename $file)" 39 size=$(stat -c '%s' $file) 40 tst_res TINFO "test IP: $(tst_ipaddr rhost), port: $port, file: $lfile" 41 42 ROD $client $(tst_ipaddr rhost) $port $lfile $file $size \> /dev/null 43 EXPECT_PASS diff $file $lfile 44 done 45} 46 47do_cleanup() 48{ 49 [ -n "$server_started" ] && tst_rhost_run -c "pkill $server" 50} 51 52. tst_net.sh 53tst_run 54