mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2025-01-10 00:29:23 +00:00
Hmm, now I look more closely at the Fuse event tests: I've got all sorts of obscure failures!
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
d15d1e0d08
commit
accdf19805
@ -4,7 +4,9 @@
|
|||||||
namespace Fuse
|
namespace Fuse
|
||||||
{
|
{
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
[DebuggerDisplay("Cycles = {Cycles}, Specififier = {Specifier}, Address = {Address}, Value = {Value}")]
|
||||||
public class TestEvent
|
public class TestEvent
|
||||||
{
|
{
|
||||||
private int cycles;
|
private int cycles;
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
namespace Fuse
|
namespace Fuse
|
||||||
{
|
{
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
public enum Register
|
public enum Register
|
||||||
{
|
{
|
||||||
AF,
|
AF,
|
||||||
@ -25,7 +27,7 @@ namespace Fuse
|
|||||||
{
|
{
|
||||||
private readonly Test<RegisterState> test;
|
private readonly Test<RegisterState> test;
|
||||||
private readonly Result<RegisterState> result;
|
private readonly Result<RegisterState> result;
|
||||||
private readonly TestEvents desiredEvents;
|
private readonly TestEvents expectedEvents = new TestEvents();
|
||||||
private readonly TestEvents actualEvents = new TestEvents();
|
private readonly TestEvents actualEvents = new TestEvents();
|
||||||
private readonly EightBit.Ram ram = new EightBit.Ram(0x10000);
|
private readonly EightBit.Ram ram = new EightBit.Ram(0x10000);
|
||||||
private readonly EightBit.InputOutput ports = new EightBit.InputOutput();
|
private readonly EightBit.InputOutput ports = new EightBit.InputOutput();
|
||||||
@ -36,7 +38,14 @@ namespace Fuse
|
|||||||
this.cpu = new EightBit.Z80(this, this.ports);
|
this.cpu = new EightBit.Z80(this, this.ports);
|
||||||
this.test = test;
|
this.test = test;
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.desiredEvents = result.Events;
|
|
||||||
|
foreach (var e in result.Events.Container)
|
||||||
|
{
|
||||||
|
if (!e.Specifier.EndsWith("C"))
|
||||||
|
{
|
||||||
|
this.expectedEvents.Add(new TestEvent(0, e.Specifier, e.Address, e.Value));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Failed { get; private set; } = false;
|
public bool Failed { get; private set; } = false;
|
||||||
@ -87,13 +96,13 @@ namespace Fuse
|
|||||||
|
|
||||||
protected override void OnReadByte()
|
protected override void OnReadByte()
|
||||||
{
|
{
|
||||||
this.actualEvents.Add(new TestEvent(this.cpu.Cycles, "MR", this.Address.Word, this.Data));
|
this.actualEvents.Add(new TestEvent(0, "MR", this.Address.Word, this.Data));
|
||||||
base.OnReadByte();
|
base.OnReadByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnWrittenByte()
|
protected override void OnWrittenByte()
|
||||||
{
|
{
|
||||||
this.actualEvents.Add(new TestEvent(this.cpu.Cycles, "MW", this.Address.Word, this.Data));
|
this.actualEvents.Add(new TestEvent(0, "MW", this.Address.Word, this.Data));
|
||||||
base.OnWrittenByte();
|
base.OnWrittenByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,38 +386,52 @@ namespace Fuse
|
|||||||
|
|
||||||
private void CheckEvents()
|
private void CheckEvents()
|
||||||
{
|
{
|
||||||
var desires = this.desiredEvents.Container;
|
var expectations = this.expectedEvents.Container;
|
||||||
var actuals = this.actualEvents.Container;
|
var actuals = this.actualEvents.Container;
|
||||||
|
|
||||||
var j = 0;
|
var eventFailure = expectations.Count != actuals.Count;
|
||||||
for (var i = 0; i < desires.Count; ++i)
|
for (var i = 0; !eventFailure && (i < expectations.Count); ++i)
|
||||||
{
|
{
|
||||||
var desire = desires[i];
|
var expectation = expectations[i];
|
||||||
if (desire.Specifier.EndsWith("C")) // Not interested in contention events (yet)
|
var actual = actuals[i];
|
||||||
{
|
|
||||||
continue;
|
var equalCycles = expectation.Cycles == actual.Cycles;
|
||||||
|
var equalSpecifier = expectation.Specifier == actual.Specifier;
|
||||||
|
var equalAddress = expectation.Address == actual.Address;
|
||||||
|
var equalValue = expectation.Value == actual.Value;
|
||||||
|
|
||||||
|
var equal = equalCycles && equalSpecifier && equalAddress && equalValue;
|
||||||
|
eventFailure = !equal;
|
||||||
}
|
}
|
||||||
|
|
||||||
var actual = actuals[j++];
|
if (eventFailure)
|
||||||
|
|
||||||
var equalCycles = desire.Cycles == actual.Cycles;
|
|
||||||
var equalSpecifier = desire.Specifier == actual.Specifier;
|
|
||||||
var equalAddress = desire.Address == actual.Address;
|
|
||||||
var equalValue = desire.Value == actual.Value;
|
|
||||||
|
|
||||||
// var equal = equalCycles && equalSpecifier && equalAddress && equalValue;
|
|
||||||
var equal = equalSpecifier && equalAddress && equalValue;
|
|
||||||
if (!equal)
|
|
||||||
{
|
{
|
||||||
this.Failed = true;
|
this.DumpExpectedEvents();
|
||||||
|
this.DumpActualEvents();
|
||||||
var expectedOutput = $"**** Event issue (desire index, {i}): {ToString(desire)}";
|
|
||||||
System.Console.Error.WriteLine(expectedOutput);
|
|
||||||
|
|
||||||
var actualOutput = $"**** Event issue (actual index, {j}): {ToString(actual)}";
|
|
||||||
System.Console.Error.WriteLine(actualOutput);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.Failed = eventFailure;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DumpExpectedEvents()
|
||||||
|
{
|
||||||
|
System.Console.Error.WriteLine("++++ Dumping expected events:");
|
||||||
|
DumpEvents(this.expectedEvents.Container);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DumpActualEvents()
|
||||||
|
{
|
||||||
|
System.Console.Error.WriteLine("++++ Dumping actual events:");
|
||||||
|
DumpEvents(this.actualEvents.Container);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DumpEvents(IEnumerable<TestEvent> events)
|
||||||
|
{
|
||||||
|
foreach (var e in events)
|
||||||
|
{
|
||||||
|
var output = $" Event issue {ToString(e)}";
|
||||||
|
System.Console.Error.WriteLine(output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user