Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add file AddTestsWin.cmake for execute tesh.perl with tests.
[simgrid.git] / buildtools / Cmake / tesh.pl
1 #!perl -w\r
2 use strict;\r
3 \r
4 if($#ARGV!=1){die "Usage: perl tesh.pl <directory> <teshfile.tesh>\n";}\r
5 my($directory)=$ARGV[0];\r
6 my($file)=$ARGV[1];\r
7 my($line1);\r
8 my($line2);\r
9 my($execline);\r
10 my($ok)=0;\r
11 chdir("$directory");\r
12 print "Change directory to \"$directory\"\n";\r
13 open SH_LIGNE, $file or die "Unable to open $file. $!\n";\r
14 \r
15 while(defined($line1=<SH_LIGNE>))\r
16 {\r
17                 if($line1 =~ /^\$/){    #command line\r
18                         $ok = 1;\r
19                         $line1 =~ s/\$\{srcdir\:\=\.\}/./g;\r
20                         $line1 =~ s/\$SG_TEST_EXENV//g;\r
21                         $line1 =~ s/\$SG_EXENV_TEST//g;\r
22                         $line1 =~ s/\$EXEEXT/.exe/g;\r
23                         $line1 =~ s/\${EXEEXT:=}//g;\r
24                         $line1 =~ s/^\$\ *//g;\r
25                         $line1 =~ s/^.\/lua/lua/g;\r
26                         $line1 =~ s/^.\/ruby/ruby/g;\r
27                         chomp $line1;\r
28                         $execline = $line1;\r
29                         print "$execline\n";\r
30                         system "$execline 1>output_tesh.txt 2>output_tesh_err.txt";\r
31                         close(FILE_ERR);\r
32                         close(FILE);\r
33                         open (FILE, "output_tesh.txt");\r
34                         open (FILE_ERR, "output_tesh_err.txt");}\r
35                         \r
36                 if($line1 =~ /^\>/){    #expected result line\r
37                         if($ok == 0){die "No command line$!";}\r
38                         $line1 =~ s/^\> //g;\r
39                         $line1 =~ s/\r//g;\r
40                         chomp $line1;\r
41                         \r
42                         if($line1 =~ /^.*\[.*\].*\[.*\/INFO\].*$/){if(!defined($line2=<FILE_ERR>)){die;}}elsif($line1 =~ /^.*\[.*\].*\[.*\/WARNING\].*$/){if(!defined($line2=<FILE_ERR>)){die;}}\r
43                         elsif($line1 =~ /^.*\[.*\].*\[.*\/CRITICAL\].*$/){if(!defined($line2=<FILE_ERR>)){die;}}\r
44                         elsif($line1 =~ /^.*\[.*\].*\[.*\/DEBUG\].*$/){if(!defined($line2=<FILE_ERR>)){die;}}\r
45                         else{if(!defined($line2=<FILE>)){die;}}\r
46                         \r
47                         $line2 =~ s/\r//g;                                                      \r
48                         chomp $line2;\r
49                         \r
50                         if($line2 eq $line1){}\r
51                         else\r
52                         {       print "- $line1\n";\r
53                                 print "+ $line2\n";\r
54                                 die;}}  \r
55 }\r
56 if($ok == 1){\r
57         print "Test of \"$file\" OK\n";\r
58         $ok = 0;}\r
59         \r
60 close(SH_LIGNE);\r
61 close(FILE_ERR);\r
62 close(FILE);