forked from emscripten-core/emscripten
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test] Avoid seeding random number generators with time. NFC (emscrip…
…ten-core#23050) Using the current time to seed the random number generator in tests will make them non-determinisitic. Simply using the default seed or seeding with a fixed value seem fine all of these test cases.
- Loading branch information
Showing
15 changed files
with
73 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"a.html": 12686, | ||
"a.html.gz": 6930, | ||
"total": 12686, | ||
"total_gz": 6930 | ||
"a.html": 12597, | ||
"a.html.gz": 6882, | ||
"total": 12597, | ||
"total_gz": 6882 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"a.html": 17266, | ||
"a.html.gz": 7515, | ||
"total": 17266, | ||
"total_gz": 7515 | ||
"a.html": 17195, | ||
"a.html.gz": 7478, | ||
"total": 17195, | ||
"total_gz": 7478 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include <stdlib.h> | ||
#include <stdbool.h> | ||
#include <stdio.h> | ||
#include <assert.h> | ||
|
||
int main() { | ||
// We need RAND_MAX to be a bitmask (power of 2 minus 1). This assertion will | ||
// error if RAND_MAX ever changes, so we don't miss that. | ||
assert(RAND_MAX == 0x7fffffff); | ||
|
||
srand(0xdeadbeef); | ||
for (int i = 0; i < 10; ++i) { | ||
printf("%d\n", rand()); | ||
} | ||
|
||
unsigned int seed = 0xdeadbeef; | ||
for (int i = 0; i < 10; ++i) { | ||
printf("%d\n", rand_r(&seed)); | ||
} | ||
|
||
bool haveEvenAndOdd = true; | ||
for (int i = 1; i <= 30; ++i) { | ||
int mask = 1 << i; | ||
if (mask > RAND_MAX) break; | ||
bool haveEven = false; | ||
bool haveOdd = false; | ||
for (int j = 0; j < 1000 && (!haveEven || !haveOdd); ++j) { | ||
if ((rand() & mask) == 0) { | ||
haveEven = true; | ||
} else { | ||
haveOdd = true; | ||
} | ||
} | ||
haveEvenAndOdd = haveEvenAndOdd && haveEven && haveOdd; | ||
} | ||
|
||
if (haveEvenAndOdd) { | ||
printf("Have even and odd!\n"); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
490242850 | ||
2074599277 | ||
1480056542 | ||
1912638067 | ||
931112055 | ||
2110392489 | ||
2053422194 | ||
1614832492 | ||
216117595 | ||
174823244 | ||
760368382 | ||
602359081 | ||
1121118963 | ||
1291018924 | ||
1608306807 | ||
352705809 | ||
958258461 | ||
1182561381 | ||
114276303 | ||
1481323674 | ||
Have even and odd! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters