R2R(1)

πŸ“¦ version 6.1.8, in ubuntu stonking

πŸŽ€ R2R(1) πŸŽ€

okay so bestie, this is the manual page for r2r from section 1, and I'm about to make you obsessed with it πŸ’…


πŸ’– NAME πŸ’–

r2r β€” the radare2 regression testsuite. no cap, that's literally the whole name and it ate ✨


🌸 SYNOPSIS 🌸

r2r [-1qvVnLiHh] [-C dir] [-F dir] [-f file] [-o file] [-s test]
    [-S percent] [-t seconds] [-j threads] [-u] [-g]
    [test file/dir | @test-type]

πŸ¦‹ DESCRIPTION πŸ¦‹

so r2r is a command-line regression testing framework for Radare2 and its third-party plugins. it's giving infrastructure queen πŸ‘‘

what it does is automate the discovery and running of a whole bunch of different test suites β€” unit tests, JSON validations, fuzz tests, architecture-specific checks β€” so that code changes don't sneak in regressions behind your back. the way that it protects you… iconic fr fr.

it supports parallel test execution, interactive failure handling, custom timeouts, and filtering tests by type or name. it slots seamlessly into continuous integration workflows or you can just run it locally, and the only thing it asks is that Radare2 be installed and chilling in your system PATH. lowkey the lowest-maintenance bestie ever 🫢


