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