Return-Path: From: Wang Mingyu Date: Tue, 3 Jul 2018 03:27:03 -0700 Message-ID: <1530613623-115473-1-git-send-email-wangmy@cn.fujitsu.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Fuego] [PATCH] Add a function in fuego_test.sh to check if the user has root privileges on the target or not. If not, add the test case that requires root privileges to the skiplist. List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: fuego@lists.linuxfoundation.org Signed-off-by: Wang Mingyu --- engine/tests/Functional.busybox/fuego_test.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/engine/tests/Functional.busybox/fuego_test.sh b/engine/tests/Functional.busybox/fuego_test.sh index 70a6ec1..861cf24 100755 --- a/engine/tests/Functional.busybox/fuego_test.sh +++ b/engine/tests/Functional.busybox/fuego_test.sh @@ -1,5 +1,5 @@ # $1: string with tests to skip separated by spaces -# $2: absolute path to the skipfile (default: ${LOGDIR}/skiplist.txt) +# absolute path to the skipfile (default: ${LOGDIR}/skiplist.txt) function skip_tests { # split $1 on whitespace, without file globbing set -f @@ -14,7 +14,7 @@ function skip_tests { # $1: command/program to look for # $2: string with busybox test names separated by spaces -# $3: This function may also be used in other tests, which can be considered as a general function of fuego. +# This function may also be used in other tests, which can be considered as a general function of fuego. function skip_if_command_unavailable { local PROGRAM="$1" local TESTS="$2" @@ -27,6 +27,17 @@ function skip_if_command_unavailable { fi } +# $1: string with busybox test names separated by spaces +# This function is used to check whether the tests that need root privileges should be skiped or not. +function skip_if_not_root { + local TESTS="$1" + check_root + if [ $? = 1 ] ;then + echo "WARNING: You need to login as root." + skip_tests "${TESTS}" + fi +} + function test_pre_check { is_on_target_path busybox PROGRAM_BUSYBOX assert_define PROGRAM_BUSYBOX "Missing 'busybox' program on target board" @@ -34,6 +45,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_not_root "busybox_chroot.sh" } function test_deploy { -- 1.8.3.1