From: Greg KH <gregkh@linuxfoundation.org>
To: Christian Brauner <christian@brauner.io>
Cc: tkjos@android.com, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
arve@android.com, maco@android.com, joel@joelfernandes.org,
tkjos@google.com, shuah@kernel.org
Subject: Re: [PATCH v2] selftests: add binderfs selftests
Date: Thu, 17 Jan 2019 11:55:49 +0100 [thread overview]
Message-ID: <20190117105549.GA28882@kroah.com> (raw)
In-Reply-To: <20190117102821.10950-1-christian@brauner.io>
On Thu, Jan 17, 2019 at 11:28:21AM +0100, Christian Brauner wrote:
> This adds the promised selftest for binderfs. It will verify the following
> things:
> - binderfs mounting works
> - binder device allocation works
> - performing a binder ioctl() request through a binderfs device works
> - binder device removal works
> - binder-control removal fails
> - binderfs unmounting works
>
> The tests are performed both privileged and unprivileged. The latter
> verifies that binderfs behaves correctly in user namespaces.
>
> Cc: Todd Kjos <tkjos@google.com>
> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Now I am just nit-picking:
> +static void write_to_file(const char *filename, const void *buf, size_t count,
> + int allowed_errno)
> +{
> + int fd, saved_errno;
> + ssize_t ret;
> +
> + fd = open(filename, O_WRONLY | O_CLOEXEC);
> + if (fd < 0)
> + ksft_exit_fail_msg("%s - Failed to open file %s\n",
> + strerror(errno), filename);
> +
> + ret = write_nointr(fd, buf, count);
> + if (ret < 0) {
> + if (allowed_errno && (errno == allowed_errno)) {
> + close(fd);
> + return;
> + }
> +
> + goto on_error;
> + }
> +
> + if ((size_t)ret != count)
> + goto on_error;
if ret < count, you are supposed to try again with the remaining data,
right? A write() implementation can just take one byte at a time.
Yes, for your example here that isn't going to happen as the kernel
should be handling a larger buffer than that, but note that if you use
this code elsewhere, it's not really correct because:
> +
> + close(fd);
> + return;
> +
> +on_error:
> + saved_errno = errno;
If you do a short write, there is no error, so who knows what errno you
end up with here.
Anyway, just one other minor question that might be relevant:
> + printf("Allocated new binder device with major %d, minor %d, and name %s\n",
> + device.major, device.minor, device.name);
Aren't tests supposed to print their output in some sort of normal
format? I thought you were supposed to use ksft_print_msg() so that
tools can properly parse the output.
thanks,
greg k-h
next prev parent reply other threads:[~2019-01-17 10:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-17 10:28 [PATCH v2] selftests: add binderfs selftests Christian Brauner
2019-01-17 10:55 ` Greg KH [this message]
2019-01-17 11:41 ` Christian Brauner
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=20190117105549.GA28882@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=arve@android.com \
--cc=christian@brauner.io \
--cc=devel@driverdev.osuosl.org \
--cc=joel@joelfernandes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maco@android.com \
--cc=shuah@kernel.org \
--cc=tkjos@android.com \
--cc=tkjos@google.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