2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
11 #include <sys/types.h>
15 #include "../../../src/libringbuffer/shm.h"
16 #include "ust-compat.h"
20 #define SHM_PATH "/ust-shm-test"
25 size_t shmsize
= LTTNG_UST_PAGE_SIZE
* 10;
26 struct shm_object_table
*table
;
27 struct shm_object
*shmobj
;
28 struct shm_ref shm_ref
;
32 /* Open a zero byte shm fd */
33 shmfd
= shm_open(SHM_PATH
, O_RDWR
| O_CREAT
, S_IRUSR
| S_IWUSR
);
34 ok(shmfd
> 0, "Open a POSIX shm fd");
36 /* Create a dummy shm object table to test the allocation function */
37 table
= shm_object_table_create(1);
38 ok(table
, "Create a shm object table");
41 /* This function sets the initial size of the shm with ftruncate and zeros it */
42 shmobj
= shm_object_table_alloc(table
, shmsize
, SHM_OBJECT_SHM
, shmfd
, -1);
43 ok(shmobj
, "Allocate the shm object table");
46 shm_ref
= zalloc_shm(shmobj
, LTTNG_UST_PAGE_SIZE
* 5);
47 ok(shm_ref
.index
!= -1, "Allocate an object in the shm with sufficient space");
49 shm_ref
= zalloc_shm(shmobj
, LTTNG_UST_PAGE_SIZE
* 6);
50 ok(shm_ref
.index
== -1, "Allocate an object in the shm with insufficient space");
53 shm_object_table_destroy(table
, 1);
This page took 0.031534 seconds and 5 git commands to generate.