1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-29 10:50:28 +00:00

Regression test rework, part 1

The regression tests were written with the assumption that all cross
assemblers would support 6502, 65C02, and 65816 code.  There are a
few that support 65816 partially (e.g. ACME) or not at all.  To best
support these, we need to split some of the tests into pieces, so
that important 6502 tests aren't skipped simply because parts of the
test also exercise 65816 code.

The first step is to change the regression test naming scheme.  The
old system used 1xxx for tests without project files, and 2xxx for
tests with project files.  The new system uses 1xxxN / 2xxxN, where
N indicates the CPU type: 0 for 6502, 1 for 65C02, and 2 for 65816.
For the 1xxxN tests the new value determines which CPU is used,
which allows us to move the "allops" 6502/65C02 tests into the
no-project category.  For 2xxxN it just allows the 6502 and 65816
versions to have the same base name and number.

This change updates the first batch of tests.  It involves minor
changes to the test harness and a whole bunch of renaming.
This commit is contained in:
Andy McFadden 2020-06-06 14:22:53 -07:00
parent b76ca09562
commit 3ff0fbae34
78 changed files with 55 additions and 112 deletions

View File

@ -1,21 +0,0 @@
### 6502bench SourceGen dis65 v1.0 ###
{
"FileDataLength":598,"FileDataCrc32":-1597128799,"ProjectProps":{
"CpuName":"6502","IncludeUndocumentedInstr":true,"EntryFlags":13566159,"AnalysisParams":{
"AnalyzeUncategorizedData":true,"MinCharsForString":4},
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":[],"ProjectSyms":{
}},
"AddressMap":[{
"Offset":0,"Addr":4096}],"TypeHints":[{
"Low":0,"High":0,"Hint":"Code"}],"StatusFlagOverrides":{
},
"Comments":{
},
"LongComments":{
},
"Notes":{
},
"UserLabels":{
},
"OperandFormats":{
}}

View File

@ -17,7 +17,7 @@
"SmartPlpHandling":true},
"PlatformSymbolFileIdentifiers":[],
"ExtensionScriptFileIdentifiers":["PROJ:2004-numeric-types.cs"],
"ExtensionScriptFileIdentifiers":["PROJ:20000-numeric-types.cs"],
"ProjectSyms":{
}},

View File

@ -1,21 +0,0 @@
### 6502bench SourceGen dis65 v1.0 ###
{
"FileDataLength":598,"FileDataCrc32":1426913860,"ProjectProps":{
"CpuName":"6502","IncludeUndocumentedInstr":true,"EntryFlags":13566159,"AnalysisParams":{
"AnalyzeUncategorizedData":true,"MinCharsForString":4},
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":[],"ProjectSyms":{
}},
"AddressMap":[{
"Offset":0,"Addr":4096}],"TypeHints":[{
"Low":0,"High":0,"Hint":"Code"}],"StatusFlagOverrides":{
},
"Comments":{
},
"LongComments":{
},
"Notes":{
},
"UserLabels":{
},
"OperandFormats":{
}}

View File

@ -1,21 +0,0 @@
### 6502bench SourceGen dis65 v1.0 ###
{
"_ContentVersion":1,"FileDataLength":489,"FileDataCrc32":2029737363,"ProjectProps":{
"CpuName":"65C02","IncludeUndocumentedInstr":true,"EntryFlags":32964815,"AnalysisParams":{
"AnalyzeUncategorizedData":true,"MinCharsForString":4,"SeekNearbyTargets":true},
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":[],"ProjectSyms":{
}},
"AddressMap":[{
"Offset":0,"Addr":4096}],"TypeHints":[{
"Low":0,"High":0,"Hint":"Code"}],"StatusFlagOverrides":{
},
"Comments":{
},
"LongComments":{
},
"Notes":{
},
"UserLabels":{
},
"OperandFormats":{
}}

View File

@ -1,21 +0,0 @@
### 6502bench SourceGen dis65 v1.0 ###
{
"_ContentVersion":1,"FileDataLength":489,"FileDataCrc32":-1807290917,"ProjectProps":{
"CpuName":"65C02","IncludeUndocumentedInstr":true,"EntryFlags":33489103,"AnalysisParams":{
"AnalyzeUncategorizedData":true,"MinCharsForString":4,"SeekNearbyTargets":true},
"PlatformSymbolFileIdentifiers":[],"ExtensionScriptFileIdentifiers":[],"ProjectSyms":{
}},
"AddressMap":[{
"Offset":0,"Addr":4096}],"TypeHints":[{
"Low":0,"High":0,"Hint":"Code"}],"StatusFlagOverrides":{
},
"Comments":{
},
"LongComments":{
},
"Notes":{
},
"UserLabels":{
},
"OperandFormats":{
}}

