From 861df3714f6738ef463529807ee2c5bc4defdff4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20Zingil=C3=A9?= Date: Thu, 4 Sep 2014 17:45:33 +0200 Subject: [PATCH] adapt suite to IVI profile MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: Id59686b3ea7a56d509fd49560d697e8a4ea070ad Signed-off-by: Nicolas Zingilé --- .../00-common/A0-sanity/02-multimedia/gst.sh | 30 ++++++++-- .../00-common/A0-sanity/02-multimedia/init.sh | 7 ++- .../00-common/A0-sanity/02-multimedia/post.sh | 7 ++- TESTDIR/runme.sh | 30 +++++++++- TESTDIR/util.sh | 56 +++++++++++++++++++ 5 files changed, 120 insertions(+), 10 deletions(-) create mode 100644 TESTDIR/util.sh diff --git a/TESTDIR/00-common/A0-sanity/02-multimedia/gst.sh b/TESTDIR/00-common/A0-sanity/02-multimedia/gst.sh index 7554f6a..a691dd6 100755 --- a/TESTDIR/00-common/A0-sanity/02-multimedia/gst.sh +++ b/TESTDIR/00-common/A0-sanity/02-multimedia/gst.sh @@ -1,9 +1,21 @@ #!/bin/bash -x -# Copyright (c) 2013 Intel Corporation. All rights reserved. -# Use of this source code is governed by a LGPL v2.1 license that can be -# found in the LICENSE file in the db directory. -# Author : Ewan Le Bideau-Canevet +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Authors : Ewan le Bideau Canevet +# Nicolas Zingile FILE=$1 @@ -16,6 +28,7 @@ echo $COMMAND $COMMAND &>$tmplog & pid=$! (sleep 5; [ -e /proc/$pid ] && kill $pid;) & + while [ -e /proc/$pid ]; do sleep 1 if grep "$UNWANTED" $tmplog ; then @@ -25,4 +38,11 @@ while [ -e /proc/$pid ]; do exit 1 fi done -exit 0 + +wait $pid + +if [[ (( $? == 137 )) || (( $? == 143 )) || (( $? == 0 )) ]]; then + exit 0 +else + echo "a core dump has occured, test failed" && exit 1 +fi diff --git a/TESTDIR/00-common/A0-sanity/02-multimedia/init.sh b/TESTDIR/00-common/A0-sanity/02-multimedia/init.sh index 24599bb..adff1ff 100755 --- a/TESTDIR/00-common/A0-sanity/02-multimedia/init.sh +++ b/TESTDIR/00-common/A0-sanity/02-multimedia/init.sh @@ -15,6 +15,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # Authors : Ewan le Bideau Canevet +# Nicolas Zingile + +source util.sh FILE=$1 -cp $FILE ~guest +user=$(gettestuser) + +cp $FILE /home/$user diff --git a/TESTDIR/00-common/A0-sanity/02-multimedia/post.sh b/TESTDIR/00-common/A0-sanity/02-multimedia/post.sh index a0dd115..26569b5 100755 --- a/TESTDIR/00-common/A0-sanity/02-multimedia/post.sh +++ b/TESTDIR/00-common/A0-sanity/02-multimedia/post.sh @@ -15,6 +15,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # # Authors : Ewan le Bideau Canevet +# Nicolas Zingile + +source util.sh FILE=$1 -rm -rf ~guest/$FILE +user=$(gettestuser) + +rm -rf /home/$user/$FILE diff --git a/TESTDIR/runme.sh b/TESTDIR/runme.sh index 59769d7..1778686 100755 --- a/TESTDIR/runme.sh +++ b/TESTDIR/runme.sh @@ -1,14 +1,38 @@ #!/bin/bash -x + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Authors : Ewan le Bideau Canevet +# Nicolas Zingile + +source util.sh + CMD="$@" tmpscript=$(mktemp) +user=$(gettestuser) +process=$(gettestprocess $user) + trap "rm -rf $tmpscript" INT QUIT TERM STOP EXIT echo "#!/bin/bash " > $tmpscript -tr '\0' '\n' > $tmpscript +tr '\0' '\n' > $tmpscript echo export PATH=$QAPATH:\$PATH >> $tmpscript -#echo env >> $tmpscript echo $CMD >> $tmpscript chmod 777 $tmpscript -su - guest -c $tmpscript + +su - $user -c $tmpscript + if [ $? -eq 0 ]; then exit 0 else diff --git a/TESTDIR/util.sh b/TESTDIR/util.sh new file mode 100644 index 0000000..6c4f370 --- /dev/null +++ b/TESTDIR/util.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# Authors: Nicolas Zingile + + +#--- some util functions to retrieve test user ---# + +function gettestuser() +{ + local testuser="" + + if [[ -n $(getent passwd guest) ]]; then + testuser=guest + elif [[ -n $(getent passwd app) ]]; then + testuser=app + else + echo "No suitable user" && exit 1 + fi + + echo $testuser +} + +function gettestprocess () +{ + local testprocess="" + + if [[ -z $1 ]]; then + echo "A user should be defined" && exit 1 + else + case $1 in + "guest") + testprocess=tz-launcher + ;; + "app") + testprocess=weston-desktop + ;; + *) + echo "Cannot get the process" && exit 1 + esac + echo $testprocess + fi +} -- 2.34.1