3 ## SPDX-License-Identifier: LGPL-2.1-only
6 ## @author Yechan Choi <yechan9.choi@samsung.com>
8 ## @brief SSAT Test Cases for NNStreamer
10 if [[ "$SSATAPILOADED" != "1" ]]; then
15 printf "${Blue}Independent Mode${NC}"
18 # This is compatible with SSAT (https://github.com/myungjoo/SSAT)
21 # NNStreamer and plugins path for test
22 PATH_TO_PLUGIN="../../build"
25 check_edgesink=$(gst-inspect-1.0 --gst-plugin-path=${PATH_TO_PLUGIN} edgesink | grep EdgeSink)
26 if [[ ! $check_edgesink ]]; then
27 echo 'Cannot find edge sink plugins. Skip tests.'
32 ## @brief Execute file comparison test if both files exist
33 function callCompareTestIfExist() {
34 if [[ ! -f "$1" ]]; then
35 echo "$1 don't exist. Skip $3($4)."
39 if [[ ! -f "$2" ]]; then
40 echo "$2 don't exist. Skip $3($4)."
44 callCompareTest $1 $2 $3 "$4" $5 $6
47 ## @brief Find the number of the first file that matches
48 ## @param $1 Raw file prefix
49 ## @param $2 Raw file suffix
50 ## @param $3 Result file name
51 ## @param $4 Test Case ID
52 function findFirstMatchedFileNumber() {
56 if [[ ! -f "$result_file" ]]; then
57 echo "$3 don't exist."
63 if [[ $? == 0 && ! -L $(which cmp) ]]; then
74 if [[ ! -f "$raw_file" ]]; then
75 echo "$raw_file don't exist."
80 if [[ "$cmp_exist" -eq "1" ]]; then
81 # use cmp - callCompareTest is too verbose
82 cmp $raw_file $result_file
84 if [[ "$output" -eq "1" ]]; then
90 # use `callCompareTest` if cmp is not exist
91 callCompareTest $raw_file $result_file "$4-$num" "find the number of the first file that matches for test $4" 0 1
94 if [[ "$output" -eq "1" ]]; then
100 # Run edge sink server as echo server with default address option.
101 PORT=`python3 ../../get_available_port.py`
102 gstTestBackground "--gst-plugin-path=${PATH_TO_PLUGIN} \
103 videotestsrc is-live=true ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tee name=t \
104 t. ! queue ! multifilesink location=raw1_%1d.log \
105 t. ! queue ! edgesink port=${PORT} async=false" 1-1 1 0 30
106 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \
107 edgesrc dest-port=${PORT} num-buffers=10 ! multifilesink location=result1_%1d.log" 1-2 0 0 $PERFORMANCE
108 findFirstMatchedFileNumber "raw1_" ".log" "result1_0.log" 1-3
109 callCompareTestIfExist raw1_$((num+0)).log result1_0.log 1-3 "Compare 1-3" 1 0
110 callCompareTestIfExist raw1_$((num+1)).log result1_1.log 1-4 "Compare 1-4" 1 0
111 callCompareTestIfExist raw1_$((num+2)).log result1_2.log 1-5 "Compare 1-5" 1 0
112 callCompareTestIfExist raw1_$((num+3)).log result1_3.log 1-6 "Compare 1-6" 1 0
113 callCompareTestIfExist raw1_$((num+4)).log result1_4.log 1-7 "Compare 1-7" 1 0
114 callCompareTestIfExist raw1_$((num+5)).log result1_5.log 1-8 "Compare 1-8" 1 0
115 callCompareTestIfExist raw1_$((num+6)).log result1_6.log 1-9 "Compare 1-9" 1 0
116 callCompareTestIfExist raw1_$((num+7)).log result1_7.log 1-10 "Compare 1-10" 1 0
117 callCompareTestIfExist raw1_$((num+8)).log result1_8.log 1-11 "Compare 1-11" 1 0
118 callCompareTestIfExist raw1_$((num+9)).log result1_9.log 1-12 "Compare 1-12" 1 0
119 kill -9 $pid &> /dev/null
122 # Run edge sink server as echo server with default address option. (multi clients)
123 PORT=`python3 ../../get_available_port.py`
124 gstTestBackground "--gst-plugin-path=${PATH_TO_PLUGIN} \
125 videotestsrc is-live=true ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tee name=t \
126 t. ! queue ! multifilesink location=raw2_%1d.log \
127 t. ! queue ! edgesink port=${PORT} async=false" 2-1 1 0 30
128 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \
129 edgesrc dest-port=${PORT} num-buffers=10 ! multifilesink location=result2_0_%1d.log" 2-2 0 0 $PERFORMANCE
130 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \
131 edgesrc dest-port=${PORT} num-buffers=10 ! multifilesink location=result2_1_%1d.log" 2-3 0 0 $PERFORMANCE
132 findFirstMatchedFileNumber "raw2_" ".log" "result2_0_0.log" 2-4
133 callCompareTestIfExist raw2_$((num+0)).log result2_0_0.log 2-4 "Compare 2-4" 1 0
134 callCompareTestIfExist raw2_$((num+1)).log result2_0_1.log 2-5 "Compare 2-5" 1 0
135 callCompareTestIfExist raw2_$((num+2)).log result2_0_2.log 2-6 "Compare 2-6" 1 0
136 findFirstMatchedFileNumber "raw2_" ".log" "result2_1_0.log" 2-7
137 callCompareTestIfExist raw2_$((num+0)).log result2_1_0.log 2-7 "Compare 2-7" 1 0
138 callCompareTestIfExist raw2_$((num+1)).log result2_1_1.log 2-8 "Compare 2-8" 1 0
139 callCompareTestIfExist raw2_$((num+2)).log result2_1_2.log 2-9 "Compare 2-9" 1 0
140 kill -9 $pid &> /dev/null
143 # Cap: Flexible Tensor
144 PORT=`python3 ../../get_available_port.py`
145 gstTestBackground "--gst-plugin-path=${PATH_TO_PLUGIN} \
146 videotestsrc is-live=true ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tensor_converter ! other/tensors,format=flexible ! tee name=t \
147 t. ! queue ! multifilesink location=raw3_%1d.log \
148 t. ! queue ! edgesink port=${PORT} async=false" 3-1 1 0 30
149 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \
150 edgesrc dest-port=${PORT} num-buffers=10 ! multifilesink location=result3_%1d.log" 3-2 0 0 $PERFORMANCE
151 findFirstMatchedFileNumber "raw3_" ".log" "result3_0.log" 3-3
152 callCompareTestIfExist raw3_$((num+0)).log result3_0.log 3-3 "Compare 3-3" 1 0
153 callCompareTestIfExist raw3_$((num+1)).log result3_1.log 3-4 "Compare 3-4" 1 0
154 callCompareTestIfExist raw3_$((num+2)).log result3_2.log 3-5 "Compare 3-5" 1 0
155 kill -9 $pid &> /dev/null
159 PORT=`python3 ../../get_available_port.py`
160 gstTestBackground "--gst-plugin-path=${PATH_TO_PLUGIN} \
161 videotestsrc is-live=true ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tensor_converter ! other/tensors,num_tensors=1,dimensions=3:300:300:1,types=uint8,format=static ! tee name=t \
162 t. ! queue ! multifilesink location=raw4_%1d.log \
163 t. ! queue ! edgesink port=${PORT} async=false" 4-1 1 0 30
164 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \
165 edgesrc dest-port=${PORT} num-buffers=10 ! multifilesink location=result4_%1d.log" 4-2 0 0 $PERFORMANCE
166 findFirstMatchedFileNumber "raw4_" ".log" "result4_0.log" 4-3
167 callCompareTestIfExist raw4_$((num+0)).log result4_0.log 4-3 "Compare 4-3" 1 0
168 callCompareTestIfExist raw4_$((num+1)).log result4_1.log 4-4 "Compare 4-4" 1 0
169 callCompareTestIfExist raw4_$((num+2)).log result4_2.log 4-5 "Compare 4-5" 1 0
170 kill -9 $pid &> /dev/null
174 PORT=`python3 ../../get_available_port.py`
175 gstTestBackground "--gst-plugin-path=${PATH_TO_PLUGIN} \
176 audiotestsrc ! audioconvert ! tee name=t \
177 t. ! queue ! multifilesink location=raw5_%1d.log \
178 t. ! queue ! edgesink port=${PORT} async=false" 5-1 1 0 30
179 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \
180 edgesrc dest-port=${PORT} num-buffers=10 ! multifilesink location=result5_%1d.log" 5-2 0 0 $PERFORMANCE
181 findFirstMatchedFileNumber "raw5_" ".log" "result5_0.log" 5-3
182 callCompareTestIfExist raw5_$((num+0)).log result5_0.log 5-3 "Compare 5-3" 1 0
183 callCompareTestIfExist raw5_$((num+1)).log result5_1.log 5-4 "Compare 5-4" 1 0
184 callCompareTestIfExist raw5_$((num+2)).log result5_2.log 5-5 "Compare 5-5" 1 0
185 kill -9 $pid &> /dev/null
188 if [ -f /usr/sbin/mosquitto ]
190 testResult 1 9-0 "mosquitto mqtt broker search" 1
192 testResult 0 9-0 "mosquitto mqtt broker search" 1
199 PORT=`python3 ../../get_available_port.py`
200 /usr/sbin/mosquitto -p ${PORT}&
203 gstTestBackground "--gst-plugin-path=${PATH_TO_PLUGIN} \
204 videotestsrc is-live=true ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tee name=t \
205 t. ! queue ! multifilesink location=raw6_%1d.log \
206 t. ! queue ! edgesink port=0 connect-type=HYBRID dest-host=127.0.0.1 dest-port=${PORT} topic=tempTopic async=false" 6-1 1 0 30
207 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \
208 edgesrc port=0 connect-type=HYBRID dest-host=127.0.0.1 dest-port=${PORT} topic=tempTopic num-buffers=10 ! multifilesink location=result6_0_%1d.log" 6-2 0 0 $PERFORMANCE
209 findFirstMatchedFileNumber "raw6_" ".log" "result6_0_0.log" 6-4
210 callCompareTestIfExist raw6_$((num+0)).log result6_0_0.log 6-4 "Compare 6-4" 1 0
211 callCompareTestIfExist raw6_$((num+1)).log result6_0_1.log 6-5 "Compare 6-5" 1 0
212 callCompareTestIfExist raw6_$((num+2)).log result6_0_2.log 6-6 "Compare 6-6" 1 0
213 kill -9 $pid &> /dev/null
216 # Check AITT lib is exist or not.
217 /sbin/ldconfig -p | grep libaitt-enable-later.so >/dev/null 2>&1
218 if [[ "$?" != 0 ]]; then
219 echo "AITT-SES lib is not installed. Skip AITT test."
221 # Data publishing via AITT
222 gstTestBackground "--gst-plugin-path=${PATH_TO_PLUGIN} \
223 videotestsrc is-live=true ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tee name=t \
224 t. ! queue ! multifilesink location=raw7_%1d.log \
225 t. ! queue ! edgesink port=0 connect-type=AITT dest-host=127.0.0.1 dest-port=${PORT} topic=tempTopic async=false" 7-1 1 0 30
226 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \
227 edgesrc port=0 connect-type=AITT dest-host=127.0.0.1 dest-port=${PORT} topic=tempTopic num-buffers=10 ! multifilesink location=result7_0_%1d.log" 7-2 0 0 $PERFORMANCE
228 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \
229 edgesrc port=0 connect-type=AITT dest-host=127.0.0.1 dest-port=${PORT} topic=tempTopic num-buffers=10 ! multifilesink location=result7_1_%1d.log" 7-3 0 0 $PERFORMANCE
230 findFirstMatchedFileNumber "raw7_" ".log" "result7_0_0.log" 7-4
231 callCompareTestIfExist raw7_$((num+0)).log result7_0_0.log 7-4 "Compare 7-4" 1 0
232 callCompareTestIfExist raw7_$((num+1)).log result7_0_1.log 7-5 "Compare 7-5" 1 0
233 callCompareTestIfExist raw7_$((num+2)).log result7_0_2.log 7-6 "Compare 7-6" 1 0
234 findFirstMatchedFileNumber "raw7_" ".log" "result7_1_0.log" 7-7
235 callCompareTestIfExist raw7_$((num+0)).log result7_1_0.log 7-7 "Compare 7-7" 1 0
236 callCompareTestIfExist raw7_$((num+1)).log result7_1_1.log 7-8 "Compare 7-8" 1 0
237 callCompareTestIfExist raw7_$((num+2)).log result7_1_2.log 7-9 "Compare 7-9" 1 0
238 kill -9 $pid &> /dev/null
242 # Data publishing via MQTT
243 kill -9 $mospid &> /dev/null
244 PORT=`python3 ../../get_available_port.py`
245 /usr/sbin/mosquitto -p ${PORT}&
248 gstTestBackground "--gst-plugin-path=${PATH_TO_PLUGIN} \
249 videotestsrc is-live=true ! videoconvert ! videoscale ! video/x-raw,width=300,height=300,format=RGB ! tee name=t \
250 t. ! queue ! multifilesink location=raw8_%1d.log \
251 t. ! queue ! edgesink port=0 connect-type=MQTT dest-host=127.0.0.1 dest-port=${PORT} topic=tempTopic async=false" 8-1 1 0 30
252 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \
253 edgesrc port=0 connect-type=MQTT dest-host=127.0.0.1 dest-port=${PORT} topic=tempTopic num-buffers=10 ! multifilesink location=result8_0_%1d.log" 8-2 0 0 $PERFORMANCE
254 gstTest "--gst-plugin-path=${PATH_TO_PLUGIN} \
255 edgesrc port=0 connect-type=MQTT dest-host=127.0.0.1 dest-port=${PORT} topic=tempTopic num-buffers=10 ! multifilesink location=result8_1_%1d.log" 8-3 0 0 $PERFORMANCE
256 findFirstMatchedFileNumber "raw8_" ".log" "result8_0_0.log" 8-4
257 callCompareTestIfExist raw8_$((num+0)).log result8_0_0.log 8-4 "Compare 8-4" 1 0
258 callCompareTestIfExist raw8_$((num+1)).log result8_0_1.log 8-5 "Compare 8-5" 1 0
259 callCompareTestIfExist raw8_$((num+2)).log result8_0_2.log 8-6 "Compare 8-6" 1 0
260 findFirstMatchedFileNumber "raw8_" ".log" "result8_1_0.log" 8-7
261 callCompareTestIfExist raw8_$((num+0)).log result8_1_0.log 8-7 "Compare 8-7" 1 0
262 callCompareTestIfExist raw8_$((num+1)).log result8_1_1.log 8-8 "Compare 8-8" 1 0
263 callCompareTestIfExist raw8_$((num+2)).log result8_1_2.log 8-9 "Compare 8-9" 1 0
264 kill -9 $pid &> /dev/null
267 kill -9 $mospid &> /dev/null