Skip to contentSkip to conversation

selftests: add binderfs selftests

PATCH In review Christian Brauner 2 participants 6 messages Jan 16, 2019 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: add binderfs selftests

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

---
 tools/testing/selftests/Makefile              |   1 +
 .../selftests/filesystems/binderfs/.gitignore |   1 +
 .../selftests/filesystems/binderfs/Makefile   |   6 +
 .../filesystems/binderfs/binderfs_test.c      | 120 ++++++++++++++++++
 .../selftests/filesystems/binderfs/config     |   3 +
 5 files changed, 131 insertions(+)
 create mode 100644 tools/testing/selftests/filesystems/binderfs/.gitignore
 create mode 100644 tools/testing/selftests/filesystems/binderfs/Makefile
 create mode 100644 tools/testing/selftests/filesystems/binderfs/binderfs_test.c
 create mode 100644 tools/testing/selftests/filesystems/binderfs/config
tools/testing/selftests/Makefile +1 -0
index 1a2bd15c5b6e..400ee81a3043 100644
@@ -10,6 +10,7 @@ TARGETS += drivers/dma-buf
 TARGETS += efivarfs
 TARGETS += exec
 TARGETS += filesystems
+TARGETS += filesystems/binderfs
 TARGETS += firmware
 TARGETS += ftrace
 TARGETS += futex
tools/testing/selftests/filesystems/binderfs/.gitignore new file +1 -0
new file mode 100644
index 000000000000..8a5d9bf63dd4
@@ -0,0 +1 @@
+binderfs_test
tools/testing/selftests/filesystems/binderfs/Makefile new file +6 -0
new file mode 100644
index 000000000000..58cb659b56b4
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+
+CFLAGS += -I../../../../../usr/include/
+TEST_GEN_PROGS := binderfs_test
+
+include ../../lib.mk
tools/testing/selftests/filesystems/binderfs/binderfs_test.c new file +120 -0

120 lines not on this page · raw message

tools/testing/selftests/filesystems/binderfs/config new file +3 -0
new file mode 100644
index 000000000000..02dd6cc9cf99
@@ -0,0 +1,3 @@
+CONFIG_ANDROID=y
+CONFIG_ANDROID_BINDERFS=y
+CONFIG_ANDROID_BINDER_IPC=y
Signature · 1 line
2.19.1
#1 lore raw
Quoted 95 lines · Christian Brauner

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

---
 tools/testing/selftests/Makefile              |   1 +
 .../selftests/filesystems/binderfs/.gitignore |   1 +
 .../selftests/filesystems/binderfs/Makefile   |   6 +
 .../filesystems/binderfs/binderfs_test.c      | 120 ++++++++++++++++++
 .../selftests/filesystems/binderfs/config     |   3 +
 5 files changed, 131 insertions(+)
 create mode 100644 tools/testing/selftests/filesystems/binderfs/.gitignore
 create mode 100644 tools/testing/selftests/filesystems/binderfs/Makefile
 create mode 100644 tools/testing/selftests/filesystems/binderfs/binderfs_test.c
 create mode 100644 tools/testing/selftests/filesystems/binderfs/config
tools/testing/selftests/Makefile +1 -0
index 1a2bd15c5b6e..400ee81a3043 100644
@@ -10,6 +10,7 @@ TARGETS += drivers/dma-buf
 TARGETS += efivarfs
 TARGETS += exec
 TARGETS += filesystems
+TARGETS += filesystems/binderfs
 TARGETS += firmware
 TARGETS += ftrace
 TARGETS += futex
tools/testing/selftests/filesystems/binderfs/.gitignore new file +1 -0
new file mode 100644
index 000000000000..8a5d9bf63dd4
@@ -0,0 +1 @@
+binderfs_test
tools/testing/selftests/filesystems/binderfs/Makefile new file +6 -0
new file mode 100644
index 000000000000..58cb659b56b4
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+
+CFLAGS += -I../../../../../usr/include/
+TEST_GEN_PROGS := binderfs_test
+
+include ../../lib.mk
tools/testing/selftests/filesystems/binderfs/binderfs_test.c new file +35 -0
new file mode 100644
index 000000000000..ca4d9b616e84
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/android/binder.h>
+#include <linux/android/binderfs.h>
+#include "../../kselftest.h"
+
+int main(int argc, char *argv[])
+{
+	int fd, ret, saved_errno;
+	size_t len;
+	struct binderfs_device device = { 0 };
+	struct binder_version version = { 0 };
+
+	ret = unshare(CLONE_NEWNS);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to unshare mount namespace\n",
+				   strerror(errno));
+
+	ret = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to mount / as private\n",
+				   strerror(errno));
+

