summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJeremy Cline <jcline@redhat.com>2019-12-04 13:51:47 -0500
committerJeremy Cline <jcline@redhat.com>2019-12-04 13:51:47 -0500
commit983730bdf1b2b5cae0e755b4c81bf96a9c3bc154 (patch)
tree011d4ee68ffdc781a28452e7357a9daeb77f7021 /tests
parent83d43d8b120aadf1f5c57ef66388992b5d1a83f4 (diff)
downloadkernel-983730bdf1b2b5cae0e755b4c81bf96a9c3bc154.tar.gz
kernel-983730bdf1b2b5cae0e755b4c81bf96a9c3bc154.tar.xz
kernel-983730bdf1b2b5cae0e755b4c81bf96a9c3bc154.zip
Sync up tests with v5.4
Diffstat (limited to 'tests')
-rwxr-xr-xtests/memory/memfd_create/runtest.sh7
-rw-r--r--tests/memory/memfd_create/t_get_seals.c3
-rw-r--r--tests/memory/memfd_create/t_memfd_create.c18
3 files changed, 17 insertions, 11 deletions
diff --git a/tests/memory/memfd_create/runtest.sh b/tests/memory/memfd_create/runtest.sh
index 24dfeb5b6..880c3096e 100755
--- a/tests/memory/memfd_create/runtest.sh
+++ b/tests/memory/memfd_create/runtest.sh
@@ -38,11 +38,12 @@ fi
function sanity_memfd_create()
{
- rlRun "./t_memfd_create memf 1024 gswS &"
- rlRun "./t_get_seals /proc/$!/fd/3 > seals"
+ rlRun "coproc ./t_memfd_create memf 1024 gswS"
+ rlRun "read -u ${COPROC[0]} MEMFD_PATH"
+ rlRun "./t_get_seals $MEMFD_PATH > ./seals"
rlRun "cat ./seals"
rlAssertGrep "SEAL GROW WRITE SHRINK" ./seals
- rlRun "pkill t_memfd_create"
+ rlRun "kill $COPROC_PID"
}
diff --git a/tests/memory/memfd_create/t_get_seals.c b/tests/memory/memfd_create/t_get_seals.c
index 8babe34d2..1a2c900e0 100644
--- a/tests/memory/memfd_create/t_get_seals.c
+++ b/tests/memory/memfd_create/t_get_seals.c
@@ -16,8 +16,9 @@
*
*/
-#include <linux/fcntl.h>
+#define _GNU_SOURCE
#include <unistd.h>
+#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
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 */