Scenario language
The gate runs every *.txt file in this directory, in byte order. Each scenario gets a fresh directory at build/gate/s/NAME.txt.
Build the gate: OMC=../omc ./build.sh tests/GATE_UNITS build/gate-bin. Run it from the repository root: build/gate-bin ../omc [SCENARIO-DIR [MUTANTS-FILE]].
Syntax
- Each non-blank line is one step. A line starting with
#is a comment. - Fields are separated by spaces or tabs.
- In arguments:
@Sexpands to the absolute scenario directory.@Bexpands to the absolutebuild/gatedirectory.@Rexpands to the repository root.
- Paths are relative to the gate's current directory, which is the repository root. Use
@S/...for files in the scenario directory.
Setup steps
mkdir PATHcreates PATH and any missing parents.copy SRC DSTcopies a regular file or a directory tree. Symlinks are copied as symlinks.write PATH TEXTandappend PATH TEXTwrite the rest of the line. Only these two steps decode the escapes\n,\r,\tand\\.symlink TARGET LINKcreates LINK pointing at TARGET.flip PATH OFFSETXORs the byte at OFFSET with 1.gen KIND PATH ARGS...compilestests/units/KIND.txtintobuild/gate/gen-KIND, then runs it asgen-KIND ARGS... PATH. The generator must exit 0.
Running programs
run EXIT STDIN -- PROGRAM ARGS...runs one program.STDINis-(meaning/dev/null) or a file.PROGRAMis:mh: the gate-built mailhand;sink: the gate-built sink;srv: the gate-built fake mail servers and helpers fromtests/srv/UNITS(srv imap DIR,srv smtp DIR SCRIPT COUNT,srv acct OUT DIR NAME KIND HOST USER PASS MODE,srv big OUT N; see the notes intests/srv/*.om). Each server picks a random loopback port in 19000..19999 and writes it to DIR/port;srv acctwaits for it and writes the accounts file;- any other path: run as given.
bg PROGRAM ARGS...starts one background process (stdin /dev/null); PROGRAM as for run.wait EXITreaps the background process, then copies its stdout and stderr into place as the "last run" for the checks below.
Checks on the last run
out-eq FILE: stdout equals FILE byte for byte.out-has TEXT/out-not TEXT: stdout contains / does not contain TEXT.out-lines N: stdout has exactly N newline bytes.err-has TEXT/err-not TEXT: stderr contains / does not contain TEXT.out-sha256 HEX: SHA-256 of stdout, in lowercase hex, equals HEX.max-ns N: an alarm, not a limit. Fails when the last run's wall time, measured with monons from spawn to reap, is above N; the process is never killed early.
File checks
file-eq PATH FILE: PATH equals FILE byte for byte.file-has PATH TEXT/file-not PATH TEXT: PATH contains / does not contain TEXT.exists PATH/absent PATH: PATH exists / does not exist, without following a final symlink.tree-not DIR TEXT: no regular file under DIR (walked without following symlinks) contains TEXT; a hit printstree-not hit: PATH. The credential leak scans use it.
Failures and limits
- A run fails when its exit status differs from EXIT. A signal, or an exit status in the trap range 101..114, is always a failure.
- Each child process has 120 seconds; each compile has 300.
- Fixed host boundaries:
execprogpackets: at most 1024 arguments and 65536 bytes;- each argument: 131072 bytes (MAX_ARG_STRLEN);
- paths: 4096 bytes (PATH_MAX);
- two-path link packets: 4096 bytes.
- Scenario files, file contents, the directory stack and the list of names are all held in stores, so they have no size limit.
Robustness
rob FILEfeedsmh parsemany damaged copies of FILE on stdin, one run per copy. Each copy is written fresh to@S/rob.in. The copies are:- FILE cut at 64 evenly spaced lengths
k*(n-1)/63for k = 0..63, which includes 0 and n-1; - FILE with each of 256 evenly spaced bytes
k*n/256(k = 0..255) xored with 0xff; - for every 4th of those positions (k rem 4 = 3), a second copy with that byte set to 0x00.
- FILE cut at 64 evenly spaced lengths
- Each run must exit 0, or exit 4 with stdout being exactly one LF-terminated JSONL line that contains
"refused". A trap (101..114), a signal, the 120 s limit or any other exit fails the step. - Every failing input is printed as
ROB FAIL FILE cut|xor|zero POSITION exit STATUS. - After the step, the gate prints
rob FILE runs=N ok=A refused=B. Before its final line it prints the totals asMHGATE rob runs=R ok=A refused=B. - In mutant runs, the gate stops at the first failure.