Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trust/cross compiled test targets #271

Merged
merged 7 commits into from
Feb 27, 2018
Merged

Trust/cross compiled test targets #271

merged 7 commits into from
Feb 27, 2018

Conversation

dhardy
Copy link
Member

@dhardy dhardy commented Feb 26, 2018

Based on dhardy#44 and later modifications, but without forcing all tests to use docker.

Motivations:

  • check tests on big-endian
  • check on a bare metal target (no std)
  • check other common platforms like ARM v7 Android

Seems to work though sometimes builds don't appear to start.

@dhardy
Copy link
Member Author

dhardy commented Feb 26, 2018

This increases Travis CPU-time from 15-18 min to 25-31 min (double the tests, new ones are a little slower), but is worth it I believe (I also realise Travis is running all my PRs twice, for my branches plus for PRs against this repo).

I have another patch to make vs os.rs but need to figure out:

Unable to find image 'japaric/thumbv6m-none-eabi:v0.1.14' locally
v0.1.14: Pulling from japaric/thumbv6m-none-eabi
Status: Downloaded newer image for japaric/thumbv6m-none-eabi:v0.1.14
   Compiling rand v0.4.2 (file:///project)
error[E0463]: can't find crate for `core`
  |
  = note: the `thumbv6m-none-eabi` target may not be installed

(I'm sure I've seen it before. @japaric would you mind giving a hint?)

Copy link
Contributor

@pitdicker pitdicker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to have big-endian testing!

https://travis-ci.org/rust-lang-nursery/rand/builds/346420053?utm_source=github_status&utm_medium=notification shows two build with Linux x86_64 nightly, it seems?

We could reduce the number of builds a little by making creative combinations of rust versions, OS and architectures. For example, test nightly on MacOS, beta on Linux x86, stable on Linux x86_64, rust 1.22 with Linux MIPS64. Would that be smart, not worth it, or the start of endless problems?

@@ -136,7 +136,8 @@ mod tests {
assert_eq!(rng1.next_u64(), 4325440999699518727);

let mut rng2 = XorShiftRng::from_rng(&mut rng1).unwrap();
assert_eq!(rng2.next_u64(), 15614385950550801700);
// Note: we cannot test the state of rng2 because from_rng does not
// fix Endianness. This is allowed in the trait specification.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a little surprised that this change is only necessary for Xorshift. With HC-128 the test is (somehow) missing? And ChaCha passes because from_rng has a default implementation with from_seed, which does the endian swapping.

Does it make sense to still do the comparison, but make it dependent on the architecture?
(also, we now have an unused variable warning)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My view is that if the documentation says from_rng isn't required to be consistent across platforms, there's no point testing consistency. Which means the ChaCha test is also kind-of wrong, but it doesn't hurt (currently).

Yeah, that explains the warning.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought of the test as a way to also catch changes in the implementation. But don't care strongly.

cross test --all --benches --target $TARGET
else
cross test --all --tests --no-default-features --target $TARGET
cross test --all --features serde-1,log --target $TARGET
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is/should this list be the same as in .travis.yml?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see why that's required; e.g. I don't see much point testing docs on multiple platforms.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest I did not check the list completely. And you are right, not everything is interesting to test on all platforms. The --all flag is mostly there for workspaces, which we don't use yet, right? But I see no problem in keeping it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I revised the tests for non-cross builds and combined the two nightly targets we've had for ages, as well as a bit more clean-up. Yes, --all does nothing helpful now. But I'm not sure it will do quite the right thing in the future either because I don't believe passed --features apply to sub-targets.

@dhardy
Copy link
Member Author

dhardy commented Feb 27, 2018

Ah, found my old question about thumb* targets. Hopefully that fixes it.

@@ -424,10 +424,10 @@ mod imp {
}
pub fn try_fill_bytes(&mut self, v: &mut [u8]) -> Result<(), Error> {
let mib = [libc::CTL_KERN, libc::KERN_ARND];
trace!("OsRng: reading {} bytes via kern.arandom", v.len());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@dhardy dhardy merged commit 250b623 into rust-random:master Feb 27, 2018
@dhardy dhardy deleted the trust branch February 27, 2018 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants