Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
basic support for automatic testing easing problem support from the users
authormquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 28 Jan 2004 22:14:49 +0000 (22:14 +0000)
committermquinson <mquinson@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 28 Jan 2004 22:14:49 +0000 (22:14 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@15 48e7efb5-ca39-0410-a469-dd3cf9ba447f

testsuite/Makefile.am
testsuite/gras/test_utils.c [new file with mode: 0644]
testsuite/xbt/config_usage.c
testsuite/xbt/dict_crash.c
testsuite/xbt/dict_usage.c
testsuite/xbt/dynar_double.c
testsuite/xbt/dynar_int.c
testsuite/xbt/dynar_string.c
testsuite/xbt/log_usage.c

index 106a861..39ce97a 100644 (file)
@@ -20,20 +20,21 @@ noinst_PROGRAMS =                             \
 
 noinst_SCRIPTS = run_tests gs_example
 
-dynar_int_LDADD=          $(top_srcdir)/src/base/libgrasutils.a
-dynar_double_LDADD=       $(top_srcdir)/src/base/libgrasutils.a
-dynar_string_LDADD=       $(top_srcdir)/src/base/libgrasutils.a
+log_usage_LDADD=          $(top_srcdir)/src/base/libgrasutils.a test_utils.o
 
-dict_usage_LDADD=         $(top_srcdir)/src/base/libgrasutils.a
-dict_crash_LDADD=         $(top_srcdir)/src/base/libgrasutils.a
-multidict_crash_LDADD=    $(top_srcdir)/src/base/libgrasutils.a
+dynar_int_LDADD=          $(top_srcdir)/src/base/libgrasutils.a test_utils.o
+dynar_double_LDADD=       $(top_srcdir)/src/base/libgrasutils.a test_utils.o
+dynar_string_LDADD=       $(top_srcdir)/src/base/libgrasutils.a test_utils.o
 
-config_usage_LDADD=       $(top_srcdir)/src/base/libgrasutils.a
+dict_usage_LDADD=         $(top_srcdir)/src/base/libgrasutils.a test_utils.o
+dict_crash_LDADD=         $(top_srcdir)/src/base/libgrasutils.a test_utils.o
+multidict_crash_LDADD=    $(top_srcdir)/src/base/libgrasutils.a test_utils.o
 
-log_usage_LDADD=           $(top_srcdir)/src/base/libgrasutils.a
+config_usage_LDADD=       $(top_srcdir)/src/base/libgrasutils.a test_utils.o
 
-gs_example_send_LDADD=    $(top_srcdir)/src/base/libgrasutils.a
-gs_example_receive_LDADD= $(top_srcdir)/src/base/libgrasutils.a
+
+gs_example_send_LDADD=    $(top_srcdir)/src/base/libgrasutils.a test_utils.o
+gs_example_receive_LDADD= $(top_srcdir)/src/base/libgrasutils.a test_utils.o
 
 TESTS=run_tests
 
diff --git a/testsuite/gras/test_utils.c b/testsuite/gras/test_utils.c
new file mode 100644 (file)
index 0000000..b55b576
--- /dev/null
@@ -0,0 +1,19 @@
+#include <string.h>
+#include <stdio.h>
+#include <gras.h>
+
+void parse_log_opt(int argc, char **argv,const char *deft);
+
+void parse_log_opt(int argc, char **argv,const char *deft) {
+   char *opt;
+   gras_error_t errcode;
+   
+   if (argc > 1 && !strncmp(argv[1],"--gras-log=",strlen("--gras-log="))) {
+    opt=strchr(argv[1],'=');
+    opt++;
+    TRYFAIL(gras_log_control_set(opt));
+  } else {
+    TRYFAIL(gras_log_control_set(deft));
+  }
+}
+
index 05a605f..e47e2a1 100644 (file)
@@ -48,12 +48,14 @@ int test5()
   return 1;
 }
  
