writing-assembly-tests
Skill4 starsChanged 8 months agoMITView on GitHub
Write and test small ObjAsm command-line exercisers under `testcode/s`, including optional reuse of Pyromaniac suites through a build-service runner when a repository needs to ship module tests outside the main Pyromaniac tree.
In this repository47 other files it gives its agents.
- allocating-resourcesSkill
- ci-testingSkill
- creating-pull-requestsSkill
- designing-modulesSkill
- porting-to-riscos-cSkill
- reading-assemblySkill
- riscos-commandsSkill
- riscos-desktop-fileractionSkill
- riscos-filer-likeSkill
- riscos-filesystemSkill
- riscos-graphics-convertersSkill
- riscos-network-dcistatisticsSkill
- riscos-network-resolverSkill
- riscos-outputSkill
- riscos-reSkill
- riscos-styleSkill
- riscos-throwbackSkill
- riscos-urls-fetchingSkill
- riscos-urls-launchingSkill
- riscos-wimp-appSkill
- riscos-wimpSkill
- riscos-wimp-templatesSkill
- updating-robe-skillsSkill
- using-bbcbasicSkill
- using-cmhgSkill
- using-ghSkill
- using-gitSkill
- using-libasmSkill
- using-libgcontextSkill
- using-liboslibSkill
- using-libriscoslibSkill
- using-libtoolboxSkill
- using-makefilesSkill
- using-perlSkill
- using-stronghelpSkill
- using-toolbox-imagefilegadgetSkill
- using-tooltesterSkill
- writing-assemblySkill
- writing-cmodulesSkill
- writing-cplusplusSkill
- writing-cSkill
- writing-fortranSkill
- writing-oslib-defsSkill
- writing-pascalSkill
- writing-prminxmlSkill
- writing-pymodulesSkill
- writing-pyromaniac-integration-testsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
33 rules. About 0 are common, 7 are distinctive, and 26 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈7
Distinctive · estimate
This author's own choices. Worth a look.
26
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Use this skill when adding or updating a small ARM assembly test program in testcode/s/ which exercises SWIs, commands, or module entry …
- Very specific: line 18
Create testcode/s/<toolname> as an ObjAsm source.
- Very specific: line 23
If the tool needs argument parsing beyond a single character dispatch, reuse the helper routines from assets/testcode/s/_args_common.
- Distinctive: line 26
Run it manually with:
- Very specific: line 32
Add a suite testcode/tests-<name>.txt and expectation files under testcode/expect/....
- Distinctive: line 34
Run the suite with:
- Very specific: line 39
When committing the test, include the built binary in testcode/bin/<toolname> as well as the source and expectations.
- Very specific: line 44
When extending an existing suite with another assembly exerciser, prefer adding another Test: entry alongside the existing one rather than …
- Very specific: line 53
Keep the assembly exercisers and expectations in a local testcode/ tree.
- Very specific: line 54
Treat tests-<name>-pyro.txt as the source suite lifted from Pyromaniac.
- Very specific: line 58
Run the resulting suite through a local copy of test.pl using a runner such as run-on-build-service.sh.
- Distinctive: line 63
Use this only when the repository needs Pyromaniac-compatible tests without depending on the whole Pyromaniac tree.
- Very specific: line 69
When restoring the bundled build-service example into a repository, do the setup in this order so the generated suites and make tests …
- Very specific: line 80
update the tests: prerequisite list to name the generated suites your repository uses
- Distinctive: line 82
add any extra copied module binaries required by the tests
- Very specific: line 88
Add tests-<area>-pyro.txt files as the source suites lifted from Pyromaniac or written in the same style.
- Very specific: line 90
Keep any non-Pyromaniac tests, such as ad hoc BASIC smoke tests, in plain tests-<name>.txt files.
- Very specific: line 93
Put the simpler assembly-based suites first in tests.txt.
- Very specific: line 99
Run the suites with make tests.
- Very specific: line 101
If make tests-<name>.txt reports no rule for a generated suite, check that:
- Distinctive: line 108
If the generated suite exists but still appears to run stale commands or expectations, rebuild it explicitly before debugging anything …
- Very specific: line 141
Do not drop them into the destination with their skill-bundle path unchanged.
- Very specific: line 147
Read the documentation in references/ and use the concrete files in assets/testcode/ as copyable examples:
- Very specific: line 165
Keep the entry point small: move R1 to R8, then dispatch on short option letters.
- Very specific: line 167
When an operation needs a filename, URL, sprite name, or other string argument, prefer a small local read_string routine in the style of …
- Distinctive: line 171
Use one-letter actions when that keeps the command line compact and makes grouped tests easy to write.
- Very specific: line 173
Prefer exercising one interface per verb, then compose verbs in the test Args: string.
- Distinctive: line 175
If the tool already has a built-in table-validation or self-checking mode, prefer driving that single mode from the suite and comparing its …
- Very specific: line 178
Keep helper state in static storage near the end of the file, following the existing testcode/s/* pattern.
- Very specific: line 180
Avoid compiling host-specific test data paths into the binary when the value can be passed in from the test harness.
- Very specific: line 183
If the assembly source changes, rebuild and commit the matching testcode/bin/<toolname> binary in the same change so the repository remains …
- Very specific: line 203
If a scenario needs setup parameters, put them directly into the argument string.
- Very specific: line 245
Do not run multiple copies of the bundled build-service runner in parallel from the same testcode/ directory unless you have first made its …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Writing tests in assembly
Use this skill when adding or updating a small ARM assembly test program in
testcode/s/ which exercises SWIs, commands, or module entry points through a
simple command-line interface.
Workflow
- Create
testcode/s/<toolname>as an ObjAsm source. - Include the standard helper headers:
GET hdr.swisGET hdr.printmacrosGET hdr.macros
- If the tool needs argument parsing beyond a single character dispatch, reuse
the helper routines from
assets/testcode/s/_args_common. - Build the tool with
make testcodeormake -C testcode bin/<toolname>. Run it manually with:
./pyro.py --load-internal-modules testcode/bin/<toolname> <args>- Add a suite
testcode/tests-<name>.txtand expectation files undertestcode/expect/.... Run the suite with:
make tests TEST=<name>- When committing the test, include the built binary in
testcode/bin/<toolname>as well as the source and expectations. In this environment CI runs the tests but does not build the test binaries first, so the checked-in binary is part of the test asset.
When extending an existing suite with another assembly exerciser, prefer adding
another Test: entry alongside the existing one rather than creating a fresh
group unless the public interface being exercised is genuinely separate.
Optional build-service reuse pattern
Some component repositories do not run the tests inside a full Pyromaniac checkout. Instead they:
- Keep the assembly exercisers and expectations in a local
testcode/tree. - Treat
tests-<name>-pyro.txtas the source suite lifted from Pyromaniac. - Generate a local
tests-<name>.txtby rewriting the Pyromaniac-specificCommand:,Expect:,Replace:, and path forms. - Bundle the module under test, the test binaries, and the harness scripts.
- Run the resulting suite through a local copy of
test.plusing a runner such asrun-on-build-service.sh. - Have that runner translate Pyromaniac-style options into a
.robuild.yamlscript and submit the archive withriscos-build-online.
Use this only when the repository needs Pyromaniac-compatible tests without depending on the whole Pyromaniac tree. Not every assembly-test repository needs this extra layer.
Reliable setup sequence for the build-service pattern
When restoring the bundled build-service example into a repository, do the
setup in this order so the generated suites and make tests target work
first time:
- Copy the bundled
assets/buildservice-example/testcode/tree into the repositorytestcode/directory. - Copy in any additional helper headers and helper sources your specific
tests need, such as
hdr/vdu,hdr/osplot,hdr/osspriteop, or locals/_*.commonhelpers that are not part of this skill bundle. - Update
testcode/Makefile:- set
MODULE = <module-under-test> - update the
tests:prerequisite list to name the generated suites your repository uses - add any extra copied module binaries required by the tests
- set
- Update
testcode/run-on-build-service.sh:- set
files=(...)to include the built test binaries and any data directories needed at runtime - set
modules=(...)to the modules that must beRMLoaded before the test command runs
- set
- Add
tests-<area>-pyro.txtfiles as the source suites lifted from Pyromaniac or written in the same style. - Keep any non-Pyromaniac tests, such as ad hoc BASIC smoke tests, in plain
tests-<name>.txtfiles. Do not route those through the Pyromaniac transform rule. - Put the simpler assembly-based suites first in
tests.txt. Place heavier smoke tests such as BASIC runners later, because the assembly tools usually provide the more fundamental interface coverage with fewer dependencies. - Build the assembly tools with
makeintestcode/. - Regenerate any transformed local suites with commands such as
make tests-<area>.txtafter editingtests-<area>-pyro.txt. - Run the suites with
make tests.
If make tests-<name>.txt reports no rule for a generated suite, check that:
tests-<name>-pyro.txtexists with the exact matching stemtransform-pyro-tests-to-buildservice.shis present and executable- the suite is intended to be generated, rather than being a hand-written non-Pyromaniac test file
If the generated suite exists but still appears to run stale commands or expectations, rebuild it explicitly before debugging anything deeper.
Asset layout
This skill stores non-documentation files under assets/ using the same names
and relative paths they would have in a testcode/ source tree.
That is intentional. If you reuse one of these bundled files, copy it back into the matching location in the target tree:
assets/testcode/s/_args_common->testcode/s/_args_commonassets/testcode/s/urlfetcher->testcode/s/urlfetcherassets/testcode/hdr/macros->testcode/hdr/macrosassets/testcode/hdr/printmacros->testcode/hdr/printmacrosassets/testcode/hdr/swis->testcode/hdr/swisassets/testcode/Makefile->testcode/Makefileassets/testcode/tests-pymodules-urlfetcher.txt->testcode/tests-pymodules-urlfetcher.txtassets/buildservice-example/testcode/...-> copy the contents of that bundled example tree back into a real repositorytestcode/directory
The build-service example bundle also includes optional common files that may be useful when the copied test sources depend on them:
assets/buildservice-example/testcode/hdr/vdu->testcode/hdr/vduassets/buildservice-example/testcode/hdr/osplot->testcode/hdr/osplotassets/buildservice-example/testcode/hdr/osspriteop->testcode/hdr/osspriteopassets/buildservice-example/testcode/s/_args_common->testcode/s/_args_commonassets/buildservice-example/testcode/s/_dump_common->testcode/s/_dump_commonassets/buildservice-example/testcode/s/_colourtrans_common->testcode/s/_colourtrans_commonassets/buildservice-example/testcode/s/_screenmode_common->testcode/s/_screenmode_commonassets/buildservice-example/testcode/.gitignore->testcode/.gitignore
Do not drop them into the destination with their skill-bundle path unchanged.
The assembler expects names such as s/<toolname> and hdr/<header> inside
the real source tree.
What to read
Read the documentation in references/ and use the concrete files in
assets/testcode/ as copyable examples:
workflow.mdfor the expected repository patternassets/testcode/s/_args_commonfor the shared argument parsersassets/testcode/hdr/macrosforPush,Pull,XSWI,XBL, andSIGNATUREassets/testcode/hdr/printmacrosforPrintMessage,PrintInteger,PrintHex, and string helpersassets/testcode/hdr/swisfor the shared SWI symbol definitionsassets/testcode/Makefilefor the exact build rulesassets/testcode/s/urlfetcherfor a full command-line exerciserassets/testcode/tests-pymodules-urlfetcher.txtfor a parameterised suite examplereferences/build-service-pyromaniac-reuse.mdfor the optional build-service bridge patternassets/buildservice-example/testcode/for a complete example tree that keeps Pyromaniac-style suites, transforms them, and runs them remotely
Style that matches this tree
- Keep the entry point small: move
R1toR8, then dispatch on short option letters. - When an operation needs a filename, URL, sprite name, or other string
argument, prefer a small local
read_stringroutine in the style oftestcode/s/sprite_plotso the value can be supplied at runtime. - Print plain text results that are easy to compare in expectation files.
- Use one-letter actions when that keeps the command line compact and makes grouped tests easy to write.
- Prefer exercising one interface per verb, then compose verbs in the test
Args:string. - If the tool already has a built-in table-validation or self-checking mode, prefer driving that single mode from the suite and comparing its full output. This keeps the assembly binary as the canonical source of the case table.
- Keep helper state in static storage near the end of the file, following the
existing
testcode/s/*pattern. - Avoid compiling host-specific test data paths into the binary when the value
can be passed in from the test harness. This matters especially for
cwd-sensitive
file:URLs. - If the assembly source changes, rebuild and commit the matching
testcode/bin/<toolname>binary in the same change so the repository remains runnable by CI and by other developers.
Test suite pattern
A common group-level pattern is:
Group: Module: Operations
Command: $TOOL --load-internal-modules bin/<toolname> $ARG1
Expect: expect/<area>/<toolname>/<toolname>_$ARG1
Test: Do one scenario
Args: abcThat lets each Args: string describe a whole scenario while keeping the suite
file short.
If a scenario needs setup parameters, put them directly into the argument
string. For example, a fetch test may prepend f<url>, before the operation
verbs so the same tool can be reused with different URLs.
For build-service runners and transformed local suites, remember that the
invoked RISC OS command path will usually use dotted form such as
bin.<toolname>, even though the host-side Pyromaniac source suite may mention
bin/<toolname>. If you invoke the bridge script manually, use the same dotted
form that the transformed local suite would pass.
Build-service example assets
The bundled example under assets/buildservice-example/testcode/ captures a
component-repository pattern for reusing Pyromaniac assembly tests elsewhere.
The important files are:
Makefileto builds/*, copy in the module under test, transformtests-*-pyro.txt, and invoketest.pltransform-pyro-tests-to-buildservice.shto normalise Pyromaniac suites for non-Pyromaniac executionrun-on-build-service.shto turn Pyromaniac-style command-line switches into.robuild.yamlcommands and submit them withriscos-build-onlinetest.plas the repository-local copy of the tooltester harnesstests.txt,tests-sysvars-pyro.txt, andtests-sysvars.txtas a source suite plus generated outputs/var_read,s/var_set,hdr/*, andexpect/var/*as a complete sample test tree- optional extra headers such as
hdr/vdu,hdr/osplot, andhdr/osspriteop - optional shared helper sources such as
s/_args_common,s/_dump_common,s/_colourtrans_common, ands/_screenmode_common - a sample
.gitignore
That example is intentionally concrete. Reuse the structure and scripts, then replace the module names, uploaded files, assembly exercisers, and expectation files for the target repository.
For repositories that mix transformed Pyromaniac suites with local smoke tests,
keep the generated tests-*-pyro.txt source files alongside any hand-written
plain tests-*.txt files. Only the Pyromaniac-derived suites should use the
automatic tests-%.txt: tests-%-pyro.txt ... conversion rule.
Do not run multiple copies of the bundled build-service runner in parallel from
the same testcode/ directory unless you have first made its temporary file
handling unique. The simple example runner writes a shared .robuild.yaml, so
parallel invocations can interfere with each other.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

