[Tools] winetest: Merge $datadir and $queuedir into $workdir.
Francois Gouget
fgouget at codeweavers.com
Tue Apr 18 05:37:35 CDT 2017
There is no reason for them not to hang off the same directory
and it was already hardcoded that way in many places.
$workdir replaces $root with a more descriptive name. It also matches
winetest.cron.
The scripts also use relative paths which makes it easier to not leak
them in error messages.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
winetest/INSTALL.txt | 2 +-
winetest/build-index | 27 +++++++++++++++------------
winetest/dissect | 22 ++++++++++++----------
winetest/gather | 39 +++++++++++++++++++++------------------
winetest/winetest.cgi | 6 +++---
winetest/winetest.conf | 5 +----
6 files changed, 53 insertions(+), 48 deletions(-)
diff --git a/winetest/INSTALL.txt b/winetest/INSTALL.txt
index d3f21ddf..d13d1cf8 100644
--- a/winetest/INSTALL.txt
+++ b/winetest/INSTALL.txt
@@ -32,7 +32,7 @@ Read-only source code account:
should be available as $HOME/tools/winetest/INSTALL.txt).
git clone git://source.winehq.org/git/tools.git
- Edit $HOME/tools/winetest/winetest.conf to set:
- $root = "/home/winehq/sites/winetest"
+ $workdir = "/home/winehq/sites/winetest";
$gitdir = "/home/wine/wine.git";
Web site account:
diff --git a/winetest/build-index b/winetest/build-index
index f5b19e09..d30fbbb3 100755
--- a/winetest/build-index
+++ b/winetest/build-index
@@ -34,7 +34,7 @@ sub BEGIN
}
unshift @INC, $1 if ($0 =~ m=^(/.*)/[^/]+$=);
}
-use vars qw/$gitdir $gitweb $queuedir/;
+use vars qw/$workdir $gitdir $gitweb/;
require "winetest.conf";
@@ -50,11 +50,11 @@ sub get_build_info($)
{
($date, $subject) = ($1, $2);
# Make sure the directory's mtime matches the commit time
- utime $date, $date, "data/$build";
+ utime $date, $date, "$workdir/data/$build";
}
else
{
- $date = (stat "./data/$build")[9];
+ $date = (stat "$workdir/data/$build")[9];
$subject = "";
}
return ($date, $subject);
@@ -100,17 +100,20 @@ my %wine = (name => "Wine");
my @groups = (\%w95, \%w98, \%me, \%nt3, \%nt4, \%w2k, \%xp, \%w2k3, \%vista, \%w2k8, \%win7, \%win8, \%win10,
\%unknown, \%linux, \%mac, \%bsd, \%solaris, \%wine);
+
+chdir($workdir) or die "could not chdir to the work directory: $!";
+
# read the test data dir
my @builds;
my @too_old;
-opendir(DIR, "./data/") or die "cannot open ./data";
+opendir(DIR, "data") or die "cannot open 'data'";
foreach my $build (readdir(DIR))
{
next if $build =~ /^\./;
next unless $build =~ /^[-.0-9a-zA-Z]+$/;
- next unless -f "./data/$build/index.html";
+ next unless -f "data/$build/index.html";
my ($date, $subject) = get_build_info($build);
if (time() - $date > 60 * 24 * 60 * 60)
@@ -137,7 +140,7 @@ my %versions = ();
foreach my $build (@builds)
{
my %build_ver = ();
- if (open TOTAL, "./data/$build->{name}/total.txt" )
+ if (open TOTAL, "data/$build->{name}/total.txt" )
{
while (<TOTAL>)
{
@@ -159,7 +162,7 @@ my %alltests = ();
foreach my $build (@builds)
{
- open SUM, "./data/$build->{name}/summary.txt" or next;
+ open SUM, "data/$build->{name}/summary.txt" or next;
while (<SUM>)
{
chomp;
@@ -183,7 +186,7 @@ foreach my $test (sort keys %alltests)
foreach my $test (keys %alltests)
{
- open OUT, ">data/tests/$test.html.new" or die "cannot create data/tests/$test.html.new";
+ open OUT, ">data/tests/$test.html.new" or die "cannot create 'data/tests/$test.html.new'";
print OUT <<EOF;
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
@@ -248,7 +251,7 @@ EOF
rename "data/tests/$test.html.new", "data/tests/$test.html" or unlink "data/tests/$test.html.new";
}
-open OUT, ">data/index.html.new" or die "cannot create data/index.html.new";
+open OUT, ">data/index.html.new" or die "cannot create 'data/index.html.new'";
print OUT <<"EOF";
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
@@ -336,11 +339,11 @@ rename "data/index.html.new", "data/index.html" or unlink "data/index.html.new";
my @errors;
-opendir DIR, $queuedir or die "cannot open $queuedir";
+opendir DIR, "queue" or die "cannot open 'queue'";
foreach my $dir (readdir DIR)
{
next unless $dir =~ /^err.....$/;
- open ERR, "$queuedir/$dir/error" or next;
+ open ERR, "queue/$dir/error" or next;
my $msg = <ERR>;
chomp $msg;
my $date = (stat ERR)[9];
@@ -349,7 +352,7 @@ foreach my $dir (readdir DIR)
}
closedir DIR;
-open OUT, ">data/errors.html.new" or die "cannot create data/errors.html.new";
+open OUT, ">data/errors.html.new" or die "cannot create 'data/errors.html.new'";
print OUT start_html( -title => "Errors caught during Wine test report processing",
-style => {src => "/summary.css"},
diff --git a/winetest/dissect b/winetest/dissect
index 141621e4..f94c621f 100755
--- a/winetest/dissect
+++ b/winetest/dissect
@@ -17,13 +17,13 @@
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
-# This program looks for a WineTest report file matching $queuedir/rep*/report,
+# This program looks for a WineTest report file matching queue/rep*/report,
# takes it apart in its directory while also creating summary.txt. If an error
# occurs the directory is renamed to errXXXXX to avoid future attempts at
# processing this report.
# If everything goes flawlessly the whole directory is renamed (based on the
-# information learned in the process) to $datadir/BUILD/VERSION_TAG_DIGIT
-# where DIGIT is for resolving name clashes and $datadir/BUILD/outdated is
+# information learned in the process) to data/BUILD/VERSION_TAG_DIGIT
+# where DIGIT is for resolving name clashes and data/BUILD/outdated is
# created to signal the change in the given build.
#
# Exit: 0 - successfully processed a report, call again
@@ -48,7 +48,7 @@ sub BEGIN
}
unshift @INC, $1 if ($0 =~ m=^(/.*)/[^/]+$=);
}
-use vars qw/$gitdir $gitweb $queuedir $datadir $maxmult $maxuserskips $maxfailedtests $maxfilesize $acceptprediluvianwin/;
+use vars qw/$workdir $gitdir $gitweb $maxmult $maxuserskips $maxfailedtests $maxfilesize $acceptprediluvianwin/;
require "winetest.conf";
my $name0=$0;
@@ -72,11 +72,11 @@ sub get_build_info($)
{
($date, $subject) = ($1, $2);
# Make sure the directory's mtime matches the commit time
- utime $date, $date, "$datadir/$build";
+ utime $date, $date, "$workdir/data/$build";
}
else
{
- $date = (stat "$datadir/$build")[9];
+ $date = (stat "$workdir/data/$build")[9];
$subject = "";
}
return ($date, $subject);
@@ -102,7 +102,7 @@ sub mydie(@)
{
my $label = $tag ? $tag : "<notag>";
if (!$update) {
- my $errdir = tempdir ("errXXXXX", DIR => $queuedir);
+ my $errdir = tempdir ("errXXXXX", DIR => "$workdir/queue");
if (!rename $tmpdir, $errdir) {
print STDERR "$name0:error: unable to rename '$tmpdir' to '$errdir': $!\n";
exit 3;
@@ -127,12 +127,14 @@ sub create_box($$$)
return $box;
}
+chdir($workdir) or die "could not chdir to the work directory: $!";
+
my $report;
if (defined $ARGV[0] and $ARGV[0] eq "--update") {
$report = $ARGV[1];
$update = 1;
} else {
- ($report, undef) = glob "$queuedir/rep*/report";
+ ($report, undef) = glob "queue/rep*/report";
}
exit 2 unless (defined $report && -f $report);
@@ -481,9 +483,9 @@ for (my $i = 0; $i <= $#boxes; $i++)
close FILE or mydie "error writing to '$tmpdir/$boxes[$i]->{id}.html': $!\n";
}
-my $builddir = "$datadir/$testbuild";
+my $builddir = "data/$testbuild";
if (!$update) {
- foreach my $dir ($datadir, $builddir) {
+ foreach my $dir ("data", $builddir) {
if (!-d $dir && !mkdir $dir) {
print STDERR "$name0:error: unable to create the '$dir' directory: $!\n";
exit 3;
diff --git a/winetest/gather b/winetest/gather
index 7e26a436..b11db9e2 100755
--- a/winetest/gather
+++ b/winetest/gather
@@ -17,9 +17,9 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# This program looks for builds that have received new reports. These are
-# identified by the presence of a file matching $datadir/*/outdated. It then
-# creates an index.html file in the same directory and removes the outdated
-# file.
+# identified by the presence of a file matching data/*/outdated.
+# It then creates an index.html file in the same directory and removes the
+# outdated file.
#
# It is thus intended to run as a second stage invoked by the winetest.cron
# script. Races and concurrency problems must be dealt with on that higher
@@ -45,7 +45,7 @@ sub BEGIN
}
unshift @INC, $1 if ($0 =~ m=^(/.*)/[^/]+$=);
}
-use vars qw/$datadir $gitdir $gitweb/;
+use vars qw/$workdir $gitdir $gitweb/;
require "winetest.conf";
my $name0=$0;
@@ -67,11 +67,11 @@ sub get_build_info($)
{
($date, $subject) = ($1, $2);
# Make sure the directory's mtime matches the commit time
- utime $date, $date, "$datadir/$build";
+ utime $date, $date, "$workdir/data/$build";
}
else
{
- $date = (stat "$datadir/$build")[9];
+ $date = (stat "$workdir/data/$build")[9];
$subject = "";
}
return ($date, $subject);
@@ -159,17 +159,20 @@ my %idmap = (95=>\%w95, 98=>\%w98, me=>\%me, nt3=>\%nt3, nt4=>\%nt4, 2000=>\%w2k
my @groups = (\%w95, \%w98, \%me, \%nt3, \%nt4, \%w2k, \%xp, \%w2k3, \%vista, \%w2k8, \%win7, \%win8, \%win10,
\%unknown, \%linux, \%mac, \%bsd, \%solaris, \%wine);
-my ($outdated,undef) = glob "$datadir/*/outdated";
+
+chdir($workdir) or die "could not chdir to the work directory: $!";
+
+my ($outdated,undef) = glob "data/*/outdated";
exit 2 unless defined $outdated;
-(my $build = $outdated) =~ s|^\Q$datadir\E/(.*)/outdated$|$1|;
+(my $build = $outdated) =~ s|^data/(.*)/outdated$|$1|;
(my $release = $build) =~ s/^(\d+).*$/$1/;
my ($date, $_subject) = get_build_info($build);
# Read in the data
my %alltests; # union of test names
-foreach my $file (glob "$datadir/$build/*/summary.txt") {
- (my $dir = $file) =~ s|^\Q$datadir/$build\E/(.*?)/summary.txt$|$1|;
+foreach my $file (glob "data/$build/*/summary.txt") {
+ (my $dir = $file) =~ s|^data/\Q$build\E/(.*?)/summary.txt$|$1|;
(my $id, my @tag) = split /_/, $dir;
my $group = $idmap{$id};
if (!defined $group) {
@@ -530,7 +533,7 @@ sub singletest($$$) {
{
my $report = $group->{reports} ? $group->{reports}->[0] : $group;
$prefix = "$testname | $report->{tag}";
- if (-r "$datadir/$build/$report->{dir}/$testname.html")
+ if (-r "data/$build/$report->{dir}/$testname.html")
{
$href = "$report->{dir}/$testname.html";
}
@@ -607,9 +610,9 @@ sub build_totals($)
{
my ($reports)=@_;
- if (!open TOTAL, ">$datadir/$build/total.txt.new")
+ if (!open TOTAL, ">data/$build/total.txt.new")
{
- print STDERR "$name0:error: unable to open '$datadir/$build/total.txt.new' for writing: $!\n";
+ print STDERR "$name0:error: unable to open 'data/$build/total.txt.new' for writing: $!\n";
return;
}
my $unit_count=scalar(keys %alltests);
@@ -628,7 +631,7 @@ sub build_totals($)
printf TOTAL "%s %u %u %u %u %u\n", $report->{group}->{name}, $report_count, $unit_count, $report->{errors}, $report->{todos}, $report->{successes};
}
close TOTAL;
- rename "$datadir/$build/total.txt.new", "$datadir/$build/total.txt" or unlink "$datadir/$build/total.txt.new";
+ rename "data/$build/total.txt.new", "data/$build/total.txt" or unlink "data/$build/total.txt.new";
}
sub output_table($)
@@ -651,7 +654,7 @@ sub output_table($)
$filename = "index.html";
}
- my $idx_file = "$datadir/$build/$filename";
+ my $idx_file = "data/$build/$filename";
if (!open OUT, ">$idx_file.new") {
print STDERR "$name0:error: unable to open '$idx_file.new' for writing: $!\n";
return;
@@ -747,9 +750,9 @@ EOF
}
-if (!open SUMMARY, ">$datadir/$build/summary.txt.new")
+if (!open SUMMARY, ">data/$build/summary.txt.new")
{
- print STDERR "$name0:error: unable to open '$datadir/$build/summary.txt.new' for writing: $!\n";
+ print STDERR "$name0:error: unable to open 'data/$build/summary.txt.new' for writing: $!\n";
goto DONE;
}
@@ -762,7 +765,7 @@ foreach my $group (@groups) {
output_table(undef);
close SUMMARY;
-rename "$datadir/$build/summary.txt.new", "$datadir/$build/summary.txt" or unlink "$datadir/$build/summary.txt.new";
+rename "data/$build/summary.txt.new", "data/$build/summary.txt" or unlink "data/$build/summary.txt.new";
build_totals(\@groups);
diff --git a/winetest/winetest.cgi b/winetest/winetest.cgi
index 93afee52..9a4ad717 100755
--- a/winetest/winetest.cgi
+++ b/winetest/winetest.cgi
@@ -18,7 +18,7 @@
use strict;
use warnings;
-use vars qw/$queuedir $maxfilesize/;
+use vars qw/$workdir $maxfilesize/;
BEGIN {
require "winetest.conf";
@@ -29,7 +29,7 @@ use File::Temp qw(tempdir);
use CGI qw(:standard);
# Cater for some overhead
$CGI::POST_MAX = $maxfilesize + 1024;
-$ENV{TMPDIR} = $queuedir;
+$ENV{TMPDIR} = "$workdir/queue";
my $name = param ("reportfile");
my $error = cgi_error ();
@@ -47,7 +47,7 @@ sub move_file($)
{
my ($filename) = @_;
my $orig = tmpFileName($filename);
- my $tmpdir = tempdir ("repXXXXX", DIR => $queuedir);
+ my $tmpdir = tempdir ("repXXXXX", DIR => "$workdir/queue");
chmod 0777, $tmpdir;
chmod 0666&~umask, $orig;
my $size = -s $orig;
diff --git a/winetest/winetest.conf b/winetest/winetest.conf
index d229c0a1..ba155141 100644
--- a/winetest/winetest.conf
+++ b/winetest/winetest.conf
@@ -1,9 +1,6 @@
# Hey Emacs! This is a -*-cperl-*- file!
-$root = "/home/winehq/opt/winetest";
-# These two below should be on the same filesystem
-$queuedir = "$root/queue";
-$datadir = "$root/data";
+$workdir = "/home/winehq/opt/winetest";
$gitdir = "/home/winehq/opt/source/git/wine.git";
$gitweb = "//source.winehq.org/git/wine.git";
--
2.11.0
More information about the wine-patches
mailing list