tools/testing/selftests/filesystems/binderfs/binderfs_test.c line 45

Quoted 10 lines
tools/testing/selftests/filesystems/binderfs/binderfs_test.c new file +10 -0
+	ret = mkdir("/dev/binderfs", 0755);
+	if (ret < 0 && errno != EEXIST)
+		ksft_exit_fail_msg(
+			"%s - Failed to create binderfs mountpoint\n",
+			strerror(errno));
+
+	ret = mount(NULL, "/dev/binderfs", "binder", 0, 0);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to mount binderfs\n",
+				   strerror(errno));

Can you check first to see if the kernel under test really even has binderfs in it? If not, you need to just abort the test, not fail it, so as to allow newer versions of kselftests to run on older kernels.

thanks,

greg k-h

#2 lore raw
Quoted 112 lines · Greg KH
Quoted 1 line · Christian Brauner

This adds the promised selftest for binderfs. It will verify the

following

Quoted 8 lines

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

Quoted 7 lines
---
 tools/testing/selftests/Makefile              |   1 +
 .../selftests/filesystems/binderfs/.gitignore |   1 +
 .../selftests/filesystems/binderfs/Makefile   |   6 +
 .../filesystems/binderfs/binderfs_test.c      | 120

++++++++++++++++++

Quoted 3 lines
 .../selftests/filesystems/binderfs/config     |   3 +
 5 files changed, 131 insertions(+)
 create mode 100644

tools/testing/selftests/filesystems/binderfs/.gitignore

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/Makefile

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/binderfs_test.c

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/config

Review

Quoted 2 lines
(quoted diff) +0 -0

b/tools/testing/selftests/Makefile

Review

Quoted 12 lines

index 1a2bd15c5b6e..400ee81a3043 100644

tools/testing/selftests/Makefile +1 -0
@@ -10,6 +10,7 @@ TARGETS += drivers/dma-buf
 TARGETS += efivarfs
 TARGETS += exec
 TARGETS += filesystems
+TARGETS += filesystems/binderfs
 TARGETS += firmware
 TARGETS += ftrace
 TARGETS += futex
(quoted diff) +0 -0

b/tools/testing/selftests/filesystems/binderfs/.gitignore

Review

Quoted 7 lines

new file mode 100644
index 000000000000..8a5d9bf63dd4

tools/testing/selftests/filesystems/binderfs/.gitignore new file +1 -0
@@ -0,0 +1 @@
+binderfs_test
(quoted diff) +0 -0

b/tools/testing/selftests/filesystems/binderfs/Makefile

Quoted 11 lines

new file mode 100644
index 000000000000..58cb659b56b4

tools/testing/selftests/filesystems/binderfs/Makefile new file +6 -0
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+
+CFLAGS += -I../../../../../usr/include/
+TEST_GEN_PROGS := binderfs_test
+
+include ../../lib.mk
Quoted 1 line

diff --git

a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c

Quoted 45 lines

new file mode 100644
index 000000000000..ca4d9b616e84

tools/testing/selftests/filesystems/binderfs/binderfs_test.c new file +40 -0
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/android/binder.h>
+#include <linux/android/binderfs.h>
+#include "../../kselftest.h"
+
+int main(int argc, char *argv[])
+{
+	int fd, ret, saved_errno;
+	size_t len;
+	struct binderfs_device device = { 0 };
+	struct binder_version version = { 0 };
+
+	ret = unshare(CLONE_NEWNS);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to unshare mount namespace\n",
+				   strerror(errno));
+
+	ret = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to mount / as private\n",
+				   strerror(errno));
+
+	ret = mkdir("/dev/binderfs", 0755);
+	if (ret < 0 && errno != EEXIST)
+		ksft_exit_fail_msg(
+			"%s - Failed to create binderfs mountpoint\n",
+			strerror(errno));
Quoted 8 lines

tools/testing/selftests/filesystems/binderfs/binderfs_test.c line 45

Quoted 5 lines
tools/testing/selftests/filesystems/binderfs/binderfs_test.c new file +5 -0
+
+	ret = mount(NULL, "/dev/binderfs", "binder", 0, 0);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to mount binderfs\n",
+				   strerror(errno));

Can you check first to see if the kernel under test really even has binderfs in it? If not, you need to just

Hm, I thought that's what the "config" file was for? E.g. a conditional compile or is this just a hint to the user what's needed to run the test?

Thanks!
Christian

Christian

abort the test, not fail it,

