|
15 | 15 | #include <unistd.h> |
16 | 16 | #include <linux/android/binder.h> |
17 | 17 | #include <linux/android/binderfs.h> |
| 18 | + |
18 | 19 | #include "../../kselftest.h" |
| 20 | +#include "../../kselftest_harness.h" |
19 | 21 |
|
20 | 22 | static ssize_t write_nointr(int fd, const void *buf, size_t count) |
21 | 23 | { |
@@ -132,7 +134,7 @@ static void rmdir_protect_errno(const char *dir) |
132 | 134 | errno = saved_errno; |
133 | 135 | } |
134 | 136 |
|
135 | | -static void __do_binderfs_test(void) |
| 137 | +static int __do_binderfs_test(void) |
136 | 138 | { |
137 | 139 | int fd, ret, saved_errno; |
138 | 140 | size_t len; |
@@ -160,8 +162,7 @@ static void __do_binderfs_test(void) |
160 | 162 | strerror(errno)); |
161 | 163 |
|
162 | 164 | keep ? : rmdir_protect_errno("/dev/binderfs"); |
163 | | - ksft_exit_skip( |
164 | | - "The Android binderfs filesystem is not available\n"); |
| 165 | + return 1; |
165 | 166 | } |
166 | 167 |
|
167 | 168 | /* binderfs mount test passed */ |
@@ -250,26 +251,24 @@ static void __do_binderfs_test(void) |
250 | 251 |
|
251 | 252 | /* binderfs unmount test passed */ |
252 | 253 | ksft_inc_pass_cnt(); |
| 254 | + return 0; |
253 | 255 | } |
254 | 256 |
|
255 | | -static void binderfs_test_privileged() |
| 257 | +TEST(binderfs_test_privileged) |
256 | 258 | { |
257 | 259 | 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"); |
262 | 264 | } |
263 | 265 |
|
264 | | -static void binderfs_test_unprivileged() |
| 266 | +TEST(binderfs_test_unprivileged) |
265 | 267 | { |
266 | 268 | change_to_userns(); |
267 | | - __do_binderfs_test(); |
268 | | -} |
269 | 269 |
|
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"); |
275 | 272 | } |
| 273 | + |
| 274 | +TEST_HARNESS_MAIN |
0 commit comments