From 7680d1b7a40f7b5888520d8556bd5d2651b848ab Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=ED=95=9C=EC=A2=85/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Engineer/=EC=82=BC=EC=84=B1=EC=A0=84?= =?utf8?q?=EC=9E=90?= Date: Mon, 21 May 2018 14:45:18 +0900 Subject: [PATCH] Get md5sum of tflite files from the file server (#1289) Get original file's md5sum from HTTP header(Content-MD5 field) so we do not have to maintain md5sum in `config.sh`. Signed-off-by: Hanjoung Lee --- tests/framework/run_test.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/framework/run_test.sh b/tests/framework/run_test.sh index 4002d16..287d579 100755 --- a/tests/framework/run_test.sh +++ b/tests/framework/run_test.sh @@ -36,6 +36,21 @@ function Usage() echo "" } +function verify_downloaded_file() +{ + LOCAL_PATH=$1 + REMOTE_URL=$2 + + LOCAL_HASH=$(md5sum $LOCAL_PATH | awk '{ print $1 }') + REMOTE_HASH=$(curl -I -ss $REMOTE_URL | grep '^Content-MD5' | tr -d '\r\n' | awk '{ print $2 }' | base64 -d | xxd -p) + # TODO Emit an error when Content-MD5 field was not found. (Server configuration issue) + + if [ "$LOCAL_HASH" != "$REMOTE_HASH" ]; then + echo "Downloaded file is outdated or incomplete." + return 1 + fi +} + DRIVER_BIN="" NNFW_LD_LIBRARY_PATH="" TAP_NAME="framework_test.tap" @@ -121,7 +136,7 @@ run_tests() fi # Download unless we have it in cache (Also check md5sum) - if [ ! -e $MODELFILE ] || [ $(md5sum $MODELFILE | awk '{ print $1 }') != "$MODELFILE_MD5SUM" ]; then + if [ ! -e $MODELFILE ] || ! verify_downloaded_file "$MODELFILE" "$MODELFILE_SERVER/$MODELFILE_NAME"; then echo "" echo "Download test file for $TEST_NAME" echo "======================" @@ -172,7 +187,7 @@ download_tests() fi # Download unless we have it in cache (Also check md5sum) - if [ ! -e $MODELFILE ] || [ $(md5sum $MODELFILE | awk '{ print $1 }') != "$MODELFILE_MD5SUM" ]; then + if [ ! -e $MODELFILE ] || ! verify_downloaded_file "$MODELFILE" "$MODELFILE_SERVER/$MODELFILE_NAME"; then echo "" echo "Download test file for $TEST_NAME" echo "======================" -- 2.7.4