|
2 | 2 |
|
3 | 3 | - Pick your favorite math function from the [issue tracker].
|
4 | 4 | - Look for the C implementation of the function in the [MUSL source code][src].
|
5 |
| -- Copy paste the C code into a Rust file in the `src/math` directory and adjust `src/math/mod.rs` |
6 |
| - accordingly. Also, uncomment the corresponding trait method in `src/lib.rs`. |
7 |
| -- Run `cargo watch check` and fix the compiler errors. |
8 |
| -- Tweak the bottom of `test-generator/src/main.rs` to add your function to the test suite. |
9 |
| -- If you can, run the full test suite locally (see the [testing](#testing) section below). If you |
10 |
| - can't, no problem! Your PR will be fully tested automatically. Though you may still want to add |
11 |
| - and run some unit tests. See the bottom of [`src/math/truncf.rs`] for an example of such tests; |
12 |
| - you can run unit tests with the `cargo test --lib` command. |
13 |
| -- Send us a pull request! Make sure to run `cargo fmt` on your code before sending the PR. Also |
14 |
| - include "closes #42" in the PR description to close the corresponding issue. |
| 5 | +- Copy paste the C code into a Rust file in the `src/math` directory and adjust |
| 6 | + `src/math/mod.rs` accordingly. Also, uncomment the corresponding trait method |
| 7 | + in `src/lib.rs`. |
| 8 | +- Write some simple tests in your module (using `#[test]`) |
| 9 | +- Run `cargo test` to make sure it works |
| 10 | +- Run `cargo test --features musl-reference-tests` to compare your |
| 11 | + implementation against musl's |
| 12 | +- Send us a pull request! Make sure to run `cargo fmt` on your code before |
| 13 | + sending the PR. Also include "closes #42" in the PR description to close the |
| 14 | + corresponding issue. |
15 | 15 | - :tada:
|
16 | 16 |
|
17 |
| -[issue tracker]: https://github.com/japaric/libm/issues |
| 17 | +[issue tracker]: https://github.com/rust-lang-nursery/libm/issues |
18 | 18 | [src]: https://git.musl-libc.org/cgit/musl/tree/src/math
|
19 |
| -[`src/math/truncf.rs`]: https://github.com/japaric/libm/blob/master/src/math/truncf.rs |
| 19 | +[`src/math/truncf.rs`]: https://github.com/rust-lang-nursery/libm/blob/master/src/math/truncf.rs |
20 | 20 |
|
21 | 21 | Check [PR #65] for an example.
|
22 | 22 |
|
23 |
| -[PR #65]: https://github.com/japaric/libm/pull/65 |
| 23 | +[PR #65]: https://github.com/rust-lang-nursery/libm/pull/65 |
24 | 24 |
|
25 | 25 | ## Tips and tricks
|
26 | 26 |
|
@@ -78,18 +78,18 @@ let x1p127 = f32::from_bits(0x7f000000); // 0x1p127f === 2 ^ 12
|
78 | 78 |
|
79 | 79 | ## Testing
|
80 | 80 |
|
81 |
| -The test suite of this crate can only be run on x86_64 Linux systems using the following commands: |
| 81 | +Normal tests can be executed with: |
82 | 82 |
|
83 |
| -``` console |
84 |
| -$ # The test suite depends on the `cross` tool so install it if you don't have it |
85 |
| -$ cargo install cross |
86 |
| - |
87 |
| -$ # and the `cross` tool requires docker to be running |
88 |
| -$ systemctl start docker |
| 83 | +``` |
| 84 | +cargo test |
| 85 | +``` |
89 | 86 |
|
90 |
| -$ # execute the test suite for the x86_64 target |
91 |
| -$ TARGET=x86_64-unknown-linux-gnu bash ci/script.sh |
| 87 | +If you'd like to run tests with randomized inputs that get compared against musl |
| 88 | +itself, you'll need to be on a Linux system and then you can execute: |
92 | 89 |
|
93 |
| -$ # execute the test suite for the ARMv7 target |
94 |
| -$ TARGET=armv7-unknown-linux-gnueabihf bash ci/script.sh |
95 | 90 | ```
|
| 91 | +cargo test --features musl-reference-tests |
| 92 | +``` |
| 93 | + |
| 94 | +Note that you may need to pass `--release` to Cargo if there are errors related |
| 95 | +to integer overflow. |
0 commit comments