($INBOX_DIR/description missing)
 help / color / mirror / Atom feed
From: Yang Xu via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] getsockopt01: Add case for errno EINVAL
Date: Mon, 22 Apr 2024 04:36:57 -0400	[thread overview]
Message-ID: <20240422083657.28363-1-xuyang2018.jy@fujitsu.com> (raw)

Currently there is no case for EINVAL, so a new case is added.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/syscalls/getsockopt/getsockopt01.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/getsockopt/getsockopt01.c b/testcases/kernel/syscalls/getsockopt/getsockopt01.c
index 4da9bd0ea..05f2be890 100644
--- a/testcases/kernel/syscalls/getsockopt/getsockopt01.c
+++ b/testcases/kernel/syscalls/getsockopt/getsockopt01.c
@@ -15,6 +15,7 @@
  * - ENOTSOCK on a file descriptor not linked to a socket
  * - EFAULT on invalid address of value or length
  * - EOPNOTSUPP on invalid option name or protocol
+ * - EINVAL on an invalid optlen
  */
 
 #include "tst_test.h"
@@ -24,6 +25,7 @@ static struct sockaddr_in sin0;
 static int sinlen;
 static int optval;
 static socklen_t optlen;
+static socklen_t optleninval;
 
 static struct test_case {
 	int *sockfd;
@@ -56,7 +58,10 @@ static struct test_case {
 	.optlen = &optlen, .experrno = ENOPROTOOPT, .desc =  "invalid option name (IP)"},
 
 	{.sockfd = &sock_bind, .level = IPPROTO_TCP, .optname = -1, .optval = &optval,
-	.optlen = &optlen, .experrno = ENOPROTOOPT, .desc = "invalid option name (TCP)"}
+	.optlen = &optlen, .experrno = ENOPROTOOPT, .desc = "invalid option name (TCP)"},
+
+	{.sockfd = &sock_bind, .level = SOL_SOCKET, .optname = SO_OOBINLINE, .optval = &optval,
+	.optlen = &optleninval, .experrno = EINVAL, .desc = "invalid optlen"},
 };
 
 
@@ -79,6 +84,7 @@ static void setup(void)
 	SAFE_BIND(sock_bind, (struct sockaddr *)&sin0, sizeof(sin0));
 	sinlen = sizeof(sin0);
 	optlen = sizeof(optval);
+	optleninval = -1;
 }
 
 static struct tst_test test = {
-- 
2.39.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2024-04-22  9:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22  8:36 Yang Xu via ltp [this message]
2024-05-16  1:34 ` [LTP] [PATCH] getsockopt01: Add case for errno EINVAL Petr Vorel
2024-05-16  1: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=20240422083657.28363-1-xuyang2018.jy@fujitsu.com \
    --to=ltp@lists.linux.it \
    --cc=xuyang2018.jy@fujitsu.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).