Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Carlos Llamas and committed by
Greg Kroah-Hartman
07e91341 06e1721d

+17
+17
tools/testing/selftests/filesystems/binderfs/binderfs_test.c
··· 62 62 struct binder_version version = { 0 }; 63 63 char binderfs_mntpt[] = P_tmpdir "/binderfs_XXXXXX", 64 64 device_path[sizeof(P_tmpdir "/binderfs_XXXXXX/") + BINDERFS_MAX_NAME]; 65 + static const char * const binder_features[] = { 66 + "oneway_spam_detection", 67 + }; 65 68 66 69 change_mountns(_metadata); 67 70 ··· 153 150 } 154 151 155 152 /* success: binder-control device removal failed as expected */ 153 + 154 + for (int i = 0; i < ARRAY_SIZE(binder_features); i++) { 155 + snprintf(device_path, sizeof(device_path), "%s/features/%s", 156 + binderfs_mntpt, binder_features[i]); 157 + fd = open(device_path, O_CLOEXEC | O_RDONLY); 158 + EXPECT_GE(fd, 0) { 159 + TH_LOG("%s - Failed to open binder feature: %s", 160 + strerror(errno), binder_features[i]); 161 + goto umount; 162 + } 163 + close(fd); 164 + } 165 + 166 + /* success: binder feature files found */ 156 167 result = 0; 157 168 158 169 umount: