From 6c6bfad1b36ddd341a082c5ac5919fc48f214471 Mon Sep 17 00:00:00 2001 From: MyungJoo Ham Date: Thu, 14 Jun 2018 20:54:30 +0900 Subject: [PATCH] [Test] Add GstFailTest API For unit-testing, we need to execute failing cases, where graceful exit is required. Signed-off-by: MyungJoo Ham --- tests/nnstreamer_converter/runTest.sh | 12 ++++++++++++ tests/testAPI.sh | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/tests/nnstreamer_converter/runTest.sh b/tests/nnstreamer_converter/runTest.sh index 239b573..07ac048 100755 --- a/tests/nnstreamer_converter/runTest.sh +++ b/tests/nnstreamer_converter/runTest.sh @@ -37,4 +37,16 @@ do_test_nonip RGB 640 480 3-2 do_test_nonip BGRx 642 480 3-3 do_test_nonip RGB 642 480 3-4 +# @TODO Change this when YUV becomes supported by tensor_converter +# Fail Test: YUV is given +gstFailTest "--gst-plugin-path=${PATH_TO_PLUGIN} videotestsrc num-buffers=1 ! video/x-raw,format=YUV,width=280,height=40,framerate=0/1 ! videoconvert ! video/x-raw, format=YUV ! tensor_converter silent=TRUE ! filesink location=\"test.yuv.fail.log\" sync=true" 5-F + +# Fail Test: Unknown property is given +gstFailTest "--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 silent=TRUE whatthehell=isthis ! filesink location=\"test.yuv.fail.log\" sync=true" 6-F + +# @TODO Change this whey audio stream is supported +# Fail Test: Audio ig given +gstFailTest "--gst-plugin-path=${PATH_TO_PLUGIN} audiotestsrc ! audio/x-raw ! tensor_converter silent=TRUE ! filesink location=\"test..audio.fail.log\" sync=true" 7-F + + report diff --git a/tests/testAPI.sh b/tests/testAPI.sh index 88d7609..17e63a7 100644 --- a/tests/testAPI.sh +++ b/tests/testAPI.sh @@ -34,6 +34,24 @@ function gstTest { } ## +# @brief execute gst-launch that is expected to fail. This may be used to test if the element fails gracefully. +# @param 1 the whole parameters +# @param 2 the case number +function gstFailTest { + stdout=$(gst-launch-1.0 -q $1) + output=$? + if [[ $output -eq 0 ]]; then + printf "$stdout\n" + lfail=$((lfail+1)) + log="${log}$RED[FAILED] (Suppsoed to be failed, but passed) gst-launch with case $2$NC\n" + else + lsucc=$((lsucc+1)) + log="${log}$GREEN[PASSED]$NC (Supposed to be failed and actually failed) gst-launch with case $2\n" + fi +} + + +## # @brief compare the golden output and the actual output # @param 1 the golden case file # @param 2 the actual output -- 2.7.4