blob: 3df3fa8182191431e99205c59c9b7751a065216c [file] [log] [blame]
robbiewa1c66572002-03-13 16:38:50 +00001#!/usr/bin/perl
2
3#LTP results gathering script: ltp_check
4# 3/12/02 William Jay Huie (creation)
robbiewdc61c582002-03-27 21:58:42 +00005# 3/28/02 William Jay Huie minor fixes, increased results parsing
robbiewa8dc2112002-05-03 15:57:43 +00006# 5/01/02 William Jay Huie parsing changes
robbiewa1c66572002-03-13 16:38:50 +00007#This will log into the LTP_HOST machine, which may be different then the
8#machine used to run the ltp_master script
9#This script will check for *ltpoutput.tgz files created by the ltprun script
10#and download them each to their own directory and do a bit of processing
11#the results gathering probably needs to be extended but hopefully this is a good
12#first go at it
13
14use Net::FTP ();
15
16#CHANGEME:
17#For some reason doesn't work if you do ~/ltp/results, so you need to code the
18#explicit path for LTP_RES_DIR unless someone can tell me why
19$LTP_RES_DIR="/home/wjhuie/ltp/results";
20#CHANGEME:
21$LTP_HOST="ltp_host.somewhere.org";
robbiewa8dc2112002-05-03 15:57:43 +000022#This is who has the *ltpoutput.tgz files, where the results are uploaded
23# not necessarially the user id that ran the test
robbiewa1c66572002-03-13 16:38:50 +000024$LTP_USER="ltp";
25$LTP_PASS="ltp";
26$LTP_LOGFILE="ltp-logfile";
27$LTP_RUN_OUTPUT="ltprun.out";
28$LTP_RUNALL_OUT="runall.output";
29$RESULTS_OUT="results.out";
robbiewa8dc2112002-05-03 15:57:43 +000030$FAILS_OUT="failures.list";
robbiewa1c66572002-03-13 16:38:50 +000031
32@res_dirs;
33$count = 0;
34$RES = 0;
robbiewa8dc2112002-05-03 15:57:43 +000035$FAILS = 0;
robbiewa1c66572002-03-13 16:38:50 +000036
37sub download_results()
38{
39 print "Attempting to download the LTP results\n";
40
41 $dir = system("ls $LTP_RES_DIR &> /dev/null") / 256;
42 if ($dir)
43 {
44 print "Making a results directory in $LTP_RES_DIR\n";
45 `mkdir -p $LTP_RES_DIR`;
46 chdir "$LTP_RES_DIR" or die "Can't change to $LTP_RES_DIR\n";
47 }
48 else
49 { chdir "$LTP_RES_DIR" or die "Can't change to $LTP_RES_DIR\n"; }
50
robbiewdc61c582002-03-27 21:58:42 +000051 $ftp = Net::FTP->new($LTP_HOST, Debug => 0) or die "Can't connect to ftp: $LTP_HOST";
robbiewa1c66572002-03-13 16:38:50 +000052 $ftp->login($LTP_USER, $LTP_PASS) or die "Unable to login";
53 $ftp->type('I') or die "Unable to set type to Binary";
54 @files = $ftp->ls("*ltpoutput.tgz");
55 $num_files = $#files + 1;
56 print "New results files found $num_files:\n";
57 for ($i = 0; $i < $num_files; $i++) { print "\t$files[$i]\n"; }
58
59 for ($i = 0; $i < $num_files; $i++)
60 {
61 print "Downloading: $files[$i]\t";
62 if ($ftp->get($files[$i]))
63 {
64 print "Successful\n";
robbiewa8dc2112002-05-03 15:57:43 +000065 $ftp->delete($files[$i]);
robbiewa1c66572002-03-13 16:38:50 +000066 }
67 else
68 { print "FAILED\n"; }
69
70 }
71 $ftp->quit;
72
73 @res = `ls $LTP_RES_DIR/*.tgz 2> /dev/null`;
74
75 if (@res)
76 {
77 $num = $#res + 1;
78 print " download of LTP results finished\n";
79 print "$num unprocessed results files found\n";
80 chomp(@res);
81 return 1;
82 }
83 else
84 { print " no apparent results to process\n"; return 0; }
85
86}
87
88sub untar_results()
89{
90 for ($i = 0; $i < $num; $i++)
91 {
92 if ( $res[$i] =~ m/\s*(\w+)-((\w+)-)*ltpoutput.tgz/ )
93 {
94 $hostname = $1;
95 $epoch_time = $3;
96 $english_time = localtime($epoch_time);
97 $dir = "$LTP_RES_DIR/$hostname/$english_time";
98
99 if ($english_time)
100 {
101 $new_dir = $dir;
102 $new_dir =~ s/ /_/g;
103 print "New results: $hostname @ $english_time\n";
104 `mkdir -p '$new_dir'`;
105 chdir "$new_dir" or die "Can't change to $new_dir\n";
106 `tar -zxf $res[$i]`;
107 `mv $res[$i] $new_dir`;
108 $res_dirs[$count] = $new_dir; $count++;
109 }
110 else
111 {
112 print "No timestamp on results file, skipping for now\n";
113#Should come up with a soultion for this, check/create $hostname
114# then some unique identifier but for now we'll complain and ignore
115 }
116 }
117 }
118 return 1;
119}
120
121sub gather_results()
122{
robbiewdc61c582002-03-27 21:58:42 +0000123 print "Gathering $count result(s):\n";
robbiewa1c66572002-03-13 16:38:50 +0000124
125 for ($i = 0; $i < $count; $i++)
126 {
robbiewdc61c582002-03-27 21:58:42 +0000127 print "\nResults for: $res_dirs[$i]\n";
robbiewa1c66572002-03-13 16:38:50 +0000128 chdir "$res_dirs[$i]" or die "Can't change to $res_dirs[$i]\n";
robbiewdc61c582002-03-27 21:58:42 +0000129
130 chomp($stat = `tail -n1 $LTP_RUNALL_OUT`);
131 print "\t\t$stat\n";
132
133 $num_success = `grep "stat=0" $LTP_LOGFILE | wc -l`;
134 if ( $num_success =~ /\s*(\d+)\s*/ ) { $num_success = $1; }
robbiewa1c66572002-03-13 16:38:50 +0000135
136 @fails = `grep "stat=" $LTP_LOGFILE | grep -v "stat=0"`;
robbiewdc61c582002-03-27 21:58:42 +0000137 $num_fail = $#fails + 1;
robbiewa1c66572002-03-13 16:38:50 +0000138
robbiewdc61c582002-03-27 21:58:42 +0000139 $pass_percent = sprintf("%.2f",
140 ($num_success / ($num_success + $num_fail)) * 100);
141
142 $ltp_ver = `grep "version" $LTP_RUN_OUTPUT`;
143 if ( $ltp_ver =~ m/.*version: (.*)/ ) { $ltp_ver = $1; }
144
145 $line = "Pass $pass_percent % : $num_success succeeded : $num_fail failed";
146 print "$line";
147
robbiewa1c66572002-03-13 16:38:50 +0000148 if (open RES, ">$RESULTS_OUT")
149 {
robbiewdc61c582002-03-27 21:58:42 +0000150 print ". -> Results stored in $RESULTS_OUT\n";
robbiewa8dc2112002-05-03 15:57:43 +0000151 if (!open FAILS, ">$FAILS_OUT") { print "Error opening $FAILS_OUT\n"; }
robbiewdc61c582002-03-27 21:58:42 +0000152 $num =
robbiewa8dc2112002-05-03 15:57:43 +0000153#The <<<test_start>>> doesn't always get into the runalltest.sh output capture
154#because some output will appear before its corresponding block
155#So for now relying on last thing from ver_linux to know when to stop copying
156# system("awk '/<<<test_start>>>/ { exit NR-1; }' $LTP_RUNALL_OUT") / 256;
robbiewdc61c582002-03-27 21:58:42 +0000157 system("awk '/bogomips/ { exit NR; }' $LTP_RUNALL_OUT") / 256;
158
159 @system_info = `head -n $num $LTP_RUNALL_OUT`;
160
161 if ($ltp_ver) { print RES "$ltp_ver : "; }
162 print RES "$line\n\n";
163 print RES "@system_info\n";
164 print RES "$stat:\n ";
robbiewa1c66572002-03-13 16:38:50 +0000165 print RES "@fails\n";
robbiewdc61c582002-03-27 21:58:42 +0000166
167 $runall = `cat $LTP_RUNALL_OUT`;
168 for ($j = 0; $j < $num_fail; $j++)
169 {
170 if ( $fails[$j] =~ m/^tag=(\w+?) / )
171 {
172 $test_case = $1;
robbiewa8dc2112002-05-03 15:57:43 +0000173 if (FAILS) { print FAILS "$test_case\n"; }
robbiewdc61c582002-03-27 21:58:42 +0000174 print RES "\nTrying to find $test_case output";
175 if ( $runall =~
robbiewa8dc2112002-05-03 15:57:43 +0000176#modified because some output is appearing before tagline
177 m/((^$test_case.*?)*<<<test_start>>>.tag=$test_case.*?<<<test_end>>>)/ms
robbiewdc61c582002-03-27 21:58:42 +0000178 )
179 {
180 print RES "\n-------------------------\n";
181 print RES "$1";
182 print RES "\n-------------------------\n";
183 }
184 else
185 {
186 print RES "\n-------------------------\n";
187 print RES "Unable to locate output for $test_case!";
188 print RES "\n-------------------------\n";
189 }
190 }
191 }
robbiewa8dc2112002-05-03 15:57:43 +0000192 close(RES); close(FAILS);
robbiewa1c66572002-03-13 16:38:50 +0000193 }
194 else
robbiewdc61c582002-03-27 21:58:42 +0000195 { print "Can't open $RESULTS_OUT, test failures are:\n @fails\n"; }
robbiewa1c66572002-03-13 16:38:50 +0000196 }
197 return 1;
198}
199
200if (!download_results)
201{ exit 0; }
202
203if (!untar_results)
204{ exit 0; }
205
206if (!gather_results)
207{ exit 0; }