Debian Codegraph @

tests/check_all_tables.pl

raw
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 $|++;
5
6 # Test all tables with lou_checktable.
7 #
8 # Copyright (C) 2010 by Swiss Library for the Blind, Visually Impaired and Print Disabled
9 # Copyright (C) 2012-2013 Mesar Hameed <[email protected]>
10 #
11 # Copying and distribution of this file, with or without modification,
12 # are permitted in any medium without royalty provided the copyright
13 # notice and this notice are preserved. This file is offered as-is,
14 # without any warranty.
15
16 my $fail = 0;
17 # some tables are quite big and take some time to check, so keep the timeout reasonably long
18 my $timeout = 120; # seconds
19
20 # In the test suite the LOUIS_TABLEPATH is set up so that it actually
21 # points at the top src dir of liblouis. So to find the productive
22 # tables, i.e. the ones that are shipped with liblouis (and need to be
23 # tested) we have to check the tables subdir.
24 my $tablesdir = "$ENV{LOUIS_TABLEPATH}/tables";
25
26 # get all the tables from the tables directory
27 my @tables = glob("$tablesdir/*.{utb,ctb,tbl}");
28
29
30 foreach my $table (@tables) {
31 if (my $pid = fork) {
32 waitpid($pid, 0);
33 if ($?) {
34 print STDERR "lou_checktable on $table failed or timed out\n";
35 $fail = 1;
36 }
37 } else {
38 die "cannot fork: $!" unless defined($pid);
39 alarm $timeout;
40
41 # ignore tables with unicode-range: ucs4
42 if (system("grep -Eq '#\\+unicode-range:[[:space:]]*ucs4' $table") == 0) {
43 print "table $table only works with ucs4. Ignoring for now...\n";
44 exit 0;
45 } else {
46 exec ("../tools/lou_checktable $table --quiet");
47 }
48 die "Exec of lou_checktable failed: $!";
49 }
50 }
51
52 exit $fail;