4
# This script runs a commnand on a list of input arguments that are supplied on
6
# Graphical output is handled in a Xephyr window.
7
# Output of the command is given in a file results.txt
8
# If the argument list contains 'FILE' the argument will be put there instead of
12
# find -name '*.odt' | \
13
# massTester.pl --withgui --timeout 3 words --export-pdf --export-filename dummy.pdf
15
# find -name '*.odt' | \
16
# massTester.pl --withgui --timeout 3 koconverter --batch FILE out.odt
18
# Author: Jos van den Oever
20
my $timeout = 3; # seconds
23
my $outputfile = "results.txt";
25
# run the given command and return the exit status
26
# the first argument is the timeout in seconds
27
# the rest of the arguments form the command
32
my $result = "undefined";
34
local $SIG{ALRM} = sub { die "alarm\n" };
45
if ($@ eq "alarm\n") {
64
if ($foundFILE == 0) {
70
# read the value for the current argument in the input array
71
sub readArgumentValue {
74
die "Provide value for $name.\n" unless defined @$argv[1];
80
while ($ARGV[0] && $ARGV[0] =~ m/^--/) {
81
if ($ARGV[0] eq "--timeout") {
82
$timeout = readArgumentValue \@ARGV;
83
} elsif ($ARGV[0] eq "--withgui") {
86
die "Unknown argument $ARGV[0].\n";
90
die "No command supplied.\n" unless $#ARGV >= 0;
97
if (!($xephyrpid = fork)) {
98
exec "Xephyr", "-noreset", $DISPLAY;
102
$ENV{'DISPLAY'} = $DISPLAY;
103
$ENV{'KDE_DEBUG'} = "0";
110
my @cmd = makeCommand $file, @command;
111
$result{$file} = testCommand $timeout, @cmd;
114
open FH, "> $outputfile";
115
foreach (keys %result) {
116
print FH $_."\t".$result{$_}."\n";
123
waitpid $xephyrpid, 0;