Signed-off-by: Bijan Mottahedeh <bijan.mottahedeh@xxxxxxxxxx> --- test/buffer-share.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/test/buffer-share.c b/test/buffer-share.c index 81e0537..cbfbfb2 100644 --- a/test/buffer-share.c +++ b/test/buffer-share.c @@ -18,6 +18,7 @@ #include <unistd.h> #include <string.h> #include <linux/fs.h> +#include <malloc.h> #include "liburing.h" @@ -71,7 +72,8 @@ unsigned long shm_sz = SZ_2M; int no_read; int warned; -int verbose = 0; +int private; +int verbose; enum { REG_NOP = 0, @@ -1120,8 +1122,11 @@ main(int argc, char *argv[]) int shmid, pid, ret = 0; char c; - while ((c = getopt(argc, argv, "s:v:")) != -1) + while ((c = getopt(argc, argv, "ps:v:")) != -1) switch (c) { + case 'p': + private++; + break; case 's': shm_sz = atoi(optarg) * SZ_2M; break; @@ -1155,10 +1160,19 @@ main(int argc, char *argv[]) if (shmid < 0) exit(1); - shmbuf = shm_attach(shmid); - if (shmbuf == MAP_FAILED) { - shm_destroy(shmid, shmbuf); - exit(1); + if (private) { + printf("private\n"); + shmbuf = memalign(4096, shm_sz); + if (shmbuf == NULL) { + perror("memalign"); + exit(1); + } + } else { + shmbuf = shm_attach(shmid); + if (shmbuf == MAP_FAILED) { + shm_destroy(shmid, shmbuf); + exit(1); + } } create_buffers(shmbuf); @@ -1178,7 +1192,8 @@ main(int argc, char *argv[]) ret |= test(TEST_IO, FD, REG_NOP, REG_ATT, TEST_DFLT, EFAULT); ret |= test(TEST_IO, FD, REG_PIN, REG_ATT, TEST_EXIT, NONE); - shm_destroy(shmid, shmbuf); + if (!private) + shm_destroy(shmid, shmbuf); return ret; } -- 1.8.3.1