Writing assembly tests
Skill gerph/riscos-agent-skills/skills/writing-assembly-tests
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.From its SKILL.md
npx -y skills add gerph/riscos-agent-skills --skill writing-assembly-testsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
11.5 KB, ~2.8k tokens by cl100k_base, as published. Nobody here has run it
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: abc
That 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.
What ships with it: 56 files
293.2 KB alongside SKILL.md, 3 of them executable
agents/
- openai.yaml261 B
assets/
- buildservice-example/testcode/expect/var/delete129 B
- buildservice-example/testcode/expect/var/read_enumeration318 B
- buildservice-example/testcode/expect/var/read_Sys$Time134 B
- buildservice-example/testcode/expect/var/read_Undefined109 B
- buildservice-example/testcode/expect/var/replacements327 B
- buildservice-example/testcode/expect/var/set_CLI$Prompt-]169 B
- buildservice-example/testcode/expect/var/set_code_error255 B
- buildservice-example/testcode/expect/var/set_code_read149 B
- buildservice-example/testcode/expect/var/set_code_write286 B
- buildservice-example/testcode/expect/var/set_expanded290 B
- buildservice-example/testcode/expect/var/set_expansion_char174 B
- buildservice-example/testcode/expect/var/set_expansion_variable188 B
- buildservice-example/testcode/expect/var/set_literal177 B
- buildservice-example/testcode/expect/var/set_macro329 B
- buildservice-example/testcode/expect/var/set_number295 B
- buildservice-example/testcode/expect/var/set_number_negative298 B
- buildservice-example/testcode/expect/var/set_quoted181 B
- buildservice-example/testcode/expect/var/set_Sys$Time-12:15124 B
- buildservice-example/testcode/expect/var/set_Undefined-NewValue181 B
- buildservice-example/testcode/expect/var/standardvars_Sys$Date138 B
- buildservice-example/testcode/expect/var/standardvars_Sys$Time134 B
- buildservice-example/testcode/expect/var/standardvars_Sys$Year130 B
- buildservice-example/testcode/expect/var/sysrq-sysvars-get110 B
- buildservice-example/testcode/expect/var/sysrq-sysvars-info2.5 KB
- buildservice-example/testcode/expect/var/sysrq-sysvars_replacements48 B
- buildservice-example/testcode/expect/var/sysrq-sysvars-set189 B
- buildservice-example/testcode/.gitignore10 B
- buildservice-example/testcode/hdr/macros3.8 KB
- buildservice-example/testcode/hdr/osplot3.1 KB
- buildservice-example/testcode/hdr/osspriteop4.2 KB
- buildservice-example/testcode/hdr/printmacros7.8 KB
- buildservice-example/testcode/hdr/swis51.9 KB
- buildservice-example/testcode/hdr/vdu1.8 KB
- buildservice-example/testcode/Makefile2.2 KB
- buildservice-example/testcode/run-on-build-service.shruns4.5 KB
- buildservice-example/testcode/s/_args_common4.2 KB
- buildservice-example/testcode/s/_colourtrans_common2.7 KB
- buildservice-example/testcode/s/_dump_common1.6 KB
- buildservice-example/testcode/s/_screenmode_common4.6 KB
16 more files not listed here. See all 56 in the repository.