llogiq / bytecount

Counting occurrences of a given byte or UTF-8 characters in a slice of memory – fast
Apache License 2.0
225 stars 27 forks source link

add Miri CI #61

Closed RalfJung closed 4 years ago

RalfJung commented 4 years ago

A long time ago, I think at RustFest Rome, we talked about using Miri to test bytecount. Back then Miri wasn't up for the task, but these days it is. :)

In the default settings, each quickcheck test takes around 50s in Miri on my machine, which seems okay. When running the tests locally, one can make things go faster with something like

QUICKCHECK_TESTS=10 cargo miri test -- -Zmiri-disable-isolation

("disable-isolation" is needed to forward the env var to the program)

Note that by default Miri makes all RNGs deterministic. We could add the -Zmiri-disable-isolation flag to allow seeing from the OS RNG.

Also fixes https://github.com/llogiq/bytecount/issues/53.

RalfJung commented 4 years ago

(Not sure what's happening with Travis, it doesn't show up in the PR for some reason but a job is running.)

RalfJung commented 4 years ago

FWIW, Miri can also run code for other architectures, so this could help with https://github.com/llogiq/bytecount/issues/53. So far I only tested cross-OS interpretation (like using a Windows target on a Linux host and vice versa), but in principle using a different CPU as a target should also work.

EDIT: did that, it works great. :)

RalfJung commented 4 years ago

(CI fails for Rust 1.32 because criterion-0.3.3 does not seem compatible.)

llogiq commented 4 years ago

Thank you!