[api] Add timeout function accepted/tizen_6.5_unified tizen_6.5 accepted/tizen/6.5/unified/20211028.223616 accepted/tizen/unified/20210624.131707 submit/tizen/20210624.024019 submit/tizen_6.5/20211028.163301 tizen_6.5.m2_release
authorGichan Jang <gichan2.jang@samsung.com>
Wed, 23 Jun 2021 02:12:08 +0000 (11:12 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 24 Jun 2021 02:40:43 +0000 (11:40 +0900)
Tizen don't provide timeout util.
Add timeout function using perl.

Signed-off-by: Gichan Jang <gichan2.jang@samsung.com>
packaging/ssat.spec
ssat-api.sh

index eaf8890..70ddb37 100644 (file)
@@ -10,6 +10,7 @@ Source1001:   ssat.manifest
 BuildArch:     noarch
 
 Requires:      bash
+Requires:      perl
 
 %description
 SSAT provides testing environment for shell scripts with Apache-2.0 license.
index cae64be..8d1a93a 100644 (file)
@@ -312,7 +312,20 @@ function gstTest() {
                calloutputprefix='valgrind --track-origins=yes'
        fi
 
+       TIMEOUT_AVAIL=1
        if [[ "${6}" -gt "0" ]]; then
+               if ! command -v timeout &> /dev/null
+               then
+                       if command -v perl &> /dev/null
+                       then
+                               timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
+                       else
+                               TIMEOUT_AVAIL=0
+                       fi
+               fi
+       fi
+
+    if [[ "${6}" -gt "0" && $TIMEOUT_AVAIL -eq 1 ]]; then
                if [[ "${SILENT}" -eq "1" ]]; then
                        calloutput=$(eval timeout ${6} $calloutputprefix gst-launch-1.0 -f -q $1 &> /dev/null)
                else