Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert the modules dict, dynar and swag to unit testing
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sun, 23 Oct 2005 15:32:43 +0000 (15:32 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Sun, 23 Oct 2005 15:32:43 +0000 (15:32 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@1820 48e7efb5-ca39-0410-a469-dd3cf9ba447f

12 files changed:
src/Makefile.am
src/xbt/dict.c
src/xbt/dynar.c
src/xbt/set.c
src/xbt/swag.c
testsuite/xbt/dict_crash.c [deleted file]
testsuite/xbt/dict_usage.c [deleted file]
testsuite/xbt/dynar_double.c [deleted file]
testsuite/xbt/dynar_int.c [deleted file]
testsuite/xbt/dynar_string.c [deleted file]
testsuite/xbt/multidict_crash.c [deleted file]
testsuite/xbt/swag_usage.c [deleted file]

index 664265c..b7790cd 100644 (file)
@@ -184,10 +184,10 @@ AMOK_SRC= \
 # Suites and tests run in the given order.
 
 TEST_CFILES=xbt/cunit.c  xbt/ex.c          \
-            xbt/set.c                      \
+            xbt/dynar.c xbt/dict.c xbt/set.c xbt/swag.c \
             xbt/config.c
 TEST_UNITS= cunit_unit.c ex_unit.c         \
-            set_unit.c                     \
+            dynar_unit.c dict_unit.c set_unit.c swag_unit.c \
             config_unit.c
 
 BUILT_SOURCES=../include/surf/surfxml.h surf/surfxml.c \
@@ -198,24 +198,19 @@ testall_SOURCES= $(TEST_UNITS) simgrid_units_main.c
 testall_LDADD=libgras.la
 
 EXTRA_DIST+=$(testall_SOURCES)
-
-# %_unit.c: $(TEST_CFILES) @top_srcdir@/tools/sg_unit_extractor.pl
-#@echo TEST_UNITS=$(TEST_UNITS)
-#      @echo testall_SOURCES=$(testall_SOURCES)
-#      @lookfor=`echo $@ | sed 's/_unit.c$$/.c/'`;      \
-#       for s in $(TEST_CFILES) ; do                    \
-#           if echo $$s | grep $$lookfor >/dev/null; then \
-#             src="$$src $$s";                            \
-#           fi;                                           \
-#          done;                                          \
-#        echo "Generate Testing Suite $@ from$$src";    
          
 if MAINTAINER_MODE
 cunit_unit.c: xbt/cunit.c
        @top_srcdir@/tools/sg_unit_extractor.pl $^
-ex_unit.c:    xbt/ex.c
+ex_unit.c: xbt/ex.c
+       @top_srcdir@/tools/sg_unit_extractor.pl $^
+dynar_unit.c: xbt/dynar.c
+       @top_srcdir@/tools/sg_unit_extractor.pl $^
+dict_unit.c: xbt/dict.c
+       @top_srcdir@/tools/sg_unit_extractor.pl $^
+set_unit.c: xbt/set.c
        @top_srcdir@/tools/sg_unit_extractor.pl $^
-set_unit.c:   xbt/set.c
+swag_unit.c: xbt/swag.c
        @top_srcdir@/tools/sg_unit_extractor.pl $^
 config_unit.c: xbt/config.c
        @top_srcdir@/tools/sg_unit_extractor.pl $^
index 12fe1d5..a673500 100644 (file)
@@ -207,3 +207,402 @@ xbt_dict_dump(xbt_dict_t     dict,
   printf("Dict %p:\n", (void*)dict);
   xbt_dictelm_dump(dict ? dict->head: NULL, output);
 }
+
+#ifdef SIMGRID_TEST
+#include "xbt.h"
+#include "xbt/ex.h"
+#include "portable.h"
+
+XBT_LOG_EXTERNAL_CATEGORY(dict);
+XBT_LOG_DEFAULT_CATEGORY(dict);
+
+XBT_TEST_SUITE("dict","Dict data container");
+
+static void print_str(void *str) {
+  printf("%s",(char*)PRINTF_STR(str));
+}
+
+static void debuged_add(xbt_dict_t head,const char*key)
+{
+  char *data=xbt_strdup(key);
+
+  xbt_test_log1("Add %s",PRINTF_STR(key));
+
+  xbt_dict_set(head,key,data,&free);
+  if (XBT_LOG_ISENABLED(dict,xbt_log_priority_debug)) {
+    xbt_dict_dump(head,(void (*)(void*))&printf);
+    fflush(stdout);
+  }
+}
+
+static void fill(xbt_dict_t *head) {
+  xbt_test_add0("Fill in the dictionnary");
+
+  *head = xbt_dict_new();
+  debuged_add(*head,"12");
+  debuged_add(*head,"12a");
+  debuged_add(*head,"12b");
+  debuged_add(*head,"123");
+  debuged_add(*head,"123456");
+  /* Child becomes child of what to add */
+  debuged_add(*head,"1234");
+  /* Need of common ancestor */
+  debuged_add(*head,"123457");
+
+}
+
+static void search(xbt_dict_t head,const char*key) {
+  void *data;
+  
+  xbt_test_add1("Search %s",key);
+  data=xbt_dict_get(head,key);
+  xbt_test_log1("Found %s",(char *)data);
+  if (data)
+    xbt_test_assert0(!strcmp((char*)data,key),"Key and data do not match");
+}
+
+static void debuged_remove(xbt_dict_t head,const char*key) {
+
+  xbt_test_add1("Remove '%s'",PRINTF_STR(key));
+  xbt_dict_remove(head,key);
+  /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
+}
+
+
+static void traverse(xbt_dict_t head) {
+  xbt_dict_cursor_t cursor=NULL;
+  char *key;
+  char *data;
+
+  xbt_dict_foreach(head,cursor,key,data) {
+    xbt_test_log2("Seen:  %s->%s",PRINTF_STR(key),PRINTF_STR(data));
+    xbt_test_assert2(!data || !strcmp(key,data),
+                    "Key(%s) != value(%s). Abording\n",key,data);
+  }
+}
+
+static void search_not_found(xbt_dict_t head, const char *data) {
+  xbt_ex_t e;
+
+  xbt_test_add1("Search %s (expected not to be found)",data);
+
+  TRY {    
+    data = xbt_dict_get(head,"Can't be found");
+    THROW1(unknown_error,0,"Found something which shouldn't be there (%s)",data);
+  } CATCH(e) {
+    if (e.category != not_found_error) 
+      xbt_test_exception(e);
+    xbt_ex_free(e);
+  }
+}
+
+xbt_ex_t e;
+xbt_dict_t head=NULL;
+char *data;
+
+
+XBT_TEST_UNIT("basic",test_dict_basic,"Basic usage: change, retrive, traverse"){
+
+  xbt_test_add0("Traversal the empty dictionnary");
+  traverse(head);
+
+  xbt_test_add0("Traverse the full dictionnary");
+  fill(&head);
+
+  search(head,"12a");
+  traverse(head);
+
+  xbt_test_add0("Free the dictionnary (twice)");
+  xbt_dict_free(&head);
+  xbt_dict_free(&head);
+
+  /* CHANGING */
+  fill(&head);
+  xbt_test_add0("Change 123 to 'Changed 123'");
+  xbt_dict_set(head,"123",strdup("Changed 123"),&free);
+
+  xbt_test_add0("Change 123 back to '123'");
+  xbt_dict_set(head,"123",strdup("123"),&free);
+
+  xbt_test_add0("Change 12a to 'Dummy 12a'");
+  xbt_dict_set(head,"12a",strdup("Dummy 12a"),&free);
+
+  xbt_test_add0("Change 12a to '12a'");
+  xbt_dict_set(head,"12a",strdup("12a"),&free);
+
+  xbt_test_add0("Traverse the resulting dictionnary");
+  traverse(head);
+  
+  /* RETRIVE */
+  xbt_test_add0("Search 123");
+  data = xbt_dict_get(head,"123");
+  xbt_test_assert(data);
+  xbt_test_assert(!strcmp("123",data));
+
+  search_not_found(head,"Can't be found");
+  search_not_found(head,"123 Can't be found");
+  search_not_found(head,"12345678 NOT");
+
+  search(head,"12a");
+  search(head,"12b");
+  search(head,"12");
+  search(head,"123456");
+  search(head,"1234");
+  search(head,"123457");
+
+  xbt_test_add0("Traverse the resulting dictionnary");
+  traverse(head);
+
+  /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
+
+  xbt_test_add0("Free the dictionnary twice");
+  xbt_dict_free(&head);
+  xbt_dict_free(&head);
+
+  xbt_test_add0("Traverse the resulting dictionnary");
+  traverse(head);
+}
+
+XBT_TEST_UNIT("remove",test_dict_remove,"Removing some values"){
+  fill(&head);
+  xbt_test_add0("Remove non existing data");
+  TRY {
+    debuged_remove(head,"Does not exist");
+  } CATCH(e) {
+    if (e.category != not_found_error) 
+      xbt_test_exception(e);
+    xbt_ex_free(e);
+  }
+  traverse(head);
+
+  xbt_dict_free(&head);
+
+  xbt_test_add0("Remove data from the NULL dict");
+  TRY {
+    debuged_remove(head,"12345");
+  } CATCH(e) {
+    if (e.category != arg_error) 
+      xbt_test_exception(e);
+    xbt_ex_free(e);
+  } 
+
+  xbt_test_add0("Remove each data manually (traversing the resulting dictionnary each time)");
+  fill(&head);
+  debuged_remove(head,"12a");    traverse(head);
+  debuged_remove(head,"12b");    traverse(head);
+  debuged_remove(head,"12");     traverse(head);
+  debuged_remove(head,"123456"); traverse(head);
+  TRY {
+    debuged_remove(head,"12346");
+  } CATCH(e) {
+    if (e.category != not_found_error) 
+      xbt_test_exception(e);
+    xbt_ex_free(e);         
+    traverse(head);
+  } 
+  debuged_remove(head,"1234");   traverse(head);
+  debuged_remove(head,"123457"); traverse(head);
+  debuged_remove(head,"123");    traverse(head);
+  TRY {
+    debuged_remove(head,"12346");
+  } CATCH(e) {
+    if (e.category != not_found_error) 
+      xbt_test_exception(e);
+    xbt_ex_free(e);
+  }                              traverse(head);
+  
+  xbt_test_add0("Free the dictionnary twice");
+  xbt_dict_free(&head);
+  xbt_dict_free(&head);      
+}
+
+XBT_TEST_UNIT("nulldata",test_dict_nulldata,"NULL data management"){
+  fill(&head);
+
+  xbt_test_add0("Store NULL under 'null'");
+  xbt_dict_set(head,"null",NULL,NULL);
+  search(head,"null");
+
+  xbt_test_add0("Check whether I see it while traversing...");
+  {
+    xbt_dict_cursor_t cursor=NULL;
+    char *key;
+    int found=0;
+    
+    xbt_dict_foreach(head,cursor,key,data) {
+      xbt_test_log2("Seen:  %s->%s",PRINTF_STR(key),PRINTF_STR(data));
+      if (!strcmp(key,"null"))
+       found = 1;
+    }
+    xbt_test_assert0(found,"the key 'null', associated to NULL is not found");
+  }
+  xbt_dict_free(&head);
+}
+
+#define NB_ELM 20000
+#define SIZEOFKEY 1024
+static int countelems(xbt_dict_t head) {
+  xbt_dict_cursor_t cursor;
+  char *key;
+  void *data;
+  int res = 0;
+
+  xbt_dict_foreach(head,cursor,key,data) {
+    res++;
+  }
+  return res;
+}
+
+XBT_TEST_UNIT("crash",test_dict_crash,"Crash test"){
+  xbt_dict_t head=NULL;
+  int i,j,k, nb;
+  char *key;
+  void *data;
+
+  srand((unsigned int)time(NULL));
+
+  xbt_test_add0("CRASH test");
+  xbt_test_log0("Fill the struct, count its elems and frees the structure (x10)");
+  xbt_test_log1("using 1000 elements with %d chars long randomized keys.",SIZEOFKEY);
+
+  for (i=0;i<10;i++) {
+    head=xbt_dict_new();
+    //    if (i%10) printf("."); else printf("%d",i/10); fflush(stdout);
+    nb=0;
+    for (j=0;j<1000;j++) {
+      key=xbt_malloc(SIZEOFKEY);
+
+      for (k=0;k<SIZEOFKEY-1;k++)
+       key[k]=rand() % ('z' - 'a') + 'a';
+      key[k]='\0';
+      /*      printf("[%d %s]\n",j,key); */
+      xbt_dict_set(head,key,key,&free);
+    }
+    /*    xbt_dict_dump(head,(void (*)(void*))&printf); */
+    nb = countelems(head);
+    xbt_test_assert1(nb == 1000,"found %d elements instead of 1000",nb);
+    traverse(head);
+    xbt_dict_free(&head);
+    xbt_dict_free(&head);
+  }
+
+
+  head=xbt_dict_new();
+  xbt_test_add1("Fill %d elements, with keys being the number of element",NB_ELM);
+  for (j=0;j<NB_ELM;j++) {
+    //    if (!(j%1000)) { printf("."); fflush(stdout); }
+
+    key = xbt_malloc(10);
+    
+    sprintf(key,"%d",j);
+    xbt_dict_set(head,key,key,&free);
+  }
+
+  xbt_test_add0("Count the elements (retrieving the key and data for each)");
+  i = countelems(head);
+  xbt_test_log1("There is %d elements",i);
+
+  xbt_test_add1("Search my %d elements 20 times",NB_ELM);
+  key=xbt_malloc(10);
+  for (i=0;i<20;i++) {
+    //    if (i%10) printf("."); else printf("%d",i/10); fflush(stdout);
+    for (j=0;j<NB_ELM;j++) {
+      
+      sprintf(key,"%d",j);
+      data = xbt_dict_get(head,key);
+      xbt_test_assert2(!strcmp(key,(char*)data),
+                      "key=%s != data=%s\n",key,(char*)data);
+    }
+  }
+  free(key);
+
+  xbt_test_add1("Remove my %d elements",NB_ELM);
+  key=xbt_malloc(10);
+  for (j=0;j<NB_ELM;j++) {
+    //if (!(j%10000)) printf("."); fflush(stdout);
+    
+    sprintf(key,"%d",j);
+    xbt_dict_remove(head,key);
+  }
+  free(key);
+
+  
+  xbt_test_add0("Free the structure (twice)");
+  xbt_dict_free(&head);
+  xbt_dict_free(&head);
+}
+
+static void str_free(void *s) {
+  char *c=*(char**)s;
+  free(c);
+}
+
+XBT_TEST_UNIT("multicrash",test_dict_multicrash,"Multi-dict crash test"){
+
+#undef NB_ELM
+#define NB_ELM 100 /*00*/
+#define DEPTH 5
+#define KEY_SIZE 512
+#define NB_TEST 20 /*20*/
+int verbose=0;
+
+  xbt_dict_t mdict = NULL;
+  int i,j,k,l;
+  xbt_dynar_t keys = xbt_dynar_new(sizeof(char*),str_free);
+  void *data;
+  char *key;
+
+
+  xbt_test_add0("Generic multicache CRASH test");
+  xbt_test_log4(" Fill the struct and frees it %d times, using %d elements, "
+               "depth of multicache=%d, key size=%d",
+               NB_TEST,NB_ELM,DEPTH,KEY_SIZE);
+
+  for (l=0 ; l<DEPTH ; l++) {
+    key=xbt_malloc(KEY_SIZE);
+    xbt_dynar_push(keys,&key);
+  }    
+
+  for (i=0;i<NB_TEST;i++) {
+    mdict = xbt_dict_new();
+    VERB1("mdict=%p",mdict);
+    if (verbose>0)
+      printf("Test %d\n",i);
+    /* else if (i%10) printf("."); else printf("%d",i/10);*/
+    
+    for (j=0;j<NB_ELM;j++) {
+      if (verbose>0) printf ("  Add {");
+      
+      for (l=0 ; l<DEPTH ; l++) {
+        key=*(char**)xbt_dynar_get_ptr(keys,l);
+        
+       for (k=0;k<KEY_SIZE-1;k++) 
+         key[k]=rand() % ('z' - 'a') + 'a';
+         
+       key[k]='\0';
+       
+       if (verbose>0) printf("%p=%s %s ",key, key,(l<DEPTH-1?";":"}"));
+      }
+      if (verbose>0) printf("in multitree %p.\n",mdict);
+                                                        
+      xbt_multidict_set(mdict,keys,xbt_strdup(key),free);
+
+      data = xbt_multidict_get(mdict,keys);
+
+      xbt_test_assert2(data && !strcmp((char*)data,key),
+                      "Retrieved value (%s) does not match the entrered one (%s)\n",
+                      (char*)data,key);
+    }
+    xbt_dict_free(&mdict);
+  }
+  
+  xbt_dynar_free(&keys);
+
+/*  if (verbose>0)
+    xbt_dict_dump(mdict,&xbt_dict_print);*/
+    
+  xbt_dict_free(&mdict);
+  xbt_dynar_free(&keys);
+
+}
+#endif /* SIMGRID_TEST */
index aece933..cdd7efc 100644 (file)
@@ -545,3 +545,412 @@ void xbt_dynar_cursor_rm(xbt_dynar_t dynar,
       (dynar->free_f)(dst);
   }
 }
+
+#ifdef SIMGRID_TEST
+
+#define NB_ELEM 5000
+
+XBT_TEST_SUITE("dynar","Dynar data container");
+XBT_LOG_EXTERNAL_CATEGORY(dynar);
+XBT_LOG_DEFAULT_CATEGORY(dynar);
+
+XBT_TEST_UNIT("int",test_dynar_int,"Dyars of integers") {
+   /* Vars_decl [doxygen cruft] */
+   xbt_dynar_t d;
+   int i,cpt,cursor;
+   int *iptr;
+   
+   xbt_test_add0("==== Traverse the empty dynar");
+   d=xbt_dynar_new(sizeof(int),NULL);
+   xbt_dynar_foreach(d,cursor,i){
+     xbt_assert0(0,"Damnit, there is something in the empty dynar");
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+   xbt_test_add1("==== Push %d int, set them again 3 times, traverse them, shift them",
+       NB_ELEM);
+   /* Populate_ints [doxygen cruft] */
+   /* 1. Populate the dynar */
+   d=xbt_dynar_new(sizeof(int),NULL);
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     xbt_dynar_push_as(d,int,cpt); /* This is faster (and possible only with scalars) */
+     /* xbt_dynar_push(d,&cpt);       This would also work */
+     xbt_test_log2("Push %d, length=%lu",cpt, xbt_dynar_length(d));
+   }
+   
+   /* 2. Traverse manually the dynar */
+   for (cursor=0; cursor< NB_ELEM; cursor++) {
+     iptr=xbt_dynar_get_ptr(d,cursor);
+     xbt_test_assert2(cursor == *iptr,
+                     "The retrieved value is not the same than the injected one (%d!=%d)",
+                     cursor,cpt);
+   }
+   
+   /* 3. Traverse the dynar using the neat macro to that extend */
+   xbt_dynar_foreach(d,cursor,cpt){
+     xbt_test_assert2(cursor == cpt,
+                     "The retrieved value is not the same than the injected one (%d!=%d)",
+                     cursor,cpt);
+   }
+   /* end_of_traversal */
+   
+   for (cpt=0; cpt< NB_ELEM; cpt++)
+     *(int*)xbt_dynar_get_ptr(d,cpt) = cpt;
+
+   for (cpt=0; cpt< NB_ELEM; cpt++) 
+     *(int*)xbt_dynar_get_ptr(d,cpt) = cpt;
+/*     xbt_dynar_set(d,cpt,&cpt);*/
+   
+   for (cpt=0; cpt< NB_ELEM; cpt++) 
+     *(int*)xbt_dynar_get_ptr(d,cpt) = cpt;
+   
+   cpt=0;
+   xbt_dynar_foreach(d,cursor,i){
+     xbt_test_assert2(i == cpt,
+                     "The retrieved value is not the same than the injected one (%d!=%d)",
+                     i,cpt);
+     cpt++;
+   }
+   xbt_test_assert2(cpt == NB_ELEM,
+                   "Cannot retrieve my %d values. Last got one is %d",
+                   NB_ELEM, cpt);
+
+   /* shifting [doxygen cruft] */
+   /* 4. Shift all the values */
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     xbt_dynar_shift(d,&i);
+     xbt_test_assert2(i == cpt,
+                     "The retrieved value is not the same than the injected one (%d!=%d)",
+                     i,cpt);
+     xbt_test_log2("Pop %d, length=%lu",cpt, xbt_dynar_length(d));
+   }
+   
+   /* 5. Free the resources */
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+   
+   xbt_test_add1("==== Unshift/pop %d int",NB_ELEM);
+   d=xbt_dynar_new(sizeof(int),NULL);
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     xbt_dynar_unshift(d,&cpt);
+     DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(d));
+   }
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     i=xbt_dynar_pop_as(d,int);
+     xbt_test_assert2(i == cpt,
+                     "The retrieved value is not the same than the injected one (%d!=%d)",
+                     i,cpt);
+     xbt_test_log2("Pop %d, length=%lu",cpt, xbt_dynar_length(d));
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+   
+   xbt_test_add1("==== Push %d int, insert 1000 int in the middle, shift everything",NB_ELEM);
+   d=xbt_dynar_new(sizeof(int),NULL);
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     xbt_dynar_push_as(d,int,cpt);
+     DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(d));
+   }
+   for (cpt=0; cpt< 1000; cpt++) {
+     xbt_dynar_insert_at_as(d,2500,int,cpt);
+     DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(d));
+   }
+
+   for (cpt=0; cpt< 2500; cpt++) {
+     xbt_dynar_shift(d,&i);
+     xbt_test_assert2(i == cpt,
+            "The retrieved value is not the same than the injected one at the begining (%d!=%d)",
+              i,cpt);
+     DEBUG2("Pop %d, length=%lu",cpt, xbt_dynar_length(d));
+   }
+   for (cpt=999; cpt>=0; cpt--) {
+     xbt_dynar_shift(d,&i);
+     xbt_test_assert2(i == cpt,
+           "The retrieved value is not the same than the injected one in the middle (%d!=%d)",
+                     i,cpt);
+   }
+   for (cpt=2500; cpt< NB_ELEM; cpt++) {
+     xbt_dynar_shift(d,&i);
+      xbt_test_assert2(i == cpt,
+           "The retrieved value is not the same than the injected one at the end (%d!=%d)",
+                      i,cpt);
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+
+   xbt_test_add1("==== Push %d int, remove 2000-4000. free the rest",NB_ELEM);
+   d=xbt_dynar_new(sizeof(int),NULL);
+   for (cpt=0; cpt< NB_ELEM; cpt++) 
+     xbt_dynar_push_as(d,int,cpt);
+   
+   for (cpt=2000; cpt< 4000; cpt++) {
+     xbt_dynar_remove_at(d,2000,&i);
+     xbt_test_assert2(i == cpt,
+                     "Remove a bad value. Got %d, expected %d",
+                     i,cpt);
+     DEBUG2("remove %d, length=%lu",cpt, xbt_dynar_length(d));
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+}
+
+XBT_TEST_UNIT("double",test_dynar_double,"Dyars of doubles") {
+   xbt_dynar_t d;
+   int cpt,cursor;
+   double d1,d2;
+   
+   xbt_test_add0("==== Traverse the empty dynar");
+   d=xbt_dynar_new(sizeof(int),NULL);
+   xbt_dynar_foreach(d,cursor,cpt){
+     xbt_test_assert0(FALSE,
+            "Damnit, there is something in the empty dynar");
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+   xbt_test_add0("==== Push/shift 5000 doubles");
+   d=xbt_dynar_new(sizeof(double),NULL);
+   for (cpt=0; cpt< 5000; cpt++) {
+     d1=(double)cpt;
+     xbt_dynar_push(d,&d1);
+   }
+   xbt_dynar_foreach(d,cursor,d2){
+     d1=(double)cursor;
+     xbt_test_assert2(d1 == d2,
+           "The retrieved value is not the same than the injected one (%f!=%f)",
+                 d1,d2);
+   }
+   for (cpt=0; cpt< 5000; cpt++) {
+     d1=(double)cpt;
+     xbt_dynar_shift(d,&d2);
+     xbt_test_assert2(d1 == d2,
+           "The retrieved value is not the same than the injected one (%f!=%f)",
+                 d1,d2);
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+
+   xbt_test_add0("==== Unshift/pop 5000 doubles");
+   d=xbt_dynar_new(sizeof(double),NULL);
+   for (cpt=0; cpt< 5000; cpt++) {
+     d1=(double)cpt;
+     xbt_dynar_unshift(d,&d1);
+   }
+   for (cpt=0; cpt< 5000; cpt++) {
+     d1=(double)cpt;
+     xbt_dynar_pop(d,&d2);
+     xbt_test_assert2 (d1 == d2,
+           "The retrieved value is not the same than the injected one (%f!=%f)",
+                  d1,d2);
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+
+
+   xbt_test_add0("==== Push 5000 doubles, insert 1000 doubles in the middle, shift everything");
+   d=xbt_dynar_new(sizeof(double),NULL);
+   for (cpt=0; cpt< 5000; cpt++) {
+     d1=(double)cpt;
+     xbt_dynar_push(d,&d1);
+   }
+   for (cpt=0; cpt< 1000; cpt++) {
+     d1=(double)cpt;
+     xbt_dynar_insert_at(d,2500,&d1);
+   }
+
+   for (cpt=0; cpt< 2500; cpt++) {
+     d1=(double)cpt;
+     xbt_dynar_shift(d,&d2);
+     xbt_test_assert2(d1 == d2,
+           "The retrieved value is not the same than the injected one at the begining (%f!=%f)",
+                 d1,d2);
+     DEBUG2("Pop %d, length=%lu",cpt, xbt_dynar_length(d));
+   }
+   for (cpt=999; cpt>=0; cpt--) {
+     d1=(double)cpt;
+     xbt_dynar_shift(d,&d2);
+     xbt_test_assert2 (d1 == d2,
+           "The retrieved value is not the same than the injected one in the middle (%f!=%f)",
+                  d1,d2);
+   }
+   for (cpt=2500; cpt< 5000; cpt++) {
+     d1=(double)cpt;
+     xbt_dynar_shift(d,&d2);
+     xbt_test_assert2 (d1 == d2,
+           "The retrieved value is not the same than the injected one at the end (%f!=%f)",
+                  d1,d2);
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+
+   xbt_test_add0("==== Push 5000 double, remove 2000-4000. free the rest");
+   d=xbt_dynar_new(sizeof(double),NULL);
+   for (cpt=0; cpt< 5000; cpt++) {
+     d1=(double)cpt;
+     xbt_dynar_push(d,&d1);
+   }
+   for (cpt=2000; cpt< 4000; cpt++) {
+     d1=(double)cpt;
+     xbt_dynar_remove_at(d,2000,&d2);
+     xbt_test_assert2 (d1 == d2,
+           "Remove a bad value. Got %f, expected %f",
+              d2,d1);
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+}
+
+
+/* doxygen_first_cruft*/
+
+/* The function we will use to free the data */
+static void free_string(void *d){
+  free(*(void**)d);
+}
+
+XBT_TEST_UNIT("string",test_dynar_string,"Dyars of strings") {
+   xbt_dynar_t d;
+   int cpt;
+   char buf[1024];
+   char *s1,*s2;
+   
+   xbt_test_add0("==== Traverse the empty dynar");
+   d=xbt_dynar_new(sizeof(char *),&free_string);
+   xbt_dynar_foreach(d,cpt,s1){
+     xbt_test_assert0(FALSE,
+                 "Damnit, there is something in the empty dynar");
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+   xbt_test_add1("==== Push %d strings, set them again 3 times, shift them",NB_ELEM);
+   d=xbt_dynar_new(sizeof(char*),&free_string);
+   /* Populate_str [doxygen cruft] */
+   /* 1. Populate the dynar */
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     sprintf(buf,"%d",cpt);
+     s1=strdup(buf);
+     xbt_dynar_push(d,&s1);
+   }
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     sprintf(buf,"%d",cpt);
+     s1=strdup(buf);
+     xbt_dynar_replace(d,cpt,&s1);
+   }
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     sprintf(buf,"%d",cpt);
+     s1=strdup(buf);
+     xbt_dynar_replace(d,cpt,&s1);
+   }
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     sprintf(buf,"%d",cpt);
+     s1=strdup(buf);
+     xbt_dynar_replace(d,cpt,&s1);
+   }
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     sprintf(buf,"%d",cpt);
+     xbt_dynar_shift(d,&s2);
+     xbt_test_assert2 (!strcmp(buf,s2),
+           "The retrieved value is not the same than the injected one (%s!=%s)",
+                  buf,s2);
+     free(s2);
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+
+   xbt_test_add1("==== Unshift, traverse and pop %d strings",NB_ELEM);
+   d=xbt_dynar_new(sizeof(char**),&free_string);
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     sprintf(buf,"%d",cpt);
+     s1=strdup(buf);
+     xbt_dynar_unshift(d,&s1);
+   }
+   /* 2. Traverse the dynar with the macro */
+   xbt_dynar_foreach(d,cpt,s1) {
+     sprintf(buf,"%d",NB_ELEM - cpt -1);
+     xbt_test_assert2 (!strcmp(buf,s1),
+           "The retrieved value is not the same than the injected one (%s!=%s)",
+              buf,s1);
+   }
+   /* 3. Traverse the dynar with the macro */
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     sprintf(buf,"%d",cpt);
+     xbt_dynar_pop(d,&s2);
+     xbt_test_assert2 (!strcmp(buf,s2),
+           "The retrieved value is not the same than the injected one (%s!=%s)",
+              buf,s2);
+     free(s2);
+   }
+   /* 4. Free the resources */
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+
+   xbt_test_add2("==== Push %d strings, insert %d strings in the middle, shift everything",NB_ELEM,NB_ELEM/5);
+   d=xbt_dynar_new(sizeof(char*),&free_string);
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     sprintf(buf,"%d",cpt);
+     s1=strdup(buf);
+     xbt_dynar_push(d,&s1);
+   }
+   for (cpt=0; cpt< NB_ELEM/5; cpt++) {
+     sprintf(buf,"%d",cpt);
+     s1=strdup(buf);
+     xbt_dynar_insert_at(d,NB_ELEM/2,&s1);
+   }
+
+   for (cpt=0; cpt< NB_ELEM/2; cpt++) {
+     sprintf(buf,"%d",cpt);
+     xbt_dynar_shift(d,&s2);
+     xbt_test_assert2(!strcmp(buf,s2),
+           "The retrieved value is not the same than the injected one at the begining (%s!=%s)",
+              buf,s2);
+      free(s2);
+   }
+   for (cpt=(NB_ELEM/5)-1; cpt>=0; cpt--) {
+     sprintf(buf,"%d",cpt);
+     xbt_dynar_shift(d,&s2);
+     xbt_test_assert2 (!strcmp(buf,s2),
+           "The retrieved value is not the same than the injected one in the middle (%s!=%s)",
+              buf,s2);
+     free(s2);
+   }
+   for (cpt=NB_ELEM/2; cpt< NB_ELEM; cpt++) {
+     sprintf(buf,"%d",cpt);
+     xbt_dynar_shift(d,&s2);
+     xbt_test_assert2 (!strcmp(buf,s2),
+           "The retrieved value is not the same than the injected one at the end (%s!=%s)",
+              buf,s2);
+     free(s2);
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);
+
+
+   xbt_test_add3("==== Push %d strings, remove %d-%d. free the rest",NB_ELEM,2*(NB_ELEM/5),4*(NB_ELEM/5));
+   d=xbt_dynar_new(sizeof(char*),&free_string);
+   for (cpt=0; cpt< NB_ELEM; cpt++) {
+     sprintf(buf,"%d",cpt);
+     s1=strdup(buf);
+     xbt_dynar_push(d,&s1);
+   }
+   for (cpt=2*(NB_ELEM/5); cpt< 4*(NB_ELEM/5); cpt++) {
+     sprintf(buf,"%d",cpt);
+     xbt_dynar_remove_at(d,2*(NB_ELEM/5),&s2);
+     xbt_test_assert2(!strcmp(buf,s2),
+                 "Remove a bad value. Got %s, expected %s",
+                 s2,buf);
+      free(s2);
+   }
+   xbt_dynar_free(&d);
+   xbt_dynar_free(&d);  
+}
+#endif /* SIMGRID_TEST */
index 8bfbb3f..5ac0f0c 100644 (file)
@@ -236,7 +236,7 @@ static void debuged_add(xbt_set_t  set,
 
   elm->data=xbt_strdup(data);
 
-  xbt_test_log2("   - Add %s (->%s)",name,data);
+  xbt_test_log2("Add %s (->%s)",name,data);
   xbt_set_add(set, (xbt_set_elm_t)elm, &my_elem_free);
 }
 
