1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-08-15 14:27:29 +00:00

Tidy up, and reduce for now to a summary report.

This commit is contained in:
Thomas Harte
2022-05-13 08:02:20 -04:00
parent 6c854e8ecc
commit 6594b38567

View File

@@ -99,8 +99,6 @@ struct Test68000 {
- (void)setUp { - (void)setUp {
// To limit tests run to a subset of files and/or of tests, uncomment and fill in below. // To limit tests run to a subset of files and/or of tests, uncomment and fill in below.
// _fileSet = [NSSet setWithArray:@[@"dbcc.json"]];
// _testSet = [NSSet setWithArray:@[@"CHK 4190"]];
// _fileSet = [NSSet setWithArray:@[@"jmp_jsr.json"]]; // _fileSet = [NSSet setWithArray:@[@"jmp_jsr.json"]];
// _testSet = [NSSet setWithArray:@[@"CHK 41a8"]]; // _testSet = [NSSet setWithArray:@[@"CHK 41a8"]];
} }
@@ -118,12 +116,15 @@ struct Test68000 {
for(NSURL *url in tests) { for(NSURL *url in tests) {
// Compare against a file set if one has been supplied. // Compare against a file set if one has been supplied.
if(_fileSet && ![_fileSet containsObject:[url lastPathComponent]]) continue; if(_fileSet && ![_fileSet containsObject:[url lastPathComponent]]) continue;
NSLog(@"Testing %@", url); // NSLog(@"Testing %@", url);
[self testJSONAtURL:url]; [self testJSONAtURL:url];
} }
// Output a summary of failures. XCTAssert(_failures.count == 0);
NSLog(@"Total: %@", @(_failures.count));
// Output a summary of failures, if any.
if(_failures.count) {
NSLog(@"Total failures: %@", @(_failures.count));
NSLog(@"Failures: %@", _failures); NSLog(@"Failures: %@", _failures);
NSLog(@"Failing opcodes:"); NSLog(@"Failing opcodes:");
@@ -134,6 +135,7 @@ struct Test68000 {
NSLog(@"%04x %s", number.intValue, description.c_str()); NSLog(@"%04x %s", number.intValue, description.c_str());
} }
} }
}
- (void)testJSONAtURL:(NSURL *)url { - (void)testJSONAtURL:(NSURL *)url {
// Read the nominated file and parse it as JSON. // Read the nominated file and parse it as JSON.
@@ -279,10 +281,12 @@ struct Test68000 {
test68000->run_for_instructions(1, comparitor); test68000->run_for_instructions(1, comparitor);
} }
- (void)testOperationExecutor:(NSDictionary *)test name:(NSString *)name { - (void)setInitialState:(NSDictionary *)test {
// Definitively erase any prior memory contents;
// 0xce is arbitrary but hopefully easier to spot
// in potential errors than e.g. 0x00 or 0xff.
memset(_test68000.ram.data(), 0xce, _test68000.ram.size()); memset(_test68000.ram.data(), 0xce, _test68000.ram.size());
{
// Apply initial memory state. // Apply initial memory state.
NSArray<NSNumber *> *const initialMemory = test[@"initial memory"]; NSArray<NSNumber *> *const initialMemory = test[@"initial memory"];
NSEnumerator<NSNumber *> *enumerator = [initialMemory objectEnumerator]; NSEnumerator<NSNumber *> *enumerator = [initialMemory objectEnumerator];
@@ -312,6 +316,9 @@ struct Test68000 {
_test68000.processor.set_state(state); _test68000.processor.set_state(state);
} }
- (void)testOperationExecutor:(NSDictionary *)test name:(NSString *)name {
[self setInitialState:test];
// Run the thing. // Run the thing.
_test68000.run_for_instructions(1); _test68000.run_for_instructions(1);
@@ -325,19 +332,19 @@ struct Test68000 {
if(state.data[c] != [finalState[dX] integerValue]) [_failures addObject:name]; if(state.data[c] != [finalState[dX] integerValue]) [_failures addObject:name];
if(c < 7 && state.address[c] != [finalState[aX] 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); // XCTAssertEqual(state.data[c], [finalState[dX] integerValue], @"%@: D%d inconsistent", name, c);
if(c < 7) { // if(c < 7) {
XCTAssertEqual(state.address[c], [finalState[aX] integerValue], @"%@: A%d inconsistent", name, c); // 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.supervisor_stack_pointer != [finalState[@"a7"] integerValue]) [_failures addObject:name];
if(state.user_stack_pointer != [finalState[@"usp"] integerValue]) [_failures addObject:name]; if(state.user_stack_pointer != [finalState[@"usp"] integerValue]) [_failures addObject:name];
if(state.status != [finalState[@"sr"] 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.supervisor_stack_pointer, [finalState[@"a7"] integerValue], @"%@: A7 inconsistent", name);
XCTAssertEqual(state.user_stack_pointer, [finalState[@"usp"] integerValue], @"%@: USP inconsistent", name); // XCTAssertEqual(state.user_stack_pointer, [finalState[@"usp"] integerValue], @"%@: USP inconsistent", name);
XCTAssertEqual(state.status, [finalState[@"sr"] integerValue], @"%@: Status inconsistent", name); // XCTAssertEqual(state.status, [finalState[@"sr"] integerValue], @"%@: Status inconsistent", name);
XCTAssertEqual(state.program_counter, [finalState[@"pc"] integerValue], @"%@: Program counter inconsistent", name); // XCTAssertEqual(state.program_counter, [finalState[@"pc"] integerValue], @"%@: Program counter inconsistent", name);
// Test final memory state. // Test final memory state.
NSArray<NSNumber *> *const finalMemory = test[@"final memory"]; NSArray<NSNumber *> *const finalMemory = test[@"final memory"];
@@ -347,11 +354,12 @@ struct Test68000 {
NSNumber *const value = [enumerator nextObject]; NSNumber *const value = [enumerator nextObject];
if(!address || !value) break; if(!address || !value) break;
XCTAssertEqual(_test68000.ram[address.integerValue], value.integerValue, @"%@: Memory at location %@ inconsistent", name, address); // XCTAssertEqual(_test68000.ram[address.integerValue], value.integerValue, @"%@: Memory at location %@ inconsistent", name, address);
if(_test68000.ram[address.integerValue] != value.integerValue) [_failures addObject:name]; if(_test68000.ram[address.integerValue] != value.integerValue) [_failures addObject:name];
} }
// Consider collating extra detail. // If this test is now in the failures set, add the corresponding opcode for
// later logging.
if([_failures containsObject:name]) { if([_failures containsObject:name]) {
[_failingOpcodes addObject:@(_test68000.read<uint16_t>(0x100, InstructionSet::M68k::FunctionCode()))]; [_failingOpcodes addObject:@(_test68000.read<uint16_t>(0x100, InstructionSet::M68k::FunctionCode()))];
} }