X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/649e8032974d045864c789e291320f61bdce482f..eb7e5d550a7b9f486a6d602f415e2a4f65351295:/testsuite/xbt/multidict_crash.c?ds=sidebyside diff --git a/testsuite/xbt/multidict_crash.c b/testsuite/xbt/multidict_crash.c index 0663563aec..9e8b1a0222 100644 --- a/testsuite/xbt/multidict_crash.c +++ b/testsuite/xbt/multidict_crash.c @@ -2,88 +2,93 @@ /* multidict_crash - A crash test for multi-level dictionnaries */ -/* Copyright (c) 2003, 2004 Martin Quinson. All rights reserved. */ +/* Copyright (c) 2003-2005 Martin Quinson. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include -#include "gras.h" +#include "xbt.h" -#define NB_ELM 10/*00*/ -#define MULTICACHE_DEPTH 5 -#define KEY_SIZE 12 /*512*/ -#define NB_TEST 20 +XBT_LOG_NEW_DEFAULT_CATEGORY(Test,"this test"); + +#define NB_ELM 100 /*00*/ +#define DEPTH 5 +#define KEY_SIZE 512 +#define NB_TEST 20 /*20*/ int verbose=0; -static xbt_error_t test1(); +static void str_free(void *s) { + char *c=*(char**)s; + free(c); +} -static xbt_error_t test1() { +int main(int argc, char *argv[]) { xbt_error_t errcode; - xbt_dict_t *head=NULL; + xbt_dict_t mdict = NULL; int i,j,k,l; - char **key = NULL; - char **val = NULL; + xbt_dynar_t keys = xbt_dynar_new(sizeof(char*),str_free); void *data; + char *key; + + xbt_init(&argc,argv); printf("\nGeneric multicache: CRASH test:\n"); - printf(" Fill the struct and frees it %d times, using %d elements, depth of multicache=%d\n",NB_TEST,NB_ELM,MULTICACHE_DEPTH); + printf(" Fill the struct and frees it %d times, using %d elements, depth of multicache=%d\n",NB_TEST,NB_ELM,DEPTH); printf(" with %d chars long randomized keys. (a point is a test)\n",KEY_SIZE); - for (i=0;i0) { + printf("Test %d\n",i); + } else if (verbose==0) { + if (i%10) printf("."); else printf("%d",i/10); + } + fflush(stdout); + for (j=0;j0) printf (" Add {"); + + for (l=0 ; l0) printf("%p=%s %s ",key, key,(l0) printf("in multitree %p.\n",mdict); + + TRYFAIL(xbt_multidict_set(mdict,keys,xbt_strdup(key),free)); - for (l=0 ; l0) + xbt_dict_dump(mdict,&xbt_dict_print);*/ + + xbt_dict_free(&mdict); + xbt_dynar_free(&keys); printf("\n"); - return no_error; -} - -int main(int argc, char *argv[]) { - xbt_error_t errcode; - xbt_init(argc,argv,"root.thresh=debug")); - TRYFAIL(test1()); - xbt_exit(); return 0; }