Skip to content

For platforms that implement runtime fallback logic, all paths should be tested #289

Closed
@briansmith

Description

@briansmith

Consider the case of Linux. We hope to use the getrandom syscall and then if that fails, we fall back to doing file I/O. We should test at least the following scenerios:

  • Linux returns ENOSYS, which should trigger the fallback to file I/O.
  • Linux returns EPERM, which is presently expected to do the same fallback, though there's an issue on file to change this.
  • The syscall succeeds.

This type of exhaustive testing might not be practical on all targets. However, BoringSSL has shown how to do it on Linux; see https://boringssl.googlesource.com/boringssl/+/refs/heads/master/crypto/fipsmodule/rand/urandom_test.cc.

Backends with runtime fallback logic:

  • linux_android_with_fallback (fallack to /dev/urandom, tested using the getrandom_test_linux_fallback configuration flag)
  • netbsd (fallback to KERN_ARND, tested using the getrandom_test_netbsd_fallback configuration flag)
  • wasm_js (runtime selection between Web and Node.js APIs, tested in CI)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions