2018-05-15 19:56:54 -04:00
|
|
|
#!/usr/bin/perl
|
2018-10-21 17:11:23 -04:00
|
|
|
#######################
|
|
|
|
#
|
|
|
|
# Test harness code for the dyesub backend (standalone sample jobs)
|
|
|
|
#
|
|
|
|
# Copyright (c) 2018 Solomon Peachy <pizza@shaftnet.org>
|
|
|
|
#
|
|
|
|
# The latest version of this program can be found at:
|
|
|
|
#
|
|
|
|
# http://git.shaftnet.org/cgit/selphy_print.git
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU General Public License as published by the Free
|
|
|
|
# Software Foundation; either version 3 of the License, or (at your option)
|
|
|
|
# any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
# for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
#
|
|
|
|
# [http://www.gnu.org/licenses/gpl-3.0.html]
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0+
|
|
|
|
#
|
|
|
|
#######################
|
2018-05-15 19:56:54 -04:00
|
|
|
use strict;
|
2018-10-21 17:11:23 -04:00
|
|
|
use IPC::Run qw( run );
|
2018-05-15 19:56:54 -04:00
|
|
|
|
2018-06-19 09:58:19 -04:00
|
|
|
my $copies = 3;
|
2018-05-19 17:45:19 -04:00
|
|
|
my $retval = 0;
|
2018-10-21 17:11:23 -04:00
|
|
|
my $valgrind = 1;
|
2018-05-15 19:56:54 -04:00
|
|
|
|
2018-10-21 17:11:23 -04:00
|
|
|
my $rotor = 0;
|
|
|
|
my $rotor_circ = 0;
|
|
|
|
my $row = 0;
|
|
|
|
|
|
|
|
my $quiet = 1;
|
|
|
|
my $proc_count = 0;
|
|
|
|
my @children = ();
|
|
|
|
my $kid;
|
|
|
|
my $error = 0;
|
|
|
|
|
|
|
|
$ENV{"TEST_MODE"} = "2";
|
|
|
|
|
|
|
|
if (!defined($ARGV[0])) {
|
|
|
|
die ("need a csv file\n");
|
|
|
|
};
|
|
|
|
|
|
|
|
if (defined($ENV{"STP_PARALLEL"})) {
|
|
|
|
$proc_count = $ENV{"STP_PARALLEL"};
|
|
|
|
};
|
|
|
|
if (defined($ENV{"STP_VERBOSE"})) {
|
|
|
|
$quiet = $ENV{"STP_VERBOSE"};
|
|
|
|
};
|
|
|
|
|
|
|
|
if ($proc_count > 1) {
|
|
|
|
$quiet = 1;
|
|
|
|
$rotor_circ = $proc_count;
|
|
|
|
for (my $child_no = 0; $child_no < $proc_count; $child_no++) {
|
|
|
|
$kid = fork();
|
|
|
|
if ($kid == 0) {
|
|
|
|
last;
|
|
|
|
} else {
|
|
|
|
push @children, $kid;
|
|
|
|
$rotor++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($proc_count > 1 && $kid > 0) {
|
|
|
|
# Parent in parallel case
|
|
|
|
while ($proc_count > 0 && $kid > 0) {
|
|
|
|
$kid = waitpid(-1, 0);
|
|
|
|
if ($kid > 0 && $? > 0) {
|
|
|
|
$error++;
|
|
|
|
}
|
2018-09-21 15:57:15 -04:00
|
|
|
}
|
2018-10-21 17:11:23 -04:00
|
|
|
$retval = $error;
|
|
|
|
|
|
|
|
} else { # worker child!
|
|
|
|
my $currow = 0;
|
|
|
|
my $rval = 0;
|
|
|
|
|
|
|
|
open (INFILE, "<$ARGV[0]") || die ("can't open csv\n");
|
|
|
|
|
|
|
|
while (<INFILE>) {
|
|
|
|
chomp;
|
|
|
|
next if /^#/;
|
|
|
|
|
|
|
|
if (defined($ARGV[1])) {
|
|
|
|
next if (index($_,$ARGV[1]) == -1);
|
|
|
|
};
|
2018-05-15 19:56:54 -04:00
|
|
|
|
2018-10-21 17:11:23 -04:00
|
|
|
# for great parallelism!
|
|
|
|
next if ($rotor_circ && ($currow++ % $rotor_circ) != $rotor);
|
2018-05-15 19:56:54 -04:00
|
|
|
|
2018-10-21 17:11:23 -04:00
|
|
|
s/(.+)#.*/$1/;
|
|
|
|
my @row = split(/,/);
|
2018-05-15 19:56:54 -04:00
|
|
|
|
2018-10-21 17:11:23 -04:00
|
|
|
$ENV{"BACKEND"} = $row[0];
|
|
|
|
$ENV{"EXTRA_VID"} = $row[1];
|
|
|
|
$ENV{"EXTRA_PID"} = $row[2];
|
2018-06-19 09:58:19 -04:00
|
|
|
|
2018-10-21 17:11:23 -04:00
|
|
|
if (length($row[4])) {
|
|
|
|
$ENV{"MEDIA_CODE"} = $row[4];
|
2018-06-19 09:58:19 -04:00
|
|
|
} else {
|
2018-10-21 17:11:23 -04:00
|
|
|
undef($ENV{"MEDIA_CODE"});
|
2018-06-19 09:58:19 -04:00
|
|
|
}
|
2018-10-21 17:11:23 -04:00
|
|
|
|
|
|
|
foreach (my $i = 1; $i <= $copies ; $i++) {
|
|
|
|
my @args = ("./dyesub_backend", "-d", $i, "testjobs/${row[3]}");
|
|
|
|
if ($valgrind) {
|
|
|
|
if ($quiet) {
|
|
|
|
unshift(@args,"-q");
|
|
|
|
}
|
|
|
|
unshift(@args,"valgrind");
|
|
|
|
}
|
|
|
|
if (!$quiet) {
|
|
|
|
print join(":", @args) . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($quiet) {
|
|
|
|
$rval = run \@args, ">", "/dev/null", "2>", "/dev/null";
|
|
|
|
} else {
|
|
|
|
$rval = run \@args;
|
|
|
|
}
|
|
|
|
if (!$rval) {
|
|
|
|
print("***** $row[0] $row[1] $row[2] $row[3] $row[4] ***** FAIL: backend $? $row[0] $row[1] $row[2] $row[3] $row[4]\n");
|
|
|
|
$error++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print "***** $row[0] $row[1] $row[2] $row[3] $row[4] ***** PASS\n";
|
2018-05-15 19:56:54 -04:00
|
|
|
}
|
2018-10-21 17:11:23 -04:00
|
|
|
$retval = $error;
|
|
|
|
close (INFILE);
|
|
|
|
exit ($retval);
|
2018-05-15 19:56:54 -04:00
|
|
|
}
|
2018-10-21 17:11:23 -04:00
|
|
|
|
2018-05-19 17:45:19 -04:00
|
|
|
exit($retval);
|