-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: improve developer documentation (#15)
- Loading branch information
1 parent
f62c00f
commit b08cf38
Showing
3 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |