From 82824d79bfd0838be0fa65c4a09655f8a77d54d5 Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Tue, 25 Nov 2014 00:28:47 +0100 Subject: [PATCH] Add test for run juju as fakeroot and for SECCOMP --- tests/test_core.sh | 25 +++++++++++++++---------- tests/utils.sh | 2 -- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/test_core.sh b/tests/test_core.sh index 1a1dc77..c83ad2d 100755 --- a/tests/test_core.sh +++ b/tests/test_core.sh @@ -7,6 +7,7 @@ # coreutils # grep # sudo +# gawk source "$(dirname $0)/utils.sh" CURRPWD=$PWD @@ -119,17 +120,21 @@ function test_run_juju_as_user_proot_args(){ is_equal $? 0 || return 1 } -#function test_run_juju_as_user_seccomp(){ - #install_mini_juju - #TRUE="/usr/bin/false" - #run_juju_as_user "" "env" "|" "grep" "PROOT_NO_SECCOMP" -#} +function test_run_juju_as_user_seccomp(){ + install_mini_juju + local output=$(run_juju_as_user "" "env" | grep "PROOT_NO_SECCOMP") + is_equal $output "" || return 1 -#function test_run_juju_as_fakeroot(){ - #install_mini_juju - #local output=$(run_juju_as_fakeroot "" "bash") - #is_equal "$output" "root" || return 1 -#} + TRUE="/usr/bin/false" + local output=$(run_juju_as_user "" "env" | grep "PROOT_NO_SECCOMP") + is_equal $output "PROOT_NO_SECCOMP=1" || return 1 +} + +function test_run_juju_as_fakeroot(){ + install_mini_juju + local output=$(run_juju_as_fakeroot "" "id" | awk '{print $1}') + is_equal "$output" "uid=0" || return 1 +} function test_delete_juju(){ install_mini_juju diff --git a/tests/utils.sh b/tests/utils.sh index bd12d4e..0ca7144 100644 --- a/tests/utils.sh +++ b/tests/utils.sh @@ -26,8 +26,6 @@ function install_mini_juju(){ mkdir -p ${JUJU_HOME}/{proc,bin,sys,dev,run,tmp,etc} touch ${JUJU_HOME}/etc/resolv.conf mkdir -p ${JUJU_HOME}/usr/bin - #echo "root:x:0:0:root:/root:/bin/bash" > ${JUJU_HOME}/etc/passwd - #cp /etc/nsswitch.conf ${JUJU_HOME} cp /usr/bin/arch-chroot ${JUJU_HOME}/usr/bin install_executable /usr/bin/bash install_executable /usr/bin/ls