From 3115f769b10605d60da69aa8fef77e3200d898d0 Mon Sep 17 00:00:00 2001 From: Anthony Cornehl Date: Thu, 31 Aug 2017 17:36:54 -0700 Subject: [PATCH] tests/language.test: Use different hashing commands when needed Outside of Linux platforms, sha1 hashing from the command-line is accomplished by commands other than sha1sum. OSX uses shasum and FreeBSD uses sha1, so I've added in detection for the appropriate command before falling back and failing the test. --- tests/languages.test | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/languages.test b/tests/languages.test index 5b8a4170..58188f8d 100755 --- a/tests/languages.test +++ b/tests/languages.test @@ -1,5 +1,24 @@ #!/bin/sh +# Test a command for presence and ability to output the sha1 hash of a file. +check_hashcmd() { + which $1 >&/dev/null && + $1 /dev/null | + awk '{if ($1 != "da39a3ee5e6b4b0d3255bfef95601890afd80709") { exit 1; }}' +} + +# Test some common commands to find the correct one for the system being tested on. +if check_hashcmd sha1sum; then + sha1sum=sha1sum +elif check_hashcmd sha1; then + sha1sum=sha1 +elif check_hashcmd shasum; then + sha1sum=shasum +else + echo "No hashing commands found." + false +fi + test_lang() { if test "$#" -eq 3; then TEST_LANG=$1 @@ -16,7 +35,7 @@ test_lang() { echo "testing ${TEST_NAME}" ESPEAK_DATA_PATH=`pwd` LD_LIBRARY_PATH=src:${LD_LIBRARY_PATH} \ src/espeak-ng --stdout -v ${TEST_LANG} "${TEST_TEXT}" | \ - sha1sum | awk '{ print $1 }' > actual.txt + $sha1sum | awk '{ print $1 }' > actual.txt echo "${EXPECTED}" > expected.txt diff expected.txt actual.txt || exit 1 }