net: Add $TST_NET_DATAROOT variable
PATCH 1/2 net: Add $TST_NET_DATAROOT variable
Because $LTPROOT/testcases/bin/datafiles is used only by network tests, once all network tests are rewritten into new API, it should the location should be changed into some network specific path.
--- testcases/lib/tst_net.sh | 2 ++ testcases/lib/tst_test.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
testcases/lib/tst_net.sh +2 -0
@@ -888,6 +888,8 @@ if [ -z "$_tst_net_parse_variables" ]; then export _tst_net_parse_variables="yes" fi +export TST_NET_DATAROOT="$LTPROOT/testcases/bin/datafiles" + export TST_NETLOAD_CLN_REQUESTS="${TST_NETLOAD_CLN_REQUESTS:-10000}" export TST_NETLOAD_CLN_NUMBER="${TST_NETLOAD_CLN_NUMBER:-2}" export TST_NETLOAD_BINDTODEVICE="${TST_NETLOAD_BINDTODEVICE-1}"
testcases/lib/tst_test.sh +1 -1
@@ -506,7 +506,7 @@ tst_run() NEEDS_DRIVERS|FS_TYPE|MNTPOINT|MNT_PARAMS);; IPV6|IPVER|TEST_DATA|TEST_DATA_IFS);; RETRY_FUNC|RETRY_FN_EXP_BACKOFF|TIMEOUT);; - NET_MAX_PKT);; + NET_DATAROOT|NET_MAX_PKT);; *) tst_res TWARN "Reserved variable TST_$_tst_i used!";; esac done
Signature · 1 line
2.26.0
PATCH 2/2 net/sendfile01.sh: Rewrite into new API
* reduce sleep to 1s (from 10s)
* continue testing on size failure
--- .../network/tcp_cmds/sendfile/sendfile01.sh | 125 ++++++------------ 1 file changed, 38 insertions(+), 87 deletions(-)
testcases/network/tcp_cmds/sendfile/sendfile01.sh +38 -87
@@ -1,111 +1,62 @@ #!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2020 Petr Vorel <[email protected]> # Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) Linux Test Project, 2001-2013 +# Copyright (c) Manoj Iyer <[email protected]> 2003 +# Copyright (c) Robbie Williamson <[email protected]> 2002-2003 # Copyright (c) International Business Machines Corp., 2000 -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it would be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# PURPOSE: Copy files from server to client using the sendfile() -# function. -# -# -# SETUP: The home directory of root on the machine exported as "RHOST" -# MUST have a ".rhosts" file with the hostname of the client -# machine, where the test is executed. -# -# HISTORY: -# 06/09/2003 Manoj Iyer [email protected] -# - Modified to use LTP APIs, and added check to if commands used in test -# exists. -# 03/01 Robbie Williamson ([email protected]) -# -Ported -# -# -#*********************************************************************** -TST_TOTAL=1 -TCID="sendfile01" +TST_SETUP=do_setup TST_CLEANUP=do_cleanup +TST_TESTFUNC=do_test +TST_NEEDS_TMPDIR=1 +TST_NEEDS_CMDS="diff stat" +. tst_net.sh do_setup() { - TCdat=${TCdat:-$LTPROOT/testcases/bin/datafiles} - CLIENT="testsf_c${TST_IPV6}" - SERVER="testsf_s${TST_IPV6}" + tst_res TINFO "copy files from server to client using the sendfile() on IPv$TST_IPVER" - FILES=${FILES:-"ascii.sm ascii.med ascii.lg ascii.jmb"} + client="testsf_c${TST_IPV6}" + server="testsf_s${TST_IPV6}" - tst_require_cmds diff stat + port=$(tst_rhost_run -s -c "tst_get_unused_port ipv$TST_IPVER stream") + [ -z "$port" ] && tst_brk TBROK "failed to get unused port" - tst_tmpdir + tst_rhost_run -s -b -c "$server $(tst_ipaddr rhost) $port" + server_started=1 + tst_res TINFO "wait for the server to start" + sleep 1 } do_test() { - tst_resm TINFO "Doing $0." - - local ipv="ipv${TST_IPV6:-"4"}" - local ipaddr=$(tst_ipaddr rhost) - local port=$(tst_rhost_run -s -c "tst_get_unused_port $ipv stream") - [ -z "$port" ] && tst_brkm TBROK "failed to get unused port" - - tst_rhost_run -s -b -c "$SERVER $ipaddr $port" - server_started=1 - sleep 10 - - for clnt_fname in $FILES; do - serv_fname=${TCdat}/$clnt_fname - local size=$(stat -c '%s' $serv_fname) - - tst_resm TINFO \ - "$CLIENT ip '$ipaddr' port '$port' file '$clnt_fname'" - - $CLIENT $ipaddr $port $clnt_fname $serv_fname $size >\ - /dev/null 2>&1 - - local ret=$? - if [ $ret -ne 0 ]; then - tst_resm TFAIL "$CLIENT returned error '$ret'" - return; - fi - - diff $serv_fname $clnt_fname > /dev/null 2>&1 - local diff_res=$? - if [ $diff_res -gt 1 ]; then - tst_resm TFAIL "ERROR: Cannot compare files" - return - fi - - if [ $diff_res -eq 1 ]; then - tst_resm TFAIL "The file copied differs from the original" - return + local file lfile ret size + + for file in $(ls $TST_NET_DATAROOT/ascii.*); do + lfile="$(basename $file)" + size=$(stat -c '%s' $file) + + tst_res TINFO "test IP: $(tst_ipaddr rhost), port: $port, file: $lfile" + ROD $client $(tst_ipaddr rhost) $port $lfile $file $size \> /dev/null + + diff $file $lfile > /dev/null + ret=$? + if [ $ret -eq 0 ]; then + tst_res TPASS "coped file is the same as the original" + elif [ $ret -gt 1 ]; then + tst_brk TFAIL "cannot compare files" + else + tst_res TFAIL "the copied file differs from the original" fi done - tst_resm TPASS "test finished successfully" } do_cleanup() { - [ -n "$server_started" ] && tst_rhost_run -c "pkill $SERVER" - tst_rmdir + [ -n "$server_started" ] && tst_rhost_run -c "pkill $server" } -TST_USE_LEGACY_API=1 -. tst_net.sh - -do_setup -do_test - -tst_exit +tst_run
Signature · 1 line
2.26.0
PATCH 2/2 net/sendfile01.sh: Rewrite into new API
Hi,
Minor grammar:
testcases/network/tcp_cmds/sendfile/sendfile01.sh line 48
Quoted 2 lines
testcases/network/tcp_cmds/sendfile/sendfile01.sh +2
-0+ if [ $ret -eq 0 ]; then + tst_res TPASS "coped file is the same as the original"
Typo copied file.
testcases/network/tcp_cmds/sendfile/sendfile01.sh line 52
Quoted 4 lines
testcases/network/tcp_cmds/sendfile/sendfile01.sh +4
-0+ elif [ $ret -gt 1 ]; then + tst_brk TFAIL "cannot compare files" + else + tst_res TFAIL "the copied file differs from the original"
I guess it should be without "the"
Kind regards,
Petr
PATCH 2/2 net/sendfile01.sh: Rewrite into new API
In reply to Petr VorelQuoted 3 lines · Petr Vorel
* reduce sleep to 1s (from 10s)
* continue testing on size failure
Hi Petr,
Quoted 71 lines
Signed-off-by Petr Vorel <[email protected]>--- .../network/tcp_cmds/sendfile/sendfile01.sh | 125 ++++++------------ 1 file changed, 38 insertions(+), 87 deletions(-)testcases/network/tcp_cmds/sendfile/sendfile01.sh +13
-38@@ -1,111 +1,62 @@ #!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2020 Petr Vorel <[email protected]> # Copyright (c) 2014 Oracle and/or its affiliates. All Rights Reserved. +# Copyright (c) Linux Test Project, 2001-2013 +# Copyright (c) Manoj Iyer <[email protected]> 2003 +# Copyright (c) Robbie Williamson <[email protected]> 2002-2003 # Copyright (c) International Business Machines Corp., 2000 -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# -# This program is distributed in the hope that it would be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -# PURPOSE: Copy files from server to client using the sendfile() -# function. -# -# -# SETUP: The home directory of root on the machine exported as "RHOST" -# MUST have a ".rhosts" file with the hostname of the client -# machine, where the test is executed. -# -# HISTORY: -# 06/09/2003 Manoj Iyer [email protected] -# - Modified to use LTP APIs, and added check to if commands used in test -# exists. -# 03/01 Robbie Williamson ([email protected]) -# -Ported -# -# -#*********************************************************************** -TST_TOTAL=1 -TCID="sendfile01" +TST_SETUP=do_setup TST_CLEANUP=do_cleanup +TST_TESTFUNC=do_test +TST_NEEDS_TMPDIR=1 +TST_NEEDS_CMDS="diff stat" +. tst_net.sh do_setup() { - TCdat=${TCdat:-$LTPROOT/testcases/bin/datafiles} - CLIENT="testsf_c${TST_IPV6}" - SERVER="testsf_s${TST_IPV6}" + tst_res TINFO "copy files from server to client using the sendfile() on IPv$TST_IPVER" - FILES=${FILES:-"ascii.sm ascii.med ascii.lg ascii.jmb"} + client="testsf_c${TST_IPV6}" + server="testsf_s${TST_IPV6}"
testcases/network/tcp_cmds/sendfile/sendfile01.sh line 31
Quoted 10 lines
testcases/network/tcp_cmds/sendfile/sendfile01.sh +6
-2- tst_require_cmds diff stat + port=$(tst_rhost_run -s -c "tst_get_unused_port ipv$TST_IPVER stream") + [ -z "$port" ] && tst_brk TBROK "failed to get unused port" - tst_tmpdir + tst_rhost_run -s -b -c "$server $(tst_ipaddr rhost) $port" + server_started=1 + tst_res TINFO "wait for the server to start" + sleep 1
It would be better to replace 'sleep' with a wait-loop and check that the port in the listen state there, e.g with ss -ltp | grep "$port.*testsf"
Quoted 48 lines
testcases/network/tcp_cmds/sendfile/sendfile01.sh +7
-37} do_test() { - tst_resm TINFO "Doing $0." - - local ipv="ipv${TST_IPV6:-"4"}" - local ipaddr=$(tst_ipaddr rhost) - local port=$(tst_rhost_run -s -c "tst_get_unused_port $ipv stream") - [ -z "$port" ] && tst_brkm TBROK "failed to get unused port" - - tst_rhost_run -s -b -c "$SERVER $ipaddr $port" - server_started=1 - sleep 10 - - for clnt_fname in $FILES; do - serv_fname=${TCdat}/$clnt_fname - local size=$(stat -c '%s' $serv_fname) - - tst_resm TINFO \ - "$CLIENT ip '$ipaddr' port '$port' file '$clnt_fname'" - - $CLIENT $ipaddr $port $clnt_fname $serv_fname $size >\ - /dev/null 2>&1 - - local ret=$? - if [ $ret -ne 0 ]; then - tst_resm TFAIL "$CLIENT returned error '$ret'" - return; - fi - - diff $serv_fname $clnt_fname > /dev/null 2>&1 - local diff_res=$? - if [ $diff_res -gt 1 ]; then - tst_resm TFAIL "ERROR: Cannot compare files" - return - fi - - if [ $diff_res -eq 1 ]; then - tst_resm TFAIL "The file copied differs from the original" - return + local file lfile ret size + + for file in $(ls $TST_NET_DATAROOT/ascii.*); do + lfile="$(basename $file)" + size=$(stat -c '%s' $file) + + tst_res TINFO "test IP: $(tst_ipaddr rhost), port: $port, file: $lfile"
testcases/network/tcp_cmds/sendfile/sendfile01.sh line 52
Quoted 10 lines
testcases/network/tcp_cmds/sendfile/sendfile01.sh +10
-0+ ROD $client $(tst_ipaddr rhost) $port $lfile $file $size \> /dev/null + + diff $file $lfile > /dev/null + ret=$? + if [ $ret -eq 0 ]; then + tst_res TPASS "coped file is the same as the original" + elif [ $ret -gt 1 ]; then + tst_brk TFAIL "cannot compare files" + else + tst_res TFAIL "the copied file differs from the original"
EXPECT_PASS diff $lfile
Quoted 11 lines
testcases/network/tcp_cmds/sendfile/sendfile01.sh +1
-3fi done - tst_resm TPASS "test finished successfully" } do_cleanup() { - [ -n "$server_started" ] && tst_rhost_run -c "pkill $SERVER" - tst_rmdir + [ -n "$server_started" ] && tst_rhost_run -c "pkill $server"
testcases/network/tcp_cmds/sendfile/sendfile01.sh line 62
Quoted 10 lines
testcases/network/tcp_cmds/sendfile/sendfile01.sh +1
-7} -TST_USE_LEGACY_API=1 -. tst_net.sh - -do_setup -do_test - -tst_exit +tst_run
The rest looks good!
PATCH 2/2 net/sendfile01.sh: Rewrite into new API
Hi Alexey,
...
Quoted 5 lines
testcases/network/tcp_cmds/sendfile/sendfile01.sh line 31
Quoted 2 lines
testcases/network/tcp_cmds/sendfile/sendfile01.sh +2
-0+ tst_res TINFO "wait for the server to start" + sleep 1It would be better to replace 'sleep' with a wait-loop and check that the port in the listen state there, e.g with ss -ltp | grep "$port.*testsf"
I'm sorry, I overlooked this. I'm sorry, merged without this. I'll implement it separately.
Thanks for your review.
...
Quoted 11 lines
testcases/network/tcp_cmds/sendfile/sendfile01.sh line 52
Quoted 8 lines
testcases/network/tcp_cmds/sendfile/sendfile01.sh +8
-0+ diff $file $lfile > /dev/null + ret=$? + if [ $ret -eq 0 ]; then + tst_res TPASS "coped file is the same as the original" + elif [ $ret -gt 1 ]; then + tst_brk TFAIL "cannot compare files" + else + tst_res TFAIL "the copied file differs from the original"
EXPECT_PASSdiff $lfile
Fixed.
Kind regards,
Petr