Quoted 5 lines

so as to allow newer versions of kselftests to run on older kernels.

thanks,

greg k-h

#3 lore raw
Quoted 122 lines · Christian Brauner
Quoted 112 lines · Greg KH
Quoted 1 line · Christian Brauner

This adds the promised selftest for binderfs. It will verify the

following

Quoted 8 lines

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

Quoted 7 lines
---
 tools/testing/selftests/Makefile              |   1 +
 .../selftests/filesystems/binderfs/.gitignore |   1 +
 .../selftests/filesystems/binderfs/Makefile   |   6 +
 .../filesystems/binderfs/binderfs_test.c      | 120

++++++++++++++++++

Quoted 3 lines
 .../selftests/filesystems/binderfs/config     |   3 +
 5 files changed, 131 insertions(+)
 create mode 100644

tools/testing/selftests/filesystems/binderfs/.gitignore

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/Makefile

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/binderfs_test.c

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/config

Review

Quoted 2 lines
(quoted diff) +0 -0

b/tools/testing/selftests/Makefile

Review

Quoted 12 lines

index 1a2bd15c5b6e..400ee81a3043 100644

tools/testing/selftests/Makefile +1 -0
@@ -10,6 +10,7 @@ TARGETS += drivers/dma-buf
 TARGETS += efivarfs
 TARGETS += exec
 TARGETS += filesystems
+TARGETS += filesystems/binderfs
 TARGETS += firmware
 TARGETS += ftrace
 TARGETS += futex
(quoted diff) +0 -0

b/tools/testing/selftests/filesystems/binderfs/.gitignore

Review

Quoted 7 lines

new file mode 100644
index 000000000000..8a5d9bf63dd4

tools/testing/selftests/filesystems/binderfs/.gitignore new file +1 -0
@@ -0,0 +1 @@
+binderfs_test
(quoted diff) +0 -0

b/tools/testing/selftests/filesystems/binderfs/Makefile

Quoted 11 lines

new file mode 100644
index 000000000000..58cb659b56b4

tools/testing/selftests/filesystems/binderfs/Makefile new file +6 -0
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+
+CFLAGS += -I../../../../../usr/include/
+TEST_GEN_PROGS := binderfs_test
+
+include ../../lib.mk
Quoted 1 line

diff --git

a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c

Quoted 45 lines

new file mode 100644
index 000000000000..ca4d9b616e84

tools/testing/selftests/filesystems/binderfs/binderfs_test.c new file +40 -0
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/android/binder.h>
+#include <linux/android/binderfs.h>
+#include "../../kselftest.h"
+
+int main(int argc, char *argv[])
+{
+	int fd, ret, saved_errno;
+	size_t len;
+	struct binderfs_device device = { 0 };
+	struct binder_version version = { 0 };
+
+	ret = unshare(CLONE_NEWNS);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to unshare mount namespace\n",
+				   strerror(errno));
+
+	ret = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to mount / as private\n",
+				   strerror(errno));
+
+	ret = mkdir("/dev/binderfs", 0755);
+	if (ret < 0 && errno != EEXIST)
+		ksft_exit_fail_msg(
+			"%s - Failed to create binderfs mountpoint\n",
+			strerror(errno));
Quoted 8 lines

tools/testing/selftests/filesystems/binderfs/binderfs_test.c line 45

Quoted 5 lines
tools/testing/selftests/filesystems/binderfs/binderfs_test.c new file +5 -0
+
+	ret = mount(NULL, "/dev/binderfs", "binder", 0, 0);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to mount binderfs\n",
+				   strerror(errno));

Can you check first to see if the kernel under test really even has binderfs in it? If not, you need to just

Quoted 3 lines

Hm, I thought that's what the "config" file was for? E.g. a conditional compile or is this just a hint to the user what's needed to run the test?

I do not know. What happens if you try to run this test on a kernel without that config option? Does it not work as the framework correctly detects this?

And new kernel self tests should cc: the ksefltest mailing list and the maintainer of that subsystem so that they can review the test for things like this.

thanks,

greg k-h

#4 lore raw
Quoted 126 lines · Greg KH
Quoted 1 line · Christian Brauner

On January 16, 2019 5:54:50 PM GMT+02:00, Greg KH

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines · Christian Brauner
Quoted 1 line

This adds the promised selftest for binderfs. It will verify the

following

Quoted 4 lines

things:
- binderfs mounting works
- binder device allocation works
- performing a binder ioctl() request through a binderfs device

works

Quoted 25 lines
Quoted 25 lines
Quoted 11 lines

