Add test for bwrap command

This commit is contained in:
Filippo Squillace 2020-03-16 18:59:01 +01:00
parent 385dd8c68c
commit 4b5b7b300b
3 changed files with 14 additions and 7 deletions

View file

@ -142,11 +142,7 @@ function build_image_env(){
then
mkdir -p ${maindir}/root_test
$TAR -zxpf ${imagefile} -C "${maindir}/root_test"
JUNEST_HOME="${maindir}/root_test" ${JUNEST_BASE}/bin/${CMD} proot --fakeroot ${JUNEST_BASE}/lib/checks/check.sh --skip-aur-tests
JUNEST_HOME="${maindir}/root_test" ${JUNEST_BASE}/bin/${CMD} proot ${JUNEST_BASE}/lib/checks/check.sh --skip-aur-tests --use-sudo
JUNEST_HOME="${maindir}/root_test" ${JUNEST_BASE}/bin/${CMD} ns --fakeroot ${JUNEST_BASE}/lib/checks/check.sh --skip-aur-tests
JUNEST_HOME="${maindir}/root_test" ${JUNEST_BASE}/bin/${CMD} ns ${JUNEST_BASE}/lib/checks/check.sh --use-sudo
JUNEST_HOME="${maindir}/root_test" sudo -E ${JUNEST_BASE}/bin/${CMD} groot ${JUNEST_BASE}/lib/checks/check.sh --run-root-tests --skip-aur-tests
JUNEST_HOME="${maindir}/root_test" ${JUNEST_BASE}/lib/checks/check_all.sh
fi
sudo cp ${maindir}/output/${imagefile} ${ORIGIN_WD}

View file

@ -145,8 +145,7 @@ function unshare_cmd(){
}
function bwrap_cmd(){
# TODO re-evaluate this strategy:
if $LD_EXEC ${JUNEST_HOME}/usr/bin/$BWRAP --dev-bind / / "${SH[0]}" "-c" ":"
if $LD_EXEC ${JUNEST_HOME}/usr/bin/$BWRAP --dev-bind / / "${SH[0]}" "-c" ":"
then
$LD_EXEC ${JUNEST_HOME}/usr/bin/$BWRAP "${@}"
else

View file

@ -34,6 +34,11 @@ function setUp(){
}
UNSHARE=unshare_mock
bwrap_mock() {
echo "bwrap $@"
}
BWRAP=bwrap_mock
}
function test_ln(){
@ -136,6 +141,13 @@ function test_unshare(){
UNSHARE=false LD_EXEC=false assertCommandFail unshare_cmd new_program
}
function test_bwrap(){
assertCommandSuccess bwrap_cmd new_program
assertEquals "$(echo -e "ld_exec ${JUNEST_HOME}/usr/bin/$BWRAP --dev-bind / / /bin/sh -c :\nld_exec ${JUNEST_HOME}/usr/bin/$BWRAP new_program")" "$(cat $STDOUTF)"
BWRAP=false LD_EXEC=false assertCommandFail bwrap_cmd new_program
}
function test_chroot(){
CLASSIC_CHROOT=echo assertCommandSuccess chroot_cmd root
assertEquals "root" "$(cat $STDOUTF)"