Commit Graph

348 Commits

Author SHA1 Message Date
Khem Raj 7f73e3ccc1 Use open instead of open64 (#326)
glibc is providing open64 and other lfs64 functions but musl aliases
them to normal equivalents since off_t is always 64-bit on musl,
therefore check for target env along when target OS is linux before
using open64, this is more available. Latest Musl has made these
namespace changes [1]

There is no need for using LFS64 open explicitly as we are only using it
for opening device files and not real files

[1] https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4

Signed-off-by: Khem Raj <raj.khem@gmail.com>

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2023-01-06 08:43:34 +00:00
Artyom Pavlov 698a6d1a06 Disable cross build/link tests (#328) 2023-01-04 00:44:52 -08:00
Kian-Meng Ang ea5ef25714 Fix typos (#327) 2023-01-04 06:58:29 +00:00
Qiu Chaofan e0e406df8a Support random file of AIX (#282) 2022-12-30 10:44:40 +00:00
Joseph Richey beb65e241e Merge pull request #325 from flba-eb/add_qnx_nto_support
Add QNX/nto support
2022-12-23 23:49:19 -08:00
Florian Bartels 993505c17f Enable tests for QNX/Neutrino, integrate new libc version 2022-12-23 07:50:53 +01:00
Florian Bartels 52c2780646 Add QNX/nto support 2022-11-15 08:43:26 +01:00
Joseph Richey 759a9d743c Merge pull request #324 from rust-random/ci
Improve CI and update runners
2022-10-31 13:28:04 -07:00
Joe Richey f096c04523 Update all runners to macOS 12
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-31 00:09:06 -07:00
Joe Richey 2e66e5921f Programaticly select iOS simulator Runtime/Device
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-31 00:09:06 -07:00
Joe Richey 62e697f9ca Run web tests on 20.04
This is necessary to get Firefox to work.

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-31 00:09:06 -07:00
Joe Richey b04bd03e14 Explicitly use windows-2022
Currently this is the same as `windows-latest` so this is not a
functional change.

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-31 00:09:06 -07:00
Joe Richey 9d4a91f9a1 Remove workaround not needed on Ubuntu 22.04
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-31 00:09:06 -07:00
Joe Richey 941c2fff69 Update tests to run on Ubuntu 22.04 (instead of 20.04)
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-31 00:09:06 -07:00
Joe Richey 5ddec2a8f4 Check OS using runner.os instead of matrix.os
This makes it easier to later update the OS verions

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-31 00:09:06 -07:00
Joe Richey 8e4ecdb72f Use "host" instead of "target" in Web Tests
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-31 00:08:59 -07:00
Joseph Richey 5a4a8eafe5 Fix iOS simulator CI (#323)
The upgrade to macOS 12 broke this iOS simulator CI (as support for the
iPhone 7 was dropped I think).

We should have a follow up PR to see if we can just test against a more
recent iPhone.

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-30 20:31:26 -07:00
Jared Ramon Elizan 8b36b3e634 README.md (#322)
fixed typo
2022-10-30 17:13:52 -07:00
Joseph Richey c93c2603f0 Merge pull request #321 from rust-random/webtest
CI: Add Web Tests for Edge on Windows
2022-10-26 01:23:35 -07:00
Joe Richey c3d9797a0b Just Pin Versions for compiled downloads
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-25 23:44:36 -07:00
Joe Richey 03f6688195 Cleanup other binary download steps
Be consistent and always use wget

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-25 23:31:56 -07:00
Joe Richey f84a061151 Add additional Web Tests
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-25 23:05:32 -07:00
Joseph Richey 8e44d13ebf Merge pull request #317 from thomcc/tvos-watchos
Add tvOS and watchOS support, identical to iOS support
2022-10-25 02:50:29 -07:00
Thom Chiovoloni e32ea822c3 Add tvOS and watchOS to CI 2022-10-24 23:24:56 -07:00
Thom Chiovoloni e6ed8e1a55 Add tvOS and watchOS support, identical to iOS support 2022-10-24 18:21:50 -07:00
Joseph Richey 2aabb63d2c Merge pull request #316 from rust-random/ci
CI: Run iOS targets and other improvements
2022-10-24 12:22:23 -07:00
Joe Richey 4917673cd2 Break up Tier 3 builds
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-24 01:56:17 -07:00
Joe Richey b35add2bb7 Uptade to Swatinem/rust-cache@v2
Also move the cache step to be right before we start running cargo
commands.

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-24 01:56:17 -07:00
Joe Richey a91ad48d8c Update to actions/checkout@v3
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-24 01:56:17 -07:00
Joe Richey b1da11b850 Run iOS Simulator Tests
This builds, links, and runs the tests on `x86_64-apple-ios` using
[`dinghy`](https://github.com/sonos/dinghy). It moves the targets
which only Build/Link to their own job.

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-24 01:56:10 -07:00
Joe Richey 14b461fa39 Make job names consistent
This makes it easier to tell on which targets we:
  - Build
  - Link
  - Run

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-24 01:50:03 -07:00
Joe Richey 762c95dd7a Move from actions-rs/toolchain to dtolnay/rust-toolchain
The current action we are using is unmantained:
https://github.com/actions-rs/toolchain/issues/216

This replacement is faster, smaller, and more cachable.

We can also completely remove the toolchain step when testing with
cross, as cross handles configuration of its own toolchain.

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-23 21:32:21 -07:00
Joseph Richey 52a4c3cbad Remove buffer zeroing from Node.js implementation (#315)
We can use
[`Uint8Array::view_mut_raw`](https://rustwasm.github.io/wasm-bindgen/api/js_sys/struct.Uint8Array.html#method.view_mut_raw)
which was
[added](https://github.com/rustwasm/wasm-bindgen/pull/1850) in version
`0.2.54` of `wasm-bindgen`. This method was introduced to deal with
uninitialized memory, see the Safety comment for more info.

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-23 16:22:28 -07:00
Joseph Richey 710b24dd27 Use getentropy on Emscripten (#307)
Signed-off-by: Joe Richey <joerichey@google.com>

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-23 15:09:31 -07:00
Joseph Richey 68b4d7a8fc Merge pull request #303 from rust-random/wasm64
Add wasm64-unknown-unknown support
2022-10-23 14:57:21 -07:00
Joe Richey 3fa761b949 Add chunking for Node.js implementation
Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-23 13:47:00 -07:00
Joe Richey 1d371ef5e2 Add wasm64-unknown-unknown support
We can build and link just fine, but we cannot actually run the tests as
`wasm-bindgen-test-runner` hasn't yet added support.

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-23 13:47:00 -07:00
Joseph Richey f2d76625d5 Solaris: consistantly use /dev/random source (#310)
On Solaris, we opt to use /dev/random source instead of /dev/urandom due
to reasons explained in the comments and
[in this Solaris blog post](https://blogs.oracle.com/solaris/post/solaris-new-system-calls-getentropy2-and-getrandom2).

However, we haven't been making the same choice when getting randomness
via the `getrandom(2)` function, as we just pass `0` for the flags. We
[used to](https://github.com/rust-random/rand/pull/730/files#diff-694d4302a3ff2a976f2fbd34bc05ada22ee61a4e21d2d985beab27f7a809268fR151)
always set `GRND_RANDOM`, but that was removed in the move from `OsRng`
to this crate.

For context, https://github.com/rust-random/rand/pull/730,
https://github.com/rust-random/getrandom/pull/9, and
https://github.com/rust-random/getrandom/pull/51 are the major changes
to the Solaris/Illumos implementation over the years.

See the solaris documentation for:
- [`getrandom(2)`](https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html)
- [`urandom(4)`](https://docs.oracle.com/cd/E88353_01/html/E37851/urandom-4d.html)

I also updated the doucmentation to better reflect when
[Illumos added the `getrandom(2)` function](https://www.illumos.org/issues/9971#change-23483).

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-23 13:46:01 -07:00
Joseph Richey ad08dd9e72 Cleanup wasm32-wasi target (#306)
* Cleanup wasm32-wasi target

This change ensures that we only compile our WASI implementation for
32-bit targets. The interaction between the WASI proposal and the
memory64 proposal is not yet clear, [wasmtime does not yet support](
https://github.com/bytecodealliance/wasmtime/issues/3594#issuecomment-992590383)
using WASI with memory64, and many of the interfaces use 32-bit values
for pointers.

This change also reduces the use of `unsafe` from the wasi
implementation. As noted in #253, changes to `Errno` mean that we can't
get the error message from the raw error code, but we can avoid using
unsafe when converting this code to a NonZeroU32. This handling also
makes WASI behave more like our other targets, which also manually check
that errno is non-zero.

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

* Disable default features for WASI crate

Similar to this crate, the `wasi` crate just uses a `std` feature to
implement `std::error::Errno`, which we don't use.

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

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-23 13:29:09 -07:00
Joseph Richey d87d3399bb Document use of /dev/urandom vs /dev/random (#311)
Also, on platforms where the devices are the same, prefer using
/dev/urandom.

Documentation of the devices being the same:
- macOS [`random(4)`](https://www.unix.com/man-page/mojave/4/urandom/)
- DragonFly [`getrandom(2)`](https://leaf.dragonflybsd.org/cgi/web-man?command=getrandom)
- Haiku [implementation](https://github.com/haiku/haiku/blob/f40bacae87f37276be7d107a6b3d41ca97b4d82c/src/add-ons/kernel/bus_managers/random/driver.cpp#L217-L222)

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

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-23 13:26:32 -07:00
Joseph Richey 88d0d31a2c Move 3ds selection above rdrand/js/custom fallback (#312)
This makes the big cfg_if easier to read.

Signed-off-by: Joe Richey <joerichey@google.com>
2022-10-23 12:59:43 -07:00
Joseph Richey 412e0d5ff5 Merge pull request #309 from briansmith/b/test-benches
CI: On Nightly toolchains, test the benchmarks instead of just building them.
2022-10-23 00:26:23 -07:00
Brian Smith 84883207b9 CI: On Nightly toolchains, test the benchmarks instead of just building them.
`cargo test` will run one iteration of each benchmark to provide evidence
that they don't fail in an obvious way (e.g. unintended panics).
2022-10-22 23:16:50 -07:00
Joseph Richey 2ec38ad931 Merge pull request #304 from rust-random/rng_tests
This PR adds some tests which make sure calls to getrandom (for both small and large buffers) "look" random.

While we could certainly add more complicated randomness tests, these simple tests are:
  - Very easy to understand
  - Don't require any external crates
  - Makes sure we aren't doing something obviously stupid like
    - forgetting [these lines](https://github.com/rust-random/getrandom/blob/bd0654fe70980583e51573e755bafa3b2f8342d9/src/rdrand.rs#L91-L95)
    - failing to initialize every other byte
    - initializing some significant fraction of bytes with a constant

As this tests all buffer sizes from 1 to 64, it also fixes #290.
2022-10-22 14:21:31 -07: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
Joseph Richey 97c17892e7 Merge pull request #300 from rust-random/custom_test
Tests: Use custom tests to verify operations on empty slices are no-ops.

Reworking of #299 to keep our custom tests in a single file (and keep things better organized in general).
2022-10-22 13:32:14 -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