commands/keyctl01: Add new regression test
PATCH 1/1 commands/keyctl01: Add new regression test
Fixed by:
commit 38327424b40bcebe2de92d07312c89360ac9229a
Author: Dan Carpenter <[email protected]> Date: Thu Jun 16 15:48:57 2016 +0100
KEYS: potential uninitialized variable
--- runtest/commands | 1 + testcases/commands/keyctl/Makefile | 24 +++++++++ testcases/commands/keyctl/keyctl01.sh | 91 +++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) create mode 100644 testcases/commands/keyctl/Makefile create mode 100644 testcases/commands/keyctl/keyctl01.sh
runtest/commands +1 -0
@@ -41,3 +41,4 @@ which01 which01.sh lsmod01 lsmod01.sh insmod01 insmod01.sh wc01 wc01.sh +keyctl01 keyctl01.sh
testcases/commands/keyctl/Makefile new file +24 -0
@@ -0,0 +1,24 @@ +# +# commands/keyctl testcases Makefile. +# +# Copyright (c) 2017 Fujitsu Ltd. +# Author:Guangwen Feng <[email protected]> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +top_srcdir ?= ../../.. + +include $(top_srcdir)/include/mk/env_pre.mk + +INSTALL_TARGETS := keyctl01.sh + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/commands/keyctl/keyctl01.sh new file +91 -0
91 lines not on this page · raw message
Signature · 1 line
1.8.4.2
PATCH 1/1 commands/keyctl01: Add new regression test
Hi!
testcases/commands/keyctl/keyctl01.sh line 53
Quoted 2 lines
testcases/commands/keyctl/keyctl01.sh new file +2
-0+ ORIG_KEYSZ=`grep -w "0:" $PATH_KEYSTAT | awk '{print $5}' | \ + cut -d '/' -f1`
This looks too complicated for what it does, we can probably simplify this by something as:
awk -F' +|/' '/0:/ {print $9}' /proc/key-users
^ ^ ^
| | This prints last number in the line
| This matches lines that contain 0:This sets field separator to any sequence of spaces or single /
Quoted 16 lines
testcases/commands/keyctl/keyctl01.sh new file +16
-0+ ORIG_MAXKEYSZ=`cat $PATH_KEYQUOTA` +} + +cleanup() +{ + if [ -n "$ORIG_MAXKEYSZ" ]; then + echo $ORIG_MAXKEYSZ >$PATH_KEYQUOTA + fi +} + +do_test() +{ + local maxkeysz=$((ORIG_KEYSZ + 100)) + + while true + do
testcases/commands/keyctl/keyctl01.sh line 79
Quoted 10 lines
testcases/commands/keyctl/keyctl01.sh new file +10
-0+ echo $maxkeysz >$PATH_KEYQUOTA + + keyctl request2 user debug:fred negate @t >temp 2>&1 + grep -q -E "quota exceeded" temp + if [ $? -eq 0 ]; then + break + fi + + local key=`keyctl show | grep -w "debug:fred" | \ + awk '{print $1}'`
Here as well, simple awk '/debug:fred/ {print $1}' should do.
testcases/commands/keyctl/keyctl01.sh line 82
Quoted 3 lines
testcases/commands/keyctl/keyctl01.sh new file +3
-0+ if [ -n "$key" ]; then + keyctl unlink $key @s >/dev/null + tst_sleep 100ms
Is this sleep here necessary? For how much time the test takes?
Quoted 17 lines
testcases/commands/keyctl/keyctl01.sh new file +9
-0+ fi + + ((maxkeysz -= 4)) + done + + tst_res TPASS "Bug not reproduced" +} + +tst_runSignature · 7 lines
1.8.4.2 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 commands/keyctl01: Add new regression test
Hi!
Thanks for your review.
Quoted 7 lines · Cyril Hrubis
Hi!
testcases/commands/keyctl/keyctl01.sh line 53
Quoted 2 lines
testcases/commands/keyctl/keyctl01.sh new file +2
-0+ ORIG_KEYSZ=`grep -w "0:" $PATH_KEYSTAT | awk '{print $5}' | \ + cut -d '/' -f1`This looks too complicated for what it does, we can probably simplify this by something as:
Quoted 6 lines
awk -F' +|/' '/0:/ {print $9}'
/proc/key-users^ ^ ^ | | This prints last number in the line | This matches lines that contain 0:This sets field separator to any sequence of spaces or single /
This is way much better than mine, thanks very much!
awk -F' +|/' '/ 0:/ {print $8}' /proc/key-users
^ ^
| Sorry, but here should be $8 I suppose
And here needs a space, to distinguish something like:
0: 6 5/5 3/200 115/20000
100: 3 3/3 3/200 84/20000
Quoted 21 lines
Quoted 21 lines
testcases/commands/keyctl/keyctl01.sh new file +20
-0+ ORIG_MAXKEYSZ=`cat $PATH_KEYQUOTA` +} + +cleanup() +{ + if [ -n "$ORIG_MAXKEYSZ" ]; then + echo $ORIG_MAXKEYSZ >$PATH_KEYQUOTA + fi +} + +do_test() +{ + local maxkeysz=$((ORIG_KEYSZ + 100)) + + while true + do + echo $maxkeysz >$PATH_KEYQUOTA + + keyctl request2 user debug:fred negate @t >temp 2>&1 + grep -q -E "quota exceeded" temp
Quoted 9 lines
testcases/commands/keyctl/keyctl01.sh line 79
Quoted 6 lines
testcases/commands/keyctl/keyctl01.sh new file +6
-0+ if [ $? -eq 0 ]; then + break + fi + + local key=`keyctl show | grep -w "debug:fred" | \ + awk '{print $1}'`Here as well, simple awk '/debug:fred/ {print $1}' should do.
OK, thanks.
Quoted 5 lines
testcases/commands/keyctl/keyctl01.sh line 82
Quoted 3 lines
testcases/commands/keyctl/keyctl01.sh new file +3
-0+ if [ -n "$key" ]; then + keyctl unlink $key @s >/dev/null + tst_sleep 100msIs this sleep here necessary? For how much time the test takes?
Yes, it is necessary, without the sleep, this test fails to reproduce the bug on RHEL7.2GA(buggy kernel), since I found that it actually takes some time to free the key.
With 100ms sleep, the whole test takes about 2s.
Best Regards,
Guangwen Feng
Quoted 19 lines
Quoted 18 lines
testcases/commands/keyctl/keyctl01.sh new file +9
-0+ fi + + ((maxkeysz -= 4)) + done + + tst_res TPASS "Bug not reproduced" +} + +tst_runSignature · 7 lines
1.8.4.2 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH 1/1 commands/keyctl01: Add new regression test
Hi!
Quoted 6 lines
Yes, it is necessary, without the sleep, this test fails to reproduce the bug on RHEL7.2GA(buggy kernel), since I found that it actually takes some time to free the key.
With 100ms sleep, the whole test takes about 2s.
Two seconds is not that bad but can we make it faster? Does the test still reproduce the issue when we decrease the sleep a bit?
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 commands/keyctl01: Add new regression test
Hi!
Quoted 11 lines · Cyril Hrubis
Hi!
Quoted 6 lines
Yes, it is necessary, without the sleep, this test fails to reproduce the bug on RHEL7.2GA(buggy kernel), since I found that it actually takes some time to free the key.
With 100ms sleep, the whole test takes about 2s.
Two seconds is not that bad but can we make it faster? Does the test still reproduce the issue when we decrease the sleep a bit?
Sleep 50ms still ensure the reproducible in my system, and it takes no more than 1 second to test, but 30ms cannot ensure the reproducible.
Best Regards,
Guangwen Feng
PATCH v2 1/1 commands/keyctl01: Add new regression test
Fixed by:
commit 38327424b40bcebe2de92d07312c89360ac9229a
Author: Dan Carpenter <[email protected]> Date: Thu Jun 16 15:48:57 2016 +0100
KEYS: potential uninitialized variable
--- runtest/commands | 1 + testcases/commands/keyctl/Makefile | 24 ++++++++++ testcases/commands/keyctl/keyctl01.sh | 89 +++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 testcases/commands/keyctl/Makefile create mode 100644 testcases/commands/keyctl/keyctl01.sh
runtest/commands +1 -0
@@ -41,3 +41,4 @@ which01 which01.sh lsmod01 lsmod01.sh insmod01 insmod01.sh wc01 wc01.sh +keyctl01 keyctl01.sh
testcases/commands/keyctl/Makefile new file +24 -0
@@ -0,0 +1,24 @@ +# +# commands/keyctl testcases Makefile. +# +# Copyright (c) 2017 Fujitsu Ltd. +# Author:Guangwen Feng <[email protected]> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# + +top_srcdir ?= ../../.. + +include $(top_srcdir)/include/mk/env_pre.mk + +INSTALL_TARGETS := keyctl01.sh + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/commands/keyctl/keyctl01.sh new file +89 -0
89 lines not on this page · raw message
Signature · 1 line
1.8.4.2
PATCH v2 1/1 commands/keyctl01: Add new regression test
Hi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]