Debian Codegraph @

tests/algebra/check-algebra

raw
1 #!/usr/bin/perl -w
2 #
3 # check-algebra - Run Rasqal against W3C DAWG SPARQL testsuite
4 #
5 # USAGE: check-algebra [options] [TEST]
6 #
7 # Copyright (C) 2009, David Beckett http://www.dajobe.org/
8 #
9 # This package is Free Software and part of Redland http://librdf.org/
10 #
11 # It is licensed under the following three licenses as alternatives:
12 # 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version
13 # 2. GNU General Public License (GPL) V2 or any newer version
14 # 3. Apache License, V2.0 or any newer version
15 #
16 # You may not use this file except in compliance with at least one of
17 # the above three licenses.
18 #
19 # See LICENSE.html or LICENSE.txt at the top of this package for the
20 # complete terms and further detail along with the license texts for
21 # the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively.
22 #
23 # Requires:
24 # convert_graph_pattern utility in the PATH
25 #
26
27 use strict;
28 use File::Basename;
29 use Getopt::Long;
30 use Pod::Usage;
31
32 my $diff_cmd = $ENV{DIFF} || "diff";
33
34 my $convert_graph_pattern="convert_graph_pattern";
35 my $out="convert.out";
36 my $err="convert.err";
37 my $diff="diff.out";
38
39 my $program=basename $0;
40 my $debug=0;
41
42 $debug=1 if defined $ENV{'RASQAL_DEBUG'};
43
44
45 # Argument handling
46 my $usage=0;
47
48 GetOptions(
49 'debug|d+' => \$debug, # incremental
50 'help|h|?' => \$usage
51 ) || pod2usage(2);
52
53 pod2usage(-verbose => 2) if $usage;
54 pod2usage(2) if @ARGV != 2;
55
56
57 my($tst,$baseuri)=@ARGV;
58
59 my $base=basename($tst, ".rq");
60 my $srcdir=dirname($tst);
61 my $expected="$srcdir/$base.out";
62
63 warn "$program: Running test $tst with base URI $baseuri\n"
64 if $debug;
65
66
67 my $cmd="convert_graph_pattern $tst $baseuri > $out 2> $err";
68 warn "$program: Running '$cmd'\n"
69 if $debug;
70 system $cmd;
71 my $rc=$?;
72 warn "$program: Result was $rc\n"
73 if $debug;
74 if($rc) {
75 warn "$program: Graph pattern conversion '$tst' FAILED to execute\n";
76 warn "Failing program was:\n";
77 warn " $cmd\n";
78 system("cat $err");
79 exit 1;
80 }
81
82
83 my $cmp_cmd="$diff_cmd -u $expected $out > $diff 2>&1";
84 warn "$program: Running '$cmp_cmd'\n"
85 if $debug;
86 system $cmp_cmd;
87 $rc=$?;
88 warn "$program: Result was $rc\n"
89 if $debug;
90 if($rc) {
91 warn "$program: Graph pattern conversion '$tst' FAILED to give correct answer\n";
92 warn "Failing program was:\n";
93 warn " $cmd\n";
94 system("cat $err");
95 warn "Difference is:\n";
96 system("cat $diff");
97 exit 1;
98 }
99
100 unlink $out, $err, $diff;
101
102 exit 0;
103
104 __END__
105
106 =head1 NAME
107
108 check-algebra - run SPARQL algebra graph pattern test
109
110 =head1 SYNOPSIS
111
112 check-algebra [options] TEST BASE-URI
113
114 =head1 OPTIONS
115
116 =over 8
117
118 =item B<--debug>
119
120 Enable extra debugging output.
121
122 =item B<--help>
123
124 Give command help summary.
125
126 =back
127
128 =head1 DESCRIPTION
129
130 Run SPARQL algebra conversion test
131
132 =cut