How to test serialization quirks - GregorR/RetroArch GitHub Wiki
This page summarizes the techniques I've used to test for serialization quirks in cores. It should be moved... somewhere, when 1.3.7 is out.
Nondeterminism/stress testing
Netplay is fairly resilient to nondeterminism with the check_frames setting, but generally, nondeterministic cores are considered a bad thing. The techniques for testing nondeterminism are also good for testing
The easiest way to test for savestate nondeterminism is to connect two instances of RetroArch via netplay over a link with high latency, making sure check_frames is off and delay_frames is a reasonable value, e.g. 16.
Finding a link with high latency isn't always easy, but luckily, Linux can make one for you. Use the following command to make connections to 127.0.0.1 impose a high latency:
$ tc qdisc add dev lo root netem delay 250ms
To remove this latency, use the following command:
$ tc qdisc del dev lo root netem
With the latency in place, you just need to run two instances of RetroArch:
$ retroarch -L my_core.so my_content.bin -H
$ retroarch -L my_core.so my_content.bin -C 127.0.0.1
Use both, and make sure they don't desync or crash. To use both simultaneously, I recommend using a controller, as both can read and interpret its input at the same time. If the views drift out of sync, your core is behaving nondeterministically when states are loaded. If one or the other crashes, your savestates are broken, and you should fix it or at least report the INCOMPLETE
quirk.
SINGLE_SESSION
This is a simple one to test. Save a state, exit and restart RetroArch, then try to load the same state. If it crashes, your states are single-session.
PLATFORM_DEPENDENT
Either transfer states or connect Netplay between hosts that differ in platform, but not specifically in endianness. A typical choice would be an x86_64 desktop and an ARM smartphone. If loading the state or connecting Netplay crashes, your states are platform dependent.
ENDIAN_DEPENDENT
Test platform dependency first. If your states aren't otherwise platform dependent, test the same with a connection to a big-endian machine, such as a PPC (PlayStation 3, older Mac) or MIPS (some embedded machines).