BACKPORT: selftests/binderfs: add test for feature files
Verify that feature files are created successfully after mounting a binderfs instance. Note that only "oneway_spam_detection" feature is tested with this patch as it is currently the only feature listed. Acked-by: Christian Brauner <christian.brauner@ubuntu.com> Signed-off-by: Carlos Llamas <cmllamas@google.com> Link: https://lore.kernel.org/r/20210715031805.1725878-3-cmllamas@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 07e913418ce4ba5eb620dd4668bf91ec94e11136) Bug: 191910201 Signed-off-by: Carlos Llamas <cmllamas@google.com> [cmllamas: fix merge issues due to missing eaa163caa4cc] Change-Id: I86d7ef34b3099c8714c319e48029aaf3dbf87081
This commit is contained in:
parent
4d4f8b7a7f
commit
8c4165a043
1 changed files with 22 additions and 0 deletions
|
|
@ -17,6 +17,10 @@
|
|||
#include <linux/android/binderfs.h>
|
||||
#include "../../kselftest.h"
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
#endif
|
||||
|
||||
static ssize_t write_nointr(int fd, const void *buf, size_t count)
|
||||
{
|
||||
ssize_t ret;
|
||||
|
|
@ -140,6 +144,10 @@ static void __do_binderfs_test(void)
|
|||
bool keep = false;
|
||||
struct binderfs_device device = { 0 };
|
||||
struct binder_version version = { 0 };
|
||||
char device_path[sizeof("/dev/binderfs/") + BINDERFS_MAX_NAME];
|
||||
static const char * const binder_features[] = {
|
||||
"oneway_spam_detection",
|
||||
};
|
||||
|
||||
change_to_mountns();
|
||||
|
||||
|
|
@ -241,6 +249,20 @@ static void __do_binderfs_test(void)
|
|||
/* binder-control device removal failed as expected */
|
||||
ksft_inc_xfail_cnt();
|
||||
|
||||
for (int i = 0; i < ARRAY_SIZE(binder_features); i++) {
|
||||
snprintf(device_path, sizeof(device_path),
|
||||
"/dev/binderfs/features/%s", binder_features[i]);
|
||||
fd = open(device_path, O_CLOEXEC | O_RDONLY);
|
||||
if (fd < 0) {
|
||||
ksft_exit_fail_msg("%s - Failed to open binder feature: %s",
|
||||
strerror(errno), binder_features[i]);
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
/* success: binder feature files found */
|
||||
ksft_inc_pass_cnt();
|
||||
|
||||
on_error:
|
||||
ret = umount2("/dev/binderfs", MNT_DETACH);
|
||||
keep ?: rmdir_protect_errno("/dev/binderfs");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue