radare2/test
Sylvain Pelissier fe31b6759f
Some checks are pending
build / linux-wasi (push) Waiting to run
build / linux-wasi-api (push) Waiting to run
build / linux-csnext (push) Waiting to run
build / tarball (push) Waiting to run
build / linux-static (push) Waiting to run
build / linux-acr-rpm-64 (push) Waiting to run
build / linux-acr-deb (amd64) (push) Waiting to run
build / linux-acr-deb (arm64, aarch64-linux-gnu) (push) Waiting to run
build / linux-acr-deb (i386, multilib) (push) Waiting to run
build / macos-acr (arm64, 13) (push) Waiting to run
build / macos-acr (x86_64, 12) (push) Waiting to run
build / ios (cydia32) (push) Waiting to run
build / ios (true, cydia) (push) Waiting to run
build / android-acr (16, arm) (push) Waiting to run
build / android-acr (aarch64) (push) Waiting to run
build / android-meson (x86_64) (push) Waiting to run
build / w32-meson (push) Waiting to run
build / w64-static-2022 (push) Waiting to run
build / w64-static (push) Waiting to run
build / w64-meson (push) Waiting to run
build / check_abi_compatibility (push) Blocked by required conditions
build / check_release (push) Blocked by required conditions
build / release (push) Blocked by required conditions
CI / linux-acr-oldlibsbug (push) Waiting to run
CI / linux-nocs (push) Waiting to run
CI / linux-acr-gperf (push) Waiting to run
CI / linux-sys-capstone (push) Waiting to run
CI / linux-acr-resymlink (push) Waiting to run
CI / linux-test (push) Waiting to run
CI / linux-static-meson (push) Waiting to run
CI / macos-test (push) Waiting to run
CI / linux-rpath (push) Waiting to run
CI / macos-rpath (push) Waiting to run
CI / linux-meson-spaces (push) Waiting to run
CI / linux-tinyasan-fuzz (push) Waiting to run
CI / linux-asan-fuzz (push) Waiting to run
CI / w64-make (push) Waiting to run
CI / w32-mingw (push) Waiting to run
CI / w64-mingw (push) Waiting to run
Code scanning - action / CodeQL-Build (push) Waiting to run
Coverity Scan / latest (push) Waiting to run
tcc / ubuntu-tcc-newabi (push) Waiting to run
tcc / ubuntu-tcc-test (push) Waiting to run
tcc / ubuntu-tcc-nodbg (push) Waiting to run
tcc / r2pm-tcc (push) Waiting to run
tcc / ubuntu-tcc-syslibs (push) Waiting to run
New commands poE and poD ##crypto
2024-10-06 20:02:34 +02:00
..
bench Add quickjs benchmark script 2022-01-06 22:54:55 +01:00
db New commands poE and poD ##crypto 2024-10-06 20:02:34 +02:00
fuzz Initial import of the dalvik.ns plugin ##arch 2024-09-19 15:56:29 +02:00
notworking_db Move test/new/* into test/ ##tests (#16511) 2020-04-13 19:49:23 +02:00
perf Fix possible null deref in the elf parser related to bin.limits 2023-08-18 17:28:01 +02:00
scripts Make rasm2 flags more coherent (-s,-S,-o,-O) ##tools 2024-09-05 16:21:11 +02:00
unit Emit span instead of font in the scr.html filter ##cons 2024-09-24 12:04:15 +02:00
.gitignore Add option to log r2r test results and publish it in the CI (#17964) ##test 2020-11-24 03:43:41 +01:00
Makefile Remove old Yara tests 2024-09-06 09:11:50 +02:00
README.md README: Fix unit tests target after fd9f8d631 ##doc 2023-08-22 17:18:44 +02:00
run_unit.sh Many improvements in the V testsuite (#15722) ##test 2019-12-29 19:26:15 +01:00

Radare2 Regression Test Suite

A set of regression tests for Radare2 (http://radare.org).

Originally based on work by and now in collaboration with pancake.

Directory Hierarchy

  • db/: The tests sources
  • unit/: Unit tests (written in C, using minunit).
  • fuzz/: Fuzzing helper scripts
  • bins/: Sample binaries (fetched from the external repository)

Requirements

  • Radare2 installed (and in $PATH or set the R2 environment).
  • r2pipe tests require Python and r2pipe (in CI uses python3 and r2pipe from git, but users may be good with latests releases)
  • Valgrind (optional).

Usage

  • To run all tests, use make -k all.
  • To execute only the unit tests use make -k unit-tests.

Failure Levels

A test can have one of the following results:

  • success: The test passed, and that was expected.
  • fixed: The test passed, but failure was expected.
  • broken: Failure was expected, and happened.
  • failed: The test failed unexpectedly. This is a regression.

Reporting a Bug

Please do not post Radare2 bugs on the r2-regressions github tracker. Instead use the official r2 tracker:

https://github.com/radareorg/radare2/issues?state=open

Test Types

There are different types of tests, asm, json and cmd. Those files are located under the db/ directory.

Assembly tests

The asm are used to verify that the assembler and disassembler for an instruction + arch works properly.

Example tests for db/asm/*:

General format:
type "assembly" opcode [offset]

	type:
		* a stands for assemble
		* d stands for disassemble
		* B stands for broken
		* E stands for cfg.bigendian=true

	offset:
		Some architectures are going to assemble an instruction differently depending
		on the offset it's written to. Optional.

Examples:
a "ret" c3
d "ret" c3
a "nop" 90 # Assembly is correct
dB "nopppp" 90 # Disassembly test is broken

You can merge lines:

adB "nop" 90

acts the same as

aB "nop" 90
dB "nop" 90

    The filename is very important. It is used to tell radare which architecture to use.

    Format:
    arch[[_cpu]_bits]

Example:
x86_32 means -a x86 -b 32
    arm_v7_64 means what it means

JSON tests

The JSON tests db/json are executed on 3 standard files (1 ELF, 1 MachO, 1 PE). The tests need to be working on the 3 files to pass.

Commands tests

Example commands tests for the other db/ folders:

NAME=test_db
FILE=bins/elf/ls
CMDS=<<EXPECT
pd 4
EXPECT=<<RUN
        ;-- main:
        ;-- entry0:
        ;-- func.100001174:
        0x100001174      55             Push rbp
        0x100001175      4889e5         Mov  rbp, rsp
        0x100001178      4157           Push r15
RUN
  • NAME is the name of the test, it must be unique
  • FILE is the path of the file used for the test
  • ARGS (optional) are the command line argument passed to r2 (e.g -b 16)
  • CMDS are the commands to be executed by the test
  • EXPECT is the expected output of the test
  • BROKEN (optional) is 1 if the tests is expected to be fail, 0 otherwise
  • TIMEOUT (optional) is the number of seconds to wait before considering the test timeout

You must end the test by adding RUN keyword

Advices

  • For portability reasons Do not use shell pipes, use ~
  • dont use pd if not necessary, use pi
  • All tests use the UTC timezone for consistency.

License

The test files are licensed under GPL 3 (or later).