Debian Codegraph @

debian/tests/dictd

raw
1 #!/bin/sh
2 #
3 # Install dict, dictd, and dict-de-en and check that german-english
4 # and english-german dictionaries are available.
5 #
6 # (c) 2018-2020 Roland Rosenfeld <[email protected]>
7
8 VERSION=$(sed 's/^.*:: //;1q' de-en.txt)
9
10 if [ -z "$AUTOPKGTEST_TMP" ]; then
11 AUTOPKGTEST_TMP=$(mktemp -d)
12 fi
13
14 trap 'rm -rf $AUTOPKGTEST_TMP' EXIT
15
16 PORT=2629
17 DICTDCONF=$AUTOPKGTEST_TMP/dictd.conf
18 DICTCONF=$AUTOPKGTEST_TMP/dict.conf
19 DICTDPID=$AUTOPKGTEST_TMP/dictd.pid
20
21 cat <<EOF > "$DICTDCONF"
22 global {
23 listen_to 127.0.0.1
24 port $PORT
25 pid_file $DICTDPID
26 }
27 access {
28 allow localhost
29 allow 127.0.0.1
30 }
31 include /var/lib/dictd/db.list
32 EOF
33
34 cat <<EOF > "$DICTCONF"
35 server localhost { port $PORT }
36 EOF
37
38 /usr/sbin/dictd -c "$DICTDCONF"
39 trap 'kill $(cat "$DICTDPID"); rm -rf $AUTOPKGTEST_TMP' EXIT
40
41 sleep 1 # wait until dictd is started up
42
43
44 EXIT=0
45
46 ######################################################################
47
48 DICTD=0
49
50 OUTPUT=$AUTOPKGTEST_TMP/dict-D.out
51 dict -c "$DICTCONF" -D > "$OUTPUT"
52
53 if ! grep -q "german-english German - English Dictionary $VERSION" "$OUTPUT"
54 then
55 echo "missing: german-english German - English Dictionary $VERSION"
56 EXIT=1
57 DICTD=1
58 fi
59
60 if ! grep -q "english-german English - German Dictionary $VERSION" "$OUTPUT"
61 then
62 echo "missing: english-german English - German Dictionary $VERSION"
63 EXIT=1
64 DICTD=1
65 fi
66
67 if [ "$DICTD" = 0 ]
68 then
69 echo "PASS: english-german and german-english dictd dictionaries found"
70 else
71 echo "found:"
72 cat "$OUTPUT"
73 fi
74
75 ######################################################################
76
77 DE_EN=0
78
79 OUTPUT=$AUTOPKGTEST_TMP/dict-de-en.out
80 dict -c "$DICTCONF" -d german-english Straße -C > "$OUTPUT"
81
82 if ! grep -q "street" "$OUTPUT"
83 then
84 echo "lookup Straße => missing: street"
85 DE_EN=1
86 EXIT=1
87 fi
88
89 if ! grep -q "road" "$OUTPUT"
90 then
91 echo "lookup Straße => missing: road"
92 DE_EN=1
93 EXIT=1
94 fi
95
96 if [ "$DE_EN" = 0 ]
97 then
98 echo "PASS: translation from Straße to street/road found"
99 else
100 echo "found:"
101 cat "$OUTPUT"
102 fi
103
104 ######################################################################
105
106 EN_DE=0
107
108 OUTPUT=$AUTOPKGTEST_TMP/dict-de-en.out
109 dict -c "$DICTCONF" -d english-german bowl -C > "$OUTPUT"
110
111 if ! grep -q "Schüssel" "$OUTPUT"
112 then
113 echo "lookup bowl => missing: Schüssel"
114 EN_DE=1
115 EXIT=1
116 fi
117
118 if ! grep -q "kegeln" "$OUTPUT"
119 then
120 echo "lookup bowl => missing: kegeln"
121 EN_DE=1
122 EXIT=1
123 fi
124
125 if [ "$EN_DE" = 0 ]
126 then
127 echo "PASS: translation from bowl to Schüssel/kegeln found"
128 else
129 echo "found:"
130 cat "$OUTPUT"
131 fi
132
133 ######################################################################
134
135 exit $EXIT