Fix RAM tests

This commit is contained in:
Jesse Talavera 2024-03-13 09:15:37 -04:00
parent 50fb22a9f7
commit 0d757151b1
2 changed files with 20 additions and 7 deletions

View File

@ -1,7 +1,12 @@
from sys import argv from ctypes import *
from libretro import default_session, RETRO_MEMORY_SYSTEM_RAM
with default_session(argv[1]) as session: from libretro import Session
from libretro.h import RETRO_MEMORY_SYSTEM_RAM
import prelude
session: Session
with prelude.session() as session:
size = session.core.get_memory_size(RETRO_MEMORY_SYSTEM_RAM) size = session.core.get_memory_size(RETRO_MEMORY_SYSTEM_RAM)
assert size is not None assert size is not None
@ -17,4 +22,9 @@ with default_session(argv[1]) as session:
assert memory is not None assert memory is not None
assert len(memory) == size assert len(memory) == size
assert id(memory) == data.value
# Let's ensure that we can write to the memory
memory[0:5] = b'hello'
mem_ptr = cast(data, POINTER(c_ubyte))
assert bytes(mem_ptr[0:5]) == b'hello'

View File

@ -1,7 +1,10 @@
from sys import argv from libretro import Session
from libretro import default_session, RETRO_MEMORY_SAVE_RAM from libretro.h import RETRO_MEMORY_SAVE_RAM
with default_session(argv[1]) as session: import prelude
session: Session
with prelude.session() as session:
size = session.core.get_memory_size(RETRO_MEMORY_SAVE_RAM) size = session.core.get_memory_size(RETRO_MEMORY_SAVE_RAM)
assert size is not None assert size is not None