• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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. tst_net.sh
16
17do_setup()
18{
19
20	tst_res TINFO "copy files from server to client using the sendfile() on IPv$TST_IPVER"
21
22	client="testsf_c${TST_IPV6}"
23	server="testsf_s${TST_IPV6}"
24
25	port=$(tst_rhost_run -s -c "tst_get_unused_port ipv$TST_IPVER stream")
26	[ -z "$port" ] && tst_brk TBROK "failed to get unused port"
27
28	tst_rhost_run -s -b -c "$server $(tst_ipaddr rhost) $port"
29	server_started=1
30	tst_res TINFO "wait for the server to start"
31	TST_RETRY_FUNC "tst_rhost_run -c 'ss -ltp' | grep -q '$port.*testsf'" 0
32}
33
34do_test()
35{
36	local file lfile size
37
38	for file in $(ls $TST_NET_DATAROOT/ascii.*); do
39		lfile="$(basename $file)"
40		size=$(stat -c '%s' $file)
41		tst_res TINFO "test IP: $(tst_ipaddr rhost), port: $port, file: $lfile"
42
43		ROD $client $(tst_ipaddr rhost) $port $lfile $file $size \> /dev/null
44		EXPECT_PASS diff $file $lfile
45	done
46}
47
48do_cleanup()
49{
50	[ -n "$server_started" ] && tst_rhost_run -c "pkill $server"
51}
52
53tst_run
54