public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] add new testcase for bind
Date: Thu, 26 Jul 2018 14:37:12 +0200	[thread overview]
Message-ID: <20180726123712.GA6687@dell5510> (raw)
In-Reply-To: <20180726084620.14645-1-mmoese@suse.de>

Hi Michael,

> With
>   0fb44559ffd6  af_unix: move unix_mknod() out of bindlock
> the behavior of bind() for STREAM UNIX sockets changed in
> case a socket that is already bound is passed to bind() again.

> This testcase fails for the new behavior and passes for the
> old one.

> Signed-off-by: Michael Moese <mmoese@suse.de>
Acked-by: Petr Vorel <pvorel@suse.cz>
Nice patch, minor nits mentioned bellow.


Kind regards,
Petr

> ---
>  runtest/syscalls                          |   1 +
>  testcases/kernel/syscalls/bind/.gitignore |   1 +
>  testcases/kernel/syscalls/bind/bind03.c   | 120 ++++++++++++++++++++++
>  3 files changed, 122 insertions(+)
>  create mode 100644 testcases/kernel/syscalls/bind/bind03.c
...

> +++ b/testcases/kernel/syscalls/bind/bind03.c
> @@ -0,0 +1,120 @@
> +/*
> + * Copyright (c) 2018 Michael Moese <mmoese@suse.com>
> + *
> + * This program is free software: you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation, either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program. If not, see <http://www.gnu.org/licenses/>.
> + */
You can use SPDX license identifier if you like:
SPDX-License-Identifier: GPL-2.0-or-later

> +/* The commit 0fb44559ffd6  af_unix: move unix_mknod() out of bindlock
> + * changed the behavior of bind() for STREAM UNIX domain sockets if
> + */
> +
> +#include <sys/types.h>
> +#include <sys/socket.h>
> +#include <sys/un.h>
These headers are included by tst_safe_net.h, maybe we don't need to include them.
The same applies for limits.h and unistd.h (loaded by tst_test.h).

> +
> +#include <err.h>
This header is not needed (we don't need warn() etc.).

> +#include <errno.h>
> +#include <limits.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <stdlib.h>
> +
> +#include "tst_test.h"
> +#include "tst_safe_net.h"
> +
> +#define SOCK_NAME "socket.1"
...

> +	/*
> +	 * Once a STREAM UNIX domain socket has been bound, it can't be
> +	 * rebound. Expected error is EINVAL.
> +	 * cannot use SAFE_BIND() here.
I wouldn't note SAFE_BIND().

> +	 */
> +	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;
> +	}
> +
> +	sock2 = SAFE_SOCKET(PF_UNIX, SOCK_STREAM, 0);
> +
> +	/*
> +	 * Since a socket is already bound to the pathname, it can't be bound
> +	 * to a second socket. Expected error is EADDRINUSE.
> +	 * again, cannot use SAFE_BIND().
> +	 */
The same here.


Kind regards,
Petr

      reply	other threads:[~2018-07-26 12:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-26  8:46 [LTP] [PATCH] add new testcase for bind Michael Moese
2018-07-26 12:37 ` Petr Vorel [this message]

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=20180726123712.GA6687@dell5510 \
    --to=pvorel@suse.cz \
    --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