uktil: add libc.memfd_create() wrapper
This is required for python3.6 where there is no `os.memfd_create()` yet. Can be removed once we move to python3.8+.
This commit is contained in:
parent
0abdfb9041
commit
09e78c52d9
2 changed files with 41 additions and 0 deletions
|
|
@ -187,6 +187,7 @@ def test_libc():
|
|||
assert libc0.RENAME_NOREPLACE
|
||||
assert libc0.RENAME_WHITEOUT
|
||||
assert libc0.renameat2
|
||||
assert libc0.memfd_create
|
||||
|
||||
|
||||
def test_libc_renameat2_errcheck():
|
||||
|
|
@ -226,6 +227,23 @@ def test_libc_renameat2_exchange(tmpdir):
|
|||
assert f.read() == "foo"
|
||||
|
||||
|
||||
def test_libc_memfd_create_errcheck():
|
||||
libc = linux.Libc.default()
|
||||
with pytest.raises(OSError) as exc:
|
||||
libc.memfd_create("foo", -1)
|
||||
assert "Invalid argument" in str(exc.value)
|
||||
|
||||
|
||||
def test_libc_memfd_create():
|
||||
libc = linux.Libc.default()
|
||||
fd = libc.memfd_create("foo", 0)
|
||||
os.write(fd, b"file content")
|
||||
fd2 = os.dup(fd)
|
||||
os.close(fd)
|
||||
os.lseek(fd2, 0, 0)
|
||||
assert os.read(fd2, 4096) == b"file content"
|
||||
|
||||
|
||||
def test_proc_boot_id():
|
||||
#
|
||||
# Test the `proc_boot_id()` function which reads the current boot-id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue