* [LTP] [RESENT PATCH 0/5] tst_net.sh: Remove rsh, update docs add debug & test
@ 2020-06-22 7:09 Petr Vorel
2020-06-22 7:09 ` [LTP] [RESENT PATCH 1/5] tst_net.sh: Remove rsh support Petr Vorel
` (4 more replies)
0 siblings, 5 replies; 14+ messages in thread
From: Petr Vorel @ 2020-06-22 7:09 UTC (permalink / raw)
To: ltp
From: Petr Vorel <pvorel@suse.cz>
Hi,
It looks this patchset from Friday didn't get to the mailing list, thus
sending it again.
started as removing rsh, then also update docs and backport testing
environment I use for some time (but not sure if needed).
Kind regards,
Petr
Petr Vorel (5):
tst_net.sh: Remove rsh support
net: Update README.md
tst_net.sh: Drop 'sh -c' use from ssh in tst_rhost_run
net/test: Add basic testing for tst_rhost_run
st_net.sh: tst_rhost_run: Add -d option (debug)
lib/newlib_tests/shell/net/tst_rhost_run.sh | 25 +++++++
testcases/lib/tst_net.sh | 37 +++++++----
testcases/network/README.md | 73 ++++++++++-----------
3 files changed, 85 insertions(+), 50 deletions(-)
create mode 100755 lib/newlib_tests/shell/net/tst_rhost_run.sh
--
2.27.0
^ permalink raw reply [flat|nested] 14+ messages in thread* [LTP] [RESENT PATCH 1/5] tst_net.sh: Remove rsh support 2020-06-22 7:09 [LTP] [RESENT PATCH 0/5] tst_net.sh: Remove rsh, update docs add debug & test Petr Vorel @ 2020-06-22 7:09 ` Petr Vorel 2020-06-25 16:42 ` Alexey Kodanev 2020-06-22 7:09 ` [LTP] [RESENT PATCH 2/5] net: Update README.md Petr Vorel ` (3 subsequent siblings) 4 siblings, 1 reply; 14+ messages in thread From: Petr Vorel @ 2020-06-22 7:09 UTC (permalink / raw) To: ltp From: Petr Vorel <pvorel@suse.cz> rsh is not used nowadays. When was the first network library version added in 18739ff06 (2014), it was a default + and ssh replacement was optional. Netns based single machine testing was added in 5f8ca6cf0 (2016). After 6 years it's time to drop legacy rsh. ssh based testing setup requires only RHOST variable, TST_USE_SSH has been removed as unneeded. Also check for ssh in tst_rhost_run(). We still keep $LTP_RSH for some of the network stress tests, which has not been ported to tst_net.sh yet. Suggested-by: Alexey Kodanev <alexey.kodanev@oracle.com> Signed-off-by: Petr Vorel <pvorel@suse.cz> --- testcases/lib/tst_net.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh index 806b540cd..1b96b3bf4 100644 --- a/testcases/lib/tst_net.sh +++ b/testcases/lib/tst_net.sh @@ -136,7 +136,7 @@ init_ltp_netspace() # -b run in background # -c CMD specify command to run (this must be binary, not shell builtin/function) # -s safe option, if something goes wrong, will exit with TBROK -# -u USER for ssh/rsh (default root) +# -u USER for ssh (default root) # RETURN: 0 on success, 1 on failure tst_rhost_run() { @@ -166,14 +166,12 @@ tst_rhost_run() return 1 fi - if [ -n "${TST_USE_SSH:-}" ]; then - output=`ssh -n -q $user@$RHOST "sh -c \ - '$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'` - elif [ -n "${TST_USE_NETNS:-}" ]; then + if [ -n "${TST_USE_NETNS:-}" ]; then output=`$LTP_NETNS sh -c \ "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR'` else - output=`rsh -n -l $user $RHOST "sh -c \ + tst_require_cmds ssh + output=`ssh -n -q $user@$RHOST "sh -c \ '$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'` fi echo "$output" | grep -q 'RTERR$' && ret=1 -- 2.27.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [RESENT PATCH 1/5] tst_net.sh: Remove rsh support 2020-06-22 7:09 ` [LTP] [RESENT PATCH 1/5] tst_net.sh: Remove rsh support Petr Vorel @ 2020-06-25 16:42 ` Alexey Kodanev 2020-06-26 6:27 ` Alexey Kodanev 0 siblings, 1 reply; 14+ messages in thread From: Alexey Kodanev @ 2020-06-25 16:42 UTC (permalink / raw) To: ltp On 22.06.2020 10:09, Petr Vorel wrote: > From: Petr Vorel <pvorel@suse.cz> > Hi Petr, > rsh is not used nowadays. When was the first network library version > added in 18739ff06 (2014), it was a default + and ssh replacement was > optional. Netns based single machine testing was added in 5f8ca6cf0 > (2016). After 6 years it's time to drop legacy rsh. > > ssh based testing setup requires only RHOST variable, TST_USE_SSH has > been removed as unneeded. Also check for ssh in tst_rhost_run(). > > We still keep $LTP_RSH for some of the network stress tests, which has > not been ported to tst_net.sh yet. But tst_net.sh not used in such tests, so why keeping LTP_RSH there? > > Suggested-by: Alexey Kodanev <alexey.kodanev@oracle.com> > Signed-off-by: Petr Vorel <pvorel@suse.cz> > --- > testcases/lib/tst_net.sh | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh > index 806b540cd..1b96b3bf4 100644 > --- a/testcases/lib/tst_net.sh > +++ b/testcases/lib/tst_net.sh > @@ -136,7 +136,7 @@ init_ltp_netspace() > # -b run in background > # -c CMD specify command to run (this must be binary, not shell builtin/function) > # -s safe option, if something goes wrong, will exit with TBROK > -# -u USER for ssh/rsh (default root) > +# -u USER for ssh (default root) > # RETURN: 0 on success, 1 on failure > tst_rhost_run() > { > @@ -166,14 +166,12 @@ tst_rhost_run() > return 1 > fi > > - if [ -n "${TST_USE_SSH:-}" ]; then > - output=`ssh -n -q $user@$RHOST "sh -c \ > - '$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'` > - elif [ -n "${TST_USE_NETNS:-}" ]; then > + if [ -n "${TST_USE_NETNS:-}" ]; then > output=`$LTP_NETNS sh -c \ > "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR'` > else > - output=`rsh -n -l $user $RHOST "sh -c \ > + tst_require_cmds ssh > + output=`ssh -n -q $user@$RHOST "sh -c \ > '$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'` > fi > echo "$output" | grep -q 'RTERR$' && ret=1 > ^ permalink raw reply [flat|nested] 14+ messages in thread
* [LTP] [RESENT PATCH 1/5] tst_net.sh: Remove rsh support 2020-06-25 16:42 ` Alexey Kodanev @ 2020-06-26 6:27 ` Alexey Kodanev 2020-06-28 3:36 ` Xiao Yang 0 siblings, 1 reply; 14+ messages in thread From: Alexey Kodanev @ 2020-06-26 6:27 UTC (permalink / raw) To: ltp On 25.06.2020 19:42, Alexey Kodanev wrote: > On 22.06.2020 10:09, Petr Vorel wrote: >> From: Petr Vorel <pvorel@suse.cz> >> > Hi Petr, > >> rsh is not used nowadays. When was the first network library version >> added in 18739ff06 (2014), it was a default + and ssh replacement was >> optional. Netns based single machine testing was added in 5f8ca6cf0 >> (2016). After 6 years it's time to drop legacy rsh. >> >> ssh based testing setup requires only RHOST variable, TST_USE_SSH has >> been removed as unneeded. Also check for ssh in tst_rhost_run(). >> >> We still keep $LTP_RSH for some of the network stress tests, which has >> not been ported to tst_net.sh yet. > > But tst_net.sh not used in such tests, so why keeping LTP_RSH there? Ok, tst_net.sh included in testscripts/network.sh, we could change it to ssh too: diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh index 41938b1ac..0e10945da 100644 --- a/testcases/lib/tst_net.sh +++ b/testcases/lib/tst_net.sh @@ -856,7 +856,7 @@ tst_default_max_pkt() export RHOST="$RHOST" export PASSWD="${PASSWD:-}" # Don't use it in new tests, use tst_rhost_run() from tst_net.sh instead. -export LTP_RSH="${LTP_RSH:-rsh -n}" +export LTP_RSH="${LTP_RSH:-ssh -nq -l root}" # Test Links # IPV{4,6}_{L,R}HOST can be set with or without prefix (e.g. IP or IP/prefix), > >> >> Suggested-by: Alexey Kodanev <alexey.kodanev@oracle.com> >> Signed-off-by: Petr Vorel <pvorel@suse.cz> >> --- >> testcases/lib/tst_net.sh | 10 ++++------ >> 1 file changed, 4 insertions(+), 6 deletions(-) >> >> diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh >> index 806b540cd..1b96b3bf4 100644 >> --- a/testcases/lib/tst_net.sh >> +++ b/testcases/lib/tst_net.sh >> @@ -136,7 +136,7 @@ init_ltp_netspace() >> # -b run in background >> # -c CMD specify command to run (this must be binary, not shell builtin/function) >> # -s safe option, if something goes wrong, will exit with TBROK >> -# -u USER for ssh/rsh (default root) >> +# -u USER for ssh (default root) >> # RETURN: 0 on success, 1 on failure >> tst_rhost_run() >> { >> @@ -166,14 +166,12 @@ tst_rhost_run() >> return 1 >> fi >> >> - if [ -n "${TST_USE_SSH:-}" ]; then >> - output=`ssh -n -q $user@$RHOST "sh -c \ >> - '$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'` >> - elif [ -n "${TST_USE_NETNS:-}" ]; then >> + if [ -n "${TST_USE_NETNS:-}" ]; then >> output=`$LTP_NETNS sh -c \ >> "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR'` >> else >> - output=`rsh -n -l $user $RHOST "sh -c \ >> + tst_require_cmds ssh >> + output=`ssh -n -q $user@$RHOST "sh -c \ >> '$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'` >> fi >> echo "$output" | grep -q 'RTERR$' && ret=1 >> > > ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [RESENT PATCH 1/5] tst_net.sh: Remove rsh support 2020-06-26 6:27 ` Alexey Kodanev @ 2020-06-28 3:36 ` Xiao Yang 0 siblings, 0 replies; 14+ messages in thread From: Xiao Yang @ 2020-06-28 3:36 UTC (permalink / raw) To: ltp On 2020/6/26 14:27, Alexey Kodanev wrote: > On 25.06.2020 19:42, Alexey Kodanev wrote: >> On 22.06.2020 10:09, Petr Vorel wrote: >>> From: Petr Vorel<pvorel@suse.cz> >>> >> Hi Petr, >> >>> rsh is not used nowadays. When was the first network library version >>> added in 18739ff06 (2014), it was a default + and ssh replacement was >>> optional. Netns based single machine testing was added in 5f8ca6cf0 >>> (2016). After 6 years it's time to drop legacy rsh. >>> >>> ssh based testing setup requires only RHOST variable, TST_USE_SSH has >>> been removed as unneeded. Also check for ssh in tst_rhost_run(). >>> >>> We still keep $LTP_RSH for some of the network stress tests, which has >>> not been ported to tst_net.sh yet. >> But tst_net.sh not used in such tests, so why keeping LTP_RSH there? > Ok, tst_net.sh included in testscripts/network.sh, we could change it > to ssh too: > > diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh > index 41938b1ac..0e10945da 100644 > --- a/testcases/lib/tst_net.sh > +++ b/testcases/lib/tst_net.sh > @@ -856,7 +856,7 @@ tst_default_max_pkt() > export RHOST="$RHOST" > export PASSWD="${PASSWD:-}" > # Don't use it in new tests, use tst_rhost_run() from tst_net.sh instead. > -export LTP_RSH="${LTP_RSH:-rsh -n}" > +export LTP_RSH="${LTP_RSH:-ssh -nq -l root}" Hi, I also prefer to init it to ssh directly. :-) BTW: Is it necessary to add fixed 'root' user? we can choose the user by current login user. Best Regards, Xiao Yang > > # Test Links > # IPV{4,6}_{L,R}HOST can be set with or without prefix (e.g. IP or IP/prefix), > >>> Suggested-by: Alexey Kodanev<alexey.kodanev@oracle.com> >>> Signed-off-by: Petr Vorel<pvorel@suse.cz> >>> --- >>> testcases/lib/tst_net.sh | 10 ++++------ >>> 1 file changed, 4 insertions(+), 6 deletions(-) >>> >>> diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh >>> index 806b540cd..1b96b3bf4 100644 >>> --- a/testcases/lib/tst_net.sh >>> +++ b/testcases/lib/tst_net.sh >>> @@ -136,7 +136,7 @@ init_ltp_netspace() >>> # -b run in background >>> # -c CMD specify command to run (this must be binary, not shell builtin/function) >>> # -s safe option, if something goes wrong, will exit with TBROK >>> -# -u USER for ssh/rsh (default root) >>> +# -u USER for ssh (default root) >>> # RETURN: 0 on success, 1 on failure >>> tst_rhost_run() >>> { >>> @@ -166,14 +166,12 @@ tst_rhost_run() >>> return 1 >>> fi >>> >>> - if [ -n "${TST_USE_SSH:-}" ]; then >>> - output=`ssh -n -q $user@$RHOST "sh -c \ >>> - '$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'` >>> - elif [ -n "${TST_USE_NETNS:-}" ]; then >>> + if [ -n "${TST_USE_NETNS:-}" ]; then >>> output=`$LTP_NETNS sh -c \ >>> "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR'` >>> else >>> - output=`rsh -n -l $user $RHOST "sh -c \ >>> + tst_require_cmds ssh >>> + output=`ssh -n -q $user@$RHOST "sh -c \ >>> '$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'` >>> fi >>> echo "$output" | grep -q 'RTERR$'&& ret=1 >>> >> > ^ permalink raw reply [flat|nested] 14+ messages in thread
* [LTP] [RESENT PATCH 2/5] net: Update README.md 2020-06-22 7:09 [LTP] [RESENT PATCH 0/5] tst_net.sh: Remove rsh, update docs add debug & test Petr Vorel 2020-06-22 7:09 ` [LTP] [RESENT PATCH 1/5] tst_net.sh: Remove rsh support Petr Vorel @ 2020-06-22 7:09 ` Petr Vorel 2020-06-23 5:16 ` Xiao Yang 2020-06-22 7:09 ` [LTP] [RESENT PATCH 3/5] tst_net.sh: Drop 'sh -c' use from ssh in tst_rhost_run Petr Vorel ` (2 subsequent siblings) 4 siblings, 1 reply; 14+ messages in thread From: Petr Vorel @ 2020-06-22 7:09 UTC (permalink / raw) To: ltp From: Petr Vorel <pvorel@suse.cz> * to previous commit (dropped rsh based testing) * fix formatting * remove suggestion to run tests for 24 hrs (we lower variables for stress testing in the past) * update package names * mention testcases/network/stress/README Signed-off-by: Petr Vorel <pvorel@suse.cz> --- testcases/network/README.md | 73 +++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/testcases/network/README.md b/testcases/network/README.md index 3a9c98125..a7eb40974 100644 --- a/testcases/network/README.md +++ b/testcases/network/README.md @@ -1,25 +1,25 @@ # LTP Network Tests -## Pre-requisites -Enable all the networking services on test machine(s): rshd, nfsd, fingerd. - ## Single Host Configuration -It is a default configuration ('RHOST' is not defined). LTP adds 'ltp_ns' -network namespace and auto-configure 'veth' pair according to LTP network -environment variables. +It is a default configuration (if the `RHOST` environment variable is not +defined). LTP adds `ltp_ns` network namespace and auto-configure `veth` pair +according to LTP network environment variables. ## Two Host Configuration -This setup requires 'RHOST' environment variable to be set properly and -configured SSH or RSH (default) access to a remote host. +This setup requires the `RHOST` environment variable to be set properly and +configured SSH access to a remote host. The 'RHOST' variable name must be set to the hostname of the server -(test management link) and PASSWD should be set to the root password +(test management link) and `PASSWD` should be set to the root password of the remote server. -In order to have RSH access: -* Edit the "/root/.rhosts" file. Please note that the file may not exist, +Some of the network stress tests hasn't been ported to network API and still +use `rsh` via `LTP_RSH` environment variable. To workaround this is best to set +it to SSH, in order to run these tests with RSH following setup is needed: + +* Edit the `/root/.rhosts` file. Please note that the file may not exist, so you must create one if it does not. You must add the fully qualified hostname of the machine you are testing on to this file. By adding the test machine's hostname to this file, you will be allowing the machine to rsh to itself, @@ -29,13 +29,13 @@ as root, without the requirement of a password. echo $client_hostname >> /root/.rhosts ``` -You may need to re-label '.rhost' file to make sure rlogind will have access to it: +You may need to re-label `.rhost` file to make sure rlogind will have access to it: ```sh /sbin/restorecon -v /root/.rhosts ``` -* Add rlogin, rsh, rexec into /etc/securetty file: +* Add rlogin, rsh, rexec into `/etc/securetty` file: ```sh for i in rlogin rsh rexec; do echo $i >> /etc/securetty; done @@ -44,48 +44,43 @@ for i in rlogin rsh rexec; do echo $i >> /etc/securetty; done ## Server Services Configuration Verify that the below daemon services are running. If not, please install and start them: -rsh-server, telnet-server, finger-server, rdist, rsync, dhcp-server, http-server. +dhcp-server, dnsmasq, http-server, nfs-kernel-server, rpcbind, rsync, vsftpd + +RSH based testing requires also: +rsh-server, telnet-server, finger-server, rdist Note: If any of the above daemon is not running on server, the test related to that service running from client will fail. ### FTP setup -* In ?/etc/ftpusers? [or vi /etc/vsftpd.ftpusers], comment the line containing -?root? string. This file lists all those users who are not given access to do ftp +* In `/etc/ftpusers` (or `/etc/vsftpd.ftpusers`), comment the line containing +"root" string. This file lists all those users who are not given access to do ftp on the current system. -* If you don?t want to do the previous step, put following entry into /root/.netrc -machine <remote_server_name> login root password <remote_root_password>. -Otherwise, ftp,rlogin & telnet fails for ?root? user & hence needs to be -executed using ?test? user to get successful results. +* If you don?t want to do the previous step, put following entry into `/root/.netrc`: +``` +machine <remote_server_name> +login root +password <remote_root_password> +``` +Otherwise, `ftp`, `rlogin` and `telnet` tests fails for `root` user. ## LTP setup -Install LTP testsuite. In case of two hosts configuration, make sure LTP is installed -on both client and server machines. - -Testcases and network tools must be in PATH, e.g.: +Install LTP testsuite. In case of two hosts configuration, LTP needs to be installed +and `LTPROOT` and `PATH` environment variables set on both client and server +machines (assuming using the default prefix `/opt/ltp`): ```sh -export PATH=/opt/ltp/testcases/bin:/usr/bin:$PATH +export LTPROOT="/opt/ltp"; export PATH="$LTPROOT/testcases/bin:$PATH" ``` -Default values for all LTP network variables are set in testcases/lib/tst_net.sh. -If you need to override some parameters please export them before test run or -specify them when running ltp-pan or testscripts/network.sh. +Default values for all LTP network parameters are set in `testcases/lib/tst_net.sh`. +Network stress parameters are documented in `testcases/network/stress/README`. ## Running the tests -To run the test type the following: ```sh TEST_VARS ./network.sh OPTIONS ``` Where -* TEST_VARS - non-default network parameters (see testcases/lib/tst_net.sh), they - could be exported before test run; -* OPTIONS - test group(s), use '-h' to see available ones. - -## Analyzing the results -Generally this test must be run more than 24 hours. When you want to stop the test -press CTRL+C to stop ./network.sh. - -Search failed tests in LTP logfile using grep FAIL <logfile>. For any failures, -run the individual tests and then try to come to the conclusion. +* TEST_VARS - non-default network parameters +* OPTIONS - test group(s), use `-h` to see available ones. -- 2.27.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [RESENT PATCH 2/5] net: Update README.md 2020-06-22 7:09 ` [LTP] [RESENT PATCH 2/5] net: Update README.md Petr Vorel @ 2020-06-23 5:16 ` Xiao Yang 0 siblings, 0 replies; 14+ messages in thread From: Xiao Yang @ 2020-06-23 5:16 UTC (permalink / raw) To: ltp On 2020/6/22 15:09, Petr Vorel wrote: > From: Petr Vorel<pvorel@suse.cz> > > * to previous commit (dropped rsh based testing) > * fix formatting > * remove suggestion to run tests for 24 hrs (we lower variables for > stress testing in the past) > * update package names > * mention testcases/network/stress/README Hi Petr, Is it necessary to metion the following requirements about ssh? 1) Start sshd service on remote host. 2) Make ssh access remote host without password. > Signed-off-by: Petr Vorel<pvorel@suse.cz> > --- > testcases/network/README.md | 73 +++++++++++++++++-------------------- > 1 file changed, 34 insertions(+), 39 deletions(-) > > diff --git a/testcases/network/README.md b/testcases/network/README.md > index 3a9c98125..a7eb40974 100644 > --- a/testcases/network/README.md > +++ b/testcases/network/README.md > @@ -1,25 +1,25 @@ > # LTP Network Tests > > -## Pre-requisites > -Enable all the networking services on test machine(s): rshd, nfsd, fingerd. > - > ## Single Host Configuration > > -It is a default configuration ('RHOST' is not defined). LTP adds 'ltp_ns' > -network namespace and auto-configure 'veth' pair according to LTP network > -environment variables. > +It is a default configuration (if the `RHOST` environment variable is not > +defined). LTP adds `ltp_ns` network namespace and auto-configure `veth` pair > +according to LTP network environment variables. > > ## Two Host Configuration > > -This setup requires 'RHOST' environment variable to be set properly and > -configured SSH or RSH (default) access to a remote host. > +This setup requires the `RHOST` environment variable to be set properly and > +configured SSH access to a remote host. > > The 'RHOST' variable name must be set to the hostname of the server > -(test management link) and PASSWD should be set to the root password > +(test management link) and `PASSWD` should be set to the root password > of the remote server. > > -In order to have RSH access: > -* Edit the "/root/.rhosts" file. Please note that the file may not exist, > +Some of the network stress tests hasn't been ported to network API and still > +use `rsh` via `LTP_RSH` environment variable. To workaround this is best to set Do you mean that workaround this by setting LTP_RSH to ssh(LTP_RSH="ssh")? I wonder if we can init LTP_RSH to ssh directly? Thanks, Xiao Yang > +it to SSH, in order to run these tests with RSH following setup is needed: > + > +* Edit the `/root/.rhosts` file. Please note that the file may not exist, > so you must create one if it does not. You must add the fully qualified > hostname of the machine you are testing on to this file. By adding the test > machine's hostname to this file, you will be allowing the machine to rsh to itself, > @@ -29,13 +29,13 @@ as root, without the requirement of a password. > echo $client_hostname>> /root/.rhosts > ``` > > -You may need to re-label '.rhost' file to make sure rlogind will have access to it: > +You may need to re-label `.rhost` file to make sure rlogind will have access to it: > > ```sh > /sbin/restorecon -v /root/.rhosts > ``` > > -* Add rlogin, rsh, rexec into /etc/securetty file: > +* Add rlogin, rsh, rexec into `/etc/securetty` file: > > ```sh > for i in rlogin rsh rexec; do echo $i>> /etc/securetty; done > @@ -44,48 +44,43 @@ for i in rlogin rsh rexec; do echo $i>> /etc/securetty; done > ## Server Services Configuration > Verify that the below daemon services are running. If not, please install > and start them: > -rsh-server, telnet-server, finger-server, rdist, rsync, dhcp-server, http-server. > +dhcp-server, dnsmasq, http-server, nfs-kernel-server, rpcbind, rsync, vsftpd > + > +RSH based testing requires also: > +rsh-server, telnet-server, finger-server, rdist > > Note: If any of the above daemon is not running on server, the test related to > that service running from client will fail. > > ### FTP setup > -* In ?/etc/ftpusers? [or vi /etc/vsftpd.ftpusers], comment the line containing > -?root? string. This file lists all those users who are not given access to do ftp > +* In `/etc/ftpusers` (or `/etc/vsftpd.ftpusers`), comment the line containing > +"root" string. This file lists all those users who are not given access to do ftp > on the current system. > > -* If you don?t want to do the previous step, put following entry into /root/.netrc > -machine<remote_server_name> login root password<remote_root_password>. > -Otherwise, ftp,rlogin& telnet fails for ?root? user& hence needs to be > -executed using ?test? user to get successful results. > +* If you don?t want to do the previous step, put following entry into `/root/.netrc`: > +``` > +machine<remote_server_name> > +login root > +password<remote_root_password> > +``` > +Otherwise, `ftp`, `rlogin` and `telnet` tests fails for `root` user. > > ## LTP setup > -Install LTP testsuite. In case of two hosts configuration, make sure LTP is installed > -on both client and server machines. > - > -Testcases and network tools must be in PATH, e.g.: > +Install LTP testsuite. In case of two hosts configuration, LTP needs to be installed > +and `LTPROOT` and `PATH` environment variables set on both client and server > +machines (assuming using the default prefix `/opt/ltp`): > > ```sh > -export PATH=/opt/ltp/testcases/bin:/usr/bin:$PATH > +export LTPROOT="/opt/ltp"; export PATH="$LTPROOT/testcases/bin:$PATH" > ``` > -Default values for all LTP network variables are set in testcases/lib/tst_net.sh. > -If you need to override some parameters please export them before test run or > -specify them when running ltp-pan or testscripts/network.sh. > +Default values for all LTP network parameters are set in `testcases/lib/tst_net.sh`. > +Network stress parameters are documented in `testcases/network/stress/README`. > > ## Running the tests > -To run the test type the following: > > ```sh > TEST_VARS ./network.sh OPTIONS > ``` > Where > -* TEST_VARS - non-default network parameters (see testcases/lib/tst_net.sh), they > - could be exported before test run; > -* OPTIONS - test group(s), use '-h' to see available ones. > - > -## Analyzing the results > -Generally this test must be run more than 24 hours. When you want to stop the test > -press CTRL+C to stop ./network.sh. > - > -Search failed tests in LTP logfile using grep FAIL<logfile>. For any failures, > -run the individual tests and then try to come to the conclusion. > +* TEST_VARS - non-default network parameters > +* OPTIONS - test group(s), use `-h` to see available ones. ^ permalink raw reply [flat|nested] 14+ messages in thread
* [LTP] [RESENT PATCH 3/5] tst_net.sh: Drop 'sh -c' use from ssh in tst_rhost_run 2020-06-22 7:09 [LTP] [RESENT PATCH 0/5] tst_net.sh: Remove rsh, update docs add debug & test Petr Vorel 2020-06-22 7:09 ` [LTP] [RESENT PATCH 1/5] tst_net.sh: Remove rsh support Petr Vorel 2020-06-22 7:09 ` [LTP] [RESENT PATCH 2/5] net: Update README.md Petr Vorel @ 2020-06-22 7:09 ` Petr Vorel 2020-06-25 16:44 ` Alexey Kodanev 2020-06-22 7:09 ` [LTP] [RESENT PATCH 4/5] net/test: Add basic testing for tst_rhost_run Petr Vorel 2020-06-22 7:09 ` [LTP] [RESENT RFC PATCH 5/5] st_net.sh: tst_rhost_run: Add -d option (debug) Petr Vorel 4 siblings, 1 reply; 14+ messages in thread From: Petr Vorel @ 2020-06-22 7:09 UTC (permalink / raw) To: ltp From: Petr Vorel <pvorel@suse.cz> This simplifies the command and allows to use double quotes in command parameter for ssh, as it removes single nested quotes of command parameter (thus fixes like c1a2d53f6 "network/nfs_lib.sh: Use double quotes for grep pattern" are not needed any more). NOTE: 'sh -c' is still required for netns based testing, but does not use nested quotes. Now both variants use only double quotes. Suggested-by: Alexey Kodanev <alexey.kodanev@oracle.com> Signed-off-by: Petr Vorel <pvorel@suse.cz> --- testcases/lib/tst_net.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh index 1b96b3bf4..2ed570a6b 100644 --- a/testcases/lib/tst_net.sh +++ b/testcases/lib/tst_net.sh @@ -167,12 +167,12 @@ tst_rhost_run() fi if [ -n "${TST_USE_NETNS:-}" ]; then - output=`$LTP_NETNS sh -c \ - "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR'` + output=$($LTP_NETNS sh -c \ + "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR') else tst_require_cmds ssh - output=`ssh -n -q $user@$RHOST "sh -c \ - '$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'` + output=$(ssh -n -q $user@$RHOST \ + "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR') fi echo "$output" | grep -q 'RTERR$' && ret=1 if [ $ret -eq 1 ]; then -- 2.27.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [RESENT PATCH 3/5] tst_net.sh: Drop 'sh -c' use from ssh in tst_rhost_run 2020-06-22 7:09 ` [LTP] [RESENT PATCH 3/5] tst_net.sh: Drop 'sh -c' use from ssh in tst_rhost_run Petr Vorel @ 2020-06-25 16:44 ` Alexey Kodanev 0 siblings, 0 replies; 14+ messages in thread From: Alexey Kodanev @ 2020-06-25 16:44 UTC (permalink / raw) To: ltp On 22.06.2020 10:09, Petr Vorel wrote: > From: Petr Vorel <pvorel@suse.cz> > > This simplifies the command and allows to use double quotes in command > parameter for ssh, as it removes single nested quotes of command > parameter (thus fixes like c1a2d53f6 "network/nfs_lib.sh: Use double > quotes for grep pattern" are not needed any more). > > NOTE: 'sh -c' is still required for netns based testing, but does not > use nested quotes. Now both variants use only double quotes. > > Suggested-by: Alexey Kodanev <alexey.kodanev@oracle.com> > Signed-off-by: Petr Vorel <pvorel@suse.cz>> --- > testcases/lib/tst_net.sh | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh > index 1b96b3bf4..2ed570a6b 100644 > --- a/testcases/lib/tst_net.sh > +++ b/testcases/lib/tst_net.sh > @@ -167,12 +167,12 @@ tst_rhost_run() > fi > > if [ -n "${TST_USE_NETNS:-}" ]; then > - output=`$LTP_NETNS sh -c \ > - "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR'` > + output=$($LTP_NETNS sh -c \ > + "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR') > else > tst_require_cmds ssh > - output=`ssh -n -q $user@$RHOST "sh -c \ > - '$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'` > + output=$(ssh -n -q $user@$RHOST \ > + "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR') > fi > echo "$output" | grep -q 'RTERR$' && ret=1 > if [ $ret -eq 1 ]; then > Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com> ^ permalink raw reply [flat|nested] 14+ messages in thread
* [LTP] [RESENT PATCH 4/5] net/test: Add basic testing for tst_rhost_run 2020-06-22 7:09 [LTP] [RESENT PATCH 0/5] tst_net.sh: Remove rsh, update docs add debug & test Petr Vorel ` (2 preceding siblings ...) 2020-06-22 7:09 ` [LTP] [RESENT PATCH 3/5] tst_net.sh: Drop 'sh -c' use from ssh in tst_rhost_run Petr Vorel @ 2020-06-22 7:09 ` Petr Vorel 2020-06-25 16:52 ` Alexey Kodanev 2020-06-22 7:09 ` [LTP] [RESENT RFC PATCH 5/5] st_net.sh: tst_rhost_run: Add -d option (debug) Petr Vorel 4 siblings, 1 reply; 14+ messages in thread From: Petr Vorel @ 2020-06-22 7:09 UTC (permalink / raw) To: ltp From: Petr Vorel <pvorel@suse.cz> Regression test for use of nested single quotes (fixed in previous commit). Signed-off-by: Petr Vorel <pvorel@suse.cz> --- lib/newlib_tests/shell/net/tst_rhost_run.sh | 25 +++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 lib/newlib_tests/shell/net/tst_rhost_run.sh diff --git a/lib/newlib_tests/shell/net/tst_rhost_run.sh b/lib/newlib_tests/shell/net/tst_rhost_run.sh new file mode 100755 index 000000000..4c034a4ac --- /dev/null +++ b/lib/newlib_tests/shell/net/tst_rhost_run.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2020 Petr Vorel <pvorel@suse.cz> + +TST_TESTFUNC=do_test +PATH="$(dirname $0)/../../../../testcases/lib/:$PATH" +. tst_net.sh + +do_test() +{ + local file="/etc/fstab" + + tst_rhost_run -c 'which grep > /dev/null' || \ + tst_res TCONF "grep not found on rhost" + + tst_rhost_run -c "[ -f $file ]" || \ + tst_res TCONF "$file not found on rhost" + + tst_rhost_run -s -c "grep -q \"[^ ]\" $file" + tst_rhost_run -s -c "grep -q '[^ ]' $file" + + tst_res TPASS "tst_rhost_run is working" +} + +tst_run -- 2.27.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [RESENT PATCH 4/5] net/test: Add basic testing for tst_rhost_run 2020-06-22 7:09 ` [LTP] [RESENT PATCH 4/5] net/test: Add basic testing for tst_rhost_run Petr Vorel @ 2020-06-25 16:52 ` Alexey Kodanev 0 siblings, 0 replies; 14+ messages in thread From: Alexey Kodanev @ 2020-06-25 16:52 UTC (permalink / raw) To: ltp On 22.06.2020 10:09, Petr Vorel wrote: > From: Petr Vorel <pvorel@suse.cz> > > Regression test for use of nested single quotes > (fixed in previous commit). > > Signed-off-by: Petr Vorel <pvorel@suse.cz> > --- > lib/newlib_tests/shell/net/tst_rhost_run.sh | 25 +++++++++++++++++++++ > 1 file changed, 25 insertions(+) > create mode 100755 lib/newlib_tests/shell/net/tst_rhost_run.sh > > diff --git a/lib/newlib_tests/shell/net/tst_rhost_run.sh b/lib/newlib_tests/shell/net/tst_rhost_run.sh > new file mode 100755 > index 000000000..4c034a4ac > --- /dev/null > +++ b/lib/newlib_tests/shell/net/tst_rhost_run.sh > @@ -0,0 +1,25 @@ > +#!/bin/sh > +# SPDX-License-Identifier: GPL-2.0-or-later > +# Copyright (c) 2020 Petr Vorel <pvorel@suse.cz> > + > +TST_TESTFUNC=do_test > +PATH="$(dirname $0)/../../../../testcases/lib/:$PATH" > +. tst_net.sh > + > +do_test() > +{ > + local file="/etc/fstab" > + > + tst_rhost_run -c 'which grep > /dev/null' || \ > + tst_res TCONF "grep not found on rhost" > + > + tst_rhost_run -c "[ -f $file ]" || \ > + tst_res TCONF "$file not found on rhost" > + > + tst_rhost_run -s -c "grep -q \"[^ ]\" $file" > + tst_rhost_run -s -c "grep -q '[^ ]' $file" > + > + tst_res TPASS "tst_rhost_run is working" > +} > + > +tst_run > Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com> ^ permalink raw reply [flat|nested] 14+ messages in thread
* [LTP] [RESENT RFC PATCH 5/5] st_net.sh: tst_rhost_run: Add -d option (debug) 2020-06-22 7:09 [LTP] [RESENT PATCH 0/5] tst_net.sh: Remove rsh, update docs add debug & test Petr Vorel ` (3 preceding siblings ...) 2020-06-22 7:09 ` [LTP] [RESENT PATCH 4/5] net/test: Add basic testing for tst_rhost_run Petr Vorel @ 2020-06-22 7:09 ` Petr Vorel 2020-06-23 5:52 ` Xiao Yang 4 siblings, 1 reply; 14+ messages in thread From: Petr Vorel @ 2020-06-22 7:09 UTC (permalink / raw) To: ltp From: Petr Vorel <pvorel@suse.cz> -d debug mode (print command and netns/ssh handling into stderr) Add tst_net_debug() simple helper for printing into stderr. Also use new parameter in tst_rhost_run.sh. Signed-off-by: Petr Vorel <pvorel@suse.cz> --- Hi, RFC: I use it quite a lot, but not sure if needed. Probably using $TST_NET_DEBUG instead of -d would be better. If we merge "tst_test.sh: Print tst_{res, brk} into stdout" [1], simple tst_res_ could be used. I was also thinking about adding new flag "DEBUG", but that's probably not needed. Kind regards, Petr [1] https://patchwork.ozlabs.org/project/ltp/patch/20200619192542.20113-1-pvorel@suse.cz/ lib/newlib_tests/shell/net/tst_rhost_run.sh | 8 +++--- testcases/lib/tst_net.sh | 29 ++++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/lib/newlib_tests/shell/net/tst_rhost_run.sh b/lib/newlib_tests/shell/net/tst_rhost_run.sh index 4c034a4ac..ebcd4ca03 100755 --- a/lib/newlib_tests/shell/net/tst_rhost_run.sh +++ b/lib/newlib_tests/shell/net/tst_rhost_run.sh @@ -10,14 +10,14 @@ do_test() { local file="/etc/fstab" - tst_rhost_run -c 'which grep > /dev/null' || \ + tst_rhost_run -d -c 'which grep > /dev/null' || \ tst_res TCONF "grep not found on rhost" - tst_rhost_run -c "[ -f $file ]" || \ + tst_rhost_run -d -c "[ -f $file ]" || \ tst_res TCONF "$file not found on rhost" - tst_rhost_run -s -c "grep -q \"[^ ]\" $file" - tst_rhost_run -s -c "grep -q '[^ ]' $file" + tst_rhost_run -ds -c "grep -q \"[^ ]\" $file" + tst_rhost_run -ds -c "grep -q '[^ ]' $file" tst_res TPASS "tst_rhost_run is working" } diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh index 2ed570a6b..d6845618d 100644 --- a/testcases/lib/tst_net.sh +++ b/testcases/lib/tst_net.sh @@ -130,11 +130,17 @@ init_ltp_netspace() tst_restore_ipaddr rhost } +tst_net_debug() +{ + echo "DEBUG: $@" >&2 +} + # Run command on remote host. # tst_rhost_run -c CMD [-b] [-s] [-u USER] # Options: # -b run in background # -c CMD specify command to run (this must be binary, not shell builtin/function) +# -d debug mode (print command and netns/ssh handling into stderr) # -s safe option, if something goes wrong, will exit with TBROK # -u USER for ssh (default root) # RETURN: 0 on success, 1 on failure @@ -143,16 +149,17 @@ tst_rhost_run() local post_cmd=' || echo RTERR' local user="root" local ret=0 - local cmd out output pre_cmd safe + local cmd debug out output pre_cmd rcmd sh_cmd safe use local OPTIND - while getopts :bsc:u: opt; do + while getopts :bc:dsu: opt; do case "$opt" in b) [ "${TST_USE_NETNS:-}" ] && pre_cmd= || pre_cmd="nohup" post_cmd=" > /dev/null 2>&1 &" out="1> /dev/null" ;; c) cmd="$OPTARG" ;; + d) debug=1 ;; s) safe=1 ;; u) user="$OPTARG" ;; *) tst_brk_ TBROK "tst_rhost_run: unknown option: $OPTARG" ;; @@ -166,14 +173,24 @@ tst_rhost_run() return 1 fi + sh_cmd="$pre_cmd $cmd $post_cmd" + if [ -n "${TST_USE_NETNS:-}" ]; then - output=$($LTP_NETNS sh -c \ - "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR') + use="NETNS" + rcmd="$LTP_NETNS sh -c" else tst_require_cmds ssh - output=$(ssh -n -q $user@$RHOST \ - "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR') + use="SSH" + rcmd="ssh -n -q $user@$RHOST" fi + + if [ "$debug" ]; then + tst_net_debug "tst_rhost_run: cmd: $cmd" + tst_net_debug "$use: $rcmd \"$sh_cmd\" $out 2>&1" + fi + + output=$($rcmd "$sh_cmd" $out 2>&1 || echo 'RTERR') + echo "$output" | grep -q 'RTERR$' && ret=1 if [ $ret -eq 1 ]; then output=$(echo "$output" | sed 's/RTERR//') -- 2.27.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
* [LTP] [RESENT RFC PATCH 5/5] st_net.sh: tst_rhost_run: Add -d option (debug) 2020-06-22 7:09 ` [LTP] [RESENT RFC PATCH 5/5] st_net.sh: tst_rhost_run: Add -d option (debug) Petr Vorel @ 2020-06-23 5:52 ` Xiao Yang 0 siblings, 0 replies; 14+ messages in thread From: Xiao Yang @ 2020-06-23 5:52 UTC (permalink / raw) To: ltp On 2020/6/22 15:09, Petr Vorel wrote: > From: Petr Vorel <pvorel@suse.cz> > > -d debug mode (print command and netns/ssh handling into stderr) > > Add tst_net_debug() simple helper for printing into stderr. > > Also use new parameter in tst_rhost_run.sh. > > Signed-off-by: Petr Vorel <pvorel@suse.cz> > --- > Hi, > > RFC: I use it quite a lot, but not sure if needed. > > Probably using $TST_NET_DEBUG instead of -d would be better. Hi Petr, Agreed. $TST_NET_DEBUG is better for user to print debug info because we don't need to change code(i.e. pass -d to tst_rhost_run()). Debug info is only related to tst_rhost_run() so is $TST_RHOST_RUN_DEBUG meaningful? > If we merge "tst_test.sh: Print tst_{res, brk} into stdout" [1], > simple tst_res_ could be used. I was also thinking about adding new flag > "DEBUG", but that's probably not needed. I think tst_res TINFO is enough. :-) Thanks, Xiao Yang > Kind regards, > Petr > > [1] https://patchwork.ozlabs.org/project/ltp/patch/20200619192542.20113-1-pvorel@suse.cz/ > > lib/newlib_tests/shell/net/tst_rhost_run.sh | 8 +++--- > testcases/lib/tst_net.sh | 29 ++++++++++++++++----- > 2 files changed, 27 insertions(+), 10 deletions(-) > > diff --git a/lib/newlib_tests/shell/net/tst_rhost_run.sh b/lib/newlib_tests/shell/net/tst_rhost_run.sh > index 4c034a4ac..ebcd4ca03 100755 > --- a/lib/newlib_tests/shell/net/tst_rhost_run.sh > +++ b/lib/newlib_tests/shell/net/tst_rhost_run.sh > @@ -10,14 +10,14 @@ do_test() > { > local file="/etc/fstab" > > - tst_rhost_run -c 'which grep > /dev/null' || \ > + tst_rhost_run -d -c 'which grep > /dev/null' || \ > tst_res TCONF "grep not found on rhost" > > - tst_rhost_run -c "[ -f $file ]" || \ > + tst_rhost_run -d -c "[ -f $file ]" || \ > tst_res TCONF "$file not found on rhost" > > - tst_rhost_run -s -c "grep -q \"[^ ]\" $file" > - tst_rhost_run -s -c "grep -q '[^ ]' $file" > + tst_rhost_run -ds -c "grep -q \"[^ ]\" $file" > + tst_rhost_run -ds -c "grep -q '[^ ]' $file" > > tst_res TPASS "tst_rhost_run is working" > } > diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh > index 2ed570a6b..d6845618d 100644 > --- a/testcases/lib/tst_net.sh > +++ b/testcases/lib/tst_net.sh > @@ -130,11 +130,17 @@ init_ltp_netspace() > tst_restore_ipaddr rhost > } > > +tst_net_debug() > +{ > + echo "DEBUG: $@" >&2 > +} > + > # Run command on remote host. > # tst_rhost_run -c CMD [-b] [-s] [-u USER] > # Options: > # -b run in background > # -c CMD specify command to run (this must be binary, not shell builtin/function) > +# -d debug mode (print command and netns/ssh handling into stderr) > # -s safe option, if something goes wrong, will exit with TBROK > # -u USER for ssh (default root) > # RETURN: 0 on success, 1 on failure > @@ -143,16 +149,17 @@ tst_rhost_run() > local post_cmd=' || echo RTERR' > local user="root" > local ret=0 > - local cmd out output pre_cmd safe > + local cmd debug out output pre_cmd rcmd sh_cmd safe use > > local OPTIND > - while getopts :bsc:u: opt; do > + while getopts :bc:dsu: opt; do > case "$opt" in > b) [ "${TST_USE_NETNS:-}" ] && pre_cmd= || pre_cmd="nohup" > post_cmd=" > /dev/null 2>&1 &" > out="1> /dev/null" > ;; > c) cmd="$OPTARG" ;; > + d) debug=1 ;; > s) safe=1 ;; > u) user="$OPTARG" ;; > *) tst_brk_ TBROK "tst_rhost_run: unknown option: $OPTARG" ;; > @@ -166,14 +173,24 @@ tst_rhost_run() > return 1 > fi > > + sh_cmd="$pre_cmd $cmd $post_cmd" > + > if [ -n "${TST_USE_NETNS:-}" ]; then > - output=$($LTP_NETNS sh -c \ > - "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR') > + use="NETNS" > + rcmd="$LTP_NETNS sh -c" > else > tst_require_cmds ssh > - output=$(ssh -n -q $user@$RHOST \ > - "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR') > + use="SSH" > + rcmd="ssh -n -q $user@$RHOST" > fi > + > + if [ "$debug" ]; then > + tst_net_debug "tst_rhost_run: cmd: $cmd" > + tst_net_debug "$use: $rcmd \"$sh_cmd\" $out 2>&1" > + fi > + > + output=$($rcmd "$sh_cmd" $out 2>&1 || echo 'RTERR') > + > echo "$output" | grep -q 'RTERR$' && ret=1 > if [ $ret -eq 1 ]; then > output=$(echo "$output" | sed 's/RTERR//') ^ permalink raw reply [flat|nested] 14+ messages in thread
* [LTP] [RESENT PATCH 0/5] tst_net.sh: Remove rsh, update docs add debug & test @ 2020-06-22 4:56 Petr Vorel 2020-06-22 4:56 ` [LTP] [RESENT RFC PATCH 5/5] st_net.sh: tst_rhost_run: Add -d option (debug) Petr Vorel 0 siblings, 1 reply; 14+ messages in thread From: Petr Vorel @ 2020-06-22 4:56 UTC (permalink / raw) To: ltp Hi, It looks this patchset from Friday didn't get to the mailing list, thus sending it again. started as removing rsh, then also update docs and backport testing environment I use for some time (but not sure if needed). Kind regards, Petr Petr Vorel (5): tst_net.sh: Remove rsh support net: Update README.md tst_net.sh: Drop 'sh -c' use from ssh in tst_rhost_run net/test: Add basic testing for tst_rhost_run st_net.sh: tst_rhost_run: Add -d option (debug) lib/newlib_tests/shell/net/tst_rhost_run.sh | 25 +++++++ testcases/lib/tst_net.sh | 37 +++++++---- testcases/network/README.md | 73 ++++++++++----------- 3 files changed, 85 insertions(+), 50 deletions(-) create mode 100755 lib/newlib_tests/shell/net/tst_rhost_run.sh -- 2.27.0 ^ permalink raw reply [flat|nested] 14+ messages in thread
* [LTP] [RESENT RFC PATCH 5/5] st_net.sh: tst_rhost_run: Add -d option (debug) 2020-06-22 4:56 [LTP] [RESENT PATCH 0/5] tst_net.sh: Remove rsh, update docs add debug & test Petr Vorel @ 2020-06-22 4:56 ` Petr Vorel 0 siblings, 0 replies; 14+ messages in thread From: Petr Vorel @ 2020-06-22 4:56 UTC (permalink / raw) To: ltp -d debug mode (print command and netns/ssh handling into stderr) Add tst_net_debug() simple helper for printing into stderr. Also use new parameter in tst_rhost_run.sh. Signed-off-by: Petr Vorel <pvorel@suse.cz> --- Hi, RFC: I use it quite a lot, but not sure if needed. Probably using $TST_NET_DEBUG instead of -d would be better. If we merge "tst_test.sh: Print tst_{res, brk} into stdout" [1], simple tst_res_ could be used. I was also thinking about adding new flag "DEBUG", but that's probably not needed. Kind regards, Petr [1] https://patchwork.ozlabs.org/project/ltp/patch/20200619192542.20113-1-pvorel@suse.cz/ lib/newlib_tests/shell/net/tst_rhost_run.sh | 8 +++--- testcases/lib/tst_net.sh | 29 ++++++++++++++++----- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/lib/newlib_tests/shell/net/tst_rhost_run.sh b/lib/newlib_tests/shell/net/tst_rhost_run.sh index 4c034a4ac..ebcd4ca03 100755 --- a/lib/newlib_tests/shell/net/tst_rhost_run.sh +++ b/lib/newlib_tests/shell/net/tst_rhost_run.sh @@ -10,14 +10,14 @@ do_test() { local file="/etc/fstab" - tst_rhost_run -c 'which grep > /dev/null' || \ + tst_rhost_run -d -c 'which grep > /dev/null' || \ tst_res TCONF "grep not found on rhost" - tst_rhost_run -c "[ -f $file ]" || \ + tst_rhost_run -d -c "[ -f $file ]" || \ tst_res TCONF "$file not found on rhost" - tst_rhost_run -s -c "grep -q \"[^ ]\" $file" - tst_rhost_run -s -c "grep -q '[^ ]' $file" + tst_rhost_run -ds -c "grep -q \"[^ ]\" $file" + tst_rhost_run -ds -c "grep -q '[^ ]' $file" tst_res TPASS "tst_rhost_run is working" } diff --git a/testcases/lib/tst_net.sh b/testcases/lib/tst_net.sh index 2ed570a6b..d6845618d 100644 --- a/testcases/lib/tst_net.sh +++ b/testcases/lib/tst_net.sh @@ -130,11 +130,17 @@ init_ltp_netspace() tst_restore_ipaddr rhost } +tst_net_debug() +{ + echo "DEBUG: $@" >&2 +} + # Run command on remote host. # tst_rhost_run -c CMD [-b] [-s] [-u USER] # Options: # -b run in background # -c CMD specify command to run (this must be binary, not shell builtin/function) +# -d debug mode (print command and netns/ssh handling into stderr) # -s safe option, if something goes wrong, will exit with TBROK # -u USER for ssh (default root) # RETURN: 0 on success, 1 on failure @@ -143,16 +149,17 @@ tst_rhost_run() local post_cmd=' || echo RTERR' local user="root" local ret=0 - local cmd out output pre_cmd safe + local cmd debug out output pre_cmd rcmd sh_cmd safe use local OPTIND - while getopts :bsc:u: opt; do + while getopts :bc:dsu: opt; do case "$opt" in b) [ "${TST_USE_NETNS:-}" ] && pre_cmd= || pre_cmd="nohup" post_cmd=" > /dev/null 2>&1 &" out="1> /dev/null" ;; c) cmd="$OPTARG" ;; + d) debug=1 ;; s) safe=1 ;; u) user="$OPTARG" ;; *) tst_brk_ TBROK "tst_rhost_run: unknown option: $OPTARG" ;; @@ -166,14 +173,24 @@ tst_rhost_run() return 1 fi + sh_cmd="$pre_cmd $cmd $post_cmd" + if [ -n "${TST_USE_NETNS:-}" ]; then - output=$($LTP_NETNS sh -c \ - "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR') + use="NETNS" + rcmd="$LTP_NETNS sh -c" else tst_require_cmds ssh - output=$(ssh -n -q $user@$RHOST \ - "$pre_cmd $cmd $post_cmd" $out 2>&1 || echo 'RTERR') + use="SSH" + rcmd="ssh -n -q $user@$RHOST" fi + + if [ "$debug" ]; then + tst_net_debug "tst_rhost_run: cmd: $cmd" + tst_net_debug "$use: $rcmd \"$sh_cmd\" $out 2>&1" + fi + + output=$($rcmd "$sh_cmd" $out 2>&1 || echo 'RTERR') + echo "$output" | grep -q 'RTERR$' && ret=1 if [ $ret -eq 1 ]; then output=$(echo "$output" | sed 's/RTERR//') -- 2.27.0 ^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-06-28 3:36 UTC | newest] Thread overview: 14+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2020-06-22 7:09 [LTP] [RESENT PATCH 0/5] tst_net.sh: Remove rsh, update docs add debug & test Petr Vorel 2020-06-22 7:09 ` [LTP] [RESENT PATCH 1/5] tst_net.sh: Remove rsh support Petr Vorel 2020-06-25 16:42 ` Alexey Kodanev 2020-06-26 6:27 ` Alexey Kodanev 2020-06-28 3:36 ` Xiao Yang 2020-06-22 7:09 ` [LTP] [RESENT PATCH 2/5] net: Update README.md Petr Vorel 2020-06-23 5:16 ` Xiao Yang 2020-06-22 7:09 ` [LTP] [RESENT PATCH 3/5] tst_net.sh: Drop 'sh -c' use from ssh in tst_rhost_run Petr Vorel 2020-06-25 16:44 ` Alexey Kodanev 2020-06-22 7:09 ` [LTP] [RESENT PATCH 4/5] net/test: Add basic testing for tst_rhost_run Petr Vorel 2020-06-25 16:52 ` Alexey Kodanev 2020-06-22 7:09 ` [LTP] [RESENT RFC PATCH 5/5] st_net.sh: tst_rhost_run: Add -d option (debug) Petr Vorel 2020-06-23 5:52 ` Xiao Yang -- strict thread matches above, loose matches on Subject: below -- 2020-06-22 4:56 [LTP] [RESENT PATCH 0/5] tst_net.sh: Remove rsh, update docs add debug & test Petr Vorel 2020-06-22 4:56 ` [LTP] [RESENT RFC PATCH 5/5] st_net.sh: tst_rhost_run: Add -d option (debug) Petr Vorel
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox