4e5c34f457
This adds a new data format option, "binary include", that takes a filename operand. When assembly sources are generated, the section of file is replaced with an appropriate pseudo-op, and binary files are generated that hold the file contents. This is a convenient way to remove large binary blobs, such as music or sound samples, that aren't useful to have in text form in the sources. Partial pathnames are allowed, so you can output a sound blob to "sounds/blather.bin". For safety reasons, we don't allow the files to be created above the project directory, and existing files will only be overwritten if they have a matching length (so you don't accidentally stomp on your project file). The files are not currently shown in the GenAsm dialog, which lets you see a preview of the generated sources. The hex dump tool can do this for the (presumably rare) situations where it's useful. A new regression test, 20300-binary-include, has been added. The pseudo-op name can be overridden on-screen in the settings. We don't currently do anything new for text/HTML exports. It might be useful to generate an optional appendix with a hex dump of the excised sections. (issue #144) |
||
---|---|---|
.. | ||
Expected | ||
FunkyProjects | ||
Source | ||
Visualization | ||
10000-allops-value-6502 | ||
10001-allops-value-65C02 | ||
10002-allops-value-65816 | ||
10003-allops-value-W65C02 | ||
10010-allops-zero-6502 | ||
10011-allops-zero-65C02 | ||
10012-allops-zero-65816 | ||
10013-allops-zero-W65C02 | ||
10020-embedded-instructions | ||
10022-embedded-instructions | ||
10030-flags-and-branches | ||
10032-flags-and-branches | ||
10040-data-recognition | ||
20000-numeric-types | ||
20000-numeric-types.cs | ||
20000-numeric-types.dis65 | ||
20010-string-types | ||
20010-string-types.dis65 | ||
20020-operand-formats | ||
20020-operand-formats.dis65 | ||
20022-operand-formats | ||
20022-operand-formats.dis65 | ||
20030-labels-and-symbols | ||
20030-labels-and-symbols.dis65 | ||
20030-labels-and-symbols.sym65 | ||
20032-labels-and-symbols | ||
20032-labels-and-symbols.dis65 | ||
20040-address-changes | ||
20040-address-changes.dis65 | ||
20042-address-changes | ||
20042-address-changes.dis65 | ||
20050-branches-and-banks | ||
20050-branches-and-banks.dis65 | ||
20050-branches-and-banks.sym65 | ||
20052-branches-and-banks | ||
20052-branches-and-banks.dis65 | ||
20060-target-adjustment | ||
20060-target-adjustment.dis65 | ||
20062-target-adjustment | ||
20062-target-adjustment.dis65 | ||
20070-hinting | ||
20070-hinting.cs | ||
20070-hinting.dis65 | ||
20081-label-localizer | ||
20081-label-localizer.dis65 | ||
20090-notes-and-comments | ||
20090-notes-and-comments.dis65 | ||
20100-label-dp | ||
20100-label-dp.dis65 | ||
20102-label-dp | ||
20102-label-dp.dis65 | ||
20110-64k-nops | ||
20110-64k-nops.dis65 | ||
20120-char-encoding-a | ||
20120-char-encoding-a.dis65 | ||
20122-char-encoding | ||
20122-char-encoding.dis65 | ||
20130-char-encoding-p | ||
20130-char-encoding-p.dis65 | ||
20140-char-encoding-s | ||
20140-char-encoding-s.dis65 | ||
20150-local-variables | ||
20150-local-variables.dis65 | ||
20152-local-variables | ||
20152-local-variables.dis65 | ||
20162-cycle-counts-65816 | ||
20162-cycle-counts-65816.dis65 | ||
20170-external-symbols | ||
20170-external-symbols-1.sym65 | ||
20170-external-symbols-2.sym65 | ||
20170-external-symbols-3.sym65 | ||
20170-external-symbols.dis65 | ||
20172-external-symbols | ||
20172-external-symbols.dis65 | ||
20172-external-symbols.sym65 | ||
20180-extension-scripts-a.cs | ||
20180-extension-scripts-b.cs | ||
20180-extension-scripts.sym65 | ||
20182-extension-scripts | ||
20182-extension-scripts.dis65 | ||
20190-non-unique-labels | ||
20190-non-unique-labels.dis65 | ||
20200-ui-edge-cases | ||
20200-ui-edge-cases.dis65 | ||
20212-reloc-data | ||
20212-reloc-data.dis65 | ||
20222-data-bank | ||
20222-data-bank.dis65 | ||
20233-rockwell | ||
20233-rockwell.dis65 | ||
20240-large-overlay | ||
20240-large-overlay.dis65 | ||
20250-nested-regions | ||
20250-nested-regions.dis65 | ||
20252-nested-regions | ||
20252-nested-regions.dis65 | ||
20260-pre-labels | ||
20260-pre-labels.dis65 | ||
20270-std-inline | ||
20270-std-inline.dis65 | ||
20280-label-placement | ||
20280-label-placement.dis65 | ||
20290-region-isolation | ||
20290-region-isolation.dis65 | ||
20300-binary-include | ||
20300-binary-include.dis65 | ||
README.md |
SourceGen Test Data
This directory contains various regression tests.
NOTE: some tests may fail if you use a version of the assembler that is different from the one used to generate the expected output. The current set was generated for:
- 64tass v1.56.2625
- ACME v0.97
- cc65 v2.18
- Merlin 32 v1.0
Generator/Assembler Tests
Files with names like "10000-nifty-test" are regression test data files for the code generator. The test harness identifies them by filename pattern: five digits, a hyphen, then one or more alphanumeric and hyphens. Files with a '.' or '_' are ignored.
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, 2 for 65816, and 3 for W65C02. Undocumented opcodes are enabled. As with all new projects, the first byte will be tagged as a code start point. The entry flags are currently set to emulation mode, but tests should not rely on that.
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.
Overriding Settings
All tests are run with a fixed set of app settings, so that the tests look the same regardless of how the assemblers are configured in the app settings file. For example, upper-case conversion is disabled, and cycle counts are not shown.
Sometimes a test will want to exercise one of these settings, so we need a way to tell the test harness to override the default. We do this by creating project symbols:
Name | Value | Description |
---|---|---|
__ENABLE_LABEL_NEWLINE | any | Puts long labels on their own line |
__ENABLE_ALL_LABEL_NEWLINE | any | Puts all labels on their own line |
__ENABLE_CYCLE_COUNTS | any | Adds cycle count to end-of-line comments |
Execution
With debug features enabled, you can open the test runner from the menu with Debug > Source Generation Tests. Click "Run Test" to run all tests.
For each test, the test harness will create a new project or open the project file. For every known assembler, the test harness will generate source code, and compare it to the corresponding entry in the Expected directory. If they don't match exactly, a failure is reported for the generation phase. (These are text files, so the line terminators are not required to match.) Next, the generated sources are fed to the appropriate cross-assembler, whether or not the sources matched expectations. If the assembler reports success, the output file is compared to the original data file. If these match, success is reported for the assembly phase.
The top window in the test harness shows a summary of success or failure. The bottom window shows details reported for each individual test. Use 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 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 failures.
As a safety measure, a directory will NOT be removed if it contains files that the test harness doesn't recognize.
Updating Tests
If you want to add or update a test, follow these steps:
- Make the changes to the test data file and test project file.
- Run the test harness. The generation test will fail and leave output in the tmpNNNNN directory. Make sure the assembly test is succeeding.
- After verifying that the generated sources look correct, copy them into the Expected directory, replacing any existing copies.
- Run the test harness. This should now report success, and will remove the tmpNNNNN directory.
- Run "git diff" to verify that the changes match your expectations.
Be sure to have the version of the cross-assembler identified at the top of this document configured.
Other Notes
The original source code used to generate the test cases can be found in the Source directory. The test harness does not use these files. If you want to update a test file, you will need to run the assembler yourself. The assembler used is noted in a comment at the top of the file.
The code is not required to do anything useful. Many of the test cases would crash or hang if executed.
FunkyProjects
This is a collection of project files with deliberate errors. These exist to exercise the load-time error reporting. See the README in that directory for a full explanation.
Visualization
Some test projects and data files for exercising the visualization generators. Not part of a formal test; load the projects and eyeball the results.