-int main() {
+void parse_log_opt(int argc, char **argv,const char *deft);
+
+int main(int argc, char **argv) {
   gras_error_t errcode;
   gras_cfg_t *set;
   int ival;
   
-  gras_log_control_set("config.thresh=debug root.thresh=info");
+  parse_log_opt(argc,argv,"config.thresh=debug root.thresh=info");
 
   fprintf(stderr,"==== Alloc and free a config set.\n");
   set=make_set();
index 75fdb10..44a4458 100644 (file)
@@ -48,14 +48,16 @@ static gras_error_t countelems(gras_dict_t *head,int*count) {
   return no_error;
 }
 
-int main() {
+void parse_log_opt(int argc, char **argv, const char *deft);
+
+int main(int argc,char **argv) {
   gras_error_t errcode;
   gras_dict_t *head=NULL;
   int i,j,k, nb;
   char *key;
   void *data;
 
-  TRY(gras_log_control_set("root.thresh=info"));
+  parse_log_opt(argc,argv,"dict.thresh=debug");
   srand((unsigned int)time(NULL));
 
   printf("Dictionnary: CRASH test:\n");
index 1d07232..c91e580 100644 (file)
@@ -96,15 +96,15 @@ static gras_error_t traverse(gras_dict_t *head) {
   return no_error;
 }
 
-int main() {
+void parse_log_opt(int argc, char **argv,const char *deft);
+
+int main(int argc,char **argv) {
   gras_error_t errcode;
   gras_dict_t *head=NULL;
   char *data;
 
-  //  TRY(gras_log_control_set("root.thresh=info dict_collapse.thresh=debug"));
-  //TRY(gras_log_control_set("root.thresh=info"));
-  //  TRY(gras_log_control_set("root.thresh=info dict_search.thresh=info dict.thresh=debug dict_collapse.thresh=debug log.thresh=debug"));
-
+  parse_log_opt(argc,argv,"dict.thresh=debug");
+   
   printf("\nGeneric dictionnary: USAGE test:\n");
 
   printf(" Traverse the empty dictionnary\n");
index 22590df..68b0469 100644 (file)
 #include <stdio.h>
 #include <gras.h>
 
+void parse_log_opt(int argc, char **argv,const char *deft);
+
 int main(int argc,char *argv[]) {
    gras_dynar_t *d;
    gras_error_t errcode;
    int cpt,cursor;
    double d1,d2;
    
+   parse_log_opt(argc,argv,"dynar.thresh=debug");
+
    fprintf(stderr,"==== Traverse the empty dynar\n");
    TRYFAIL(gras_dynar_new(&d,sizeof(int),NULL));
    gras_dynar_foreach(d,cursor,cpt){
index e65b29d..0dc8641 100644 (file)
 #define NB_ELEM 5000
 GRAS_LOG_NEW_DEFAULT_CATEGORY(test);
 
+void parse_log_opt(int argc, char **argv, const char *def);
+
 int main(int argc,char *argv[]) {
    gras_dynar_t *d;
    gras_error_t errcode;
    int i,cpt,cursor;
    
-   //   TRYFAIL(gras_log_control_set("root.thresh=debug dynar.thresh=info"));
-   TRYFAIL(gras_log_control_set("dynar.thresh=debug root.thresh=info"));
+   parse_log_opt(argc,argv,"dynar.thresh=debug");
+
    fprintf(stderr,"==== Traverse the empty dynar\n");
    TRYFAIL(gras_dynar_new(&d,sizeof(int),NULL));
    gras_dynar_foreach(d,cursor,i){
index b37b6a8..7fea46b 100644 (file)
@@ -17,6 +17,8 @@ void free_string(void *d){
   free(*(void**)d);
 }
 
+void parse_log_opt(int argc, char **argv,const char *deft);
+
 int main(int argc,char *argv[]) {
    gras_dynar_t *d;
    gras_error_t errcode;
@@ -24,6 +26,8 @@ int main(int argc,char *argv[]) {
    char buf[1024];
    char *s1,*s2;
    
+   parse_log_opt(argc,argv,"dynar.thresh=debug");
+   
    fprintf(stderr,"==== Traverse the empty dynar\n");
    TRYFAIL(gras_dynar_new(&d,sizeof(int),NULL));
    gras_dynar_foreach(d,cpt,i){
index 3a6f864..14cba8d 100644 (file)
 GRAS_LOG_NEW_DEFAULT_SUBCATEGORY(Test, Top);
 GRAS_LOG_NEW_CATEGORY(Top);
 
-int main(int ac, char **av) {
-  gras_error_t errcode;
+void parse_log_opt(int argc, char **argv,const char *deft);
+
+int main(int argc, char **argv) {
+  parse_log_opt(argc,argv,"root.thresh=debug log.thresh=debug");
 
-  if (ac > 1) {
-    TRYFAIL(gras_log_control_set(av[1]));
-  } else {
-    TRYFAIL(gras_log_control_set("root.thresh=debug log.thresh=debug"));
-  }
   DEBUG1("val=%d", 1);
   WARNING1("val=%d", 2);
   CDEBUG2(Top, "val=%d%s", 3, "!");