From dc77e459601de7ee83aef38085877e33bb543968 Mon Sep 17 00:00:00 2001 From: Wendy Liang Date: Fri, 22 Feb 2019 17:46:57 -0800 Subject: [PATCH] test: linux: shmem: line up with shmem API change Update Linux shmem test due to shmem API changes. Signed-off-by: Wendy Liang --- test/system/linux/shmem.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/test/system/linux/shmem.c b/test/system/linux/shmem.c index cb9f91b6..9f801c21 100644 --- a/test/system/linux/shmem.c +++ b/test/system/linux/shmem.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -20,20 +21,28 @@ static void *shmem_child(void *arg) const char *name = arg; struct { metal_mutex_t mutex; - int counter; + int counter; } *virt; + struct metal_generic_shmem *shm; struct metal_io_region *io; + struct metal_scatter_list *sg; unsigned long phys; size_t size = 2 * 1024 * 1024; int error; - error = metal_shmem_open(name, size, &io); + error = metal_shmem_open(name, size, 0, &shm); if (error) { metal_log(METAL_LOG_ERROR, "Failed shmem_open: %d.\n", error); atomic_fetch_add(&nb_err, 1); return NULL; } - + sg = metal_shmem_mmap(shm, size); + if (sg == NULL) { + metal_log(METAL_LOG_ERROR, "Failed to shmem_mmap %s, %s.\n", + shm->name, name); + return NULL; + } + (void)metal_scatterlist_get_ios(sg, &io); virt = metal_io_virt(io, 0); phys = metal_io_phys(io, 0); if (phys != METAL_BAD_OFFSET) { @@ -48,12 +57,14 @@ static void *shmem_child(void *arg) } metal_io_finish(io); + metal_shmem_munmap(shm, sg); + metal_shmem_close(shm); return NULL; } static int shmem(void) { - return atomic_load(&nb_err) || metal_run(shmem_threads, shmem_child, "/foo"); + return atomic_load(&nb_err) || metal_run(shmem_threads, shmem_child, "linux_shm/foo"); } METAL_ADD_TEST(shmem);