From 438eeafb634386802cb2e7edec1f3ab59e887d5c Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Sun, 5 Jul 2015 11:46:35 +0000 Subject: [PATCH] Issue #93: Add test for chroot --- lib/core.sh | 4 ++++ tests/test_core.sh | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/lib/core.sh b/lib/core.sh index a9576a8..a9055a7 100644 --- a/lib/core.sh +++ b/lib/core.sh @@ -205,6 +205,10 @@ function setup_env_from_file(){ } function run_env_as_root(){ + source ${JUNEST_HOME}/etc/junest/info + [ "$JUNEST_ARCH" != "$ARCH" ] && \ + die "The host system architecture is not correct: $ARCH != $JUNEST_ARCH" + local uid=$UID # SUDO_USER is more reliable compared to SUDO_UID [ -z $SUDO_USER ] || uid=$SUDO_USER:$SUDO_GID diff --git a/tests/test_core.sh b/tests/test_core.sh index cafaa72..b2ef4fc 100755 --- a/tests/test_core.sh +++ b/tests/test_core.sh @@ -207,6 +207,15 @@ function test_run_env_as_root(){ assertEquals 0 $? } +function test_run_env_as_root_different_arch(){ + [ $SKIP_ROOT_TESTS -eq 1 ] && return + + install_mini_env + echo "JUNEST_ARCH=XXX" > ${JUNEST_HOME}/etc/junest/info + $(run_env_as_root pwd 2> /dev/null) + assertEquals 1 $? +} + function test_run_env_as_classic_root(){ [ $SKIP_ROOT_TESTS -eq 1 ] && return