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