1#!/bin/bash 2 3# Copyright (c) 2011-2014, Intel Corporation 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without modification, 7# are permitted provided that the following conditions are met: 8# 9# 1. Redistributions of source code must retain the above copyright notice, this 10# list of conditions and the following disclaimer. 11# 12# 2. Redistributions in binary form must reproduce the above copyright notice, 13# this list of conditions and the following disclaimer in the documentation and/or 14# other materials provided with the distribution. 15# 16# 3. Neither the name of the copyright holder nor the names of its contributors 17# may be used to endorse or promote products derived from this software without 18# specific prior written permission. 19# 20# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 24# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 27# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 31# It creates XML settings from a .pfw description 32# It Also instanciate a PFW with them loaded 33 34# The generated pfw commands 35scriptPFWFile="/tmp/scriptPFW" 36 37# A tmp file, the pfw must have write priviledge on it 38ExportTmpFile="/data/routageDomains.xml" 39 40set -e -u -o pipefail 41 42 43if test $# -eq 0 44then 45 DomainFile="${PFWtest_DomainFile}" 46else 47 DomainFile="$@" 48fi 49 50function echoColor () 51{ 52 if test -t 1 ; 53 then 54 # stdout is a tty => colors 55 /bin/echo -e "\033[32m$@\033[0m" 56 else 57 # stdout is not a tty => no color 58 /bin/echo -e "$@" 59 fi 60} 61 62 63function androidWithError () 64{ 65 echo " \$ $PFWtest_prefixCommand $@" 66 local result 67 68 result=$( $PFWtest_prefixCommand "$*"' ; echo $?' | sed -e 's#[\r]##' ); 69 70 echo "$(echo "$result" | sed '$d')" ; 71 72 return "$(echo "$result" | tail -n1 )"; 73} 74 75echoColor "Translate domains to pfw commands" 76echoColor "Domains source file: $DomainFile" 77m4 "$DomainFile" | $(dirname $0)/PFWScriptGenerator.py --output-kind pfw -o "$scriptPFWFile" 78 79echoColor "List of generated domains :" 80sed -ne 's/createDomain \(.*\)/ \1/p' "$scriptPFWFile" 81 82echoColor "Make fs writable" 83adb remount 84 85echoColor "instanciate pseudo hal" 86$PFWtest_test_scripts/instanciatePseudoHal.sh "$PFWtest_ParameterFrameworkConfigurationFile" "$PFWtest_CriterionFile" 87 88echoColor "Create Domains" 89$(dirname $0)/domainGenerator.sh "$scriptPFWFile" --keep-autoSync-disable 90 91echoColor "Export domains and settings" 92androidWithError remote-process $PFWtest_ParameterFramworkHost exportDomainsWithSettingsXML "$ExportTmpFile" 93androidWithError cp "$ExportTmpFile" "$PFWtest_RemoteOutputFile" 94 95echoColor "restart PseudoHal" 96$PFWtest_test_scripts/instanciatePseudoHal.sh "$PFWtest_ParameterFrameworkConfigurationFile" "$PFWtest_CriterionFile" 97 98echoColor "Synchronization with local file : $PFWtest_LocalOutputFile" 99adb pull "$PFWtest_RemoteOutputFile" "$PFWtest_LocalOutputFile" 100 101 102