blob: 17ef582a30731afec8bcf8350063eb8f1af34a2c [file] [log] [blame]
#!/usr/bin/perl
use warnings;
use strict;
$|++;
# Test all tables with lou_checktable.
#
# Copyright (C) 2010 by Swiss Library for the Blind, Visually Impaired and Print Disabled
# Copyright (C) 2012 Mesar Hameed <mhameed @ src.gnome.org>
#
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.
my $fail = 0;
# some tables are quite big and take some time to check, so keep the timeout reasonably long
my $timeout = 120; # seconds
# We assume that the productive tables, i.e. the ones that are shipped
# with liblouis (and need to be tested) are found in the first path in
# LOUIS_TABLEPATH. The subsequent entries are for test tables.
my $tablesdir = (split(',', $ENV{LOUIS_TABLEPATH}))[0];
# get all the tables from the tables directory
my @tables = glob("$tablesdir/*");
# exclude hyphenation dicts
@tables = grep(!/.+\.dic$/, @tables);
# exclude Makefiles, README and shell scripts
@tables = grep(!/Makefile|README|maketablelist\.sh/, @tables);
# exclude backup, diff, patch, txt and zip files
@tables = grep(!/.+~$|.+\.diff$|.+\.patch$|.+\.txt$|.+\.zip$/, @tables);
# exclude tables that only work when included inside others
@tables = grep(!/countries\.cti|compress\.ctb|corrections\.ctb|hu-exceptionwords\.cti|core\.[cu]tb|-translation\.ctb/, @tables);
# exclude other oddballs
@tables = grep(!/lang2table$/, @tables);
# exclude known bad tables
@tables = grep(!/eo-g1\.ctb/, @tables);
foreach my $table (@tables) {
if (my $pid = fork) {
waitpid($pid, 0);
if ($?) {
print STDERR "lou_checktable on $table failed or timed out\n";
$fail = 1;
}
} else {
die "cannot fork: $!" unless defined($pid);
alarm $timeout;
exec ("../tools/lou_checktable $table --quiet");
die "Exec of lou_checktable failed: $!";
}
}
exit $fail;