diff options
author | David Ward <david.ward@ll.mit.edu> | 2019-11-11 14:06:01 -0500 |
---|---|---|
committer | David Ward <david.ward@ll.mit.edu> | 2019-11-11 14:06:01 -0500 |
commit | bee04eadf8306be0349b9f75559a1fea80591d7f (patch) | |
tree | cfe6131460910719fab342b0c9e20076d7217d4f /tests/memory/memfd_create/t_memfd_create.c | |
parent | a86513b40ec92203cf73c27feed0f4045db15634 (diff) | |
download | kernel-bee04eadf8306be0349b9f75559a1fea80591d7f.tar.gz kernel-bee04eadf8306be0349b9f75559a1fea80591d7f.tar.xz kernel-bee04eadf8306be0349b9f75559a1fea80591d7f.zip |
Fix existing CI test for memfd_create()
The test was failing (after hanging for several hours) because of a
hard-coded assumption about which file descriptor would be returned
by memfd_create(). The actual file descriptor gets printed by the
test program though, so read this and use it instead. (Adjust the
test program so that this is not printed until the file is ready.)
Resolve compiler warnings about implicit function declarations, by
using the #include statements listed in the kernel.org man-pages.
Diffstat (limited to 'tests/memory/memfd_create/t_memfd_create.c')
-rw-r--r-- | tests/memory/memfd_create/t_memfd_create.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/memory/memfd_create/t_memfd_create.c b/tests/memory/memfd_create/t_memfd_create.c index 73d641a6e..4250d7174 100644 --- a/tests/memory/memfd_create/t_memfd_create.c +++ b/tests/memory/memfd_create/t_memfd_create.c @@ -16,11 +16,12 @@ * */ -#include <linux/memfd.h> -#include <linux/fcntl.h> +#define _GNU_SOURCE +#include <unistd.h> +#include <fcntl.h> +#include <sys/mman.h> #include <sys/syscall.h> #include <stdlib.h> -#include <unistd.h> #include <string.h> #include <stdio.h> @@ -66,10 +67,6 @@ int main(int argc, char *argv[]) if (write(fd, message, strlen(message)) <= 0) errExit("write"); - //printf("PID: %ld; fd: %d; /proc/%ld/fd/%d\n", - // (long) getpid(), fd, (long) getpid(), fd); - printf("/proc/%ld/fd/%d\n", (long) getpid(), fd); - /* Code to map the file and populate the mapping with data omitted */ @@ -92,6 +89,13 @@ int main(int argc, char *argv[]) errExit("fcntl"); } + /* Output the pathname of (a symbolic link to) the file + created by memfd_create() */ + + printf("/proc/%ld/fd/%d\n", (long) getpid(), fd); + + fflush(stdout); + /* Keep running, so that the file created by memfd_create() continues to exist */ |