From e52a98d319ffca7b717e2819df5d2e2df5b903f9 Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Jan 02 2019 11:00:02 +0000 Subject: Function to select alternative --- diff --git a/tests/0_lib/functions.sh b/tests/0_lib/functions.sh index ed6a3a8..6898171 100755 --- a/tests/0_lib/functions.sh +++ b/tests/0_lib/functions.sh @@ -142,6 +142,18 @@ function t_Assert_Equals [ $1 -eq $2 ] t_CheckExitStatus $? } +function t_Select_Alternative +{ + name=$1 + search=$2 + option=$(/bin/echo|/usr/sbin/alternatives --config "$name"|/bin/grep -E "$search"|/usr/bin/head -n1|sed 's/ .*//g;s/[^0-9]//g') + if [ -z "$option" ];then + t_Log "Option not found for altenative $search of $name" + t_CheckExitStatus 1 + fi + t_Log "Selecing alternative $option for $name--$search" + /bin/echo "$option"|/usr/sbin/alternatives --config "$name" >/dev/null 2>&1 +} export -f t_Log export -f t_CheckExitStatus export -f t_InstallPackage @@ -156,5 +168,6 @@ export -f t_GetArch export -f t_CheckForPort export -f t_Assert export -f t_Assert_Equals +export -f t_Select_Alternative export centos_ver export arch