Convert tests to programs
[idzebra-moved-to-github.git] / test / xpath / test5.sh
1 #!/bin/sh
2 # $Id: test5.sh,v 1.3 2004-06-15 09:43:34 adam Exp $
3
4 pp=${srcdir:-"."}
5
6 LOG="test5.log"
7 TMP="test5.tmp"
8 DBG="-v 1647"
9 rm -f $LOG
10 rm -f $TMP.*
11 ../../index/zebraidx -c $pp/zebra.cfg -l $LOG init || exit 1
12 ../../index/zebraidx -c $pp/zebra.cfg -l $LOG -t grs.sgml update $pp/rec5.xml || exit 2
13 test -f dict*.mf || exit 1
14 ../../index/zebrasrv -c $pp/zebra.cfg -l $LOG $DBG -S unix:socket & 
15 sleep 1
16 test -f zebrasrv.pid || exit 2
17 ../api/testclient unix:socket '@attr 1=/record/title foo' >$TMP.1
18 ../api/testclient unix:socket '@attr 1=/record/title bar' >$TMP.2
19 ../api/testclient unix:socket "@attr {1=/record/title[@lang='da']} foo" >$TMP.3
20 ../api/testclient unix:socket "@attr {1=/record/title[@lang='en']} foo" >$TMP.4
21 ../api/testclient unix:socket "@attr 1=/record/title @and foo bar" >$TMP.5
22 # The last one returns two hits, as the and applies to the whole
23 # record, so it matches <title>foo</title><title>bar</title>
24 # This might not have to be like that, but currently that is what
25 # zebra does.
26 ../api/testclient unix:socket "@attr 1=/record/value bar" >$TMP.6
27 ../api/testclient unix:socket "@and @attr 1=/record/title foo @attr 1=/record/title grunt" >$TMP.7
28
29 echo 'Killing server' >>$LOG
30 kill `cat zebrasrv.pid` || exit 3
31 sleep 1
32 echo "Result counts: " >> $LOG
33 cat $TMP.* >>$LOG
34 echo 'Checking that result count is 4' >>$LOG
35 grep "^Result count: 4$" $TMP.1 >/dev/null || exit 4
36 echo 'Checking that result count is 2' >>$LOG
37 grep "^Result count: 2$" $TMP.2 >/dev/null || exit 5
38 echo 'Checking that result count is 1' >>$LOG
39 grep "^Result count: 1$" $TMP.3 >/dev/null || exit 6
40 echo 'Checking that result count is 1' >>$LOG
41 grep "^Result count: 1$" $TMP.4 >/dev/null || exit 7
42 echo 'Checking that result count is 2' >>$LOG
43 grep "^Result count: 2$" $TMP.5 >/dev/null || exit 8
44 echo 'Checking that result count is 1' >>$LOG
45 grep "^Result count: 1$" $TMP.6 >/dev/null || exit 8
46 echo 'Checking that result count is 1' >>$LOG
47 grep "^Result count: 1$" $TMP.7 >/dev/null || exit 8
48 echo 'Test OK' >>$LOG
49 exit 0
50