* [PATCH] seltests/zram: fix syntax error [not found] ` <1442203768-35696-1-git-send-email-zhenzhang.zhang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> @ 2015-09-14 4:13 ` Zhang Zhen [not found] ` <55F64967.3090508-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> 0 siblings, 1 reply; 2+ messages in thread From: Zhang Zhen @ 2015-09-14 4:13 UTC (permalink / raw) To: shuahkh-JPH+aEBZ4P+UEJcrhfAQsw, naresh.kamboju-QSEj5FYQhm4dnm+yROfE0A, alexey.kodanev-QHcLZuEGTsvQT0dZR+AlfA Cc: linux-api-u79uwXL29TY76Z2rM5mHXA Not all shells define a variable UID. This is a bash and zsh feature only. In other shells, the UID variable is not defined, so here test command expands to [ != 0 ] which is a syntax error. Without this patch: root@HGH1000007090:/opt/work/linux/tools/testing/selftests/zram# sh zram.sh zram.sh: 8: [: !=: unexpected operator zram.sh : No zram.ko module or /dev/zram0 device file not found zram.sh : CONFIG_ZRAM is not set With this patch: root@HGH1000007090:/opt/work/linux/tools/testing/selftests/zram# sh ./zram.sh zram.sh : No zram.ko module or /dev/zram0 device file not found zram.sh : CONFIG_ZRAM is not set Signed-off-by: Zhang Zhen <zhenzhang.zhang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> --- tools/testing/selftests/zram/zram.sh | 10 +--------- tools/testing/selftests/zram/zram_lib.sh | 3 ++- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/zram/zram.sh b/tools/testing/selftests/zram/zram.sh index 20de9a7..683a292 100755 --- a/tools/testing/selftests/zram/zram.sh +++ b/tools/testing/selftests/zram/zram.sh @@ -1,15 +1,7 @@ #!/bin/bash TCID="zram.sh" -check_prereqs() -{ - local msg="skip all tests:" - - if [ $UID != 0 ]; then - echo $msg must be run as root >&2 - exit 0 - fi -} +. ./zram_lib.sh run_zram () { echo "--------------------" diff --git a/tools/testing/selftests/zram/zram_lib.sh b/tools/testing/selftests/zram/zram_lib.sh index 424e68e..f561a17 100755 --- a/tools/testing/selftests/zram/zram_lib.sh +++ b/tools/testing/selftests/zram/zram_lib.sh @@ -23,8 +23,9 @@ trap INT check_prereqs() { local msg="skip all tests:" + local uid=$(id -u) - if [ $UID != 0 ]; then + if [ $uid -ne 0 ]; then echo $msg must be run as root >&2 exit 0 fi -- 1.9.1 . ^ permalink raw reply related [flat|nested] 2+ messages in thread
[parent not found: <55F64967.3090508-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>]
* Re: [PATCH] seltests/zram: fix syntax error [not found] ` <55F64967.3090508-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> @ 2015-09-14 22:54 ` Shuah Khan 0 siblings, 0 replies; 2+ messages in thread From: Shuah Khan @ 2015-09-14 22:54 UTC (permalink / raw) To: Zhang Zhen, naresh.kamboju-QSEj5FYQhm4dnm+yROfE0A, alexey.kodanev-QHcLZuEGTsvQT0dZR+AlfA Cc: linux-api-u79uwXL29TY76Z2rM5mHXA, Shuah Khan On 09/13/2015 10:13 PM, Zhang Zhen wrote: > Not all shells define a variable UID. This is a bash and zsh feature only. > In other shells, the UID variable is not defined, so here test command > expands to [ != 0 ] which is a syntax error. > > Without this patch: > root@HGH1000007090:/opt/work/linux/tools/testing/selftests/zram# sh zram.sh > zram.sh: 8: [: !=: unexpected operator > zram.sh : No zram.ko module or /dev/zram0 device file not found > zram.sh : CONFIG_ZRAM is not set > > With this patch: > root@HGH1000007090:/opt/work/linux/tools/testing/selftests/zram# sh ./zram.sh > zram.sh : No zram.ko module or /dev/zram0 device file not found > zram.sh : CONFIG_ZRAM is not set > > Signed-off-by: Zhang Zhen <zhenzhang.zhang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> > --- > tools/testing/selftests/zram/zram.sh | 10 +--------- > tools/testing/selftests/zram/zram_lib.sh | 3 ++- > 2 files changed, 3 insertions(+), 10 deletions(-) > Thanks for fixing this. Applied to linux-kselftest fixes for 4.3-rc2 -- Shuah -- Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) shuahkh-JPH+aEBZ4P+UEJcrhfAQsw@public.gmane.org | (970) 217-8978 ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-14 22:54 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <1442203768-35696-1-git-send-email-zhenzhang.zhang@huawei.com> [not found] ` <1442203768-35696-1-git-send-email-zhenzhang.zhang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> 2015-09-14 4:13 ` [PATCH] seltests/zram: fix syntax error Zhang Zhen [not found] ` <55F64967.3090508-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> 2015-09-14 22:54 ` Shuah Khan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).