4 # input file = AddTest.txt
7 die "Usage: generate_memcheck_tests.pl <CMAKE_HOME_DIRECTORY> AddTests.cmake\n";
10 my ($proj_dir) = $ARGV[0];
11 open MAKETEST, $ARGV[1] or die "Unable to open $ARGV[1]. $!\n";
14 my ($text, $name, $value) = @_;
16 $text =~ s/\${$name(?::=[^}]*)?}/$value/g;
17 $text =~ s/\$$name(\W|$)/$value$1/g;
20 $text =~ s/\${$name:=([^}]*)}/$1/g;
21 $text =~ s/\${$name}//g;
22 $text =~ s/\$$name(\W|$)/$1/g;
38 while ( defined( $line = <MAKETEST> ) ) {
40 if ( $line =~ /BEGIN TESH TESTS/ ) {
44 if ( $line =~ /END TESH TESTS/ ) {
49 if ( $line =~ /^\s*ADD_TEST\(\S+\s+\S*\/tesh\s/ ) {
58 if ( $line =~ /ADD_TEST\((\S+)/ ) {
61 while ( $line =~ /--cfg\s+(\S+)/g ) {
62 $config_var = "--cfg=$1 $config_var";
64 while ( $line =~ /--cd\s+(\S+)/g ) {
68 while ( $line =~ /--setenv\s+(\S+)\=(\S+)/g ) {
69 my ( $env_var, $value_var ) = ( $1, $2 );
70 if ( $env_var =~ /srcdir/ ) {
73 elsif ( $env_var =~ /bindir/ ) {
77 if ( $line =~ /(\S+)\)$/ ) {
79 $tesh_file =~ s/^[^\/\$]/$path\/$&/;
80 $tesh_file =~ s/\${CMAKE_HOME_DIRECTORY}/$proj_dir/g;
81 if ( ! -e "$tesh_file" ) {
82 print "# tesh_file: $tesh_file does not exist!\n";
89 print "test_name = $name_test\n";
90 print "$config_var\n";
91 print "path = $path\n";
92 print "srcdir=$srcdir\n";
93 print "bindir=$bindir\n";
94 print "tesh_file = $tesh_file\n";
99 my ($count_first) = 0;
100 my ($count_second) = 0;
101 open TESH_FILE, $tesh_file or die "Unable to open $tesh_file $!\n";
103 while ( defined( $l = <TESH_FILE> ) ) {
105 if ( $l =~ /^\$ (.*)$/ ) {
107 $command = var_subst($command, "srcdir", $srcdir);
108 $command = var_subst($command, "bindir", $bindir);
109 $command = var_subst($command, "EXEEXT", "");
110 $command = var_subst($command, "SG_TEST_EXENV", "");
111 $command = var_subst($command, "SG_TEST_ENV", "");
112 $command = var_subst($command, "SG_EXENV_TEST", "");
113 $command = var_subst($command, "ARGS", "");
114 $command =~ s/\$@//g;
115 # $command =~ s/..\/..\/bin\/smpirun/\${CMAKE_BINARY_DIR\}\/bin\/smpirun/g;
116 $command =~ s/^\s+//;
117 $command =~ s/^[^\/\$]\S*\//$path\/$&/;
118 $command =~ s/^(\S*\/)(?:\.\/)+/$1/g;
121 $command = "$command $config_var";
123 print "ADD_TEST(memcheck-$name_test-$count $command --cd $path\/)\n";
125 #push @test_list, "memcheck-$name_test-$count";
128 if ( $l =~ /^\& (.*)$/ ) {
134 elsif ( $line =~ /^\s*set_tests_properties/ ) {
135 if ( $line =~ /set_tests_properties\(([\S]+)/ ) {
136 my ($name_temp) = ($1);
137 $line =~ s/$name_temp/memcheck-$name_temp-0/g;
148 #print "nb_test = $nb_test\n";
149 #print "set(MEMCHECK_LIST\n";
150 #print (join("\n", @test_list));