Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression testing? #9

Open
DCNick3 opened this issue Jul 23, 2020 · 2 comments
Open

Regression testing? #9

DCNick3 opened this issue Jul 23, 2020 · 2 comments

Comments

@DCNick3
Copy link

DCNick3 commented Jul 23, 2020

It would be nice to have some instruction regression tests to be sure that the implementation would be consistent with real x86.

@nepx
Copy link
Owner

nepx commented Jul 24, 2020

I "test" for regressions by booting the following operating systems:

  • DOS (floppy drive problems)
  • Windows 95 (general system state)
  • OS/2 Warp 4.5 (esoteric protected mode operations like call gates)
  • Windows NT 4.0 (disk drives)
  • Windows XP (VESA, uncommon instructions like bound, page-split traces)
  • Mandrake Linux (hardware task switching)
  • Windows 7 (MMX, SSE, SSE2, large disk images)
  • Windows 10 (PAE, NX, only occasionally, though, since boot times are long)

These operating systems are pretty complete in their usage of the entire x86 instruction set. Now, they won't check for edge-case shift instructions like the ones described in #7 and #8, but they do tell me if some major bug has been introduced.

Another option is to randomly "fuzz" a bunch of instructions with random assignment of operands and inputs, but the process is too unpredictable and non-deterministic for me, and quite a few operations cause undefined behavior or faults, usually in flags (i.e. af for shifts) but occasionally in outputs as well. With all these constraints, you're better off just going with hard-coded inputs and outputs.

For a more rigorous test, I use the QEMU TCG test suite for i386, which can be found here. I use a version set up on this disk image, which includes test output created on a real processor. It exercises a large variety of arithmetic instructions, but is limited due to the fact that it runs entirely in user mode (so nothing crazy like far calls/far returns).

I've always wanted a series of tests for x86 like the ones that NESDev developers use. I'll have a go at writing some; it'll be fun to write some x86 assembly.

I'll create a separate repository for these tests so that other emulators can use them too; testing an x86 CPU is a project in itself.

@nepx
Copy link
Owner

nepx commented Jul 25, 2020

Unit tests: https://github.com/nepx/verr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants