Algorithmique Numérique Distribuée Public GIT Repository
1 #! /usr/bin/perl -w\r
2 \r
3 use strict;\r
4 \r
5 if(\$#ARGV!=2){die "Usage: tesh.pl --cd <directory> <teshfile.tesh>\n";}\r
6 my(\$line1);\r
7 my(\$line2);\r
8 my(\$execline);\r
9 my(\$ok)=0;\r
10 my(\$nb_arg)=0;\r
11 \r
12 do{\r
13         if(\$ARGV[\$nb_arg] =~ /^--cd\$/)\r
14         {\r
15                 \$nb_arg++;\r
16                 my(\$directory)=\$ARGV[\$nb_arg];\r
17                 chdir("\$directory");\r
18                 print "Change directory to \"\$directory\"\n";   \r
19         }\r
20         \$nb_arg++;\r
21 }while((\$nb_arg-1)!=\$#ARGV);\r
22 \r
23 my(\$file)=\$ARGV[\$nb_arg-1];\r
24 open SH_LIGNE, \$file or die "Unable to open \$file. \$!\n";\r
25 \r
26 while(defined(\$line1=<SH_LIGNE>))\r
27 {\r
28                 if(\$line1 =~ /^\\$/){    #command line\r
29                         \$ok = 1;\r
30                         \$line1 =~ s/\\$\{srcdir\:\=\.\}/./g;\r
31                         \$line1 =~ s/\\$SG_TEST_EXENV//g;\r
32                         \$line1 =~ s/\\$SG_EXENV_TEST//g;\r
33                         \$line1 =~ s/\\$EXEEXT//g;\r
34                         \$line1 =~ s/\\${EXEEXT:=}//g;\r
35                         \$line1 =~ s/^\\$\ *//g;\r
36                         \$line1 =~ s/^.\/lua/lua/g;\r
37                         \$line1 =~ s/^.\/ruby/ruby/g;\r
38                         \r
39                         \$line1 =~ s/\(%i:%P@%h\)/\\\(%i:%P@%h\\\)/g;\r
40                         chomp \$line1;\r
41                         \$execline = \$line1;\r
42                         print "\$execline\n";\r
43                         system "\$execline 1>output_tesh.txt 2>output_tesh_err.txt";\r
44                         close(FILE_ERR);\r
45                         close(FILE);\r
46                         open (FILE, "output_tesh.txt");\r
47                         open (FILE_ERR, "output_tesh_err.txt");}\r
48                         \r
49                 if(\$line1 =~ /^\>/){    #expected result line\r
50                         if(\$ok == 0){die "No command line\$!";}\r
51                         \$line1 =~ s/^\> //g;\r
52                         \$line1 =~ s/\r//g;\r
53                         chomp \$line1;\r
54                         \r
55                         if(\$line1 =~ /^.*\[.*\].*\[.*\/INFO\].*\$/)\r
56                                 {if(!defined(\$line2=<FILE_ERR>))\r
57                                         {       print "- \$line1\n";\r
58                                                 die;}}\r
59                         elsif(\$line1 =~ /^.*\[.*\].*\[.*\/WARNING\].*\$/)\r
60                                 {if(!defined(\$line2=<FILE_ERR>))\r
61                                         {       print "- \$line1\n";\r
62                                                 die;}}\r
63                         elsif(\$line1 =~ /^.*\[.*\].*\[.*\/CRITICAL\].*\$/)\r
64                                 {if(!defined(\$line2=<FILE_ERR>))\r
65                                         {       print "- \$line1\n";\r
66                                                 die;}}\r
67                         elsif(\$line1 =~ /^.*\[.*\].*\[.*\/DEBUG\].*\$/)\r
68                                 {if(!defined(\$line2=<FILE_ERR>))\r
69                                         {       print "- \$line1\n";\r
70                                                 die;}}\r
71                         elsif(\$line1 =~ /^.*\[.*\].*\[0\:\@\].*\$/)\r
72                                 {if(!defined(\$line2=<FILE_ERR>))\r
73                                         {       print "- \$line1\n";\r
74                                                 die;}}\r
75                         elsif(\$line1 =~ /^.*\[.*\].*\(0\:\@\).*\$/)\r
76                                 {if(!defined(\$line2=<FILE_ERR>))\r
77                                         {       print "- \$line1\n";\r
78                                                 die;}}\r
79                         else{if(!defined(\$line2=<FILE>))\r
80                                         {       print "- \$line1\n";\r
81                                                 die;}}          \r
82                         \$line2 =~ s/\r//g;                                                      \r
83                         chomp \$line2;\r
84                         \r
85                         if(\$line2 eq \$line1){}\r
86                         else\r
87                         {       print "- \$line1\n";\r
88                                 print "+ \$line2\n";\r
89                                 die;}}  \r
90 }\r
91 if(\$ok == 1){\r
92         print "Test of \"\$file\" OK\n";\r
93         \$ok = 0;}\r
94         \r
95 close(SH_LIGNE);\r
96 close(FILE_ERR);\r
97 close(FILE);