diff mbox series

[RFC,v2,1/2] lib: TCONF on "not supported" errnos in SAFE_SOCKET()

Message ID 20180301105943.5487-1-pvorel@suse.cz
State Superseded
Delegated to: Petr Vorel
Headers show
Series [RFC,v2,1/2] lib: TCONF on "not supported" errnos in SAFE_SOCKET() | expand

Commit Message

Petr Vorel March 1, 2018, 10:59 a.m. UTC
*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(-)

Comments

Alexey Kodanev March 1, 2018, 3:43 p.m. UTC | #1
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
diff mbox series

Patch

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;