emutest

command module
v0.0.0-...-7a8adc7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 27, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

README

emutest

Emutest is a simple test framework for libretro cores. It embeds a small Lua VM so tests can be written in Lua. It is a Lua scriptable headless libretro frontend.

Emutest is not a unit test framework. It is more like an end to end test utility that you can use in combination with test ROMs like the z80 Master System test ROM, or the Genesis VDP test ROM. It does a good job at testing the integration of your emulator with a libretro frontend.

Features:

  • Lua scriptable
  • Load core using dlopen
  • Load games
  • Run core
  • Dump video framebuffer
  • Get a checksum of the video framebuffer
  • Dump video geometry and pitch
  • Dump SRAM
  • Load SRAM
  • Dump Savestate
  • Load Savestate
  • Set core options
  • Set inputs for any player at any frame
  • Record and filter core logs
  • Screenshots
  • Reset
  • Unload

Not yet implemented:

  • Harware accelerated cores
  • Analog inputs
  • Libretro Subsystems
  • Concurrent libretro cores loaded in the single test file

Known limitations:

  • Cores using libco will crash because of Go

Setup

go install github.com/kivutar/emutest@latest

Usage:

Example:

emutest -t path/to/random_test.lua

You can also pass the core and rom like this:

emutest -L path/to/core_libretro.so -r path/to/rom.bin -t path/to/test.lua

This is an example test file:

set_options_string("mesen-s_hle_coprocessor = \"enabled\"")
load_core("../mesens/Libretro/mesens_libretro.so")
load_game("../roms/Nintendo - Super Nintendo Entertainment System/Super Mario Kart (Europe).zip")

local logs = get_logs()

if not string.find(logs, "Coprocessor: DSP1B") then
	error("missing dsp log")
end

for i=1,20 do run() end
local _, _, _, frame1 = get_video()
for i=1,500 do run() end
local _, _, _, frame2 = get_video()
if frame1 == frame2 then
	error("hle coproc not working")
end

local state = get_state()
if string.len(state) ~= 542720 then
	error("wrong savestate size")
end

screenshot("../mkart.png")

set_inputs(0, "0001000000000000") -- press start for player 1

for i=1,60 do run() end

screenshot("../mkart2.png")

local crc = get_fb_crc()

print(crc)

You can find more test examples in the examples folder.

To run the same test on a full set of ROMs in parallel:

find "./nesroms" -type f -name '*.zip' | \
parallel -j 8 ./emutest -L ~/mesen/Libretro/mesen_libretro.dylib -r {} -t boot200.lua

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package audio uses OpenAL to play game audio by exposing the two audio callbacks Sample and SampleBatch for the libretro implementation.
Package audio uses OpenAL to play game audio by exposing the two audio callbacks Sample and SampleBatch for the libretro implementation.
Package core takes care of instanciating the libretro core, setting the input, audio, video, environment callbacks needed to play the games.
Package core takes care of instanciating the libretro core, setting the input, audio, video, environment callbacks needed to play the games.
Package input exposes the two input callbacks Poll and State needed by the libretro implementation.
Package input exposes the two input callbacks Poll and State needed by the libretro implementation.
Package options deals with configuration at the libretro core level.
Package options deals with configuration at the libretro core level.
Package savefiles takes care of saving the game SRAM to the filesystem
Package savefiles takes care of saving the game SRAM to the filesystem
Package savestates takes care of serializing and unserializing the game RAM to the host filesystem.
Package savestates takes care of serializing and unserializing the game RAM to the host filesystem.
Package state holds the global state of the app.
Package state holds the global state of the app.
Package utils contains utility functions that are used everywhere in the app.
Package utils contains utility functions that are used everywhere in the app.
Package video takes care on the game display.
Package video takes care on the game display.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL