]> git.saurik.com Git - apt.git/commit - apt-pkg/contrib/srvrec.cc
ensure a good clock() value for usage and tests
authorDavid Kalnischkies <david@kalnischkies.de>
Fri, 12 Aug 2016 08:02:28 +0000 (10:02 +0200)
committerDavid Kalnischkies <david@kalnischkies.de>
Fri, 12 Aug 2016 09:12:10 +0000 (11:12 +0200)
commit379a36f43d3f4db4afa5ad4fb6f79b89824c999c
tree03820e0718fe0b888581c1738a61c2c6eba229c2
parent1cb047079aa2c26a8159d100348b7e69a49bc117
ensure a good clock() value for usage and tests

We use clock() as a very cheap way of getting a "random" value, but the
manpage warns that this could return -1, so we should be dealing with
this. Additionally, e.g. on hurd-i386 the value increases only slowly –
to slow for our fast running tests for randomness hence producing the
same range in both samples, so we introduce a simple busy-wait loop (as
clock is counting processor time used by the program) in the test which
delays the second sample just enough making our randomness a bit more
predictable.
apt-pkg/contrib/srvrec.cc
test/libapt/srvrecs_test.cc