All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [RFC PATCH v2 1/2] lib: TCONF on "not supported" errnos in SAFE_SOCKET()
@ 2018-03-01 10:59 Petr Vorel
  2018-03-01 10:59 ` [LTP] [RFC PATCH v2 2/2] tst_netload: Exit with TCONF when netstress exit with CONF Petr Vorel
  2018-03-01 15:43 ` [LTP] [RFC PATCH v2 1/2] lib: TCONF on "not supported" errnos in SAFE_SOCKET() Alexey Kodanev
  0 siblings, 2 replies; 6+ messages in thread
From: Petr Vorel @ 2018-03-01 10:59 UTC (permalink / raw)
  To: ltp

*NOSUPPORT errnos likely mean there is configuration issue rather than
test failure.

e.g. missing dccp module in netstress.c which was sofar set as TBROK:
safe_net.c:117: BROK: netstress.c:654: socket(10, 6, 33) failed: ESOCKTNOSUPPORT

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
Changes v1->v2:
* Add more errnos.

Maybe it'd make sense to pick suitable errnos and test it against each
safe_*() in lib/safe_net.c or even against all safe_*().
---
 lib/safe_net.c | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/lib/safe_net.c b/lib/safe_net.c
index 9ea9d2b42..1f1cd0358 100644
--- a/lib/safe_net.c
+++ b/lib/safe_net.c
@@ -107,14 +107,25 @@ int tst_getsockport(const char *file, const int lineno, int sockfd)
 int safe_socket(const char *file, const int lineno, void (cleanup_fn)(void),
 		int domain, int type, int protocol)
 {
-	int rval;
+	int rval, ttype;
 
 	rval = socket(domain, type, protocol);
 
 	if (rval < 0) {
-		tst_brkm(TBROK | TERRNO, cleanup_fn,
-			 "%s:%d: socket(%d, %d, %d) failed", file, lineno,
-			 domain, type, protocol);
+		switch (errno) {
+		case EPROTONOSUPPORT:
+		case ESOCKTNOSUPPORT:
+		case EOPNOTSUPP:
+		case EPFNOSUPPORT:
+		case EAFNOSUPPORT:
+			ttype = TCONF;
+			break;
+		default:
+			ttype = TBROK;
+		}
+
+		tst_brkm(ttype | TERRNO, cleanup_fn, "%s:%d: socket(%d, %d, %d) failed",
+				 file, lineno, domain, type, protocol);
 	}
 
 	return rval;
-- 
2.16.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [RFC PATCH v2 2/2] tst_netload: Exit with TCONF when netstress exit with CONF
  2018-03-01 10:59 [LTP] [RFC PATCH v2 1/2] lib: TCONF on "not supported" errnos in SAFE_SOCKET() Petr Vorel
@ 2018-03-01 10:59 ` Petr Vorel
  2018-03-01 15:49   ` Alexey Kodanev
  2018-03-01 15:43 ` [LTP] [RFC PATCH v2 1/2] lib: TCONF on "not supported" errnos in SAFE_SOCKET() Alexey Kodanev
  1 sibling, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2018-03-01 10:59 UTC (permalink / raw)
  To: ltp

as some issues are configuration issues.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 testcases/lib/test_net.sh | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
index 95e13ee03..db9bb028d 100644
--- a/testcases/lib/test_net.sh
+++ b/testcases/lib/test_net.sh
@@ -453,7 +453,9 @@ tst_netload()
 	tst_rhost_run -c "netstress $s_opts" > tst_netload.log 2>&1
 	if [ $? -ne 0 ]; then
 		cat tst_netload.log
-		tst_brkm TFAIL "server failed"
+		local ttype="TFAIL"
+		grep -e 'CONF:' tst_netload.log && ttype="TCONF"
+		tst_brkm $ttype "server failed"
 	fi
 
 	local port=$(tst_rhost_run -s -c "cat $TST_TMPDIR/netstress_port")
-- 
2.16.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [RFC PATCH v2 1/2] lib: TCONF on "not supported" errnos in SAFE_SOCKET()
  2018-03-01 10:59 [LTP] [RFC PATCH v2 1/2] lib: TCONF on "not supported" errnos in SAFE_SOCKET() Petr Vorel
  2018-03-01 10:59 ` [LTP] [RFC PATCH v2 2/2] tst_netload: Exit with TCONF when netstress exit with CONF Petr Vorel
@ 2018-03-01 15:43 ` Alexey Kodanev
  1 sibling, 0 replies; 6+ messages in thread
From: Alexey Kodanev @ 2018-03-01 15:43 UTC (permalink / raw)
  To: ltp

On 03/01/2018 01:59 PM, Petr Vorel wrote:
> *NOSUPPORT errnos likely mean there is configuration issue rather than
> test failure.
> 
> e.g. missing dccp module in netstress.c which was sofar set as TBROK:
> safe_net.c:117: BROK: netstress.c:654: socket(10, 6, 33) failed: ESOCKTNOSUPPORT
> 
...
>  
>  	if (rval < 0) {
> -		tst_brkm(TBROK | TERRNO, cleanup_fn,
> -			 "%s:%d: socket(%d, %d, %d) failed", file, lineno,
> -			 domain, type, protocol);
> +		switch (errno) {
> +		case EPROTONOSUPPORT:
> +		case ESOCKTNOSUPPORT:
> +		case EOPNOTSUPP:
> +		case EPFNOSUPPORT:
> +		case EAFNOSUPPORT:
> +			ttype = TCONF;
> +			break;
> +		default:
> +			ttype = TBROK;
> +		}
> +
> +		tst_brkm(ttype | TERRNO, cleanup_fn, "%s:%d: socket(%d, %d, %d) failed",

Looks like this line is over 80 chars. Otherwise looks good to me.

Thanks,
Alexey

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [RFC PATCH v2 2/2] tst_netload: Exit with TCONF when netstress exit with CONF
  2018-03-01 10:59 ` [LTP] [RFC PATCH v2 2/2] tst_netload: Exit with TCONF when netstress exit with CONF Petr Vorel
@ 2018-03-01 15:49   ` Alexey Kodanev
  2018-03-01 18:42     ` Petr Vorel
  0 siblings, 1 reply; 6+ messages in thread
From: Alexey Kodanev @ 2018-03-01 15:49 UTC (permalink / raw)
  To: ltp

On 03/01/2018 01:59 PM, Petr Vorel wrote:
> as some issues are configuration issues.
> 
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
>  testcases/lib/test_net.sh | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
> index 95e13ee03..db9bb028d 100644
> --- a/testcases/lib/test_net.sh
> +++ b/testcases/lib/test_net.sh
> @@ -453,7 +453,9 @@ tst_netload()
>  	tst_rhost_run -c "netstress $s_opts" > tst_netload.log 2>&1
>  	if [ $? -ne 0 ]; then
>  		cat tst_netload.log
> -		tst_brkm TFAIL "server failed"
> +		local ttype="TFAIL"
> +		grep -e 'CONF:' tst_netload.log && ttype="TCONF"


What about using the returned status instead of grep?

Thanks,
Alexey

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [RFC PATCH v2 2/2] tst_netload: Exit with TCONF when netstress exit with CONF
  2018-03-01 15:49   ` Alexey Kodanev
@ 2018-03-01 18:42     ` Petr Vorel
  2018-03-02  9:12       ` Petr Vorel
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2018-03-01 18:42 UTC (permalink / raw)
  To: ltp

Hi Alexey,

> On 03/01/2018 01:59 PM, Petr Vorel wrote:
> > as some issues are configuration issues.

> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> >  testcases/lib/test_net.sh | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)

> > diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
> > index 95e13ee03..db9bb028d 100644
> > --- a/testcases/lib/test_net.sh
> > +++ b/testcases/lib/test_net.sh
> > @@ -453,7 +453,9 @@ tst_netload()
> >  	tst_rhost_run -c "netstress $s_opts" > tst_netload.log 2>&1
> >  	if [ $? -ne 0 ]; then
> >  		cat tst_netload.log
> > -		tst_brkm TFAIL "server failed"
> > +		local ttype="TFAIL"
> > +		grep -e 'CONF:' tst_netload.log && ttype="TCONF"


> What about using the returned status instead of grep?
Sure, that's much better solution, thanks!


Kind regards,
Petr

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [RFC PATCH v2 2/2] tst_netload: Exit with TCONF when netstress exit with CONF
  2018-03-01 18:42     ` Petr Vorel
@ 2018-03-02  9:12       ` Petr Vorel
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2018-03-02  9:12 UTC (permalink / raw)
  To: ltp

Hi Alexey,

> > > diff --git a/testcases/lib/test_net.sh b/testcases/lib/test_net.sh
> > > index 95e13ee03..db9bb028d 100644
> > > --- a/testcases/lib/test_net.sh
> > > +++ b/testcases/lib/test_net.sh
> > > @@ -453,7 +453,9 @@ tst_netload()
> > >  	tst_rhost_run -c "netstress $s_opts" > tst_netload.log 2>&1
> > >  	if [ $? -ne 0 ]; then
> > >  		cat tst_netload.log
> > > -		tst_brkm TFAIL "server failed"
> > > +		local ttype="TFAIL"
> > > +		grep -e 'CONF:' tst_netload.log && ttype="TCONF"


> > What about using the returned status instead of grep?
> Sure, that's much better solution, thanks!

Actually, this would not work - we need to get info from:
	tst_rhost_run -c "netstress $s_opts" > tst_netload.log 2>&1

But tst_rhost_run return only 1 on failure:

	local ret=0
	...
	'$pre_cmd $cmd $post_cmd'" $out 2>&1 || echo 'RTERR'`
	...
	echo "$output" | grep -q 'RTERR$' && ret=1

So I'd leave it using grep unless we want to change tst_rhost_run to return the exit code
of the last command (this would work for ssh and netns, and I guess for rsh as well).

Another thing in tst_netload(), on client side:
	netstress -l $c_opts > tst_netload.log 2>&1 || ret=1
	tst_rhost_run -c "pkill -9 netstress\$"

	if [ "$expect_ret" -ne "$ret" ]; then
		tst_dump_rhost_cmd
		cat tst_netload.log
		tst_brkm TFAIL "expected '$expect_res' but ret: '$ret'"
	fi

There are 3 netstress usages expecting to fail (via virt_compare_netperf "fail").
So far we don't report TCONF for client, so this code is correct. But if not we can have
TCONF and result will be TPASS as we don't distinguish between TCONF and TFAIL when
running netstress on client side either.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-03-02  9:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-01 10:59 [LTP] [RFC PATCH v2 1/2] lib: TCONF on "not supported" errnos in SAFE_SOCKET() Petr Vorel
2018-03-01 10:59 ` [LTP] [RFC PATCH v2 2/2] tst_netload: Exit with TCONF when netstress exit with CONF Petr Vorel
2018-03-01 15:49   ` Alexey Kodanev
2018-03-01 18:42     ` Petr Vorel
2018-03-02  9:12       ` Petr Vorel
2018-03-01 15:43 ` [LTP] [RFC PATCH v2 1/2] lib: TCONF on "not supported" errnos in SAFE_SOCKET() Alexey Kodanev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.