mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Simplifies failure output for me.
This commit is contained in:
parent
81cc278b98
commit
e603fc6aaa
@ -17,19 +17,47 @@
|
||||
@interface M68000ComparativeTests : XCTestCase
|
||||
@end
|
||||
|
||||
@implementation M68000ComparativeTests
|
||||
@implementation M68000ComparativeTests {
|
||||
NSSet<NSString *> *_fileSet;
|
||||
NSSet<NSString *> *_testSet;
|
||||
|
||||
NSMutableSet<NSString *> *_failures;
|
||||
NSMutableArray<NSNumber *> *_failingOpcodes;
|
||||
}
|
||||
|
||||
- (void)setUp {
|
||||
// To limit tests run to a subset of files and/or of tests, uncomment and fill in below.
|
||||
// _fileSet = [NSSet setWithArray:@[@"eor.json"]];
|
||||
// _testSet = [NSSet setWithArray:@[@"EOR b0c0", @"EOR b0c2", @"EOR b0c3", @"EOR b0c5", @"EOR b0c6", @"EOR b0c7", @"OR b0c7"]];
|
||||
}
|
||||
|
||||
- (void)testAll {
|
||||
// These will accumulate a list of failing tests and associated opcodes.
|
||||
_failures = [[NSMutableSet alloc] init];
|
||||
_failingOpcodes = [[NSMutableArray alloc] init];
|
||||
|
||||
// Get the full list of available test files.
|
||||
NSBundle *const bundle = [NSBundle bundleForClass:[self class]];
|
||||
NSArray<NSURL *> *const tests = [bundle URLsForResourcesWithExtension:@"json" subdirectory:@"68000 Comparative Tests"];
|
||||
|
||||
// Issue each test file.
|
||||
for(NSURL *url in tests) {
|
||||
// Compare against a file set if one has been supplied.
|
||||
if(_fileSet && ![_fileSet containsObject:[[url path] lastPathComponent]]) continue;
|
||||
NSLog(@"Testing %@", url);
|
||||
[self testJSONAtURL:url];
|
||||
}
|
||||
|
||||
// Output a summary of failures.
|
||||
NSLog(@"Failures: %@", _failures);
|
||||
NSLog(@"Failing opcodes:");
|
||||
for(NSNumber *number in _failingOpcodes) {
|
||||
NSLog(@"%04x", number.intValue);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testJSONAtURL:(NSURL *)url {
|
||||
// Read the nominated file and parse it as JSON.
|
||||
NSData *const data = [NSData dataWithContentsOfURL:url];
|
||||
NSError *error;
|
||||
NSArray *const jsonContents = [NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
||||
@ -38,6 +66,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Perform each dictionary in the array as a test.
|
||||
for(NSDictionary *test in jsonContents) {
|
||||
if(![test isKindOfClass:[NSDictionary class]]) continue;
|
||||
[self testOperation:test];
|
||||
@ -49,7 +78,8 @@
|
||||
NSString *const name = test[@"name"];
|
||||
if(!name) return;
|
||||
|
||||
// if(![name isEqualToString:@"ORI 7c"]) return;
|
||||
// Compare against a test set if one has been supplied.
|
||||
if(_testSet && ![_testSet containsObject:name]) return;
|
||||
|
||||
// This is the test class for 68000 execution.
|
||||
struct Test68000: public CPU::MC68000::BusHandler {
|
||||
@ -126,11 +156,18 @@
|
||||
const NSString *dX = [@"d" stringByAppendingFormat:@"%d", c];
|
||||
const NSString *aX = [@"a" stringByAppendingFormat:@"%d", c];
|
||||
|
||||
if(state.data[c] != [finalState[dX] integerValue]) [_failures addObject:name];
|
||||
if(c < 7 && state.address[c] != [finalState[aX] integerValue]) [_failures addObject:name];
|
||||
|
||||
XCTAssertEqual(state.data[c], [finalState[dX] integerValue], @"%@: D%d inconsistent", name, c);
|
||||
if(c < 7) {
|
||||
XCTAssertEqual(state.address[c], [finalState[aX] integerValue], @"%@: A%d inconsistent", name, c);
|
||||
}
|
||||
}
|
||||
if(state.supervisor_stack_pointer != [finalState[@"a7"] integerValue]) [_failures addObject:name];
|
||||
if(state.user_stack_pointer != [finalState[@"usp"] integerValue]) [_failures addObject:name];
|
||||
if(state.status != [finalState[@"sr"] integerValue]) [_failures addObject:name];
|
||||
|
||||
XCTAssertEqual(state.supervisor_stack_pointer, [finalState[@"a7"] integerValue], @"%@: A7 inconsistent", name);
|
||||
XCTAssertEqual(state.user_stack_pointer, [finalState[@"usp"] integerValue], @"%@: USP inconsistent", name);
|
||||
XCTAssertEqual(state.status, [finalState[@"sr"] integerValue], @"%@: Status inconsistent", name);
|
||||
@ -144,6 +181,12 @@
|
||||
|
||||
if(!address || !value) break;
|
||||
XCTAssertEqual(test68000->ram[address.integerValue ^ 1], value.integerValue, @"%@: Memory at location %@ inconsistent", name, address);
|
||||
if(test68000->ram[address.integerValue ^ 1] != value.integerValue) [_failures addObject:name];
|
||||
}
|
||||
|
||||
// Consider collating extra detail.
|
||||
if([_failures containsObject:name]) {
|
||||
[_failingOpcodes addObject:@((test68000->ram[0x100] << 8) | test68000->ram[0x101])];
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user