Skip to content

Tests break under Windows because of /dev/urandom #4

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

Closed
lkarlslund opened this issue Nov 13, 2017 · 2 comments
Closed

Tests break under Windows because of /dev/urandom #4

lkarlslund opened this issue Nov 13, 2017 · 2 comments

Comments

@lkarlslund
Copy link

Several places in your code, you open /dev/urandom directly, and use that to feed into math/rand.Seed(). This breaks Windows tests, as /dev/urandom is Linux only.

Consider switching to crypto/rand.Read() as seed source instead, or just using current timestamp to seed with, that's universal.

Additionally in sortedset.go (init) you should not apply seeding. It's not really your library's responsibility to do so. For testing, modules, yes, but otherwise actually it's the programmers responsibility (perhaps they want to keep it unseeded for reproducable testing).

@timtadh
Copy link
Owner

timtadh commented Nov 13, 2017

Hi @lkarlslund

Thanks for the bug report. I will try and put together a patch when I have a spare moment (but feel free to contribute one if you like). Some of this code (and the init's are part of it) comes from the pre-history of Go before there was a) windows support or b) rand.Read(). So that is likely why those init blocks are still around. I will check into whether ensure the randomization is necessary still. In the early days I don't think math/rand was seeded from a random source (it may be now).

@timtadh timtadh assigned timtadh and unassigned timtadh Nov 13, 2017
This was referenced Dec 10, 2017
@timtadh
Copy link
Owner

timtadh commented Dec 10, 2017

I just tagged v0.5.2 which includes #5 and should no longer reference /dev/urandom.

@timtadh timtadh closed this as completed Dec 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants