Skip to content

Commit 6e29225

Browse files
Christian Braunergregkh
authored andcommitted
binderfs: port tests to test harness infrastructure
Makes for nicer output and prepares for additional tests. Signed-off-by: Christian Brauner <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 095cf50 commit 6e29225

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

tools/testing/selftests/filesystems/binderfs/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
CFLAGS += -I../../../../../usr/include/
44
TEST_GEN_PROGS := binderfs_test
55

6+
binderfs_test: binderfs_test.c ../../kselftest.h ../../kselftest_harness.h
7+
68
include ../../lib.mk

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
#include <unistd.h>
1616
#include <linux/android/binder.h>
1717
#include <linux/android/binderfs.h>
18+
1819
#include "../../kselftest.h"
20+
#include "../../kselftest_harness.h"
1921

2022
static ssize_t write_nointr(int fd, const void *buf, size_t count)
2123
{
@@ -132,7 +134,7 @@ static void rmdir_protect_errno(const char *dir)
132134
errno = saved_errno;
133135
}
134136

135-
static void __do_binderfs_test(void)
137+
static int __do_binderfs_test(void)
136138
{
137139
int fd, ret, saved_errno;
138140
size_t len;
@@ -160,8 +162,7 @@ static void __do_binderfs_test(void)
160162
strerror(errno));
161163

162164
keep ? : rmdir_protect_errno("/dev/binderfs");
163-
ksft_exit_skip(
164-
"The Android binderfs filesystem is not available\n");
165+
return 1;
165166
}
166167

167168
/* binderfs mount test passed */
@@ -250,26 +251,24 @@ static void __do_binderfs_test(void)
250251

251252
/* binderfs unmount test passed */
252253
ksft_inc_pass_cnt();
254+
return 0;
253255
}
254256

255-
static void binderfs_test_privileged()
257+
TEST(binderfs_test_privileged)
256258
{
257259
if (geteuid() != 0)
258-
ksft_print_msg(
259-
"Tests are not run as root. Skipping privileged tests\n");
260-
else
261-
__do_binderfs_test();
260+
XFAIL(return, "Tests are not run as root. Skipping privileged tests");
261+
262+
if (__do_binderfs_test() == 1)
263+
XFAIL(return, "The Android binderfs filesystem is not available");
262264
}
263265

264-
static void binderfs_test_unprivileged()
266+
TEST(binderfs_test_unprivileged)
265267
{
266268
change_to_userns();
267-
__do_binderfs_test();
268-
}
269269

270-
int main(int argc, char *argv[])
271-
{
272-
binderfs_test_privileged();
273-
binderfs_test_unprivileged();
274-
ksft_exit_pass();
270+
if (__do_binderfs_test() == 1)
271+
XFAIL(return, "The Android binderfs filesystem is not available");
275272
}
273+
274+
TEST_HARNESS_MAIN

0 commit comments

Comments
 (0)