@@ -289,7 +289,6 @@ static void search_id(xbt_set_t head,int id,const char*key) {
   if (strcmp(elm->name,elm->data))
     THROW2(mismatch_error,0,"The name (%s) != data (%s)",
           elm->name,elm->data);
-  fflush(stdout);
 }
 
 
@@ -314,9 +313,8 @@ static void search_not_found(xbt_set_t set, const char *data) {
     xbt_set_get_by_name(set,data);
     THROW1(unknown_error,0,"Found something which shouldn't be there (%s)",data);
   } CATCH(e) {
-    if (e.category != not_found_error) {
+    if (e.category != not_found_error) 
       xbt_test_exception(e);
-    }
     xbt_ex_free(e);  
   }
 }
@@ -359,7 +357,7 @@ XBT_TEST_UNIT("change",test_set_change,"Changing some values") {
   traverse(set);
 }
 
-XBT_TEST_UNIT("retrieve",test_set_retrieve,"Retrieve some values") {
+XBT_TEST_UNIT("retrieve",test_set_retrieve,"Retrieving some values") {
   my_elem_t elm;
 
   xbt_test_add0("Search 123");
index 6af2554..17b2c89 100644 (file)
@@ -229,3 +229,63 @@ int xbt_swag_belongs(void *obj, xbt_swag_t swag)
   return ((NEXT(obj, swag->offset)) || (PREV(obj, swag->offset))
          || (swag->head == obj));
 }
+
+
+#ifdef SIMGRID_TEST
+
+XBT_TEST_SUITE("swag","Swag data container");
+
+typedef struct {
+  s_xbt_swag_hookup_t setA;
+  s_xbt_swag_hookup_t setB;
+  const char *name;
+} shmurtz, s_shmurtz_t, *shmurtz_t;
+
+
+XBT_TEST_UNIT("basic",test_swag_basic,"Basic usage") {
+  shmurtz_t obj1, obj2, obj;
+  xbt_swag_t setA,setB;
+
+  obj1 = calloc(1,sizeof(s_shmurtz_t));
+  obj2 = calloc(1,sizeof(s_shmurtz_t));
+
+  obj1->name="Obj 1";
+  obj2->name="Obj 2";
+
+  xbt_test_add0("Basic usage");
+  xbt_test_log3("%p %p %ld\n",obj1,&(obj1->setB),
+               (long)((char *)&(obj1->setB) - (char *)obj1));
+
+  setA = xbt_swag_new(xbt_swag_offset(*obj1,setA));
+  setB = xbt_swag_new(xbt_swag_offset(*obj1,setB));
+
+  xbt_swag_insert(obj1, setA);
+  xbt_swag_insert(obj1, setB);
+  xbt_swag_insert(obj2, setA);
+  xbt_swag_insert(obj2, setB);
+
+  xbt_swag_remove(obj1, setB);
+  /*  xbt_swag_remove(obj2, setB);*/
+
+  xbt_test_add0("Traverse set A");
+  xbt_swag_foreach(obj,setA) {
+    xbt_test_log1("Saw: %s",obj->name);
+  }
+
+  xbt_test_add0("Traverse set B");
+  xbt_swag_foreach(obj,setB) {
+    xbt_test_log1("Saw: %s",obj->name);
+  }
+
+  xbt_test_add0("Ensure set content and length");
+  xbt_test_assert(  xbt_swag_belongs(obj1,setA));
+  xbt_test_assert(  xbt_swag_belongs(obj2,setA));
+
+  xbt_test_assert(! xbt_swag_belongs(obj1,setB));
+  xbt_test_assert(  xbt_swag_belongs(obj2,setB));
+
+  xbt_test_assert(xbt_swag_size(setA) == 2);
+  xbt_test_assert(xbt_swag_size(setB) == 1);
+}
+
+#endif /* SIMGRID_TEST */
diff --git a/testsuite/xbt/dict_crash.c b/testsuite/xbt/dict_crash.c
deleted file mode 100644 (file)
index c16121f..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-/* $Id$ */
-
-/* dict_crash - A crash test for dictionnaries                              */
-
-/* Copyright (c) 2003, 2004 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 "gras.h"
-#include <time.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#define NB_ELM 20000
-#define SIZEOFKEY 1024
-
-static void print_str(void *str);
-static void print_str(void *str) {
-  printf("%s",(char*)str);
-}
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
-
-static void traverse(xbt_dict_t head) {
-  xbt_dict_cursor_t cursor=NULL;
-  char *key;
-  char *data;
-
-  xbt_dict_foreach(head,cursor,key,data) {
-    /*    printf("   Seen:  %s=%s\n",key,data); */
-    xbt_assert2 (!strcmp(key,data),
-      "Key(%s) != value(%s). Abording\n",key,data);
-  }
-}
-
-static int countelems(xbt_dict_t head) {
-  xbt_dict_cursor_t cursor;
-  char *key;
-  void *data;
-  int res = 0;
-
-  xbt_dict_foreach(head,cursor,key,data) {
-    res++;
-  }
-  return res;
-}
-
-int main(int argc,char **argv) {
-  xbt_dict_t head=NULL;
-  int i,j,k, nb;
-  char *key;
-  void *data;
-
-  xbt_init(&argc,argv);
-  srand((unsigned int)time(NULL));
-
-  printf("Dictionnary: CRASH test:\n");
-  printf(" Fill the struct, count its elems and frees the structure (x20)\n");
-  printf(" using 1000 elements with %d chars long randomized keys.\n",SIZEOFKEY);
-  printf(" (a point is a test)\n");
-
-  for (i=0;i<20;i++) {
-    head=xbt_dict_new();
-    if (i%10) printf("."); else printf("%d",i/10); fflush(stdout);
-    nb=0;
-    for (j=0;j<1000;j++) {
-      if (!(key=malloc(SIZEOFKEY))) {
-       fprintf(stderr,"Out of memory\n");
-       return 1;
-      }
-
-      for (k=0;k<SIZEOFKEY-1;k++)
-       key[k]=rand() % ('z' - 'a') + 'a';
-      key[k]='\0';
-      /*      printf("[%d %s]\n",j,key); */
-      xbt_dict_set(head,key,key,&free);
-    }
-    /*    xbt_dict_dump(head,(void (*)(void*))&printf); */
-    nb = countelems(head);
-    if (nb != 1000) {
-       printf ("\nI found %d elements, and not 1000\n",nb);
-       abort();
-    }    
-    traverse(head);
-    xbt_dict_free(&head);
-    xbt_dict_free(&head);
-  }
-
-
-  head=xbt_dict_new();
-  printf("\n Fill 20 000 elements, with keys being the number of element\n");
-  printf("  (a point is 1 000 elements)\n");
-  for (j=0;j<NB_ELM;j++) {
-    if (!(j%1000)) {
-      printf("."); 
-      fflush(stdout);
-    }
-    if (!(key=malloc(10))) {
-      fprintf(stderr,"Out of memory\n");
-      abort();
-    }
-    
-    sprintf(key,"%d",j);
-    xbt_dict_set(head,key,key,&free);
-  }
-
-  printf("\n Count the elements (retrieving the key and data for each): \n");
-  i = countelems(head);
-
-  printf(" There is %d elements\n",i);
-  printf("\n Search my 20 000 elements 20 times. (a point is a test)\n");
-  if (!(key=malloc(10))) {
-    fprintf(stderr,"Out of memory\n");
-    abort();
-  } 
-  for (i=0;i<20;i++) {
-    if (i%10) printf("."); else printf("%d",i/10); fflush(stdout);
-    for (j=0;j<NB_ELM;j++) {
-      
-      sprintf(key,"%d",j);
-      data = xbt_dict_get(head,key);
-      if (strcmp(key,(char*)data)) {
-       printf("key=%s != data=%s\n",key,(char*)data);
-       abort();
-      }
-    }
-  }
-  free(key);
-
-  printf("\n Remove my 20 000 elements. (a point is 10 000 elements)\n");
-  if (!(key=malloc(10))) {
-    fprintf(stderr,"Out of memory\n");
-    abort();
-  }
-  for (j=0;j<NB_ELM;j++) {
-    if (!(j%10000)) printf("."); fflush(stdout);
-    
-    sprintf(key,"%d",j);
-    xbt_dict_remove(head,key);
-  }
-  printf("\n");
-  free(key);
-
-  
-  printf("\n Free the structure (twice)\n");
-  xbt_dict_free(&head);
-  xbt_dict_free(&head);
-  
-  xbt_exit();
-  return 0;
-}
diff --git a/testsuite/xbt/dict_usage.c b/testsuite/xbt/dict_usage.c
deleted file mode 100644 (file)
index feae8e2..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/* $Id$ */
-
-/* dict_usage - A test of normal usage of a dictionnary                     */
-
-/* Copyright (c) 2003,2004 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 <stdio.h>
-
-#include "gras.h"
-#include "portable.h"
-#include "xbt/ex.h"
-
-XBT_LOG_EXTERNAL_CATEGORY(dict);
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
-
-static void fill(xbt_dict_t *head);
-static void debuged_add(xbt_dict_t head,const char*key);
-static void search(xbt_dict_t head,const char*key);
-static void debuged_remove(xbt_dict_t head,const char*key);
-static void traverse(xbt_dict_t head);
-
-static void print_str(void *str);
-static void print_str(void *str) {
-  printf("%s",(char*)PRINTF_STR(str));
-}
-
-static void fill(xbt_dict_t *head) {
-  printf("\n Fill in the dictionnary\n");
-
-  *head = xbt_dict_new();
-  debuged_add(*head,"12");
-  debuged_add(*head,"12a");
-  debuged_add(*head,"12b");
-  debuged_add(*head,"123");
-  debuged_add(*head,"123456");
-  /* Child becomes child of what to add */
-  debuged_add(*head,"1234");
-  /* Need of common ancestor */
-  debuged_add(*head,"123457");
-
-}
-
-static void debuged_add(xbt_dict_t head,const char*key)
-{
-  char *data=xbt_strdup(key);
-
-  printf("   - Add %s\n",PRINTF_STR(key));
-  xbt_dict_set(head,key,data,&free);
-  if (XBT_LOG_ISENABLED(dict,xbt_log_priority_debug)) {
-    xbt_dict_dump(head,(void (*)(void*))&printf);
-    fflush(stdout);
-  }
-}
-
-static void search(xbt_dict_t head,const char*key) {
-  void *data;
-  
-  data=xbt_dict_get(head,key);
-  printf("   - Search %s. Found %s\n",PRINTF_STR(key),(char*) PRINTF_STR(data));fflush(stdout);
-  if (data && strcmp((char*)data,key)) 
-    THROW2(mismatch_error,0,"Found %s while looking for %s",(char*)data,key);
-}
-
-static void debuged_remove(xbt_dict_t head,const char*key) {
-
-  printf("   Remove '%s'\n",PRINTF_STR(key));fflush(stdout);
-  xbt_dict_remove(head,key);
-  /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
-}
-
-
-static void traverse(xbt_dict_t head) {
-  xbt_dict_cursor_t cursor=NULL;
-  char *key;
-  char *data;
-
-  xbt_dict_foreach(head,cursor,key,data) {
-    printf("   - Seen:  %s->%s\n",PRINTF_STR(key),PRINTF_STR(data));
-    xbt_assert2(!data || !strcmp(key,data),
-                "Key(%s) != value(%s). Abording\n",key,data);
-  }
-}
-
-static void search_not_found(xbt_dict_t head, const char *data) {
-  xbt_ex_t e;
-
-  TRY {    
-    data = xbt_dict_get(head,"Can't be found");
-    THROW1(unknown_error,0,"Found something which shouldn't be there (%s)",data);
-  } CATCH(e) {
-    if (e.category != not_found_error) 
-      RETHROW;
-    xbt_ex_free(e);
-  }
-}
-
-int main(int argc,char **argv) {
-  xbt_ex_t e;
-  xbt_dict_t head=NULL;
-  char *data;
-
-  xbt_init(&argc,argv);
-   
-  printf("\nGeneric dictionnary: USAGE test:\n");
-
-  printf(" Traverse the empty dictionnary\n");
-  traverse(head);
-
-  printf(" Traverse the full dictionnary\n");
-  fill(&head);
-  search(head,"12a");
-xbt_dict_dump(head,(void (*)(void*))&printf);
-  traverse(head);
-
-  printf(" Free the dictionnary (twice)\n");
-  xbt_dict_free(&head);
-  xbt_dict_free(&head);
-  
-  fill(&head);
-
-  /* xbt_dict_dump(head,(void (*)(void*))&printf);*/
-  printf(" - Test that it works with NULL data\n");
-  printf("   - Store NULL under 'null'\n");fflush(stdout);
-  xbt_dict_set(head,"null",NULL,NULL);
-  search(head,"null");
-  /* xbt_dict_dump(head,(void (*)(void*))&printf); */
-  printf("   Check whether I see it while traversing...\n");fflush(stdout);
-  {
-     xbt_dict_cursor_t cursor=NULL;
-     char *key;
-     int found=0;
-     
-     xbt_dict_foreach(head,cursor,key,data) {
-       printf("   - Seen:  %s->%s\n",PRINTF_STR(key),PRINTF_STR(data));fflush(stdout);
-       if (!strcmp(key,"null"))
-         found = 1;
-     }
-     xbt_assert0(found,"the key 'null', associated to NULL is not found");
-  }
-  printf("   OK, I did found the searched NULL\n");
-
-  printf(" - Change some values\n");
-  printf("   - Change 123 to 'Changed 123'\n");
-  xbt_dict_set(head,"123",strdup("Changed 123"),&free);
-  printf("   - Change 123 back to '123'\n");
-  xbt_dict_set(head,"123",strdup("123"),&free);
-  printf("   - Change 12a to 'Dummy 12a'\n");
-  xbt_dict_set(head,"12a",strdup("Dummy 12a"),&free);
-  printf("   - Change 12a to '12a'\n");
-  xbt_dict_set(head,"12a",strdup("12a"),&free);
-
-  /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
-  printf(" - Traverse the resulting dictionnary\n");
-  traverse(head);
-
-  printf(" - Retrive values\n");
-  data = xbt_dict_get(head,"123");
-  xbt_assert(data);
-  strcmp("123",data);
-
-  search_not_found(head,"Can't be found");
-  search_not_found(head,"123 Can't be found");
-  search_not_found(head,"12345678 NOT");
-
-  search(head,"12a");
-  search(head,"12b");
-  search(head,"12");
-  search(head,"123456");
-  search(head,"1234");
-  search(head,"123457");
-
-  printf(" - Traverse the resulting dictionnary\n");
-  traverse(head);
-
-  /*  xbt_dict_dump(head,(void (*)(void*))&printf); */
-
-  printf(" Free the dictionnary twice\n");
-  xbt_dict_free(&head);
-  xbt_dict_free(&head);
-
-  printf(" - Traverse the resulting dictionnary\n");
-  traverse(head);
-
-  printf("\n");
-  fill(&head);
-  printf(" - Remove the data (traversing the resulting dictionnary each time)\n");
-  TRY {
-    debuged_remove(head,"Does not exist");
-  } CATCH(e) {
-    if (e.category != not_found_error) 
-      RETHROW;
-    xbt_ex_free(e);
-  }
-  traverse(head);
-
-  xbt_dict_free(&head);
-
-  printf(" - Remove data from the NULL dict (error message expected)\n");
-  TRY {
-    debuged_remove(head,"12345");
-  } CATCH(e) {
-    if (e.category != arg_error) 
-      RETHROW;
-    xbt_ex_free(e);
-  } 
-
-  printf(" - Remove each data manually (traversing the resulting dictionnary each time)\n");
-  fill(&head);
-  debuged_remove(head,"12a");    traverse(head);
-  debuged_remove(head,"12b");    traverse(head);
-  debuged_remove(head,"12");     traverse(head);
-  debuged_remove(head,"123456"); traverse(head);
-  TRY {
-    debuged_remove(head,"12346");
-  } CATCH(e) {
-    if (e.category != not_found_error) 
-      RETHROW;
-    xbt_ex_free(e);              traverse(head);
-  } 
-  debuged_remove(head,"1234");   traverse(head);
-  debuged_remove(head,"123457"); traverse(head);
-  debuged_remove(head,"123");    traverse(head);
-  TRY {
-    debuged_remove(head,"12346");
-  } CATCH(e) {
-    if (e.category != not_found_error) 
-      RETHROW;
-    xbt_ex_free(e);
-  }                              traverse(head);
-  
-  printf(" - Free the dictionnary twice\n");
-  xbt_dict_free(&head);
-  xbt_dict_free(&head);
-  xbt_exit();
-  return 0;
-}
diff --git a/testsuite/xbt/dynar_double.c b/testsuite/xbt/dynar_double.c
deleted file mode 100644 (file)
index 7e8ef1a..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/* $Id$ */
-
-/* dynar_double: A test case for the dynar using doubles as content         */
-
-/* Copyright (c) 2003,2004 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 "gras.h"
-
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
-
-int main(int argc,char *argv[]) {
-   xbt_dynar_t d;
-   int cpt,cursor;
-   double d1,d2;
-   
-   xbt_init(&argc,argv);
-
-   INFO0("==== Traverse the empty dynar");
-   d=xbt_dynar_new(sizeof(int),NULL);
-   xbt_dynar_foreach(d,cursor,cpt){
-     xbt_assert0(FALSE,
-            "Damnit, there is something in the empty dynar");
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-   INFO0("==== Push/shift 5000 doubles");
-   d=xbt_dynar_new(sizeof(double),NULL);
-   for (cpt=0; cpt< 5000; cpt++) {
-     d1=(double)cpt;
-     xbt_dynar_push(d,&d1);
-   }
-   xbt_dynar_foreach(d,cursor,d2){
-     d1=(double)cursor;
-     xbt_assert2(d1 == d2,
-           "The retrieved value is not the same than the injected one (%f!=%f)",
-                 d1,d2);
-   }
-   for (cpt=0; cpt< 5000; cpt++) {
-     d1=(double)cpt;
-     xbt_dynar_shift(d,&d2);
-     xbt_assert2(d1 == d2,
-           "The retrieved value is not the same than the injected one (%f!=%f)",
-                 d1,d2);
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-
-   INFO0("==== Unshift/pop 5000 doubles");
-   d=xbt_dynar_new(sizeof(double),NULL);
-   for (cpt=0; cpt< 5000; cpt++) {
-     d1=(double)cpt;
-     xbt_dynar_unshift(d,&d1);
-   }
-   for (cpt=0; cpt< 5000; cpt++) {
-     d1=(double)cpt;
-     xbt_dynar_pop(d,&d2);
-     xbt_assert2 (d1 == d2,
-           "The retrieved value is not the same than the injected one (%f!=%f)",
-                  d1,d2);
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-
-
-   INFO0("==== Push 5000 doubles, insert 1000 doubles in the middle, shift everything");
-   d=xbt_dynar_new(sizeof(double),NULL);
-   for (cpt=0; cpt< 5000; cpt++) {
-     d1=(double)cpt;
-     xbt_dynar_push(d,&d1);
-   }
-   for (cpt=0; cpt< 1000; cpt++) {
-     d1=(double)cpt;
-     xbt_dynar_insert_at(d,2500,&d1);
-   }
-
-   for (cpt=0; cpt< 2500; cpt++) {
-     d1=(double)cpt;
-     xbt_dynar_shift(d,&d2);
-     xbt_assert2(d1 == d2,
-           "The retrieved value is not the same than the injected one at the begining (%f!=%f)",
-                 d1,d2);
-     DEBUG2("Pop %d, length=%lu",cpt, xbt_dynar_length(d));
-   }
-   for (cpt=999; cpt>=0; cpt--) {
-     d1=(double)cpt;
-     xbt_dynar_shift(d,&d2);
-     xbt_assert2 (d1 == d2,
-           "The retrieved value is not the same than the injected one in the middle (%f!=%f)",
-                  d1,d2);
-   }
-   for (cpt=2500; cpt< 5000; cpt++) {
-     d1=(double)cpt;
-     xbt_dynar_shift(d,&d2);
-     xbt_assert2 (d1 == d2,
-           "The retrieved value is not the same than the injected one at the end (%f!=%f)",
-                  d1,d2);
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-
-   INFO0("==== Push 5000 double, remove 2000-4000. free the rest");
-   d=xbt_dynar_new(sizeof(double),NULL);
-   for (cpt=0; cpt< 5000; cpt++) {
-     d1=(double)cpt;
-     xbt_dynar_push(d,&d1);
-   }
-   for (cpt=2000; cpt< 4000; cpt++) {
-     d1=(double)cpt;
-     xbt_dynar_remove_at(d,2000,&d2);
-     xbt_assert2 (d1 == d2,
-           "Remove a bad value. Got %f, expected %f",
-              d2,d1);
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-   xbt_exit();
-   return 0;
-}
diff --git a/testsuite/xbt/dynar_int.c b/testsuite/xbt/dynar_int.c
deleted file mode 100644 (file)
index 7082478..0000000
+++ /dev/null
@@ -1,162 +0,0 @@
-/* $Id$ */
-
-/* dynar_int: A test case for the dynar using integers as content           */
-
-/* Copyright (c) 2003, 2004 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 "gras.h"
-
-#define NB_ELEM 5000
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
-
-int main(int argc,char *argv[]) {
-   /* Vars_decl [doxygen cruft] */
-   xbt_dynar_t d;
-   int i,cpt,cursor;
-   int *iptr;
-   
-   xbt_init(&argc,argv);
-
-   INFO0("==== Traverse the empty dynar");
-   d=xbt_dynar_new(sizeof(int),NULL);
-   xbt_dynar_foreach(d,cursor,i){
-     xbt_assert0(0,"Damnit, there is something in the empty dynar");
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-   INFO1("==== Push %d int, set them again 3 times, traverse them, shift them",
-       NB_ELEM);
-   /* Populate_ints [doxygen cruft] */
-   /* 1. Populate the dynar */
-   d=xbt_dynar_new(sizeof(int),NULL);
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     xbt_dynar_push_as(d,int,cpt); /* This is faster (and possible only with scalars) */
-     /* xbt_dynar_push(d,&cpt);       This would also work */
-     DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(d));
-   }
-   
-   /* 2. Traverse manually the dynar */
-   for (cursor=0; cursor< NB_ELEM; cursor++) {
-     iptr=xbt_dynar_get_ptr(d,cursor);
-     xbt_assert2(cursor == *iptr,
-                "The retrieved value is not the same than the injected one (%d!=%d)",
-                cursor,cpt);
-   }
-   
-   /* 3. Traverse the dynar using the neat macro to that extend */
-   xbt_dynar_foreach(d,cursor,cpt){
-     xbt_assert2(cursor == cpt,
-                "The retrieved value is not the same than the injected one (%d!=%d)",
-                cursor,cpt);
-   }
-   /* end_of_traversal */
-   
-   for (cpt=0; cpt< NB_ELEM; cpt++)
-     *(int*)xbt_dynar_get_ptr(d,cpt) = cpt;
-
-   for (cpt=0; cpt< NB_ELEM; cpt++) 
-     *(int*)xbt_dynar_get_ptr(d,cpt) = cpt;
-/*     xbt_dynar_set(d,cpt,&cpt);*/
-   
-   for (cpt=0; cpt< NB_ELEM; cpt++) 
-     *(int*)xbt_dynar_get_ptr(d,cpt) = cpt;
-   
-   cpt=0;
-   xbt_dynar_foreach(d,cursor,i){
-     xbt_assert2(i == cpt,
-         "The retrieved value is not the same than the injected one (%d!=%d)",
-                 i,cpt);
-     cpt++;
-   }
-   xbt_assert2(cpt == NB_ELEM,
-               "Cannot retrieve my %d values. Last got one is %d",
-               NB_ELEM, cpt);
-
-   /* shifting [doxygen cruft] */
-   /* 4. Shift all the values */
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     xbt_dynar_shift(d,&i);
-     xbt_assert2(i == cpt,
-           "The retrieved value is not the same than the injected one (%d!=%d)",
-              i,cpt);
-     DEBUG2("Pop %d, length=%lu",cpt, xbt_dynar_length(d));
-   }
-   
-   /* 5. Free the resources */
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-   
-   INFO1("==== Unshift/pop %d int",NB_ELEM);
-   d=xbt_dynar_new(sizeof(int),NULL);
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     xbt_dynar_unshift(d,&cpt);
-     DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(d));
-   }
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     i=xbt_dynar_pop_as(d,int);
-     xbt_assert2(i == cpt,
-           "The retrieved value is not the same than the injected one (%d!=%d)",
-                i,cpt);
-     DEBUG2("Pop %d, length=%lu",cpt, xbt_dynar_length(d));
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-   
-   INFO1("==== Push %d int, insert 1000 int in the middle, shift everything",NB_ELEM);
-   d=xbt_dynar_new(sizeof(int),NULL);
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     xbt_dynar_push_as(d,int,cpt);
-     DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(d));
-   }
-   for (cpt=0; cpt< 1000; cpt++) {
-     xbt_dynar_insert_at_as(d,2500,int,cpt);
-     DEBUG2("Push %d, length=%lu",cpt, xbt_dynar_length(d));
-   }
-
-   for (cpt=0; cpt< 2500; cpt++) {
-     xbt_dynar_shift(d,&i);
-     xbt_assert2(i == cpt,
-           "The retrieved value is not the same than the injected one at the begining (%d!=%d)",
-              i,cpt);
-     DEBUG2("Pop %d, length=%lu",cpt, xbt_dynar_length(d));
-   }
-   for (cpt=999; cpt>=0; cpt--) {
-     xbt_dynar_shift(d,&i);
-     xbt_assert2(i == cpt,
-           "The retrieved value is not the same than the injected one in the middle (%d!=%d)",
-              i,cpt);
-   }
-   for (cpt=2500; cpt< NB_ELEM; cpt++) {
-     xbt_dynar_shift(d,&i);
-      xbt_assert2(i == cpt,
-           "The retrieved value is not the same than the injected one at the end (%d!=%d)",
-              i,cpt);
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-
-   INFO1("==== Push %d int, remove 2000-4000. free the rest",NB_ELEM);
-   d=xbt_dynar_new(sizeof(int),NULL);
-   for (cpt=0; cpt< NB_ELEM; cpt++) 
-     xbt_dynar_push_as(d,int,cpt);
-   
-   for (cpt=2000; cpt< 4000; cpt++) {
-     xbt_dynar_remove_at(d,2000,&i);
-     xbt_assert2(i == cpt,
-                 "Remove a bad value. Got %d, expected %d",
-                 i,cpt);
-     DEBUG2("remove %d, length=%lu",cpt, xbt_dynar_length(d));
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-   xbt_exit();
-   return 0;
-}
diff --git a/testsuite/xbt/dynar_string.c b/testsuite/xbt/dynar_string.c
deleted file mode 100644 (file)
index 645ce5b..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/* $Id$ */
-
-/* dynar_string: A test case for the dynar using strings as content         */
-
-/* Copyright (c) 2003, 2004 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 <stdio.h> /* sprintf */
-#include "gras.h"
-
-/* NB_ELEM HAS to be a multiple of 5 */
-#define NB_ELEM 5000
-XBT_LOG_NEW_DEFAULT_CATEGORY(test,"Logging specific to this test");
-
-/* doxygen_first_cruft*/
-
-/* The function we will use to free the data */
-static void free_string(void *d){
-  free(*(void**)d);
-}
-
-int main(int argc,char *argv[]) {
-   xbt_dynar_t d;
-   int cpt;
-   char buf[1024];
-   char *s1,*s2;
-   
-   xbt_init(&argc,argv);
-   
-   INFO0("==== Traverse the empty dynar");
-   d=xbt_dynar_new(sizeof(char *),&free_string);
-   xbt_dynar_foreach(d,cpt,s1){
-     xbt_assert0(FALSE,
-                 "Damnit, there is something in the empty dynar");
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-   INFO1("==== Push %d strings, set them again 3 times, shift them",NB_ELEM);
-   d=xbt_dynar_new(sizeof(char*),&free_string);
-   /* Populate_str [doxygen cruft] */
-   /* 1. Populate the dynar */
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     sprintf(buf,"%d",cpt);
-     s1=strdup(buf);
-     xbt_dynar_push(d,&s1);
-   }
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     sprintf(buf,"%d",cpt);
-     s1=strdup(buf);
-     xbt_dynar_replace(d,cpt,&s1);
-   }
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     sprintf(buf,"%d",cpt);
-     s1=strdup(buf);
-     xbt_dynar_replace(d,cpt,&s1);
-   }
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     sprintf(buf,"%d",cpt);
-     s1=strdup(buf);
-     xbt_dynar_replace(d,cpt,&s1);
-   }
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     sprintf(buf,"%d",cpt);
-     xbt_dynar_shift(d,&s2);
-     xbt_assert2 (!strcmp(buf,s2),
-           "The retrieved value is not the same than the injected one (%s!=%s)",
-                  buf,s2);
-     free(s2);
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-
-   INFO1("==== Unshift, traverse and pop %d strings",NB_ELEM);
-   d=xbt_dynar_new(sizeof(char**),&free_string);
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     sprintf(buf,"%d",cpt);
-     s1=strdup(buf);
-     xbt_dynar_unshift(d,&s1);
-   }
-   /* 2. Traverse the dynar with the macro */
-   xbt_dynar_foreach(d,cpt,s1) {
-     sprintf(buf,"%d",NB_ELEM - cpt -1);
-     xbt_assert2 (!strcmp(buf,s1),
-           "The retrieved value is not the same than the injected one (%s!=%s)",
-              buf,s1);
-   }
-   /* 3. Traverse the dynar with the macro */
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     sprintf(buf,"%d",cpt);
-     xbt_dynar_pop(d,&s2);
-     xbt_assert2 (!strcmp(buf,s2),
-           "The retrieved value is not the same than the injected one (%s!=%s)",
-              buf,s2);
-     free(s2);
-   }
-   /* 4. Free the resources */
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-
-   INFO2("==== Push %d strings, insert %d strings in the middle, shift everything",NB_ELEM,NB_ELEM/5);
-   d=xbt_dynar_new(sizeof(char*),&free_string);
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     sprintf(buf,"%d",cpt);
-     s1=strdup(buf);
-     xbt_dynar_push(d,&s1);
-   }
-   for (cpt=0; cpt< NB_ELEM/5; cpt++) {
-     sprintf(buf,"%d",cpt);
-     s1=strdup(buf);
-     xbt_dynar_insert_at(d,NB_ELEM/2,&s1);
-   }
-
-   for (cpt=0; cpt< NB_ELEM/2; cpt++) {
-     sprintf(buf,"%d",cpt);
-     xbt_dynar_shift(d,&s2);
-     xbt_assert2(!strcmp(buf,s2),
-           "The retrieved value is not the same than the injected one at the begining (%s!=%s)",
-              buf,s2);
-      free(s2);
-   }
-   for (cpt=(NB_ELEM/5)-1; cpt>=0; cpt--) {
-     sprintf(buf,"%d",cpt);
-     xbt_dynar_shift(d,&s2);
-     xbt_assert2 (!strcmp(buf,s2),
-           "The retrieved value is not the same than the injected one in the middle (%s!=%s)",
-              buf,s2);
-     free(s2);
-   }
-   for (cpt=NB_ELEM/2; cpt< NB_ELEM; cpt++) {
-     sprintf(buf,"%d",cpt);
-     xbt_dynar_shift(d,&s2);
-     xbt_assert2 (!strcmp(buf,s2),
-           "The retrieved value is not the same than the injected one at the end (%s!=%s)",
-              buf,s2);
-     free(s2);
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-
-   INFO3("==== Push %d strings, remove %d-%d. free the rest",NB_ELEM,2*(NB_ELEM/5),4*(NB_ELEM/5));
-   d=xbt_dynar_new(sizeof(char*),&free_string);
-   for (cpt=0; cpt< NB_ELEM; cpt++) {
-     sprintf(buf,"%d",cpt);
-     s1=strdup(buf);
-     xbt_dynar_push(d,&s1);
-   }
-   for (cpt=2*(NB_ELEM/5); cpt< 4*(NB_ELEM/5); cpt++) {
-     sprintf(buf,"%d",cpt);
-     xbt_dynar_remove_at(d,2*(NB_ELEM/5),&s2);
-     xbt_assert2(!strcmp(buf,s2),
-                 "Remove a bad value. Got %s, expected %s",
-                 s2,buf);
-      free(s2);
-   }
-   xbt_dynar_free(&d);
-   xbt_dynar_free(&d);
-
-   xbt_exit();
-   return 0;
-}
diff --git a/testsuite/xbt/multidict_crash.c b/testsuite/xbt/multidict_crash.c
deleted file mode 100644 (file)
index 2a0e4b0..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/* $Id$ */
-
-/* multidict_crash - A crash test for multi-level dictionnaries             */
-
-/* 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 <stdio.h>
-
-#include "xbt.h"
-
-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 void str_free(void *s) {
-  char *c=*(char**)s;
-  free(c);
-}
-
-int main(int argc, char *argv[]) {
-  xbt_dict_t mdict = NULL;
-  int i,j,k,l;
-  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,DEPTH);
-  printf(" with %d chars long randomized keys. (a point is a test)\n",KEY_SIZE);
-
-  for (l=0 ; l<DEPTH ; l++) {
-    key=xbt_malloc(KEY_SIZE);
-    xbt_dynar_push(keys,&key);
-  }    
-
-
-  for (i=0;i<NB_TEST;i++) {
-    mdict = xbt_dict_new();
-    VERB1("mdict=%p",mdict);
-    if (verbose>0) {
-      printf("Test %d\n",i);
-    } else if (verbose==0) {
-      if (i%10) printf("."); else printf("%d",i/10);
-    }
-    fflush(stdout);
-    
-    for (j=0;j<NB_ELM;j++) {
-      if (verbose>0) printf ("  Add {");
-      
-      for (l=0 ; l<DEPTH ; l++) {
-        key=*(char**)xbt_dynar_get_ptr(keys,l);
-        
-       for (k=0;k<KEY_SIZE-1;k++) 
-         key[k]=rand() % ('z' - 'a') + 'a';
-         
-       key[k]='\0';
-       
-       if (verbose>0) printf("%p=%s %s ",key, key,(l<DEPTH-1?";":"}"));
-      }
-      if (verbose>0) printf("in multitree %p.\n",mdict);
-                                                        
-      xbt_multidict_set(mdict,keys,xbt_strdup(key),free);
-
-      data = xbt_multidict_get(mdict,keys);
-
-      xbt_assert2(data && !strcmp((char*)data,key),
-                 "Retrieved value (%s) does not match the entrered one (%s)\n",
-                 (char*)data,key);
-    }
-    xbt_dict_free(&mdict);
-  }
-  
-  xbt_dynar_free(&keys);
-
-/*  if (verbose>0)
-    xbt_dict_dump(mdict,&xbt_dict_print);*/
-    
-  xbt_dict_free(&mdict);
-  xbt_dynar_free(&keys);
-  printf("\n");
-
-  xbt_exit();
-  return 0;
-}
diff --git a/testsuite/xbt/swag_usage.c b/testsuite/xbt/swag_usage.c
deleted file mode 100644 (file)
index 760f231..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*     $Id$     */
-
-/* A simple example to demonstrate the use of swags */
-
-/* Copyright (c) 2004 Arnaud Legrand. 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 <stdlib.h>
-#include <stdio.h>
-#include "xbt/swag.h"
-
-typedef struct {
-  s_xbt_swag_hookup_t setA;
-  s_xbt_swag_hookup_t setB;
-  const char *name;
-} shmurtz, s_shmurtz_t, *shmurtz_t;
-
-int main(void)
-{
-  shmurtz_t obj1, obj2, obj;
-  xbt_swag_t setA,setB;
-
-  obj1 = calloc(1,sizeof(s_shmurtz_t));
-  obj2 = calloc(1,sizeof(s_shmurtz_t));
-
-  obj1->name="Obj 1";
-  obj2->name="Obj 2";
-
-  printf("%p %p %ld\n",obj1,&(obj1->setB),
-        (long)((char *)&(obj1->setB) - (char *)obj1));
-
-  setA = xbt_swag_new(xbt_swag_offset(*obj1,setA));
-  setB = xbt_swag_new(xbt_swag_offset(*obj1,setB));
-
-  xbt_swag_insert(obj1, setA);
-  xbt_swag_insert(obj1, setB);
-  xbt_swag_insert(obj2, setA);
-  xbt_swag_insert(obj2, setB);
-
-  xbt_swag_remove(obj1, setB);
-  /*  xbt_swag_remove(obj2, setB);*/
-
-  xbt_swag_foreach(obj,setA) {
-    printf("\t%s\n",obj->name);
-  }
-
-  xbt_swag_foreach(obj,setB) {
-    printf("\t%s\n",obj->name);
-  }
-
-  printf("Belongs : %d\n", xbt_swag_belongs(obj2,setB));
-
-  printf("%d %d\n", xbt_swag_size(setA),xbt_swag_size(setB));
-  return 0;
-}