aboutsummaryrefslogtreecommitdiffstats
path: root/testrecovery.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2001-10-18 07:55:04 +0000
committerH. Peter Anvin <hpa@zytor.com>2001-10-18 07:55:04 +0000
commit05bccefa7306165bb1c36f469f429500e0e6f919 (patch)
tree82fe6f08e28902dffa61d00b71c32aad3ba59cf2 /testrecovery.c
parent3adff3ab0f554dc8d08c563f61b93e7c1ca80805 (diff)
downloadlpsm-05bccefa7306165bb1c36f469f429500e0e6f919.tar.gz
lpsm-05bccefa7306165bb1c36f469f429500e0e6f919.tar.xz
lpsm-05bccefa7306165bb1c36f469f429500e0e6f919.zip
Fix bug that causes failures if size extended in the middle of realloc().
Correct bugs in tests :)
Diffstat (limited to 'testrecovery.c')
-rw-r--r--testrecovery.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/testrecovery.c b/testrecovery.c
index 4c14b01..262a95b 100644
--- a/testrecovery.c
+++ b/testrecovery.c
@@ -27,12 +27,13 @@
#include <unistd.h>
#include <limits.h>
#include <signal.h>
+#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "objstore.h"
-#define COUNT 32768
-#define SLOTS 1024
+#define COUNT 262144
+#define SLOTS 65536
#define MAXLOG 26
void **areas;
@@ -60,7 +61,7 @@ void verify_no_overlap(int slot)
}
struct misc_info {
- unsigned long occupied;
+ long occupied;
int count;
};
@@ -138,20 +139,29 @@ int main(int argc, char *argv[])
if ( WIFEXITED(status) )
break; /* Child exited, not killed, consider us done */
} else {
- pid = getpid();
+ struct timeval start_time, init_time;
+ pid = getpid();
printf("*** Process starting: %d, master_waits = %d\n",
pid, master_waits);
+ gettimeofday(&start_time, NULL);
+
root_ptr = objstore_arena_init("arena.dat", "arena.log");
+ gettimeofday(&init_time, NULL);
+
misc_ptr = root_ptr[0];
areas = root_ptr[1];
sizes = root_ptr[2];
printf("*** Recovering at count %d, occupied = %ld,\n"
- "*** areas = %p, sizes = %p\n",
- misc_ptr->count, misc_ptr->occupied, areas, sizes);
+ "*** areas = %p, sizes = %p, replay time = %.6f s\n",
+ misc_ptr->count, misc_ptr->occupied, areas, sizes,
+ (init_time.tv_sec-start_time.tv_sec)+
+ (init_time.tv_usec-start_time.tv_usec)/1e+6);
+
+ assert(misc_ptr->occupied >= 0);
/* In case the master process decided to be kind and wait for replay */
if ( master_waits )
@@ -170,6 +180,7 @@ int main(int argc, char *argv[])
sizes[slot], sizes[slot], areas[slot]);
areas[slot] = NULL;
misc_ptr->occupied -= sizes[slot];
+ assert(misc_ptr->occupied >= 0);
} else {
rnd = (double)rand()/RAND_MAX;
newsize = (int)pow(2.0, MAXLOG*pow(rnd,3.0));
@@ -179,6 +190,7 @@ int main(int argc, char *argv[])
sizes[slot], areas[slot], newsize, nptr);
misc_ptr->occupied += newsize;
misc_ptr->occupied -= sizes[slot];
+ assert(misc_ptr->occupied >= 0);
sizes[slot] = newsize;
areas[slot] = nptr;
verify_no_overlap(slot);
@@ -191,9 +203,15 @@ int main(int argc, char *argv[])
rnd = (double)rand()/RAND_MAX;
sizes[slot] = (int)pow(2.0, MAXLOG*pow(rnd,5.0));
areas[slot] = objstore_malloc(sizes[slot]);
- printf("Alloc: %d (0x%08x) bytes at %p\n",
- sizes[slot], sizes[slot], areas[slot]);
- misc_ptr->occupied += sizes[slot];
+ if (areas[slot]) {
+ printf("Alloc: %d (0x%08x) bytes at %p\n",
+ sizes[slot], sizes[slot], areas[slot]);
+ misc_ptr->occupied += sizes[slot];
+ } else {
+ printf("Alloc: %d (0x%08x) bytes FAILED\n",
+ sizes[slot], sizes[slot]);
+ }
+ assert(misc_ptr->occupied >= 0);
verify_no_overlap(slot);
}