aboutsummaryrefslogtreecommitdiffstats
path: root/mps/code
diff options
context:
space:
mode:
authorGareth Rees2013-06-03 16:05:19 +0100
committerGareth Rees2013-06-03 16:05:19 +0100
commitbe868669e31773ce7082ee4f2a6758d78aed8d59 (patch)
tree9465ef6dd08ac9113e6b6c4afafa3f01df97a7d8 /mps/code
parent9c9e1668a14a05437a38c42184030b73a1ff1d86 (diff)
downloademacs-be868669e31773ce7082ee4f2a6758d78aed8d59.tar.gz
emacs-be868669e31773ce7082ee4f2a6758d78aed8d59.zip
Use rnd() from testlib instead for rand() from libc, so that test case is repeatable.
Copied from Perforce Change: 182430 ServerID: perforce.ravenbrook.com
Diffstat (limited to 'mps/code')
-rw-r--r--mps/code/apss.c10
-rw-r--r--mps/code/mv2test.c11
2 files changed, 10 insertions, 11 deletions
diff --git a/mps/code/apss.c b/mps/code/apss.c
index e55a911a9a0..8821542cec8 100644
--- a/mps/code/apss.c
+++ b/mps/code/apss.c
@@ -16,8 +16,8 @@
16#include "testlib.h" 16#include "testlib.h"
17#include "mpslib.h" 17#include "mpslib.h"
18 18
19#include <stdlib.h>
20#include <stdarg.h> 19#include <stdarg.h>
20#include <stdlib.h> /* malloc */
21 21
22 22
23#define testArenaSIZE ((((size_t)3)<<24) - 4) 23#define testArenaSIZE ((((size_t)3)<<24) - 4)
@@ -43,14 +43,14 @@ static mps_res_t make(mps_addr_t *p, mps_ap_t ap, size_t size)
43 43
44/* stress -- create a pool of the requested type and allocate in it */ 44/* stress -- create a pool of the requested type and allocate in it */
45 45
46static mps_res_t stress(mps_class_t class, size_t (*size)(int i), 46static mps_res_t stress(mps_class_t class, size_t (*size)(unsigned long i),
47 mps_arena_t arena, ...) 47 mps_arena_t arena, ...)
48{ 48{
49 mps_res_t res = MPS_RES_OK; 49 mps_res_t res = MPS_RES_OK;
50 mps_pool_t pool; 50 mps_pool_t pool;
51 mps_ap_t ap; 51 mps_ap_t ap;
52 va_list arg; 52 va_list arg;
53 int i, k; 53 unsigned long i, k;
54 int *ps[testSetSIZE]; 54 int *ps[testSetSIZE];
55 size_t ss[testSetSIZE]; 55 size_t ss[testSetSIZE];
56 56
@@ -78,7 +78,7 @@ static mps_res_t stress(mps_class_t class, size_t (*size)(int i),
78 for (k=0; k<testLOOPS; ++k) { 78 for (k=0; k<testLOOPS; ++k) {
79 /* shuffle all the objects */ 79 /* shuffle all the objects */
80 for (i=0; i<testSetSIZE; ++i) { 80 for (i=0; i<testSetSIZE; ++i) {
81 int j = rand()%(testSetSIZE-i); 81 unsigned long j = rnd()%(testSetSIZE-i);
82 void *tp; 82 void *tp;
83 size_t ts; 83 size_t ts;
84 84
@@ -119,7 +119,7 @@ allocFail:
119/* randomSizeAligned -- produce sizes both large and small, 119/* randomSizeAligned -- produce sizes both large and small,
120 * aligned by platform alignment */ 120 * aligned by platform alignment */
121 121
122static size_t randomSizeAligned(int i) 122static size_t randomSizeAligned(unsigned long i)
123{ 123{
124 size_t maxSize = 2 * 160 * 0x2000; 124 size_t maxSize = 2 * 160 * 0x2000;
125 /* Reduce by a factor of 2 every 10 cycles. Total allocation about 40 MB. */ 125 /* Reduce by a factor of 2 every 10 cycles. Total allocation about 40 MB. */
diff --git a/mps/code/mv2test.c b/mps/code/mv2test.c
index 54b64d8792b..29e5606327a 100644
--- a/mps/code/mv2test.c
+++ b/mps/code/mv2test.c
@@ -5,7 +5,6 @@
5 */ 5 */
6 6
7#include <stdio.h> 7#include <stdio.h>
8#include <stdlib.h>
9#include <stdarg.h> 8#include <stdarg.h>
10#include "mpstd.h" 9#include "mpstd.h"
11#include <time.h> 10#include <time.h>
@@ -47,7 +46,7 @@ static size_t max;
47static int verbose = 0; 46static int verbose = 0;
48static mps_pool_t pool; 47static mps_pool_t pool;
49 48
50static size_t randomSize(int i) 49static size_t randomSize(unsigned long i)
51{ 50{
52 /* Distribution centered on mean. Verify that allocations 51 /* Distribution centered on mean. Verify that allocations
53 below min and above max are handled correctly */ 52 below min and above max are handled correctly */
@@ -93,11 +92,11 @@ static mps_res_t make(mps_addr_t *p, mps_ap_t ap, size_t size)
93 92
94 93
95static mps_res_t stress(mps_class_t class, mps_arena_t arena, 94static mps_res_t stress(mps_class_t class, mps_arena_t arena,
96 size_t (*size)(int i), mps_arg_s args[]) 95 size_t (*size)(unsigned long i), mps_arg_s args[])
97{ 96{
98 mps_res_t res; 97 mps_res_t res;
99 mps_ap_t ap; 98 mps_ap_t ap;
100 int i, k; 99 unsigned long i, k;
101 int *ps[TEST_SET_SIZE]; 100 int *ps[TEST_SET_SIZE];
102 size_t ss[TEST_SET_SIZE]; 101 size_t ss[TEST_SET_SIZE];
103 102
@@ -127,10 +126,10 @@ static mps_res_t stress(mps_class_t class, mps_arena_t arena,
127 } 126 }
128 127
129 for (k=0; k<TEST_LOOPS; ++k) { 128 for (k=0; k<TEST_LOOPS; ++k) {
130 int x = rand()%(TEST_SET_SIZE-1); 129 unsigned long x = rnd()%(TEST_SET_SIZE-1);
131 /* shuffle all the objects */ 130 /* shuffle all the objects */
132 for(i=0; i<TEST_SET_SIZE; ++i) { 131 for(i=0; i<TEST_SET_SIZE; ++i) {
133 int j = rand()%(TEST_SET_SIZE-i); 132 unsigned long j = rnd()%(TEST_SET_SIZE-i);
134 void *tp; 133 void *tp;
135 size_t ts; 134 size_t ts;
136 135