Debian Codegraph @

extra_tests/test__posixshmem.py

raw symbols SCIP
1 import pytest
2
3 _posixshmem = pytest.importorskip('_posixshmem')
4
5 import os
6 import mmap
7
8 def test_simple():
9 mode = 0o600
10 tmp_path = "/psm_%s" % (hex(id(hex)), ) # hack to get a uniquish path
11 flags = os.O_RDWR | os.O_CREAT | os.O_EXCL
12 fd = _posixshmem.shm_open(tmp_path, flags, mode)
13 try:
14 size = 1024
15 os.ftruncate(fd, size)
16 mem1 = mmap.mmap(fd, size)
17
18 fd2 = _posixshmem.shm_open(tmp_path, flags & ~os.O_CREAT, mode)
19 mem2 = mmap.mmap(fd2, size)
20 mem1[0] = 14
21 assert mem1[0] == 14
22 finally:
23 _posixshmem.shm_unlink(tmp_path)
24