Giter Club home page Giter Club logo

rfc2119 / radare2-regressions Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aassfxxx/r2-regressions

0.0 3.0 0.0 69.64 MB

Regression Tests for the Radare2 Reverse Engineer's Debugger

Home Page: http://www.radare.org

License: GNU General Public License v3.0

Makefile 1.96% C 51.26% Brainfuck 0.08% Java 0.48% Assembly 1.76% C++ 14.08% Rebol 1.49% Shell 4.53% Python 1.85% Objective-C 0.30% WebAssembly 11.53% JavaScript 10.05% Roff 0.23% R 0.39% Rascal 0.01%

radare2-regressions's Introduction

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

  • new/: New testsuite written in NodeJS.
  • unit/: Unit tests (written in C, using minunit).
  • bins/: Sample binaries.

Requirements

  • Radare2 installed (and in $PATH or set the R2 environment).
  • Valgrind (optional).
  • nodeJS 8 or above

Usage

  • To run all tests, use make -k all.
  • To execute only the unit tests use make -k unit_tests.
  • To execute only the regressions tests use make -k js-tests.
  • To execute and autofix a specific set of tests use node node_modules/node-r2r/bin/r2r.js -i db/XXXX/YYYY within new directory, this will provide a dialog in which you can ask the program to replace the expected output with the current output of radare2.

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 expeced.
  • broken: Failure was expected, and happened.
  • failed: The test failed unexpectedly. This is a regression.

Reporting Radare2 Bugs

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

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

Writing Assembly tests

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

Writing JSON tests

The JSON tests db/new/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 new/ 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

You must end the test by adding RUN keyword

Advices

  • Never use shell pipes, use ~
  • dont use pd if not necessary, use pi

License

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

radare2-regressions's People

Contributors

alvarofe avatar astuder avatar crowell avatar cyanpencil avatar deeso avatar fumfel avatar giuscri avatar gustavolcr avatar h4ng3r avatar hyask avatar jroimartin avatar jvoisin avatar kazarmy avatar maijin avatar maskray avatar mrmacete avatar neuschaefer avatar oddcoder avatar p4n74 avatar radare avatar ret2libc avatar rlaemmert avatar rudis avatar sivaramaaa avatar svenito avatar thestr4ng3r avatar vext01 avatar wargio avatar xarkes avatar xvilka avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.