summaryrefslogtreecommitdiff
path: root/automated/lib
diff options
context:
space:
mode:
authorNicolas Dechesne <nicolas.dechesne@linaro.org>2017-01-25 14:15:43 +0100
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-01-26 18:44:15 +0000
commit7a69531c00ecf502fcd9912e3ed9a8d1e7f435a0 (patch)
tree42fe3c54ca3269b4efa6e915c0ae90532295176a /automated/lib
parentc917abdefd3693fbd4d585efae802a10867b03fb (diff)
downloadtest-definitions-pipe-7a69531c00ecf502fcd9912e3ed9a8d1e7f435a0.tar.gz
automated: sh-test-lib: add check_root() when needed
In a few lib functions , we are running commands which require root. so let's call check_root() whenever it's needed, to avoid adding the check in the test scripts themselves. For example , in many test case we use check_root() mostly because we want to install packages with install_deps(). Let's add a call to check_root() in install_deps() directly, since installing packages *always* require root. Then we can remove un-needed checks from the test case themselves. Change-Id: Ifd76dacf85f21825f2e47cd224a3725c69eba899 Signed-off-by: Nicolas Dechesne <nicolas.dechesne@linaro.org>
Diffstat (limited to 'automated/lib')
-rwxr-xr-xautomated/lib/sh-test-lib6
1 files changed, 6 insertions, 0 deletions
diff --git a/automated/lib/sh-test-lib b/automated/lib/sh-test-lib
index bdc74e8..1429db6 100755
--- a/automated/lib/sh-test-lib
+++ b/automated/lib/sh-test-lib
@@ -186,6 +186,8 @@ install_deps() {
if [ "${skip_install}" = "True" ] || [ "${skip_install}" = "true" ]; then
info_msg "install_deps skipped"
else
+ ! check_root && \
+ error_msg "About to install packages, please run this script as root."
info_msg "Installing ${pkgs}"
dist_name
case "${dist}" in
@@ -281,6 +283,8 @@ add_key() {
[ "$#" -ne 1 ] && error_msg "Usage: add_key url"
url="$1"
+ ! check_root && \
+ error_msg "About to use apt-key, please run this script as root."
dist_name
case "${dist}" in
debian|ubuntu) wget -O - "${url}" | apt-key add - ;;
@@ -293,6 +297,8 @@ add_repo() {
[ "$#" -lt 1 ] && error_msg "Usage: add_repo <url> [backports]"
url="$1"
+ ! check_root && \
+ error_msg "About to add a repo, please run this script as root."
dist_name
case "${dist}" in
# Detect Debian/Ubuntu codename and add repo automatically. The same url