[Fuego] [PATCH] Modify the bashims that may not be supported by board of the test of command chroot.
Tim Bird
tbird20d at gmail.com
Tue Jun 19 23:39:22 UTC 2018
On Fri, Jun 15, 2018 at 1:21 AM, Wang Mingyu <wangmy at cn.fujitsu.com> wrote:
> Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
> ---
> engine/tests/Functional.busybox/fuego_test.sh | 1 +
> engine/tests/Functional.busybox/tests/busybox_chroot.sh | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/engine/tests/Functional.busybox/fuego_test.sh b/engine/tests/Functional.busybox/fuego_test.sh
> index 70a6ec1..aa78abf 100755
> --- a/engine/tests/Functional.busybox/fuego_test.sh
> +++ b/engine/tests/Functional.busybox/fuego_test.sh
> @@ -34,6 +34,7 @@ function test_pre_check {
> touch ${LOGDIR}/skiplist.txt
> skip_if_command_unavailable expect "busybox_ash.sh"
> skip_if_command_unavailable tr "busybox_chgrp1.sh busybox_chgrp2.sh busybox_chmod1.sh busybox_chmod2.sh busybox_chown1.sh busybox_chown2.sh"
> + skip_if_command_unavailable expr "busybox_chroot.sh"
> }
>
> function test_deploy {
> diff --git a/engine/tests/Functional.busybox/tests/busybox_chroot.sh b/engine/tests/Functional.busybox/tests/busybox_chroot.sh
> index fd3c524..6fff60e 100644
> --- a/engine/tests/Functional.busybox/tests/busybox_chroot.sh
> +++ b/engine/tests/Functional.busybox/tests/busybox_chroot.sh
> @@ -14,7 +14,7 @@ mkdir -p $test_dir/lib
> cp -v /bin/ls $test_dir/bin/
> list="$(ldd /bin/ls | egrep -o '/lib.*\.[0-9]')"
> for i in $list; do
> - j=${i:1:5}
> + j=$(expr substr "$i" 2 5)
> if $j = lib64
> then
> echo "lib64"
> --
> 1.8.3.1
OK - Sorry for the slow response. I've been traveling. I tried this
here, and had problems with it.
I replaced this with the following patch, which worked better on my machines:
Subject: [PATCH] busybox: Remove bashisms in chroot subtest
Refactor lib copy to not require bash variable slicing.
Also, the refactoring simplifies the copying of the
dynamic libraries needed for chrooted ls.
Signed-off-by: Tim Bird <tim.bird at sony.com>
---
engine/tests/Functional.busybox/tests/busybox_chroot.sh | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/engine/tests/Functional.busybox/tests/busybox_chroot.sh
b/engine/tests/Functional.busybox/tests/busybox_chroot.sh
index fd3c524..d78b029 100644
--- a/engine/tests/Functional.busybox/tests/busybox_chroot.sh
+++ b/engine/tests/Functional.busybox/tests/busybox_chroot.sh
@@ -11,18 +11,13 @@ mkdir -p $test_dir
mkdir -p $test_dir/bin
mkdir -p $test_dir/lib64
mkdir -p $test_dir/lib
+# put ls and the libs it needs into the chroot area
cp -v /bin/ls $test_dir/bin/
-list="$(ldd /bin/ls | egrep -o '/lib.*\.[0-9]')"
-for i in $list; do
- j=${i:1:5}
- if $j = lib64
- then
- echo "lib64"
- cp -v "$i" $test_dir/lib64/
- else
- echo "lib"
- cp -v "$i" $test_dir/lib/
- fi
+libs="$(ldd /bin/ls | egrep -o '/lib.*\.[0-9]')"
+for lib in $libs; do
+ lib_dirname=$(dirname $lib)
+ mkdir -p ${test_dir}${lib_dirname}
+ cp -v $lib ${test_dir}${lib_dirname}
done
busybox chroot $test_dir /bin/ls
if [ $? = 0 ]
--
2.7.4
Another issue with this test is that it requires root privileges in order to
do the actual chroot operation. Can you add a check in fuego_test.sh
and add this to the skiplist, if the user does not have root privileges
on the target. You can call the function "check_root" from fuego_test.sh
if needed. See fuego-core/engine/scripts/need_check.sh.
Let me know if you have questions.
-- Tim
More information about the Fuego
mailing list