Commit 7ef7cc9f authored by Zhang Zhen's avatar Zhang Zhen Committed by Shuah Khan

seltests/zram: fix syntax error

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: default avatarZhang Zhen <zhenzhang.zhang@huawei.com>
Signed-off-by: default avatarShuah Khan <shuahkh@osg.samsung.com>
parent 6ff33f39
#!/bin/bash #!/bin/bash
TCID="zram.sh" TCID="zram.sh"
check_prereqs() . ./zram_lib.sh
{
local msg="skip all tests:"
if [ $UID != 0 ]; then
echo $msg must be run as root >&2
exit 0
fi
}
run_zram () { run_zram () {
echo "--------------------" echo "--------------------"
......
...@@ -23,8 +23,9 @@ trap INT ...@@ -23,8 +23,9 @@ trap INT
check_prereqs() check_prereqs()
{ {
local msg="skip all tests:" 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 echo $msg must be run as root >&2
exit 0 exit 0
fi fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment