Debian Codegraph @

tests/common

raw symbols SCIP
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 # Test a command for presence and ability to output the sha1 hash of a file
3 is_hashscip-shell shell espeak-ng 1.52.0+dfsg-5 is_hash().() {
4 echoscip-shell system . . echo. -n "checking for SHA1 hashing command ... "
5 if check_hashscip-shell shell espeak-ng 1.52.0+dfsg-5 check_hash(). sha1sum; then
6 sha1sum=sha1sum
7 elif check_hashscip-shell shell espeak-ng 1.52.0+dfsg-5 check_hash(). sha1; then
8 sha1sum=sha1
9 elif check_hashscip-shell shell espeak-ng 1.52.0+dfsg-5 check_hash(). shasum; then
10 sha1sum=shasum
11 else
12 echoscip-shell system . . echo. "no"
13 exit 1
14 fi
15 }
16 check_hashscip-shell shell espeak-ng 1.52.0+dfsg-5 check_hash().() {
17 whichscip-shell system . . which. $1 &&
18 $1 </dev/nullscip-shell filesystem . . `/dev/null`. 2>/dev/nullscip-shell filesystem . . `/dev/null`. |
19 awkscip-shell system . . awk. '{if ($1 != "da39a3ee5e6b4b0d3255bfef95601890afd80709") { exit 1; }}'
20 # Test some common commands to find the correct one for the system being tested on.
21 }
22
23 # test if MBROLA synthesizer is installed
24 is_mbrolascip-shell shell espeak-ng 1.52.0+dfsg-5 is_mbrola().() {
25 echoscip-shell system . . echo. -n "checking if MBROLA is installed ... "
26 if [scip-shell system . . `[`. "`whichscip-shell system . . which. mbrola`" != "" ]; then
27 echoscip-shell system . . echo. "yes"
28 else
29 echoscip-shell system . . echo. "no"
30 exit
31 fi
32 }
33
34 # Check processed text by phonetic representation of the output
35 test_phonscip-shell shell espeak-ng 1.52.0+dfsg-5 test_phon().() {
36 TEST_LANG=$1
37 EXPECTED=$2
38 TEST_TEXT=$3
39 MESSAGE=$4
40 OPTIONS=$5
41
42 if [scip-shell system . . `[`. "$MESSAGE" = "" ] ; then
43 MESSAGE=$TEST_TEXT
44 fi
45
46 echoscip-shell system . . echo. "testing ${TEST_LANG} $MESSAGE"
47 RESULT=$(
48 ESPEAK_DATA_PATH=`pwdscip-shell system . . pwd.` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
49 $VALGRIND src/espeak-ng -xq ${OPTIONS} -v ${TEST_LANG} "${TEST_TEXT}" || exit 1
50 )
51 if [scip-shell system . . `[`. "x$RESULT" != "x$EXPECTED" ] ; then
52 echoscip-shell system . . echo. "$RESULT != $EXPECTED"
53 if [scip-shell system . . `[`. "$MESSAGE" = "Ignore" ] ; then
54 echoscip-shell system . . echo. "... ignoring error"
55 else
56 exit 1
57 fi
58 fi
59 }
60
61 # Check generated wav file from processed text
62 test_wavscip-shell shell espeak-ng 1.52.0+dfsg-5 test_wav(). () {
63 VOICE=$1
64 EXPECTED=$2
65 TEST_TEXT=$3
66 MESSAGE=$4
67
68 echoscip-shell system . . echo. "testing ${VOICE} ${MESSAGE}"
69 RESULT=$(
70 ESPEAK_DATA_PATH=`pwdscip-shell system . . pwd.` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
71 $VALGRIND src/espeak-ng -D --stdout -v ${VOICE} "${TEST_TEXT}" | $sha1sum | awk '{ print $1 }' || exit 1
72 )
73 if [scip-shell system . . `[`. "x$RESULT" != "x$EXPECTED" ] ; then
74 echoscip-shell system . . echo. "$RESULT != $EXPECTED"
75 if [scip-shell system . . `[`. "$MESSAGE" = "Ignore" ] ; then
76 echoscip-shell system . . echo. "... ignoring error"
77 else
78 exit 1
79 fi
80 fi
81 }
82
83 # Check generated wav file from processed text, where $EXPECTED is grep string
84 test_wav_grepscip-shell shell espeak-ng 1.52.0+dfsg-5 test_wav_grep(). () {
85 VOICE=$1
86 EXPECTED=$2
87 TEST_TEXT=$3
88 MESSAGE=$4
89 echoscip-shell system . . echo. "testing ${VOICE} ${MESSAGE}"
90 $()
91 ESPEAK_DATA_PATH=`pwdscip-shell system . . pwd.` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
92 $VALGRIND src/espeak-ng -D --stdout -v ${VOICE} "${TEST_TEXT}" \
93 > actual.txt || exit 1
94 < actual.txt $sha1sum | awkscip-shell system . . awk. '{ print $1 }' > sum.txt
95 if [scip-shell system . . `[`. "$MESSAGE" = "Ignore" ] ; then
96 catscip-shell system . . cat. sum.txt | grepscip-shell system . . grep. -E "$EXPECTED" || (echoscip-shell system . . echo. "... ignoring error" && truescip-shell system . . true.)
97 else
98 catscip-shell system . . cat. sum.txt | grepscip-shell system . . grep. -E "$EXPECTED" || { printfscip-shell system . . printf. "wrong hash: "; catscip-shell system . . cat. sum.txt; exit 1; }
99 fi
100 }
101
102 # Check generated wav file from list of phonemes
103 test_phwavscip-shell shell espeak-ng 1.52.0+dfsg-5 test_phwav().() {
104 TEST_LANG=$1
105 EXPECTED=$2
106 TEST_TEXT=$3
107 test_wavscip-shell shell espeak-ng 1.52.0+dfsg-5 test_wav(). $TEST_LANG $EXPECTED "[[$TEST_TEXT]]"
108 }
109
110 test_replacescip-shell shell espeak-ng 1.52.0+dfsg-5 test_replace().() {
111 TEST_LANG=$1
112 TEST_TEXT=$2
113 EXPECTED=$3
114 MESSAGE=$4
115
116 if [scip-shell system . . `[`. "$MESSAGE" = "" ] ; then
117 MESSAGE=$TEST_TEXT
118 fi
119
120 echoscip-shell system . . echo. "testing ${TEST_LANG}"
121 RESULT=$(
122 ESPEAK_DATA_PATH=`pwdscip-shell system . . pwd.` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \
123 $VALGRIND src/espeak-ng -Xq -v ${TEST_LANG} "${TEST_TEXT}" | \
124 grep -a -E "(Translate|Found:) " | sed -e 's/ \[.*][ ]*$//g' || exit 1
125 )
126 if [scip-shell system . . `[`. "x$RESULT" != "x$EXPECTED" ] ; then
127 echoscip-shell system . . echo. "$RESULT != $EXPECTED"
128 if [scip-shell system . . `[`. "$MESSAGE" = "Ignore" ] ; then
129 echoscip-shell system . . echo. "... ignoring error"
130 else
131 exit 1
132 fi
133 fi
134 }