Skip to content

Commit 37e1ae2

Browse files
committed
test schema UPDATE use malloc instead of mmap
1 parent 08871a6 commit 37e1ae2

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

tests/utests/schema/test_schema.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,7 +2123,7 @@ test_lysc_backlinks(void **state)
21232123
static void
21242124
test_compiled_print(void **state)
21252125
{
2126-
int size, fd;
2126+
int size;
21272127
void *mem, *mem_end;
21282128
struct lyd_node *tree = NULL;
21292129
struct ly_ctx *printed_ctx = NULL, *printed_ctx2 = NULL;
@@ -2203,12 +2203,9 @@ test_compiled_print(void **state)
22032203
/* get the size of the compiled ctx */
22042204
size = ly_ctx_compiled_size(UTEST_LYCTX);
22052205

2206-
/* prepare the shared memory segment */
2207-
fd = shm_open("/ly_test_schema_ctx", O_RDWR | O_CREAT, 00600);
2208-
assert_int_not_equal(fd, -1);
2209-
ftruncate(fd, size);
2210-
mem = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
2211-
assert_ptr_not_equal(mem, MAP_FAILED);
2206+
/* prepare memory chunk for the printed context */
2207+
mem = malloc(size);
2208+
assert_non_null(mem);
22122209

22132210
/* print the context into the shared memory */
22142211
assert_int_equal(LY_SUCCESS, ly_ctx_compiled_print(UTEST_LYCTX, mem, &mem_end));
@@ -2267,9 +2264,7 @@ test_compiled_print(void **state)
22672264

22682265
/* cleanup */
22692266
ly_ctx_destroy(printed_ctx);
2270-
munmap(mem, size);
2271-
close(fd);
2272-
shm_unlink("/ly_test_schema_ctx");
2267+
free(mem);
22732268
}
22742269

22752270
int

0 commit comments

Comments
 (0)