Skip to content

Commit

Permalink
refactor migration tests and small test fixes
Browse files Browse the repository at this point in the history
Signed-off-by: William Henderson <william.henderson@nutanix.com>
  • Loading branch information
w-henderson committed Sep 7, 2023
1 parent 5678b32 commit b19a9b1
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 114 deletions.
16 changes: 16 additions & 0 deletions test/py/libvfio_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,4 +1287,20 @@ def get_bitmap_size(size: int, pgsize: int) -> int:
return ((nr_pages + 63) & ~63) // 8


get_errno_loc = libc.__errno_location
get_errno_loc.restype = c.POINTER(c.c_int)


def set_real_errno(errno: int):
"""
ctypes's errno is an internal value that only updates the real value when
the foreign function call returns. In callbacks, however, this doesn't
happen, so `c.set_errno` doesn't propagate in time. In this case we need to
manually set the real errno.
"""

c.set_errno(errno) # set internal errno so `c.get_errno` gives right value
get_errno_loc()[0] = errno # set real errno


# ex: set tabstop=4 shiftwidth=4 softtabstop=4 expandtab: #
4 changes: 2 additions & 2 deletions test/py/test_dirty_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def get_dirty_page_bitmap(addr=0x10 << PAGE_SHIFT, length=0x10 << PAGE_SHIFT,
page_size=PAGE_SIZE, expect=0):
"""
Get the dirty page bitmap from the server for the given region and page
size as a 64-bit integer. This only works for bitmaps that fit within a
64-bit integer.
size as a 64-bit integer. This function only works for bitmaps that fit
within a 64-bit integer because that's what it returns.
"""

bitmap_size = get_bitmap_size(length, page_size)
Expand Down
Loading

0 comments on commit b19a9b1

Please sign in to comment.