Scroll to navigation

R2R(1) General Commands Manual R2R(1)

NAME

r2rradare2 regression testsuite

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

r2r is a command-line regression testing framework for Radare2 and its third-party plugins.

It automates the discovery and execution of diverse test suites—including unit tests, JSON validations, fuzz tests, and architecture-specific checks—to ensure that code changes do not introduce regressions.

r2r supports parallel test execution, interactive failure handling, custom timeouts, and filtering of tests by type or name. It integrates seamlessly into continuous integration workflows or can be used locally, and requires only that Radare2 be installed and available in the system PATH.

OPTIONS

Run tests in a single thread (same as -j 1)
dir
Chdir before running r2r (default follows executable symlink + test/new)
dir
Run fuzz tests (open and default analysis) on all files in the given dir
Log mode (better printing for CI, logfiles, etc.)
Verbose
file
File to use for json tests (default is bins/elf/crackme0x00b)
Run the tests specified via '// R2R' comments in modified source files
Print help message
Display environment variables
Interactive mode
threads
How many threads to use for running tests concurrently (default is 8)
Do nothing (don't run any test, just load/parse them)
file
Output test run information in JSON format to file
Quiet (only show errors; suppress non-error output)
test
Set R2R_SKIP_(TEST)=1 to skip running that test type
percent
Set R2R_SHALLOW=N to skip a random percentage (0-100) of tests
seconds
Timeout per test (default is 3600 seconds)
Do not git pull/clone test/bins (See R2R_OFFLINE)
Show version

ENVIRONMENT

Do not run the arch-os-specific tests
Do not run the JSON tests
Do not run the fuzz tests
Do not run the unit tests
Do not run the cmd tests
Do not run the rasm2 tests
Maximum parallel jobs (default: 8)
Timeout in seconds (default: 3600 seconds)
Same as passing -u flag
Skip 0-100% random tests

USAGE

Use the -n flag to not run any test. Just load them.


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

Run the tests contained in a directory interactively, if any of those tests fail to run, prompt the user to autofix, edit the commands, etc.


$ 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:

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 are terminated by “RUN” Every record is validated at load time.

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 is ignored by the parser. Records are loaded only when terminated by “RUN” and otherwise treated as disabled.

TEST RULES

Accepted command/leak test keys are handled by R2R_CMD_TEST_FOREACH_RECORD in binr/r2r/r2r.h with the following accepted keys:

Optional identifier used for reporting.
Optional file input for the r2 command. You can list multiple files on separate lines. If omitted, stdin “-” is used.
Extra arguments passed directly to r2 before “-Qc” and the command block.
Skip condition string. Supported tokens are “gas, unix, windows, linux, arm, x86, little”. Known host tokens are checked at run time; if unsupported, the test is skipped.
Numeric repeat count. The test command is executed that many times; only the last output is checked.
Numeric timeout override for this test in seconds.
Parsed and accepted for compatibility; no additional runtime behavior is wired in.
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.
Exact expected stdout match.
Exact expected stderr match.
Extended-regex match against stdout.
Extended-regex match against stderr.
Semicolon-separated “KEY=VALUE” environment overrides. Tokens missing “=” are ignored.
Boolean (`0`/`1`) marking the test as expected-failing. Failed broken tests are counted as broken instead of failed.
Boolean (`0`/`1`) to skip this test when built with ASAN.
Boolean fields accept only “1” or “0” as values.

A command/leak test is only accepted when:

  1. 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.

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”.

SEE ALSO

radare2(1)

AUTHORS

Written by pancake <pancake@nopcode.org>.

July 10, 2025