add_executable(log_large_test log_large_test.c)
add_executable(parallel_log_crashtest parallel_log_crashtest.c)
+add_executable(mmalloc_test mmalloc_test.c)
### Add definitions for compile
if(NOT WIN32)
target_link_libraries(log_large_test gras m pthread )
target_link_libraries(parallel_log_crashtest gras m pthread )
+ target_link_libraries(mmalloc_test gras m pthread )
else(NOT WIN32)
target_link_libraries(log_large_test gras)
target_link_libraries(parallel_log_crashtest gras)
+ target_link_libraries(mmalloc_test gras)
endif(NOT WIN32)
set(tesh_files
-#include "../mmalloc.h"
+#include "xbt/mmalloc.h"
#include <stdio.h>
#include <assert.h>
#include <fcntl.h>
int main()
{
- void *A, *B;
- int fd1, fd2;
- void *heapA, *heapB;
+ void *heapA;
void *pointers[TESTSIZE];
-/*
- unlink("heap1");
- fd1=open("heap1",O_CREAT|O_RDWR,S_IRWXU|S_IRWXG|S_IRWXO);
- assert(fd1>0);
- close(fd1);
- fd1=open("heap1",O_RDWR);
- assert(fd1>0);
- */
+ srand(0); // we need the test to be reproducible
- heapA = xbt_mheap_new(-1, sbrk(0) + BUFFSIZE);
+ heapA = xbt_mheap_new(-1, ((char*)sbrk(0)) + BUFFSIZE);
if (heapA == NULL) {
perror("attach 1 failed");
fprintf(stderr, "bye\n");
}
fprintf(stderr, "HeapA=%p\n", heapA);
-
+ fflush(stderr);
int i, size;
for (i = 0; i < TESTSIZE; i++) {
size = rand() % 1000;
pointers[i] = mmalloc(heapA, size);
- fprintf(stderr, "%d bytes allocated at %p\n", size, pointers[i]);
+ fprintf(stderr, "%d bytes allocated with offset %li\n", size, ((char*)pointers[i])-((char*)heapA));
}
- char c;
- scanf("%c", &c);
for (i = 0; i < TESTSIZE; i++) {
mfree(heapA, pointers[i]);