Giter Site home page Giter Site logo

emutest's Introduction

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

emutest's People

Contributors

1lann avatar arthurlutz avatar dashodanger avatar grinsted avatar imjezze avatar jessetg avatar jstine35 avatar julianxhokaxhiu avatar kivutar avatar kwyxz avatar m-p-3 avatar predr avatar robloach avatar vulpivia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.