From 7e669f18120751e8f711731081ce51ae095986d8 Mon Sep 17 00:00:00 2001 From: Sascha Brawer Date: Fri, 2 Mar 2018 11:29:40 +0100 Subject: [PATCH] Add tests on SSML parsing A corpus of SSML input files will also be needed for fuzzing. https://github.com/espeak-ng/espeak-ng/issues/407 --- .gitignore | 1 + Makefile.am | 1 + tests/ssml.test | 13 +++++++++++++ tests/ssml/billion-laughs.expected | 3 +++ tests/ssml/billion-laughs.ssml | 20 ++++++++++++++++++++ tests/ssml/external-entity.expected | 9 +++++++++ tests/ssml/external-entity.ssml | 12 ++++++++++++ tests/ssml/language-switch.expected | 10 ++++++++++ tests/ssml/language-switch.ssml | 7 +++++++ tests/ssml/spec-example-1.expected | 12 ++++++++++++ tests/ssml/spec-example-1.ssml | 18 ++++++++++++++++++ 11 files changed, 106 insertions(+) create mode 100755 tests/ssml.test create mode 100644 tests/ssml/billion-laughs.expected create mode 100644 tests/ssml/billion-laughs.ssml create mode 100644 tests/ssml/external-entity.expected create mode 100644 tests/ssml/external-entity.ssml create mode 100644 tests/ssml/language-switch.expected create mode 100644 tests/ssml/language-switch.ssml create mode 100644 tests/ssml/spec-example-1.expected create mode 100644 tests/ssml/spec-example-1.ssml diff --git a/.gitignore b/.gitignore index 145e4cf1..617d6282 100644 --- a/.gitignore +++ b/.gitignore @@ -100,6 +100,7 @@ tests/*.test !tests/languages.test !tests/phoneme-output.test !tests/phoneme-audio.test +!tests/ssml.test espeak-ng.pc diff --git a/Makefile.am b/Makefile.am index c2d5851b..28c39f87 100644 --- a/Makefile.am +++ b/Makefile.am @@ -252,6 +252,7 @@ check: tests/encoding.check \ tests/api.check \ tests/phoneme-output.check \ tests/phoneme-audio.check \ + tests/ssml.check \ tests/languages.check ##### phoneme data: diff --git a/tests/ssml.test b/tests/ssml.test new file mode 100755 index 00000000..37504383 --- /dev/null +++ b/tests/ssml.test @@ -0,0 +1,13 @@ +#!/bin/sh + +test_ssml() { + INPUT=$1 + echo "testing ${INPUT}" + cp $(dirname $INPUT)/$(basename ${INPUT%.*}).expected expected.txt + ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \ + src/espeak-ng -m -v en-US --ipa=2 -f ${INPUT} > actual.txt + diff expected.txt actual.txt || exit 1 +} + +for i in `ls tests/ssml/*.ssml` ; do test_ssml $i ; done + diff --git a/tests/ssml/billion-laughs.expected b/tests/ssml/billion-laughs.expected new file mode 100644 index 00000000..18c59b5b --- /dev/null +++ b/tests/ssml/billion-laughs.expected @@ -0,0 +1,3 @@ + lˈɑːl ænd lˈɑːl nˈa͡ɪn + lˈɑːl + diff --git a/tests/ssml/billion-laughs.ssml b/tests/ssml/billion-laughs.ssml new file mode 100644 index 00000000..a0b374ea --- /dev/null +++ b/tests/ssml/billion-laughs.ssml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + +]> + + lol &lol9; lol + diff --git a/tests/ssml/external-entity.expected b/tests/ssml/external-entity.expected new file mode 100644 index 00000000..8d8cef37 --- /dev/null +++ b/tests/ssml/external-entity.expected @@ -0,0 +1,9 @@ + + + hˈɪɹ ɑː͡ɹ ðə pˈæswɜːdz + + + ænd ˈɛkszˈiːɾæk + + + diff --git a/tests/ssml/external-entity.ssml b/tests/ssml/external-entity.ssml new file mode 100644 index 00000000..8ceb6058 --- /dev/null +++ b/tests/ssml/external-entity.ssml @@ -0,0 +1,12 @@ + + + +]> + +

Here are the passwords:

+

&xxeattack;

+
diff --git a/tests/ssml/language-switch.expected b/tests/ssml/language-switch.expected new file mode 100644 index 00000000..5b65ee9b --- /dev/null +++ b/tests/ssml/language-switch.expected @@ -0,0 +1,10 @@ + + bˈuːhuː + + bˈoːhuː + + booˈɔo + + bˌooˈoo + + diff --git a/tests/ssml/language-switch.ssml b/tests/ssml/language-switch.ssml new file mode 100644 index 00000000..8772babb --- /dev/null +++ b/tests/ssml/language-switch.ssml @@ -0,0 +1,7 @@ + + +

Boohoo

+

Boohoo

+

Boohoo

+

Boohoo

+
diff --git a/tests/ssml/spec-example-1.expected b/tests/ssml/spec-example-1.expected new file mode 100644 index 00000000..6760149b --- /dev/null +++ b/tests/ssml/spec-example-1.expected @@ -0,0 +1,12 @@ + + + + juː hæv fˈoː͡ɹ nˈuː mˈɛsɪd͡ʒᵻz + + ðə fˈɜːst ɪz fɹʌm stˈɛfəni wˈɪljəmz ænd ɚɹˈa͡ɪvd æt + θɹˈiː fˈoː͡ɹɾi fˈa͡ɪv pˌiːˈɛm + + ðə sˈʌbd͡ʒɛkt ɪz skˈiː tɹˈɪp + + + diff --git a/tests/ssml/spec-example-1.ssml b/tests/ssml/spec-example-1.ssml new file mode 100644 index 00000000..e46706d5 --- /dev/null +++ b/tests/ssml/spec-example-1.ssml @@ -0,0 +1,18 @@ + + + +

+ You have 4 new messages. + The first is from Stephanie Williams and arrived at 3:45pm. + + The subject is ski trip + +

+