Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix a segfault when Host.getByName(null) is called
[simgrid.git] / buildtools / Cmake / Scripts / generate_new_tests.pl
1 #!/usr/bin/perl -w
2
3 # Copyright (c) 2012, 2014. The SimGrid Team.
4 # All rights reserved.
5
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the license (GNU LGPL) which comes with this package.
8
9 use strict;
10
11 # input file = AddTest.txt
12
13 if($#ARGV!=0) {
14     die "Usage: generate_new_tests.pl AddTests.cmake\n";
15 }
16
17 open MAKETEST, $ARGV[0] or die "Unable to open $ARGV[1]. $!\n";
18
19 my($line);
20 my($path);
21 my($dump)=0;
22 my($setenv);
23 my($tesh_file);
24 my($config_var);
25 my($name_test);
26
27 while(defined($line=<MAKETEST>))
28 {
29     chomp $line;
30     if($line =~ /BEGIN CONTEXTS FACTORY/) {
31         print "$line\n";
32                 $dump = 1;
33                 next;
34             } 
35     if($line =~ /HAVE_TRACING/) {
36         print "$line\n";
37                 $dump = !$dump;
38                 next;
39             }
40         if($line =~ /HAVE_LUA/) {
41         print "$line\n";
42                 $dump = !$dump;
43                 next;
44             }
45         if($line =~ /HAVE_RUBY/) {
46         print "$line\n";
47                 $dump = !$dump;
48                 next;
49             }
50     if($dump) 
51     {
52                 if($line =~ /ADD_TEST.*\/bin\/tesh/) 
53                 {       
54                         $setenv = "";
55                         $config_var = "";
56                         $path = "";
57                         $tesh_file = "";
58                         $name_test = "";
59                         
60                         if($line =~ /ADD_TEST\(([\S]+)/)
61                         {
62                                 $name_test =($1);
63                         }
64                         if($line =~ /--cfg\s*\t*(\S*)/)
65                         {
66                                 $config_var = "--cfg $1 $config_var";
67                         }
68                         if($line =~ /--cd\s*(\S+)/)
69                         {
70                                 $path="--cd $1";
71                         }
72                         if($line =~ /--setenv\s*\t*(\S*)\=(\S*)/)
73                         {
74                                 $setenv = "--setenv $1=$2 $setenv";
75                         }
76                         if($line =~ /([\S]+)[)]$/)
77                         {
78                                 $tesh_file =($1);                               
79                         }
80                         
81                         print "ADD_TEST($name_test-raw          \$\{CMAKE_BINARY_DIR\}/bin/tesh --cfg contexts/factory:raw      $config_var     $setenv $path $tesh_file)\n";
82                         print "ADD_TEST($name_test-thread       \$\{CMAKE_BINARY_DIR\}/bin/tesh --cfg contexts/factory:thread   $config_var     $setenv $path $tesh_file)\n";   
83                         print "ADD_TEST($name_test-ucontext     \$\{CMAKE_BINARY_DIR\}/bin/tesh --cfg contexts/factory:ucontext $config_var     $setenv $path $tesh_file)\n";   
84                 }
85                 elsif($line =~ /set_tests_properties\(([\S]+)/)
86                 {
87                                 my($name_temp)=($1);
88                                 $line =~ s/$name_temp/$name_temp-raw $name_temp-thread $name_temp-ucontext/g;
89                                 print $line."\n";
90                 }
91                 else
92                 {
93                         print "$line\n";
94                 }
95         
96         }
97         else
98         {
99                 print "$line\n";
100         }   
101 }
102 close(MAKETEST);