- binder device removal works
- binder-control removal fails
- binderfs unmounting works

---
 tools/testing/selftests/Makefile              |   1 +
 .../selftests/filesystems/binderfs/.gitignore |   1 +
 .../selftests/filesystems/binderfs/Makefile   |   6 +
 .../filesystems/binderfs/binderfs_test.c      | 120

++++++++++++++++++

Quoted 3 lines
 .../selftests/filesystems/binderfs/config     |   3 +
 5 files changed, 131 insertions(+)
 create mode 100644

tools/testing/selftests/filesystems/binderfs/.gitignore

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/Makefile

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/binderfs_test.c

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/config

Review

Quoted 2 lines
(quoted diff) +0 -0

b/tools/testing/selftests/Makefile

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines

index 1a2bd15c5b6e..400ee81a3043 100644

tools/testing/selftests/Makefile +0 -0
@@ -10,6 +10,7 @@ TARGETS += drivers/dma-buf
Quoted 8 lines
Quoted 8 lines
tools/testing/selftests/Makefile +1 -0
 TARGETS += efivarfs
 TARGETS += exec
 TARGETS += filesystems
+TARGETS += filesystems/binderfs
 TARGETS += firmware
 TARGETS += ftrace
 TARGETS += futex

diff --git

a/tools/testing/selftests/filesystems/binderfs/.gitignore

Quoted 77 lines
Quoted 76 lines

b/tools/testing/selftests/filesystems/binderfs/.gitignore

Review

Quoted 7 lines

new file mode 100644
index 000000000000..8a5d9bf63dd4

tools/testing/selftests/filesystems/binderfs/.gitignore new file +1 -0
@@ -0,0 +1 @@
+binderfs_test
(quoted diff) +0 -0

b/tools/testing/selftests/filesystems/binderfs/Makefile

Quoted 11 lines

new file mode 100644
index 000000000000..58cb659b56b4

tools/testing/selftests/filesystems/binderfs/Makefile new file +6 -0
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+
+CFLAGS += -I../../../../../usr/include/
+TEST_GEN_PROGS := binderfs_test
+
+include ../../lib.mk
Quoted 1 line

diff --git

a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c

Quoted 40 lines

new file mode 100644
index 000000000000..ca4d9b616e84

tools/testing/selftests/filesystems/binderfs/binderfs_test.c new file +35 -0
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/android/binder.h>
+#include <linux/android/binderfs.h>
+#include "../../kselftest.h"
+
+int main(int argc, char *argv[])
+{
+	int fd, ret, saved_errno;
+	size_t len;
+	struct binderfs_device device = { 0 };
+	struct binder_version version = { 0 };
+
+	ret = unshare(CLONE_NEWNS);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to unshare mount namespace\n",
+				   strerror(errno));
+
+	ret = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to mount / as private\n",
+				   strerror(errno));
+

tools/testing/selftests/filesystems/binderfs/binderfs_test.c line 45

Quoted 10 lines
tools/testing/selftests/filesystems/binderfs/binderfs_test.c new file +10 -0
+	ret = mkdir("/dev/binderfs", 0755);
+	if (ret < 0 && errno != EEXIST)
+		ksft_exit_fail_msg(
+			"%s - Failed to create binderfs mountpoint\n",
+			strerror(errno));
+
+	ret = mount(NULL, "/dev/binderfs", "binder", 0, 0);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to mount binderfs\n",
+				   strerror(errno));

Can you check first to see if the kernel under test really even has binderfs in it? If not, you need to just

Quoted 8 lines
Quoted 3 lines

Hm, I thought that's what the "config" file was for? E.g. a conditional compile or is this just a hint to the user what's needed to run the test?

I do not know. What happens if you try to run this test on a kernel without that config option? Does it not work as the framework correctly
detects this?

I did test and it worked fine but let me check by setting up a clean vm and retry.

Quoted 5 lines

And new kernel self tests should cc: the ksefltest mailing list and the maintainer of that subsystem so that they can review the test for things
like this.

Thanks, missed them in my Cc list.

Christian

#5 lore raw
Quoted 131 lines · Christian Brauner
Quoted 130 lines · Greg KH
Quoted 1 line · Christian Brauner

On January 16, 2019 5:54:50 PM GMT+02:00, Greg KH

Quoted 7 lines · <[email protected]> wrote:
Quoted 7 lines · Christian Brauner
Quoted 1 line

This adds the promised selftest for binderfs. It will verify the

following

Quoted 4 lines

things:
- binderfs mounting works
- binder device allocation works
- performing a binder ioctl() request through a binderfs device

