1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00

Switch to accepting failures only with a reason.

This commit is contained in:
Thomas Harte 2023-11-09 11:55:36 -05:00
parent 800c76a4fe
commit ed3922e458

View File

@ -387,16 +387,17 @@ struct FailedExecution {
@implementation i8088Tests {
std::vector<FailedExecution> execution_failures;
std::vector<FailedExecution> permitted_failures;
ExecutionSupport execution_support;
}
- (NSArray<NSString *> *)testFiles {
NSString *path = [NSString stringWithUTF8String:TestSuiteHome];
NSSet *allowList = [NSSet setWithArray:@[
// Current execution failures:
// @"D4.json.gz", // AAM
// @"F6.7.json.gz", // IDIV
// @"F7.7.json.gz", // IDIV
// Current execution failures, albeit all permitted:
@"D4.json.gz", // AAM
@"F6.7.json.gz", // IDIV byte
@"F7.7.json.gz", // IDIV word
]];
NSSet *ignoreList = nil;
@ -639,7 +640,37 @@ struct FailedExecution {
const bool registersEqual = intended_registers == execution_support.registers;
const bool flagsEqual = (intended_flags.get() & flags_mask) == (execution_support.flags.get() & flags_mask);
if(!flagsEqual || !registersEqual || !ramEqual) {
// Exit if no issues were found.
if(flagsEqual && registersEqual && ramEqual) {
return;
}
// Presume this is a genuine failure.
std::vector<FailedExecution> *failure_list = &execution_failures;
// Redirect it if it's an acceptable failure.
using Operation = InstructionSet::x86::Operation;
// AAM 00h throws its exception only after modifying flags in an undocumented manner;
// I'm not too concerned about this because AAM 00h is an undocumented usage of 00h,
// not even supported by NEC amongst others, and the proper exception is being thrown.
if(decoded.second.operation() == Operation::AAM && !decoded.second.operand()) {
failure_list = &permitted_failures;
}
// IDIV_REP has a couple of cases...
if(decoded.second.operation() == Operation::IDIV_REP) {
// For reasons I don't understand, sometimes the test set doesn't increment the IP
// across a REP_IDIV. I don't think (?) this correlates to real 8086 behaviour.
// More research required, but for now I'm not treating this as a roadblock.
Registers advanced_registers = intended_registers;
advanced_registers.ip_ += decoded.first;
if(advanced_registers == execution_support.registers && ramEqual && flagsEqual) {
failure_list = &permitted_failures;
}
}
// Record a failure.
FailedExecution failure;
failure.instruction = decoded.second;
failure.test_name = std::string([test[@"name"] UTF8String]);
@ -684,8 +715,7 @@ struct FailedExecution {
}
failure.reason = std::string([reasons componentsJoinedByString:@"; "].UTF8String);
execution_failures.push_back(std::move(failure));
}
failure_list->push_back(std::move(failure));
}
- (void)printFailures:(NSArray<NSString *> *)failures {
@ -744,20 +774,16 @@ struct FailedExecution {
}
// Lock in current failure rate.
XCTAssertLessThanOrEqual(execution_failures.size(), 4009);
// Current accepted failures:
// * 2484 instances of LEA from a register, which officially has undefined results;
// * 42 instances of AAM 00h for which I can't figure out what to do with flags; and
// * 1486 instances of IDIV, most either with a rep or repne that on the 8086 specifically negatives the result,
// but some admittedly still unexplained (primarily setting overflow even though the result doesn't overflow;
// a couple of online 8086 emulators also didn't throw so maybe this is an 8086 quirk?)
XCTAssertLessThanOrEqual(execution_failures.size(), 0);
for(const auto &failure: execution_failures) {
NSLog(@"Failed %s — %s", failure.test_name.c_str(), failure.reason.c_str());
}
for(const auto &failure: permitted_failures) {
NSLog(@"Permitted failure of %s — %s", failure.test_name.c_str(), failure.reason.c_str());
}
NSLog(@"Files with failures were: %@", failures);
NSLog(@"Files with failures, permitted or otherwise, were: %@", failures);
}
@end