[UNITTEST] Skip the test when there is not tensorflow and lite
authorjijoong.moon <jijoong.moon@samsung.com>
Wed, 17 Apr 2019 01:38:18 +0000 (10:38 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Wed, 8 May 2019 08:31:59 +0000 (17:31 +0900)
We need to skip tests using tensorflow and lite if they are not
installed. So pkg-config is used to identify their installation.

**Self evaluation:**
1. Build test:  [X]Passed [ ]Failed [ ]Skipped
2. Run test:  [X]Passed [ ]Failed [ ]Skipped

Signed-off-by: jijoong.moon <jijoong.moon@samsung.com>
tests/nnstreamer_decoder_image_labeling/runTest.sh
tests/nnstreamer_filter_tensorflow/runTest.sh
tests/nnstreamer_filter_tensorflow_lite/runTest.sh

index 7facec2..038cbd4 100644 (file)
@@ -24,6 +24,50 @@ PATH_TO_MODEL="../test_models/models/mobilenet_v1_1.0_224_quant.tflite"
 PATH_TO_LABEL="../test_models/labels/labels.txt"
 PATH_TO_IMAGE="img/orange.png"
 
+if [[ -d $PATH_TO_PLUGIN ]]; then
+    ini_path="${PATH_TO_PLUGIN}/ext/nnstreamer/tensor_filter"
+    if [[ -d ${ini_path} ]]; then
+       check=$(ls ${ini_path} | grep tensorflow-lite.so)
+       if [[ ! $check ]]; then
+           echo "Cannot find tensorflow-lite shared lib"
+           report
+           exit
+       fi
+    else
+       echo "Cannot find ${ini_path}"
+    fi
+else
+    ini_file="/etc/nnstreamer.ini"
+    if [[ -f ${ini_file} ]]; then
+       path=$(grep "^filters" ${ini_path})
+       key=${path%=*}
+       value=${path##*=}
+
+       if [[ $key != "filters" ]]
+       then
+           echo "String Error"
+           report
+           exit
+       fi
+
+       if [[ -d ${value} ]]; then
+           check=$(ls ${value} | grep tensorflow-lite.so)
+           if [[ ! $check ]]; then
+               echo "Cannot find tensorflow-lite shared lib"
+               report
+               exit
+           fi
+       else
+           echo "Cannot file ${value}"
+           report
+           exit
+       fi
+    fi
+    echo "Cannot identify nnstreamer.ini"
+    report
+    exit
+fi
+
 # Decoding 'orange' tests
 # Since data type of output tensor is uint8, int8 requires another 'quantization' (such as /2)
 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=\"${PATH_TO_IMAGE}\" ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw, format=RGB, framerate=0/1 ! tensor_converter ! tensor_filter framework=\"tensorflow-lite\" model=\"${PATH_TO_MODEL}\" ! \
index f12aaa8..b7ceb54 100755 (executable)
@@ -17,15 +17,56 @@ fi
 
 # This is compatible with SSAT (https://github.com/myungjoo/SSAT)
 testInit $1
-if [[ -z "${TEST_TENSORFLOW}" ]]; then
-    report
-fi
 
 # Test with mnist model
 PATH_TO_PLUGIN="../../build"
 PATH_TO_MODEL="../test_models/models/mnist.pb"
 PATH_TO_DATA="data/9.raw"
 
+if [[ -d $PATH_TO_PLUGIN ]]; then
+    ini_path="${PATH_TO_PLUGIN}/ext/nnstreamer/tensor_filter"
+    if [[ -d ${ini_path} ]]; then
+       check=$(ls ${ini_path} | grep tensorflow.so)
+       if [[ ! $check ]]; then
+           echo "Cannot find tensorflow shared lib"
+           report
+           exit
+       fi
+    else
+       echo "Cannot find ${ini_path}"
+    fi
+else
+    ini_file="/etc/nnstreamer.ini"
+    if [[ -f ${ini_file} ]]; then
+       path=$(grep "^filters" ${ini_path})
+       key=${path%=*}
+       value=${path##*=}
+
+       if [[ $key != "filters" ]]
+       then
+           echo "String Error"
+           report
+           exit
+       fi
+
+       if [[ -d ${value} ]]; then
+           check=$(ls ${value} | grep tensorflow.so)
+           if [[ ! $check ]]; then
+               echo "Cannot find tensorflow shared lib"
+               report
+               exit
+           fi
+       else
+           echo "Cannot file ${value}"
+           report
+           exit
+       fi
+    fi
+    echo "Cannot identify nnstreamer.ini"
+    report
+    exit
+fi
+
 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_DATA} ! application/octet-stream ! tensor_converter input-dim=784:1 input-type=uint8 ! tensor_transform mode=arithmetic option=typecast:float32,add:-127.5,div:127.5 ! tensor_filter framework=tensorflow model=${PATH_TO_MODEL} input=784:1:1:1 inputtype=float32 inputname=input output=10:1:1:1 outputtype=float32 outputname=softmax ! filesink location=tensorfilter.out.1.log " 1 0 0 $PERFORMANCE
 python checkLabel.py tensorfilter.out.1.log ${PATH_TO_DATA}
 testResult $? 1 "Golden test comparison" 0 1
index 3ae4296..e3ec601 100644 (file)
@@ -24,6 +24,50 @@ PATH_TO_MODEL="../test_models/models/mobilenet_v1_1.0_224_quant.tflite"
 PATH_TO_LABEL="../test_models/labels/labels.txt"
 PATH_TO_IMAGE="img/orange.png"
 
+if [[ -d $PATH_TO_PLUGIN ]]; then
+    ini_path="${PATH_TO_PLUGIN}/ext/nnstreamer/tensor_filter"
+    if [[ -d ${ini_path} ]]; then
+       check=$(ls ${ini_path} | grep tensorflow-lite.so)
+       if [[ ! $check ]]; then
+           echo "Cannot find tensorflow-lite shared lib"
+           report
+           exit
+       fi
+    else
+       echo "Cannot find ${ini_path}"
+    fi
+else
+    ini_file="/etc/nnstreamer.ini"
+    if [[ -f ${ini_file} ]]; then
+       path=$(grep "^filters" ${ini_path})
+       key=${path%=*}
+       value=${path##*=}
+
+       if [[ $key != "filters" ]]
+       then
+           echo "String Error"
+           report
+           exit
+       fi
+
+       if [[ -d ${value} ]]; then
+           check=$(ls ${value} | grep tensorflow-lite.so)
+           if [[ ! $check ]]; then
+               echo "Cannot find tensorflow-lite shared lib"
+               report
+               exit
+           fi
+       else
+           echo "Cannot file ${value}"
+           report
+           exit
+       fi
+    fi
+    echo "Cannot identify nnstreamer.ini"
+    report
+    exit
+fi
+
 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} filesrc location=${PATH_TO_IMAGE} ! pngdec ! videoscale ! imagefreeze ! videoconvert ! video/x-raw,format=RGB,framerate=0/1 ! tensor_converter ! tensor_filter framework=tensorflow-lite model=${PATH_TO_MODEL} ! filesink location=tensorfilter.out.log" 1 0 0 $PERFORMANCE
 python checkLabel.py tensorfilter.out.log ${PATH_TO_LABEL} ${PATH_TO_IMAGE}
 testResult $? 1 "Golden test comparison" 0 1