1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-04-08 08:43:42 +00:00

Introduce Archimedes analyser tests.

This commit is contained in:
Thomas Harte 2024-05-20 22:48:20 -04:00
parent 3be5d60b1e
commit 6d6dfa4f44
2 changed files with 68 additions and 0 deletions

View File

@ -1050,6 +1050,7 @@
4BD67DD1209BF27B00AB2146 /* Encoder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD67DCE209BF27B00AB2146 /* Encoder.cpp */; };
4BD91D732401960C007BDC91 /* STX.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B7BA03323C58B1E00B98D9E /* STX.cpp */; };
4BD91D772401C2B8007BDC91 /* PatrikRakTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BD91D762401C2B8007BDC91 /* PatrikRakTests.swift */; };
4BD971392BFC3D9D00C907AA /* ArchimedesStaticAnalyserTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BD971382BFC3D9C00C907AA /* ArchimedesStaticAnalyserTests.mm */; };
4BDA00DA22E60EE300AC3CD0 /* ROMRequester.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4BDA00D922E60EE300AC3CD0 /* ROMRequester.xib */; };
4BDA00DD22E622C200AC3CD0 /* ROMImages in Resources */ = {isa = PBXBuildFile; fileRef = 4BC9DF441D044FCA00F44158 /* ROMImages */; };
4BDA00E022E644AF00AC3CD0 /* CSROMReceiverView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BDA00DF22E644AF00AC3CD0 /* CSROMReceiverView.m */; };
@ -2266,6 +2267,7 @@
4BD67DCF209BF27B00AB2146 /* Encoder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Encoder.hpp; sourceTree = "<group>"; };
4BD9137D1F311BC5009BCF85 /* i8255.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = i8255.hpp; sourceTree = "<group>"; };
4BD91D762401C2B8007BDC91 /* PatrikRakTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PatrikRakTests.swift; sourceTree = "<group>"; };
4BD971382BFC3D9C00C907AA /* ArchimedesStaticAnalyserTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ArchimedesStaticAnalyserTests.mm; sourceTree = "<group>"; };
4BDA00D922E60EE300AC3CD0 /* ROMRequester.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ROMRequester.xib; sourceTree = "<group>"; };
4BDA00DE22E644AF00AC3CD0 /* CSROMReceiverView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CSROMReceiverView.h; sourceTree = "<group>"; };
4BDA00DF22E644AF00AC3CD0 /* CSROMReceiverView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CSROMReceiverView.m; sourceTree = "<group>"; };
@ -4546,6 +4548,7 @@
4B9D0C4E22C7E0CF00DE1AD3 /* 68000RollShiftTests.mm */,
4BD388872239E198002D14B5 /* 68000Tests.mm */,
4BF7019F26FFD32300996424 /* AmigaBlitterTests.mm */,
4BD971382BFC3D9C00C907AA /* ArchimedesStaticAnalyserTests.mm */,
4B2005422B804D6400420C5C /* ARMDecoderTests.mm */,
4B924E981E74D22700B76AF1 /* AtariStaticAnalyserTests.mm */,
4BE34437238389E10058E78F /* AtariSTVideoTests.mm */,
@ -6383,6 +6386,7 @@
4B7BC7F51F58F27800D1B1B4 /* 6502AllRAM.cpp in Sources */,
4BC5C3E022C994CD00795658 /* 68000MoveTests.mm in Sources */,
4B778F5923A5F2D00000D260 /* Z80.cpp in Sources */,
4BD971392BFC3D9D00C907AA /* ArchimedesStaticAnalyserTests.mm in Sources */,
4B08A2751EE35D56008B7065 /* Z80InterruptTests.swift in Sources */,
4B778F0E23A5EC4F0000D260 /* Tape.cpp in Sources */,
4B778F2D23A5EF190000D260 /* MFMDiskController.cpp in Sources */,

View File

@ -0,0 +1,64 @@
//
// ArchimedesStaticAnalyserTests.m
// Clock Signal
//
// Created by Thomas Harte on 20/05/2024.
// Copyright 2024 Thomas Harte. All rights reserved.
//
#import <XCTest/XCTest.h>
#import <CommonCrypto/CommonDigest.h>
#include "../../../Analyser/Static/StaticAnalyser.hpp"
#include "../../../Analyser/Static/Acorn/Target.hpp"
static NSString *archimedesDiskPath = @"/Users/thomasharte/Library/Mobile Documents/com~apple~CloudDocs/Soft/Archimedes";
static NSDictionary<NSString *, NSString *> *mainProgramsBySHA1 = @{
@"371b30787a782cb1fe6cb6ad2217a832a06e1e96": @"!TimeZone",
@"3459adef724e2cd6f3681050a9ce47394231b4f9": @"!Talisman",
@"3022e18d47ed0fc14b09c18caff3fc0ac1f4edff": @"!StarTrade",
@"252bfde8d602fe171e0657fa3f9dfeba1803e6eb": @"!Blowpipe",
@"e3c32b8cbd3cd31cbca93e5a45b94e7f8058b8f7": @"Zelanites.!Zelanites",
@"2e1cb15cde588e22f50518b6ffa47a8df89b14c0": @"!Fire_Ice",
@"069592c0b90a0b9112daf014b7e19b4a51f9653b": @"!UIM",
@"14c3785b3bc3f7e2d4a81e92ff06e11656e6b76c": @"!UIM",
// Various things that are not the first disk.
@"2cff99237837e2291b845eb63977362ad9b4f040": @"",
@"3615bcb8a953fbba3d56a956243341a022208101": @"",
};
#undef Record
@interface ArchimedesStaticAnalyserTests : XCTestCase
@end
@implementation ArchimedesStaticAnalyserTests
- (void)testADFs {
for(NSString *testFile in [[NSFileManager defaultManager] contentsOfDirectoryAtPath:archimedesDiskPath error:nil]) {
NSString *fullPath = [archimedesDiskPath stringByAppendingPathComponent:testFile];
// Compute file SHA1.
NSData *fileData = [NSData dataWithContentsOfFile:fullPath];
uint8_t sha1Bytes[CC_SHA1_DIGEST_LENGTH];
CC_SHA1([fileData bytes], (CC_LONG)[fileData length], sha1Bytes);
NSMutableString *const sha1 = [[NSMutableString alloc] init];
for(int c = 0; c < CC_SHA1_DIGEST_LENGTH; c++) [sha1 appendFormat:@"%02x", sha1Bytes[c]];
// Get analysed target and correct answer per list above.
auto targets = Analyser::Static::GetTargets([fullPath UTF8String]);
NSString *const mainProgram = mainProgramsBySHA1[sha1];
if(!mainProgram) {
NSLog(@"Not checking %@ with SHA1 %@", testFile, sha1);
continue;
}
// Test equality.
auto *const target = dynamic_cast<Analyser::Static::Acorn::ArchimedesTarget *>(targets.front().get());
XCTAssert(target != nullptr);
XCTAssert(target->main_program == std::string([mainProgram UTF8String]), @"%@; should be %@, is %s", testFile, mainProgram, target->main_program.c_str());
}
}
@end