ANDROID: selftests/wrapfd: Strengthen fork() tests The fork test simply invokes wait() without checking the syscall's error code, as well as confirming that the child process did indeed terminate normally and successfully. Add assertions to confirm all of that. While we're here, remove the FDINFO_BUF_SIZE constant from the wrapfd driver, since it is unused. Bug: 480234490 Change-Id: Icc4dfb562b64038d13cdb6561f60ffbfb9ed5e51 Signed-off-by: Isaac J. Manjarres <isaacmanjarres@google.com>
diff --git a/drivers/android/wrapfd.c b/drivers/android/wrapfd.c index 85613cc..f2208c7 100644 --- a/drivers/android/wrapfd.c +++ b/drivers/android/wrapfd.c
@@ -24,9 +24,6 @@ #include <linux/wrapfd.h> #include <uapi/linux/wrapfd.h> - -#define FDINFO_BUF_SIZE 100 - struct wrap_ctx; struct wrap_content; static const struct file_operations wrap_fops;
diff --git a/tools/testing/selftests/drivers/wrapfd/wrapfd.c b/tools/testing/selftests/drivers/wrapfd/wrapfd.c index a37a874..549f5e5 100644 --- a/tools/testing/selftests/drivers/wrapfd/wrapfd.c +++ b/tools/testing/selftests/drivers/wrapfd/wrapfd.c
@@ -364,7 +364,7 @@ static void test_wrap_remap(struct __test_metadata *_metadata, static void test_wrap_fork(struct __test_metadata *_metadata, FIXTURE_DATA(wrapfd_tests) *self, int fd) { - int wrapfd; + int wrapfd, status; char *ptr; pid_t pid; @@ -386,7 +386,9 @@ static void test_wrap_fork(struct __test_metadata *_metadata, ASSERT_EQ(memcmp(self->content, ptr, self->size), 0); exit(EXIT_SUCCESS); } else { - wait(NULL); + ASSERT_NE(wait(&status), -1); + ASSERT_TRUE(WIFEXITED(status)); + ASSERT_EQ(WEXITSTATUS(status), 0); } ASSERT_EQ(munmap(ptr, self->size), 0);