From: MyungJoo Ham Date: Mon, 2 Jul 2018 11:02:28 +0000 (+0900) Subject: [Filter/Test] Add regression test for issue #190 X-Git-Tag: v0.0.1~103 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=776660bf91043c39192e366c99005c7b0649fd6d;p=platform%2Fupstream%2Fnnstreamer.git [Filter/Test] Add regression test for issue #190 Test case with 640x480 --> 320x240 scaler. Signed-off-by: MyungJoo Ham --- diff --git a/tests/nnstreamer_filter_custom/checkScaledTensor.py b/tests/nnstreamer_filter_custom/checkScaledTensor.py new file mode 100644 index 0000000..61b7432 --- /dev/null +++ b/tests/nnstreamer_filter_custom/checkScaledTensor.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +## +# Copyright (C) 2018 Samsung Electronics +# License: Apache-2.0 +# +# @file checkScaledTensor.py +# @brief Check if the scaled results are correct +# @author MyungJoo Ham + +import sys + + +def compare (data1, width1, height1, data2, width2, height2, innerdim): + if (len(data1) * width2 * height2) != (len(data2) * width1 * height1): + print(str(len(data1) * width2 * height2)+" / "+str(len(data2) * width1 * height1)) + return 1 + + count = 0 + count2 = 0 + while (count < len(data1)): + # Terminated incorrectly + if (count + (innerdim * width1 * height1)) > len(data1): + return 2 + if (count2 + (innerdim * width2 * height2)) > len(data2): + return 3 + if count2 >= len(data2): + return 4 + + for y in range(0, height2): + for x in range(0, width2): + for c in range(0, innerdim): + ix = x * width1 / width2 + iy = y * height1 / height2 + if data1[count + c + ix * innerdim + iy * width1 * innerdim] != data2[count2 + c + x * innerdim + y * width2 * innerdim]: + print("At "+str(x)+","+str(y)) + return 5 + count = count + innerdim * width1 * height1 + count2 = count2 + innerdim * width2 * height2 + + if count > len(data1): + return 6 + if count2 > len(data2): + return 7 + return 0 + +def readfile (filename): + F = open(filename, 'r') + readfile = F.read() + F.close() + return readfile + + +if len(sys.argv) != 8: + exit(9) + +data1 = readfile(sys.argv[1]) +width1 = int(sys.argv[2]) +height1 = int(sys.argv[3]) +data2 = readfile(sys.argv[4]) +width2 = int(sys.argv[5]) +height2 = int(sys.argv[6]) +innerdim = int(sys.argv[7]) + +exit(compare(data1, width1, height1, data2, width2, height2, innerdim)) diff --git a/tests/nnstreamer_filter_custom/runTest.sh b/tests/nnstreamer_filter_custom/runTest.sh index 78478b3..cd408f6 100755 --- a/tests/nnstreamer_filter_custom/runTest.sh +++ b/tests/nnstreamer_filter_custom/runTest.sh @@ -1,10 +1,12 @@ #!/usr/bin/env bash source ../testAPI.sh +# Test gst availability. (0) gstTest "videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=280,height=40,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! filesink location=\"testcase02.apitest.log\" sync=true" 0 + +# Test constant passthrough custom filter (1, 2) PATH_TO_MODEL="../../build/nnstreamer_example/custom_example_passthrough/libnnstreamer_customfilter_passthrough.so" -PATH_TO_MODEL_V="../../build/nnstreamer_example/custom_example_passthrough/libnnstreamer_customfilter_passthrough_variable.so" gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=280,height=40,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tee name=t ! queue ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL}\" input=\"3:280:40\" inputtype=\"uint8\" output=\"3:280:40\" outputtype=\"uint8\" ! filesink location=\"testcase01.passthrough.log\" sync=true t. ! queue ! filesink location=\"testcase01.direct.log\" sync=true" 1 @@ -15,13 +17,27 @@ gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/ compareAll testcase02.direct.log testcase02.passthrough.log 2 +# Test variable-dim passthrough custom filter (3, 4) +PATH_TO_MODEL_V="../../build/nnstreamer_example/custom_example_passthrough/libnnstreamer_customfilter_passthrough_variable.so" + gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tee name=t ! queue ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL_V}\" input=\"3:640:480\" inputtype=\"uint8\" output=\"3:640:480\" outputtype=\"uint8\" ! filesink location=\"testcase03.passthrough.log\" sync=true t. ! queue ! filesink location=\"testcase03.direct.log\" sync=true" 3 compareAll testcase03.direct.log testcase03.passthrough.log 3 -## @TODO there is a known bug that breaks case 4. gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tee name=t ! queue ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL_V}\" ! filesink location=\"testcase04.passthrough.log\" sync=true t. ! queue ! filesink location=\"testcase04.direct.log\" sync=true" 4 compareAll testcase04.direct.log testcase04.passthrough.log 4 + +# Test scaler (5, 6, 7) +PATH_TO_MODEL_S="../../build/nnstreamer_example/custom_example_scaler/libnnstreamer_customfilter_scaler.so" + +gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tee name=t ! queue ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL_S}\" custom=\"640x480\" ! filesink location=\"testcase05.passthrough.log\" sync=true t. ! queue ! filesink location=\"testcase05.direct.log\" sync=true" 5 +compareAll testcase05.direct.log testcase05.passthrough.log 5 + +gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=RGB,width=640,height=480,framerate=0/1 ! videoconvert ! video/x-raw, format=RGB ! tensor_converter ! tee name=t ! queue ! tensor_filter framework=\"custom\" model=\"${PATH_TO_MODEL_S}\" custom=\"320x240\" ! filesink location=\"testcase06.scaled.log\" sync=true t. ! queue ! filesink location=\"testcase06.direct.log\" sync=true" 6 +python checkScaledTensor.py testcase06.direct.log 640 480 testcase06.scaled.log 320 240 3 +casereport 6 $? "Golden test comparison" + + report diff --git a/tests/testAPI.sh b/tests/testAPI.sh index 0dc8156..87d8cc1 100644 --- a/tests/testAPI.sh +++ b/tests/testAPI.sh @@ -113,6 +113,21 @@ function compareAllSizeLimit { } ## +# @brief Report additional script test case result +# @param 1 the case number +# @param 2 the result (exit code) +# @param 3 test description +function casereport { + if [[ $2 -eq 0 ]]; then + lsucc=$((lsucc+1)) + log="${log}$GREEN[PASSED]$NC $3: $1\n" + else + lfail=$((lfail+1)) + log="${log}$RED[FAILED] $3: $1$NC\n" + fi +} + +## # @brief "runTest.sh" should call this at the end of the file. function report { printf "${log}"