From: Junchi Chen <junchi.chen@intel.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH ltp] syscalls/bind03: Add version compare according to behaviour difference.
Date: Fri, 31 Aug 2018 21:24:53 +0800 [thread overview]
Message-ID: <20180831132453.6461-1-junchi.chen@intel.com> (raw)
ISSUE:
The case is designed to test the behaviour diverse caused by kernel
commit 0fb44559ffd6. And it failed for the new behaviour.
ACTION:
Add a version compare to split part of the test.
Signed-off-by: Junchi Chen <junchi.chen@intel.com>
---
testcases/kernel/syscalls/bind/bind03.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/bind/bind03.c b/testcases/kernel/syscalls/bind/bind03.c
index 2fe342a54..955a69dd2 100644
--- a/testcases/kernel/syscalls/bind/bind03.c
+++ b/testcases/kernel/syscalls/bind/bind03.c
@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <string.h>
+#include "tst_kvercmp.h"
#include "tst_test.h"
#include "tst_safe_net.h"
@@ -37,16 +38,28 @@ void run(void)
/*
* Once a STREAM UNIX domain socket has been bound, it can't be
- * rebound. Expected error is EINVAL.
+ * rebound.
*/
if (bind(sock1, (struct sockaddr *)&sun, sizeof(sun)) == 0) {
tst_res(TFAIL, "re-binding of socket succeeded");
return;
}
- if (errno != EINVAL) {
- tst_res(TFAIL | TERRNO, "expected EINVAL");
- return;
+ /*
+ * The behavious diverse according to kernel version
+ * for v4.10 or later, the expected error is EADDRINUSE,
+ * otherwise EINVAL.
+ */
+ if (tst_kvercmp(4, 10, 0) < 0) {
+ if (errno != EINVAL) {
+ tst_res(TFAIL | TERRNO, "expected EINVAL");
+ return;
+ }
+ } else {
+ if (errno != EADDRINUSE) {
+ tst_res(TFAIL | TERRNO, "expected EADDRINUSE");
+ return;
+ }
}
sock2 = SAFE_SOCKET(PF_UNIX, SOCK_STREAM, 0);
--
2.17.1
next reply other threads:[~2018-08-31 13:24 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-31 13:24 Junchi Chen [this message]
2018-08-31 8:37 ` [LTP] [PATCH ltp] syscalls/bind03: Add version compare according to behaviour difference Petr Vorel
2018-08-31 8:42 ` Cyril Hrubis
2018-09-07 10:12 ` Petr Vorel
2018-08-31 8:48 ` Xiao Yang
2018-08-31 9:34 ` Cyril Hrubis
2018-08-31 8:41 ` Cyril Hrubis
2018-08-31 9:37 ` Cyril Hrubis
2018-08-31 10:39 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180831132453.6461-1-junchi.chen@intel.com \
--to=junchi.chen@intel.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox