From 0f598bb0fd9108a7752a1175f8b03ee15b45d376 Mon Sep 17 00:00:00 2001 From: Gichan Jang Date: Wed, 23 Jun 2021 11:12:08 +0900 Subject: [PATCH] [api] Add timeout function Tizen don't provide timeout util. Add timeout function using perl. Signed-off-by: Gichan Jang --- packaging/ssat.spec | 1 + ssat-api.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/packaging/ssat.spec b/packaging/ssat.spec index eaf8890..70ddb37 100644 --- a/packaging/ssat.spec +++ b/packaging/ssat.spec @@ -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. diff --git a/ssat-api.sh b/ssat-api.sh index cae64be..8d1a93a 100644 --- a/ssat-api.sh +++ b/ssat-api.sh @@ -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 -- 2.7.4