19 Commits

Author SHA1 Message Date
Artyom Pavlov 169944f107 Fix custom backend for targets without atomics (#385) 2023-11-08 08:58:24 +03:00
Joe Richey b893cb9c77 Use iterators for num_diff_bits
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-22 13:52:42 -07:00
Joe Richey c83edb650b Add quality tests for calling getrandom on small buffers
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-22 13:37:23 -07:00
Joe Richey c12f70c20a Sharpen bounds in test_diff
We can be much stricter without risking inadvertant failure.

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-22 13:37:21 -07:00
Brian Smith cf85546863 Tests: Use custom tests to verify operations on empty slices are no-ops.
Modify the custom tests so that they would have detected and prevented
the issue fixed in https://github.com/rust-random/getrandom/pull/298.
2022-10-22 13:25:44 -07:00
Joe Richey ee0ca47aa2 Run (most) common tests against the custom RNG
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-22 13:25:44 -07:00
Joe Richey 92af82ab9a Remove state from Custom RNG
This makes it much easier to run this RNG alongside other tests.

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-22 13:25:44 -07:00
Brian Smith 47a59dda25 Add getrandom_uninit_slice(dest: &mut [MaybeUninit<u8>]) -> .... (#291)
* Add `getrandom_uninit(dest: &mut [MaybeUninit<u8>]) -> ...`.

Add a public API for filling an `&mut [MaybeUninit<u8>]`. This will primarily
serve as the building block for more typeful APIs for constructing random
arrays.

Increase the MSRV to 1.36, as `MaybeUninit` was added in that release.

Fixes #226.

* Revert testing changes

Signed-off-by: Joe Richey <joerichey@google.com>

* Allow rdrand tests to work with new implementation

Signed-off-by: Joe Richey <joerichey@google.com>

* Add Additional benchmarks and buffer size

Signed-off-by: Joe Richey <joerichey@google.com>

* Use pointer casts instead of transmute

Signed-off-by: Joe Richey <joerichey@google.com>

* Avoid initializing the buffer in `getrandom_uninit` benchmarks.

* Benchmarks: Consume the result in `black_box`.

Signed-off-by: Joe Richey <joerichey@google.com>
Co-authored-by: Joe Richey <joerichey@google.com>
2022-10-20 19:09:20 -07:00
Joseph Richey 347a300215 Add test for custom RNG handler (#197)
See #194

This uses the fact that `wasm32-unknown-unknown` is an "unsupported" target. This means we can use the `"custom"` feature to define a custom handler, and then write tests to make sure that function is called.
2021-01-05 02:00:21 -08:00
Joseph Richey e29ed04f28 Move tests to tests/ directory (#195)
Signed-off-by: Joe Richey <joerichey@google.com>
2021-01-03 22:24:48 -08:00
Joe Richey 1375181832 tests: Improve testing infrastructure
- Cleanup .travis.yml
  - Loops over std/no_std targets
  - Remove deprecated/useless keys
  - No more `cd`, we just use `--package`.
- Improve tests
  - Main `getrandom` tests are now unit test modules instead of
    integration tests, making the code cleaner.
  - The custom RNG crates now use this common module as part of their
    integration tests.
  - No more weird test-only features needed to get the crate to build.

Signed-off-by: Joe Richey <joerichey@google.com>
2020-02-19 10:21:58 -08:00
Joe Richey 8365277450 custom: Add Custom RNG for wasm-bindgen 2020-01-10 09:16:20 +00:00
Joe Richey 7d558f1cc3 custom: Add custom RNG for stdweb 2020-01-10 09:16:20 +00:00
Joseph Richey fa6f929aed Improve CI for web targets (#108)
* Simplify CI process for WASM

Run WASI tests, and run both stdweb/wasm-bindgen on both node and in browsers

These changes also remove the need for a separate tests/wasm_bindgen

* Use all pre-built binaries in the CI

* Fix Cargo.toml typo

Co-Authored-By: Artyom Pavlov <newpavlov@gmail.com>

* Fix install location

* Debug CI
2019-09-21 01:46:26 -07:00
Joe Richey 3d8373b89d Run Rustfmt on entire repo 2019-06-26 02:56:41 -07:00
Diggory Hardy aa2bde5be0 Prepare 0.1.1 release and add zero-len test 2019-04-05 16:16:27 +01:00
Diggory Hardy 51303b5bb8 Implement on WASM via stdweb and bindgen; add tests 2019-02-25 12:54:46 +00:00
Артём Павлов [Artyom Pavlov] 9855b52df2 change test cfg 2019-02-05 22:07:56 +03:00
newpavlov 71a3cb8a96 first commit 2019-02-04 20:57:30 +03:00