Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename SIMIX files
[simgrid.git] / buildtools / Cmake / generate_new_tests.pl
1 #!/usr/bin/perl -w
2 use strict;
3
4 # input file = AddTest.txt
5
6 if($#ARGV!=0) {
7     die "Usage: generate_new_tests.pl AddTests.cmake\n";
8 }
9
10 open MAKETEST, $ARGV[0] or die "Unable to open $ARGV[1]. $!\n";
11
12 my($line);
13 my($path);
14 my($dump)=0;
15 my($setenv);
16 my($tesh_file);
17 my($config_var);
18 my($name_test);
19
20 while(defined($line=<MAKETEST>))
21 {
22     chomp $line;
23     if($line =~ /BEGIN CONTEXTS FACTORY/) {
24         print "$line\n";
25                 $dump = 1;
26                 next;
27             } 
28     if($line =~ /HAVE_TRACING/) {
29         print "$line\n";
30                 $dump = !$dump;
31                 next;
32             }
33         if($line =~ /HAVE_LUA/) {
34         print "$line\n";
35                 $dump = !$dump;
36                 next;
37             }
38         if($line =~ /HAVE_RUBY/) {
39         print "$line\n";
40                 $dump = !$dump;
41                 next;
42             }
43     if($dump) 
44     {
45                 if($line =~ /ADD_TEST.*\/bin\/tesh/) 
46                 {       
47                         $setenv = "";
48                         $config_var = "";
49                         $path = "";
50                         $tesh_file = "";
51                         $name_test = "";
52                         
53                         if($line =~ /ADD_TEST\(([\S]+)/)
54                         {
55                                 $name_test =($1);
56                         }
57                         if($line =~ /--cfg\s*\t*(\S*)/)
58                         {
59                                 $config_var = "--cfg $1 $config_var";
60                         }
61                         if($line =~ /--cd\s*(\S+)/)
62                         {
63                                 $path="--cd $1";
64                         }
65                         if($line =~ /--setenv\s*\t*(\S*)\=(\S*)/)
66                         {
67                                 $setenv = "--setenv $1=$2 $setenv";
68                         }
69                         if($line =~ /([\S]+)[)]$/)
70                         {
71                                 $tesh_file =($1);                               
72                         }
73                         
74                         print "ADD_TEST($name_test-raw          \$\{CMAKE_BINARY_DIR\}/bin/tesh --cfg contexts/factory:raw      $config_var     $setenv $path $tesh_file)\n";
75                         print "ADD_TEST($name_test-thread       \$\{CMAKE_BINARY_DIR\}/bin/tesh --cfg contexts/factory:thread   $config_var     $setenv $path $tesh_file)\n";   
76                         print "ADD_TEST($name_test-ucontext     \$\{CMAKE_BINARY_DIR\}/bin/tesh --cfg contexts/factory:ucontext $config_var     $setenv $path $tesh_file)\n";   
77                 }
78                 elsif($line =~ /set_tests_properties\(([\S]+)/)
79                 {
80                                 my($name_temp)=($1);
81                                 $line =~ s/$name_temp/$name_temp-raw $name_temp-thread $name_temp-ucontext/g;
82                                 print $line."\n";
83                 }
84                 else
85                 {
86                         print "$line\n";
87                 }
88         
89         }
90         else
91         {
92                 print "$line\n";
93         }   
94 }
95 close(MAKETEST);