Skip to content

Commit

Permalink
test: linux: shmem: line up with shmem API change
Browse files Browse the repository at this point in the history
Update Linux shmem test due to shmem API changes.

Signed-off-by: Wendy Liang <wendy.liang@xilinx.com>
  • Loading branch information
Wendy Liang committed Mar 6, 2019
1 parent 06f2ac4 commit dc77e45
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions test/system/linux/shmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <metal/log.h>
#include <metal/mutex.h>
#include <metal/shmem.h>
#include <metal/scatterlist.h>
#include <metal/sys.h>
#include <metal/atomic.h>

Expand All @@ -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) {
Expand All @@ -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);

0 comments on commit dc77e45

Please sign in to comment.