✨ OPTIONS ✨

  • -1 β€” run tests in a single thread (same as -j 1). one thing at a time, main character energy ✨
  • -C dir β€” chdir before running r2r (the default follows the executable symlink + test/new)
  • -F dir β€” run fuzz tests (open and default analysis) on all files in the given dir πŸ”₯
  • -L β€” log mode (better printing for CI, logfiles, etc.). yes bestie, made for your logs
  • -V β€” verbose. tell me EVERYTHING πŸ’¬
  • -f file β€” file to use for json tests (default is bins/elf/crackme0x00b)
  • -g β€” run the tests specified via // R2R comments in modified source files
  • -h β€” print help message πŸ†˜
  • -H β€” display environment variables
  • -i β€” interactive mode πŸ™ˆ
  • -j threads β€” how many threads to use for running tests concurrently (default is 8)
  • -n β€” do nothing (don't run any test, just load/parse them). the "just vibes, no execution" option πŸ’€
  • -o file β€” output test run information in JSON format to file
  • -q β€” quiet (only show errors; suppress non-error output) 🀫
  • -s test β€” set R2R_SKIP_(TEST)=1 to skip running that test type
  • -S percent β€” set R2R_SHALLOW=N to skip a random percentage (0-100) of tests
  • -t seconds β€” timeout per test (default is 3600 seconds). an hour, that's the limit bestie ⏰
  • -u β€” do not git pull/clone test/bins (see R2R_OFFLINE)
  • -v β€” show version 🌈

πŸ’œ ENVIRONMENT πŸ’œ

the vibes are controlled by env vars, periodt:

  • R2R_SKIP_ARCHOS β€” do not run the arch-os-specific tests
  • R2R_SKIP_JSON β€” do not run the JSON tests
  • R2R_SKIP_FUZZ β€” do not run the fuzz tests
  • R2R_SKIP_UNIT β€” do not run the unit tests
  • R2R_SKIP_CMD β€” do not run the cmd tests
  • R2R_SKIP_ASM β€” do not run the rasm2 tests
  • R2R_JOBS β€” maximum parallel jobs (default: 8)
  • R2R_TIMEOUT β€” timeout in seconds (default: 3600 seconds)
  • R2R_OFFLINE β€” same as passing the -u flag
  • R2R_SHALLOW β€” skip 0-100% random tests

🌈 USAGE 🌈

use the -n flag to not run any test. just load them. iykyk 🧚

$ r2r -n
[r2r] Loading tests...

run the tests contained in a directory interactively β€” and if any of those tests fail to run, it prompts you to autofix, edit the commands, etc. so helpful πŸ₯Ή

$ r2r -i test/db/cmd/cmd_pdf

run specific test types using @ notation:

$ r2r @asm       # Run assembly tests
$ r2r @json      # Run JSON tests
$ r2r @unit      # Run unit tests
$ r2r @fuzz      # Run fuzz tests
$ r2r @arch      # Run architecture-specific tests
$ r2r @cmd       # Run command tests

πŸ“ CREATING TESTS πŸ“

r2r loads tests from files under test/db and infers the test type from the path. the path is the vibe check:

  • test/db/asm/* β€” parsed as ASM tests.
  • test/db/json/* β€” parsed as JSON tests.
  • test/db/leak/* β€” parsed as leak tests (command syntax, executed with Valgrind checks).
  • Other files β€” parsed as command tests.

command-style test files are "KEY=VALUE" records, and they're terminated by "RUN". every record is validated at load time. no skipping the validation, bestie πŸ‘‘

NAME=example
FILE=bins/elf/crackme
ARGS=-a x86 -b 64
CMDS=<<EOF
pd 1
EOF
EXPECT=<<EOF
EOF
RUN

"NORUN" marks a pending record as incomplete, so it gets ignored by the parser. records are loaded only when terminated by "RUN" β€” otherwise they're treated as disabled. so if your test is just sitting there with a "NORUN", it is not the moment πŸ’€


πŸ’… TEST RULES πŸ’…

accepted command/leak test keys are handled by R2R_CMD_TEST_FOREACH_RECORD in binr/r2r/r2r.h, and here are the accepted keys:

  • NAME β€” optional identifier used for reporting.
  • FILE β€” optional file input for the r2 command. you can list multiple files on separate lines. if it's omitted, stdin - is used.
  • ARGS β€” extra arguments passed directly to r2 before -Qc and the command block.
  • REQUIRE β€” whitespace-, comma- or semicolon-separated requirement tokens. all listed requirements must be available; otherwise the test is skipped. accepted values are:
    • gas β€” GNU assembler (as) is available in PATH.
    • unix β€” the host is Unix-like.
    • windows β€” the host is Windows.
    • linux β€” the host is Linux.
    • arm β€” the host CPU is ARM.
    • x86 β€” the host CPU is x86.
    • little β€” the host is little-endian.
    • gpl β€” radare2 was built with GPL plugins enabled.
    • zydis β€” radare2 was built with Zydis support.
    • arm.v35 β€” radare2 was built with ARM v35 support.
    • hexagon β€” the selected rasm2 binary lists the hexagon architecture.
    • network β€” network-dependent tests are enabled by R2R_NETWORK=1.
    • x86.udis β€” the selected rasm2 binary lists the x86.udis architecture.
  • REPEAT β€” numeric repeat count. the test command is executed that many times; only the last output is checked. so it's giving "run it back" πŸ”
  • TIMEOUT β€” numeric timeout override for this test, in seconds.
  • SOURCE β€” parsed and accepted for compatibility; no additional runtime behavior is wired in. it's there, it's accepted, it does nothing extra. we love a decorative queen πŸ’…
  • CMDS β€” required command block, passed as -Qc <CMDS>. multiline command blocks must use <<EOF with the closing token at the beginning of the line. single-line quoted values are not accepted. no exceptions bestie 😀
  • EXPECT β€” exact expected stdout match.
  • EXPECT_ERR β€” exact expected stderr match.
  • REGEXP_OUT β€” extended-regex match against stdout.
  • REGEXP_ERR β€” extended-regex match against stderr.
  • ENV β€” semicolon-separated "KEY=VALUE" environment overrides. tokens missing = are ignored.
  • BROKEN β€” boolean (0/1) marking the test as expected-failing. failed broken tests are counted as broken instead of failed.
  • SKIPONASAN β€” boolean (0/1) to skip this test when built with ASAN.
boolean fields accept only "1" or "0" as values. that's it, that's the whole menu πŸŽ€

a command/leak test is only accepted when:

  1. CMDS is present.
  2. Either exact-output or regex-output assertions are present: EXPECT or EXPECT_ERR or REGEXP_OUT or REGEXP_ERR

unknown keys cause parser failure. sorry bestie, there's no "close enough" here πŸ’€

JSON tests load one command per non-empty, non-comment line from files under test/db/json/*. empty lines and # lines are ignored. if a line contains the word "BROKEN," the test is marked broken.

ASM tests are parsed line-by-line as

<modes> "<disassembly text>" <hexbytes>[ <offset>]

"a" enables assemble mode, "d" disassemble mode, "E" enables big-endian and "B" marks the case broken. the filename selects architecture and optional CPU/bits via arch[_cpu]_bits. literally the filename doing double duty, iconic ✨


πŸ” SEE ALSO πŸ”

  • radare2(1) β€” go read that one next, bestie 🫢

πŸ’œ AUTHORS πŸ’œ

written by pancake <pancake@nopcode.org>. thank you pancake, we are forever grateful πŸ™


and that's the whole page, babe β€” this little cutie was dated Jul 10, 2025, and it lives in section R2R(1) πŸ’– slay, you made it to the end πŸŽ€

πŸ“¦ where this page comes from