Message ID | 20200710172044.21592-7-pvorel@suse.cz |
---|---|
State | Accepted |
Headers | show |
Series | tst_net.sh: Remove rsh, update docs add debug & test | expand |
On 2020/7/11 1:20, Petr Vorel wrote: > Regression test for use of nested single quotes > (fixed in previous commit). > > Acked-by: Alexey Kodanev <alexey.kodanev@oracle.com> > 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" Hi Petr, 1) Do you want to discard stderr as well? For example: ------------------------------------------------- # which gre >/dev/null /usr/bin/which: no gre in (/opt/ltp/testcases/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin) ------------------------------------------------- 2) Is it necessary to continue if grep command is not found on rhost? How about calling tst_brk? > + > + tst_rhost_run -c "[ -f $file ]" || \ > + tst_res TCONF "$file not found on rhost" Call tst_brk as well? Thanks, Xiao Yang > + > + 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
Hi, > > + tst_rhost_run -c 'which grep > /dev/null' || \ > > + tst_res TCONF "grep not found on rhost" > Hi Petr, > 1) Do you want to discard stderr as well? For example: > ------------------------------------------------- > # which gre >/dev/null > /usr/bin/which: no gre in > (/opt/ltp/testcases/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin) That's not needed because tst_rhost_run already redirect stderr to stdout. > ------------------------------------------------- > 2) Is it necessary to continue if grep command is not found on rhost? > How about calling tst_brk? Good catch, I should use tst_brk on both places. > > + > > + tst_rhost_run -c "[ -f $file ]" || \ > > + tst_res TCONF "$file not found on rhost" > Call tst_brk as well? > Thanks, > Xiao Yang Thanks! Petr
On 7/20/20 7:53 PM, Petr Vorel wrote: > Hi, > >>> + tst_rhost_run -c 'which grep > /dev/null' || \ >>> + tst_res TCONF "grep not found on rhost" >> Hi Petr, >> 1) Do you want to discard stderr as well? For example: >> ------------------------------------------------- >> # which gre >/dev/null >> /usr/bin/which: no gre in >> (/opt/ltp/testcases/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin) > That's not needed because tst_rhost_run already redirect stderr to stdout. Hi Petr, I think you means tst_rhost_run -c 'which grep' >/dev/null rather than tst_rhost_run -c 'which grep > /dev/null' The current code just discard stdout, for example: ------------------------------------------------------- [root@Fedora-30-workstation net]# ./tst_rhost_run.sh ... tst_rhost_run 1 TINFO: NETNS: ns_exec 3079 net,mnt sh -c " which gre > /dev/null || echo RTERR" 2>&1 which: no gre in (./../../../../testcases/lib/:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/root/bin:/opt/ltp/testcases/bin) ------------------------------------------------------- Thanks, Xiao Yang > >> ------------------------------------------------- >> 2) Is it necessary to continue if grep command is not found on rhost? >> How about calling tst_brk? > Good catch, I should use tst_brk on both places. > >>> + >>> + tst_rhost_run -c "[ -f $file ]" || \ >>> + tst_res TCONF "$file not found on rhost" >> Call tst_brk as well? >> Thanks, >> Xiao Yang > Thanks! > Petr >
Hi Yang, > > > Hi Petr, > > > 1) Do you want to discard stderr as well? For example: > > > ------------------------------------------------- > > > # which gre >/dev/null > > > /usr/bin/which: no gre in > > > (/opt/ltp/testcases/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin) > > That's not needed because tst_rhost_run already redirect stderr to stdout. > Hi Petr, > I think you means tst_rhost_run -c 'which grep' >/dev/null rather than > tst_rhost_run -c 'which grep > /dev/null' > The current code just discard stdout, for example: > ------------------------------------------------------- > [root@Fedora-30-workstation net]# ./tst_rhost_run.sh > ... > tst_rhost_run 1 TINFO: NETNS: ns_exec 3079 net,mnt sh -c " which gre > > /dev/null || echo RTERR" 2>&1 > which: no gre in (./../../../../testcases/lib/:/usr/share/Modules/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/root/bin:/opt/ltp/testcases/bin) I'm sorry, I accidentally tested on which version from debianutils which prints also errors to stdout. which from GNU which (used in openSUSE/SLES, Fedora/RHEL) prints errors to stderr => you're right stderr should be redirected. On the other hand when not redirected, you can see PATH. Kind regards, Petr
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