Algorithmique Numérique Distribuée Public GIT Repository
d4e4c995558e63babf1d65b21965c9ae6a20484c
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 \r
14 open SH_LIGNE, \$file or die "Unable to open \$file. \$!\n";\r
15 \r
16 while(defined(\$line1=<SH_LIGNE>))\r
17 {\r
18                 if(\$line1 =~ /^\\$/){    #command line\r
19                         \$ok = 1;\r
20                         \$line1 =~ s/\\$\{srcdir\:\=\.\}/./g;\r
21                         \$line1 =~ s/\\$SG_TEST_EXENV//g;\r
22                         \$line1 =~ s/\\$SG_EXENV_TEST//g;\r
23                         \$line1 =~ s/\\$EXEEXT//g;\r
24                         \$line1 =~ s/\\${EXEEXT:=}//g;\r
25                         \$line1 =~ s/^\\$\ *//g;\r
26                         \$line1 =~ s/^.\/lua/lua/g;\r
27                         \$line1 =~ s/^.\/ruby/ruby/g;\r
28                         chomp \$line1;\r
29                         \$execline = \$line1;\r
30                         print "\$execline\n";\r
31                         system "\$execline 1>output_tesh.txt 2>output_tesh_err.txt";\r
32                         close(FILE_ERR);\r
33                         close(FILE);\r
34                         open (FILE, "output_tesh.txt");\r
35                         open (FILE_ERR, "output_tesh_err.txt");}\r
36                         \r
37                 if(\$line1 =~ /^\>/){    #expected result line\r
38                         if(\$ok == 0){die "No command line\$!";}\r
39                         \$line1 =~ s/^\> //g;\r
40                         \$line1 =~ s/\r//g;\r
41                         chomp \$line1;\r
42                         \r
43                         if(\$line1 =~ /^.*\[.*\].*\[.*\/INFO\].*\$/)\r
44                                 {if(!defined(\$line2=<FILE_ERR>))\r
45                                         {       print "- \$line1\n";\r
46                                                 die;}}\r
47                         elsif(\$line1 =~ /^.*\[.*\].*\[.*\/WARNING\].*\$/)\r
48                                 {if(!defined(\$line2=<FILE_ERR>))\r
49                                         {       print "- \$line1\n";\r
50                                                 die;}}\r
51                         elsif(\$line1 =~ /^.*\[.*\].*\[.*\/CRITICAL\].*\$/)\r
52                                 {if(!defined(\$line2=<FILE_ERR>))\r
53                                         {       print "- \$line1\n";\r
54                                                 die;}}\r
55                         elsif(\$line1 =~ /^.*\[.*\].*\[.*\/DEBUG\].*\$/)\r
56                                 {if(!defined(\$line2=<FILE_ERR>))\r
57                                         {       print "- \$line1\n";\r
58                                                 die;}}\r
59                         else{if(!defined(\$line2=<FILE>))\r
60                                         {       print "- \$line1\n";\r
61                                                 die;}}\r
62                         \r
63                         \$line2 =~ s/\r//g;                                                      \r
64                         chomp \$line2;\r
65                         \r
66                         if(\$line2 eq \$line1){}\r
67                         else\r
68                         {       print "- \$line1\n";\r
69                                 print "+ \$line2\n";\r
70                                 die;}}  \r
71 }\r
72 if(\$ok == 1){\r
73         print "Test of \"\$file\" OK\n";\r
74         \$ok = 0;}\r
75         \r
76 close(SH_LIGNE);\r
77 close(FILE_ERR);\r
78 close(FILE);