You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2007/10/30 00:36:09 UTC
svn commit: r589911 - in /apr/apr-util/trunk/test: testdate.c testreslist.c
Author: trawick
Date: Mon Oct 29 16:36:09 2007
New Revision: 589911
URL: http://svn.apache.org/viewvc?rev=589911&view=rev
Log:
when !APR_HAS_RANDOM, use a lame initial "random" number
in test programs instead of bombing with a link failure
Modified:
apr/apr-util/trunk/test/testdate.c
apr/apr-util/trunk/test/testreslist.c
Modified: apr/apr-util/trunk/test/testdate.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/test/testdate.c?rev=589911&r1=589910&r2=589911&view=diff
==============================================================================
--- apr/apr-util/trunk/test/testdate.c (original)
+++ apr/apr-util/trunk/test/testdate.c Mon Oct 29 16:36:09 2007
@@ -155,7 +155,11 @@
ABTS_TRUE(tc, secstodate == newsecs);
}
+#if APR_HAS_RANDOM
apr_generate_random_bytes((unsigned char *)&guess, sizeof(guess));
+#else
+ guess = apr_time_now() % APR_USEC_PER_SEC;
+#endif
for (i = 0; i < 10000; ++i) {
guess = (time_t)lgc((apr_uint32_t)guess);
Modified: apr/apr-util/trunk/test/testreslist.c
URL: http://svn.apache.org/viewvc/apr/apr-util/trunk/test/testreslist.c?rev=589911&r1=589910&r2=589911&view=diff
==============================================================================
--- apr/apr-util/trunk/test/testreslist.c (original)
+++ apr/apr-util/trunk/test/testreslist.c Mon Oct 29 16:36:09 2007
@@ -111,7 +111,11 @@
my_thread_info_t *thread_info = data;
apr_reslist_t *rl = thread_info->reslist;
+#if APR_HAS_RANDOM
apr_generate_random_bytes((void*)&chance, sizeof(chance));
+#else
+ chance = (apr_uint32_t)(apr_time_now() % APR_USEC_PER_SEC);
+#endif
for (i = 0; i < CONSUMER_ITERATIONS; i++) {
rv = apr_reslist_acquire(rl, &vp);
Re: svn commit: r589911 - in /apr/apr-util/trunk/test: testdate.c
testreslist.c
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Jeff Trawick wrote:
> On 10/29/07, William A. Rowe, Jr. <wr...@rowe-clan.net> wrote:
>> trawick@apache.org wrote:
>>> Author: trawick
>>> Date: Mon Oct 29 16:36:09 2007
>>> New Revision: 589911
>>>
>>> URL: http://svn.apache.org/viewvc?rev=589911&view=rev
>>> Log:
>>> when !APR_HAS_RANDOM, use a lame initial "random" number
>>> in test programs instead of bombing with a link failure
>>> + guess = apr_time_now() % APR_USEC_PER_SEC;
>> To make this slightly less lame, would you take this % a number prime to
>> 2^32 for some extra flukeishness? (can hardly call it entropy :)
>
> Some text can be hard to parse (and not knowing what "prime to n"
> means doesn't help). By that do you mean
>
> guess = apr_time_now() % APR_USEC_PER_SEC % x;
>
> where
>
> gcd(x, 2^32) == 1?
>
> (or just "apr_time_now() % x" which makes more sense, or something
> completely different?)
Seed with (apr_uint32_t)(apr_time_now() % 4,294,967,291) which will
cleanly collapse the entire current time into (2^32 - 5).
Bill
Re: svn commit: r589911 - in /apr/apr-util/trunk/test: testdate.c testreslist.c
Posted by Jeff Trawick <tr...@gmail.com>.
On 10/29/07, William A. Rowe, Jr. <wr...@rowe-clan.net> wrote:
> trawick@apache.org wrote:
> > Author: trawick
> > Date: Mon Oct 29 16:36:09 2007
> > New Revision: 589911
> >
> > URL: http://svn.apache.org/viewvc?rev=589911&view=rev
> > Log:
> > when !APR_HAS_RANDOM, use a lame initial "random" number
> > in test programs instead of bombing with a link failure
>
> > + guess = apr_time_now() % APR_USEC_PER_SEC;
>
> To make this slightly less lame, would you take this % a number prime to
> 2^32 for some extra flukeishness? (can hardly call it entropy :)
Some text can be hard to parse (and not knowing what "prime to n"
means doesn't help). By that do you mean
guess = apr_time_now() % APR_USEC_PER_SEC % x;
where
gcd(x, 2^32) == 1?
(or just "apr_time_now() % x" which makes more sense, or something
completely different?)
Just type in the desired expression and commit ;)
Re: svn commit: r589911 - in /apr/apr-util/trunk/test: testdate.c
testreslist.c
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
trawick@apache.org wrote:
> Author: trawick
> Date: Mon Oct 29 16:36:09 2007
> New Revision: 589911
>
> URL: http://svn.apache.org/viewvc?rev=589911&view=rev
> Log:
> when !APR_HAS_RANDOM, use a lame initial "random" number
> in test programs instead of bombing with a link failure
> + guess = apr_time_now() % APR_USEC_PER_SEC;
To make this slightly less lame, would you take this % a number prime to
2^32 for some extra flukeishness? (can hardly call it entropy :)
Re: svn commit: r589911 - in /apr/apr-util/trunk/test: testdate.c
testreslist.c
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
trawick@apache.org wrote:
> Author: trawick
> Date: Mon Oct 29 16:36:09 2007
> New Revision: 589911
>
> URL: http://svn.apache.org/viewvc?rev=589911&view=rev
> Log:
> when !APR_HAS_RANDOM, use a lame initial "random" number
> in test programs instead of bombing with a link failure
> + guess = apr_time_now() % APR_USEC_PER_SEC;
To make this slightly less lame, would you take this % a number prime to
2^32 for some extra flukeishness? (can hardly call it entropy :)