View File

@ -1,4 +1,4 @@
# 6502bench SourceGen generated linker script for 2001-allops-zero-6502
# 6502bench SourceGen generated linker script for 10000-allops-value-6502
MEMORY {
MAIN: file=%O, start=%S, size=65536;
# MEM000: file=%O, start=$1000, size=598;

View File

@ -1,4 +1,4 @@
# 6502bench SourceGen generated linker script for 2003-allops-zero-65C02
# 6502bench SourceGen generated linker script for 10001-allops-value-65C02
MEMORY {
MAIN: file=%O, start=%S, size=65536;
# MEM000: file=%O, start=$1000, size=489;

View File

@ -1,4 +1,4 @@
# 6502bench SourceGen generated linker script for 1001-allops-zero-65816
# 6502bench SourceGen generated linker script for 10002-allops-value-65816
MEMORY {
MAIN: file=%O, start=%S, size=65536;
# MEM000: file=%O, start=$1000, size=588;

View File

@ -1,4 +1,4 @@
# 6502bench SourceGen generated linker script for 2000-allops-value-6502
# 6502bench SourceGen generated linker script for 10010-allops-zero-6502
MEMORY {
MAIN: file=%O, start=%S, size=65536;
# MEM000: file=%O, start=$1000, size=598;

View File

@ -1,4 +1,4 @@
# 6502bench SourceGen generated linker script for 2002-allops-value-65C02
# 6502bench SourceGen generated linker script for 10011-allops-zero-65C02
MEMORY {
MAIN: file=%O, start=%S, size=65536;
# MEM000: file=%O, start=$1000, size=489;

View File

@ -1,4 +1,4 @@
# 6502bench SourceGen generated linker script for 1000-allops-value-65816
# 6502bench SourceGen generated linker script for 10012-allops-zero-65816
MEMORY {
MAIN: file=%O, start=%S, size=65536;
# MEM000: file=%O, start=$1000, size=588;

View File

@ -1,4 +1,4 @@
# 6502bench SourceGen generated linker script for 1002-embedded-instructions
# 6502bench SourceGen generated linker script for 10022-embedded-instructions
MEMORY {
MAIN: file=%O, start=%S, size=65536;
# MEM000: file=%O, start=$1000, size=101;

View File

@ -1,4 +1,4 @@
# 6502bench SourceGen generated linker script for 1003-flags-and-branches
# 6502bench SourceGen generated linker script for 10032-flags-and-branches
MEMORY {
MAIN: file=%O, start=%S, size=65536;
# MEM000: file=%O, start=$1000, size=336;

View File

@ -1,4 +1,4 @@
# 6502bench SourceGen generated linker script for 1004-data-recognition
# 6502bench SourceGen generated linker script for 10042-data-recognition
MEMORY {
MAIN: file=%O, start=%S, size=65536;
# MEM000: file=%O, start=$1000, size=196;

View File

@ -1,4 +1,4 @@
# 6502bench SourceGen generated linker script for 2004-numeric-types
# 6502bench SourceGen generated linker script for 20000-numeric-types
MEMORY {
MAIN: file=%O, start=%S, size=65536;
# MEM000: file=%O, start=$1000, size=1032;

View File

@ -14,18 +14,19 @@ set was generated for:
## Generator/Assembler Tests ##
Files with names like "1000-nifty-test" are regression test data files
Files with names like "10000-nifty-test" are regression test data files
for the code generator. The test harness identifies them by filename
pattern: four digits, a hyphen, then one or more alphanumeric and
pattern: five digits, a hyphen, then one or more alphanumeric and
hyphens. Files with a '.' or '_' are ignored.
If the leading number is between 1000 and 1999, inclusive, the test file
will be loaded as a new project. A 65816 CPU and load address of $1000
are assumed. As with all new projects, the first byte will be hinted as
a code entry point. The entry flags are currently set to emulation mode,
but tests should not rely on that.
If the leading number is between 10000 and 19999, inclusive, the test file
will be loaded as a new project. A load address of $1000 is assumed.
The CPU type is determined by the last digit: 0 for 6502, 1 for 65C02,
and 2 for 65816. Undocumented opcodes are enabled. As with all new
projects, the first byte will be hinted as a code entry point. The entry
flags are currently set to emulation mode, but tests should not rely on that.
If the leading number is 2000 or greater, the test file will be loaded as
If the leading number is 20000 or greater, the test file will be loaded as
a saved project. A file with the same name plus a ".dis65" extension will
be opened as the project file.
@ -50,8 +51,8 @@ the drop list to select which test is shown.
The generated sources and assembled output is placed into a temporary
directory inside SGTestData that is named after the test. For example,
test 2000-allops-value-6502 will have all of its generated output in a
directory called "tmp2000". If all parts of the test are successful, the
test 10000-allops-value-6502 will have all of its generated output in a
directory called "tmp10000". If all parts of the test are successful, the
directory will be removed. If generation or assembly fails, or if you check
the "retain output" box in the test harness, the directory and its contents
will remain. This allows you to examine the outputs when investigating
@ -66,11 +67,11 @@ If you want to add or update a test, follow these steps:
1. Make the changes to the test data file and test project file.
2. Run the test harness. The generation test will fail and leave output in
the tmpNNNN directory. Make sure the assembly test is succeeding.
the tmpNNNNN directory. Make sure the assembly test is succeeding.
3. After verifying that the generated sources look correct, copy them
into the Expected directory, replacing any existing copies.
4. Run the test harness. This should now report success, and will
remove the tmpNNNN directory.
remove the tmpNNNNN directory.
Be sure to have the version of the cross-assembler identified at the top
of this document configured.

View File

@ -20,7 +20,7 @@ using System.Diagnostics;
using System.IO;
using System.Text.RegularExpressions;
using System.Windows.Media;
using Asm65;
using CommonUtil;
using SourceGen.AsmGen;
@ -40,7 +40,7 @@ namespace SourceGen.Tests {
private const string EXPECTED_DIR_NAME = "Expected";
//private static char[] sInvalidChars = new char[] { '.', '_' };
private const string TestCasePattern = @"^\d\d\d\d-[A-Za-z0-9-]+$";
private const string TestCasePattern = @"^\d\d\d\d\d-[A-Za-z0-9-]+$";
private static Regex sTestCaseRegex = new Regex(TestCasePattern);
/// <summary>
@ -185,7 +185,21 @@ namespace SourceGen.Tests {
private int GetTestNum(string pathName) {
// Should always succeed if pathName matched on our regex.
string fileName = Path.GetFileName(pathName);
return int.Parse(fileName.Substring(0, 4));
return int.Parse(fileName.Substring(0, 5));
}
/// <summary>
/// Determines the desired CPU from the test case number.
/// </summary>
/// <param name="testNum"></param>
/// <returns></returns>
private CpuDef.CpuType GetCpuTypeFromNum(int testNum) {
switch (testNum % 10) {
case 0: return CpuDef.CpuType.Cpu6502;
case 1: return CpuDef.CpuType.Cpu65C02;
case 2: return CpuDef.CpuType.Cpu65816;
default: return CpuDef.CpuType.CpuUnknown;
}
}
/// <summary>
@ -434,8 +448,9 @@ namespace SourceGen.Tests {
projectLoadReport = null;
int testNum = GetTestNum(dataPathName);
CpuDef.CpuType cpuType = GetCpuTypeFromNum(testNum);
if (testNum < 2000) {
if (testNum < 20000) {
// create new disasm project for data file
byte[] fileData;
try {
@ -446,6 +461,10 @@ namespace SourceGen.Tests {
}
project.Initialize(fileData.Length);
project.ProjectProps.CpuType = cpuType;
project.ProjectProps.IncludeUndocumentedInstr = true;
project.ProjectProps.TwoByteBrk = false;
project.UpdateCpuDef();
project.PrepForNew(fileData, Path.GetFileName(dataPathName));
// no platform symbols to load
} else {
@ -471,6 +490,13 @@ namespace SourceGen.Tests {
string extMsgs = project.LoadExternalFiles();
if (!string.IsNullOrEmpty(extMsgs)) {
ReportErrMsg(extMsgs);
// keep going
}
if (project.ProjectProps.CpuType != cpuType) {
ReportErrMsg("Mismatch CPU type for test " + testNum + ": project wants " +
project.ProjectProps.CpuType);
// keep going
}
}
@ -543,7 +569,7 @@ namespace SourceGen.Tests {
/// <param name="testNum"></param>
private void ScrubWorkDirectory(string workDir, int testNum) {
string checkString = testNum.ToString();
if (checkString.Length != 4) {
if (checkString.Length != 5) {
Debug.Assert(false);
return;
}