Logo AND Algorithmique Numérique Distribuée

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