Skip to content

Commit

Permalink
doc: improve developer documentation (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbatashev committed Apr 20, 2024
1 parent f62c00f commit b08cf38
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CONTRIBUTING
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ This allow us to review and pull in new features or improvements individually.

All pull requests SHOULD adhere to the [Conventional Commits specification](https://conventionalcommits.org/)

## A Plea for Lean Software

We value concise and readable code. Please, avoid large pull requests, unnecessary dependencies and
complicated abstractions. Some good examples of lean software are [tinygrad](https://github.com/tinygrad/tinygrad)
or [llm.c](https://github.com/karpathy/llm.c) from which we take a lot of inspiration. You can also refer
to this blog post to learn more: https://berthub.eu/articles/posts/a-2024-plea-for-lean-software/.

## License

You must agree that your patch will be licensed under the Conventional Commit License, and when we change the license we will assume that you agreed with the change unless you object to the changes in time.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@ various binary analysis tasks.
- **One-Size-Fits-All Solution:** TIR does not aim to be a one-size-fits-all
tool for all binary analysis needs, but rather a modular framework that can
be extended and customized as needed.

## Building from source

TIR is a Rust project, and can be built with `cargo`, just like any other Rust
project. If you want to contribute to this repository, refer to our
[Developer guide](docs/dev_guide.md) and [Contribution guide](./CONTRIBUTING).
73 changes: 73 additions & 0 deletions docs/dev_guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Developer Guide

## Setting up Rust

The easiest way to set up Rust toolchain is with https://rustup.rs/.
By default, only stable toolchain is installed. Active Rust development
also requires nightly toolchain:

```sh
rustup install nightly
```

## Building and testing

Build is done with `cargo` tool, just like any other Rust project.

```sh
cargo build
# or
cargo build --release
```

Tests can also be done with `cargo test` command, but a much better way is to
use `nextest` tool. To install it, do `cargo install cargo-nextest`. Then run
tests with the following command:

```sh
cargo nextest r
```

`nextest` is much faster than the default test runner.

### Running fuzz tests

We also have fuzzing set up for each user input parser, like a disassembler
or an IR parser. These tests also require an external tool, that can be
installed with a command like `cargo install cargo-fuzz`. The usage is very
simple:

```sh
# List tests
cargo fuzz list
# Run specific test
cargo +nightly fuzz run fuzz_riscv_disassembler -- -max_total_time=60 -max_len=16384
```

### Collecting coverage info


**WARNING!!!** Coverage tool creates a lot of temp files in your working
directory. You better commit all your changes to be able to use git to
clean up.

Install dependencies:

```sh
rustup component add llvm-tools-preview
cargo install grcov
```

Run tests with special flags:

```sh
CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='cargo-test-%p-%m.profraw' cargo test
grcov . --binary-path target/debug/ -s . -t coveralls+ --branch --llvm \
--ignore '../*' --ignore "/*" --ignore 'macros/*' --ignore 'fuzz/*' \
--ignore '**/tests/**' -o target/coverage/html
```

Open `target/coverage/html/index.html` to see the report.

Also `main` branch reports are available at
https://coveralls.io/github/perf-toolbox/tir.

0 comments on commit b08cf38

Please sign in to comment.