#!/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 <ewan.lebideau-canevet@open.eurogiciel.org>
+# Nicolas Zingile <nicolas.zingile@open.eurogiciel.org>
FILE=$1
$COMMAND &>$tmplog &
pid=$!
(sleep 5; [ -e /proc/$pid ] && kill $pid;) &
+
while [ -e /proc/$pid ]; do
sleep 1
if grep "$UNWANTED" $tmplog ; then
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
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Authors : Ewan le Bideau Canevet <ewan.lebideau-canevet@open.eurogiciel.org>
+# Nicolas Zingile <nicolas.zingile@open.eurogiciel.org>
+
+source util.sh
FILE=$1
-cp $FILE ~guest
+user=$(gettestuser)
+
+cp $FILE /home/$user
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Authors : Ewan le Bideau Canevet <ewan.lebideau-canevet@open.eurogiciel.org>
+# Nicolas Zingile <nicolas.zingile@open.eurogiciel.org>
+
+source util.sh
FILE=$1
-rm -rf ~guest/$FILE
+user=$(gettestuser)
+
+rm -rf /home/$user/$FILE
#!/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 <ewan.lebideau-canevet@open.eurogiciel.org>
+# Nicolas Zingile <nicolas.zingile@open.eurogiciel.org>
+
+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' </proc/$(pgrep tz-launcher -u guest)/environ | awk 'FS="=" {if ($1 != "_") { print "export",$0;} }' >> $tmpscript
+tr '\0' '\n' </proc/$(pgrep $process -u $user)/environ | awk 'FS="=" {if ($1 != "_") { print "export",$0;} }' >> $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
--- /dev/null
+#!/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 <nicolas.zingile@open.eurogiciel.org>
+
+
+#--- 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
+}