Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Changes path to find cmake files.
[simgrid.git] / buildtools / Cmake / generate_memcheck_tests.pl
1 #!/usr/bin/perl -w
2 use strict;
3
4 # input file = AddTest.txt
5
6 if($#ARGV!=1) {
7     die "Usage: generate_memcheck_tests.pl <project_directory> AddTests.cmake\n";
8 }
9
10 my($proj_dir)=$ARGV[0];
11 open MAKETEST, $ARGV[1] or die "Unable to open $ARGV[1]. $!\n";
12
13 my(@test_list)=();
14
15 my($line);
16 my($dump)=0;
17 print "if(enable_memcheck)\n";
18 while(defined($line=<MAKETEST>)) {
19     chomp $line;
20     if($line =~ /BEGIN TESH TESTS/) {
21         $dump = 1;
22         next;
23     } 
24     if($line =~ /END TESH TESTS/) {
25         $dump = 0;
26         last;
27     }
28     if($dump) {
29         if($line =~ /ADD_TEST/) {
30             if($line =~ /ADD_TEST\(([\S]+)\s+.*\/tools\/tesh\/tesh\s*--cd\s*(\S+)\s+(.*)\)$/) {
31                 my($name_test,$path,$tesh_file)=($1,$2,$3);
32                 $path=~ s/\"//g;
33                 my($complete_tesh_file)=$path."/".$tesh_file;
34                 my($count)=0;
35                 my($count_first)=0;
36                 my($count_second)=0;
37                 $complete_tesh_file =~ s/\${PROJECT_DIRECTORY}/$proj_dir/g;
38                 open TESH_FILE, $complete_tesh_file or die "Unable to open $complete_tesh_file $!\n";
39                 my($l);
40                 while(defined($l=<TESH_FILE>)) {
41                     chomp $l;
42                     if($l =~ /^\$ (.*)$/) {
43                         my($command) = $1;
44                         $command =~ s/\${srcdir:=.}/./g;
45                         $command =~ s/\${EXEEXT:=}//g;
46                         $command =~ s/\$SG_TEST_EXENV //g;
47                         $command =~ s/\$SG_TEST_ENV //g;
48                         $command =~ s/\$SG_EXENV_TEST //g; 
49                         $command =~ s/\$EXEEXT//g;
50                         $command =~ s/\${srcdir}/\${PROJECT_DIRECTORY}\/src/g;
51                         $command =~ s/ \$ARGS//g;
52                         $command =~ s/ \$@ //g; 
53                         print "ADD_TEST(memcheck-$name_test-$count $command --cd $path\/)\n";
54                         #push @test_list, "memcheck-$name_test-$count";
55                         $count++;
56                     }
57                     if($l =~ /^\& (.*)$/) {
58                         last;
59                     }
60                 }
61                 close(TESH_FILE);
62             } else {
63                 next;
64             }
65         } else {
66             print $line."\n";
67         }
68     }   
69 }
70 close(MAKETEST);
71 print "endif(enable_memcheck)\n";
72 #print "set(MEMCHECK_LIST\n";
73 #print (join("\n", @test_list));
74 #print ")\n";