From: Christian Brauner <christian.brauner@ubuntu.com>
To: gregkh@linuxfoundation.org, tkjos@android.com,
keescook@chromium.org, linux-kernel@vger.kernel.org
Cc: christian.brauner@ubuntu.com, ard.biesheuvel@linaro.org,
ardb@kernel.org, arve@android.com, hridya@google.com,
joel@joelfernandes.org, john.stultz@linaro.org,
kernel-team@android.com, linux-kselftest@vger.kernel.org,
maco@android.com, naresh.kamboju@linaro.org, shuah@kernel.org
Subject: [PATCH v2 1/3] binderfs: port tests to test harness infrastructure
Date: Fri, 13 Mar 2020 16:24:18 +0100 [thread overview]
Message-ID: <20200313152420.138777-1-christian.brauner@ubuntu.com> (raw)
In-Reply-To: <20200312131531.3615556-1-christian.brauner@ubuntu.com>
Makes for nicer output and prepares for additional tests.
Cc: Kees Cook <keescook@chromium.org>:
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
---
/* v2 */
- Kees Cook <keescook@chromium.org>:
- Switch to XFAIL() to skip tests.
---
.../selftests/filesystems/binderfs/Makefile | 2 ++
.../filesystems/binderfs/binderfs_test.c | 31 +++++++++----------
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/tools/testing/selftests/filesystems/binderfs/Makefile b/tools/testing/selftests/filesystems/binderfs/Makefile
index 58cb659b56b4..75315d9ba7a9 100644
--- a/tools/testing/selftests/filesystems/binderfs/Makefile
+++ b/tools/testing/selftests/filesystems/binderfs/Makefile
@@ -3,4 +3,6 @@
CFLAGS += -I../../../../../usr/include/
TEST_GEN_PROGS := binderfs_test
+binderfs_test: binderfs_test.c ../../kselftest.h ../../kselftest_harness.h
+
include ../../lib.mk
diff --git a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
index 8c2ed962e1c7..0cfca65e095a 100644
--- a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
+++ b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
@@ -15,7 +15,9 @@
#include <unistd.h>
#include <linux/android/binder.h>
#include <linux/android/binderfs.h>
+
#include "../../kselftest.h"
+#include "../../kselftest_harness.h"
static ssize_t write_nointr(int fd, const void *buf, size_t count)
{
@@ -132,7 +134,7 @@ static void rmdir_protect_errno(const char *dir)
errno = saved_errno;
}
-static void __do_binderfs_test(void)
+static int __do_binderfs_test(void)
{
int fd, ret, saved_errno;
size_t len;
@@ -160,8 +162,7 @@ static void __do_binderfs_test(void)
strerror(errno));
keep ? : rmdir_protect_errno("/dev/binderfs");
- ksft_exit_skip(
- "The Android binderfs filesystem is not available\n");
+ return 1;
}
/* binderfs mount test passed */
@@ -250,26 +251,24 @@ static void __do_binderfs_test(void)
/* binderfs unmount test passed */
ksft_inc_pass_cnt();
+ return 0;
}
-static void binderfs_test_privileged()
+TEST(binderfs_test_privileged)
{
if (geteuid() != 0)
- ksft_print_msg(
- "Tests are not run as root. Skipping privileged tests\n");
- else
- __do_binderfs_test();
+ XFAIL(return, "Tests are not run as root. Skipping privileged tests");
+
+ if (__do_binderfs_test() == 1)
+ XFAIL(return, "The Android binderfs filesystem is not available");
}
-static void binderfs_test_unprivileged()
+TEST(binderfs_test_unprivileged)
{
change_to_userns();
- __do_binderfs_test();
-}
-int main(int argc, char *argv[])
-{
- binderfs_test_privileged();
- binderfs_test_unprivileged();
- ksft_exit_pass();
+ if (__do_binderfs_test() == 1)
+ XFAIL(return, "The Android binderfs filesystem is not available");
}
+
+TEST_HARNESS_MAIN
base-commit: 2c523b344dfa65a3738e7039832044aa133c75fb
--
2.25.1
next prev parent reply other threads:[~2020-03-13 15:24 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-11 7:52 WARNING: at refcount.c:190 refcount_sub_and_test_checked+0xac/0xc8 - refcount_t: underflow; use-after-free Naresh Kamboju
2020-03-11 7:52 ` Naresh Kamboju
2020-03-11 9:13 ` Christian Brauner
2020-03-11 9:13 ` Christian Brauner
2020-03-11 10:53 ` [PATCH] binderfs: use refcount for binder control devices too Christian Brauner
2020-03-11 18:25 ` Todd Kjos
2020-03-12 13:15 ` [PATCH 1/3] binderfs: port tests to test harness infrastructure Christian Brauner
2020-03-12 13:15 ` [PATCH 2/3] binderfs: add stress test for binderfs binder devices Christian Brauner
2020-03-12 23:53 ` Kees Cook
2020-03-13 12:54 ` Christian Brauner
2020-03-12 13:15 ` [PATCH 3/3] binderfs_test: switch from /dev to /tmp as mountpoint Christian Brauner
2020-03-12 23:54 ` Kees Cook
2020-03-13 12:55 ` Christian Brauner
2020-03-12 21:24 ` [PATCH] binderfs: port to new mount api Christian Brauner
2020-03-12 23:56 ` Kees Cook
2020-03-13 12:55 ` Christian Brauner
2020-03-13 12:56 ` Christian Brauner
2020-03-12 23:51 ` [PATCH 1/3] binderfs: port tests to test harness infrastructure Kees Cook
2020-03-13 15:24 ` Christian Brauner [this message]
2020-03-13 15:24 ` [PATCH v2 2/3] binderfs_test: switch from /dev to a unique per-test mountpoint Christian Brauner
2020-03-13 23:07 ` Kees Cook
2020-03-13 15:24 ` [PATCH v2 3/3] binderfs: add stress test for binderfs binder devices Christian Brauner
2020-03-13 23:08 ` Kees Cook
2020-03-16 22:44 ` Hridya Valsaraju
2020-03-17 8:27 ` Christian Brauner
2020-03-13 23:07 ` [PATCH v2 1/3] binderfs: port tests to test harness infrastructure Kees Cook
2020-03-13 15:34 ` [PATCH v2] binderfs: port to new mount api Christian Brauner
2020-03-13 23:08 ` Kees Cook
2020-03-18 12:29 ` Greg KH
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=20200313152420.138777-1-christian.brauner@ubuntu.com \
--to=christian.brauner@ubuntu.com \
--cc=ard.biesheuvel@linaro.org \
--cc=ardb@kernel.org \
--cc=arve@android.com \
--cc=gregkh@linuxfoundation.org \
--cc=hridya@google.com \
--cc=joel@joelfernandes.org \
--cc=john.stultz@linaro.org \
--cc=keescook@chromium.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=maco@android.com \
--cc=naresh.kamboju@linaro.org \
--cc=shuah@kernel.org \
--cc=tkjos@android.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 NNTP newsgroup(s).