Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / liblouis / src / tests / check_all_tables.pl
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 <mhameed @ src.gnome.org>
10
11 #
12 # Copying and distribution of this file, with or without modification,
13 # are permitted in any medium without royalty provided the copyright
14 # notice and this notice are preserved.
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 # We assume that the productive tables, i.e. the ones that are shipped
21 # with liblouis (and need to be tested) are found in the first path in
22 # LOUIS_TABLEPATH. The subsequent entries are for test tables.
23 my $tablesdir = (split(',', $ENV{LOUIS_TABLEPATH}))[0];
24
25 # get all the tables from the tables directory
26 my @tables = glob("$tablesdir/*.{utb,ctb}");
27
28
29 foreach my $table (@tables) {
30     if (my $pid = fork) {
31         waitpid($pid, 0);
32         if ($?) {
33             print STDERR "lou_checktable on $table failed or timed out\n";
34             $fail = 1;
35         }
36     } else {
37         die "cannot fork: $!" unless defined($pid);
38         alarm $timeout;
39         exec ("../tools/lou_checktable $table --quiet");
40         die "Exec of lou_checktable failed: $!";
41     }
42 }
43
44 exit $fail;