works

Quoted 25 lines
Quoted 25 lines
Quoted 11 lines

- binder device removal works
- binder-control removal fails
- binderfs unmounting works

---
 tools/testing/selftests/Makefile              |   1 +
 .../selftests/filesystems/binderfs/.gitignore |   1 +
 .../selftests/filesystems/binderfs/Makefile   |   6 +
 .../filesystems/binderfs/binderfs_test.c      | 120

++++++++++++++++++

Quoted 3 lines
 .../selftests/filesystems/binderfs/config     |   3 +
 5 files changed, 131 insertions(+)
 create mode 100644

tools/testing/selftests/filesystems/binderfs/.gitignore

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/Makefile

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/binderfs_test.c

Quoted 1 line
 create mode 100644

tools/testing/selftests/filesystems/binderfs/config

Review

Quoted 2 lines
(quoted diff) +0 -0

b/tools/testing/selftests/Makefile

Quoted 12 lines
Quoted 4 lines
Quoted 4 lines

index 1a2bd15c5b6e..400ee81a3043 100644

tools/testing/selftests/Makefile +0 -0
@@ -10,6 +10,7 @@ TARGETS += drivers/dma-buf
Quoted 8 lines
Quoted 8 lines
tools/testing/selftests/Makefile +1 -0
 TARGETS += efivarfs
 TARGETS += exec
 TARGETS += filesystems
+TARGETS += filesystems/binderfs
 TARGETS += firmware
 TARGETS += ftrace
 TARGETS += futex

diff --git

a/tools/testing/selftests/filesystems/binderfs/.gitignore

Quoted 80 lines
Quoted 68 lines

b/tools/testing/selftests/filesystems/binderfs/.gitignore

Review

Quoted 7 lines

new file mode 100644
index 000000000000..8a5d9bf63dd4

tools/testing/selftests/filesystems/binderfs/.gitignore new file +1 -0
@@ -0,0 +1 @@
+binderfs_test
(quoted diff) +0 -0

b/tools/testing/selftests/filesystems/binderfs/Makefile

Quoted 11 lines

new file mode 100644
index 000000000000..58cb659b56b4

tools/testing/selftests/filesystems/binderfs/Makefile new file +6 -0
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+
+CFLAGS += -I../../../../../usr/include/
+TEST_GEN_PROGS := binderfs_test
+
+include ../../lib.mk
Quoted 1 line

diff --git

a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c

Quoted 45 lines

new file mode 100644
index 000000000000..ca4d9b616e84

tools/testing/selftests/filesystems/binderfs/binderfs_test.c new file +40 -0
@@ -0,0 +1,120 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#define _GNU_SOURCE
+#include <errno.h>
+#include <fcntl.h>
+#include <sched.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <linux/android/binder.h>
+#include <linux/android/binderfs.h>
+#include "../../kselftest.h"
+
+int main(int argc, char *argv[])
+{
+	int fd, ret, saved_errno;
+	size_t len;
+	struct binderfs_device device = { 0 };
+	struct binder_version version = { 0 };
+
+	ret = unshare(CLONE_NEWNS);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to unshare mount namespace\n",
+				   strerror(errno));
+
+	ret = mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to mount / as private\n",
+				   strerror(errno));
+
+	ret = mkdir("/dev/binderfs", 0755);
+	if (ret < 0 && errno != EEXIST)
+		ksft_exit_fail_msg(
+			"%s - Failed to create binderfs mountpoint\n",
+			strerror(errno));
Quoted 8 lines

tools/testing/selftests/filesystems/binderfs/binderfs_test.c line 45

Quoted 5 lines
tools/testing/selftests/filesystems/binderfs/binderfs_test.c new file +5 -0
+
+	ret = mount(NULL, "/dev/binderfs", "binder", 0, 0);
+	if (ret < 0)
+		ksft_exit_fail_msg("%s - Failed to mount binderfs\n",
+				   strerror(errno));

Can you check first to see if the kernel under test really even has binderfs in it? If not, you need to just

Hm, I thought that's what the "config" file was for? E.g. a conditional compile or is this just a hint to the user what's needed to run the test?

Quoted 6 lines
Quoted 4 lines

I do not know. What happens if you try to run this test on a kernel without that config option? Does it not work as the framework correctly
detects this?

I did test and it worked fine but let me check by setting up a clean vm and retry.

The compile always happens and always succeeds but the test will fail if run on a kernel that does not have binderfs. So the mount() call should check for ret == ENODEV and then exit with skip.

Thanks!
Christian