From: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] commands/keyctl01: Add new regression test
Date: Tue, 28 Mar 2017 14:46:26 +0800 [thread overview]
Message-ID: <58DA06C2.6050703@cn.fujitsu.com> (raw)
In-Reply-To: <20170327134232.GA21272@rei.lan>
Hi!
Thanks for your review.
On 03/27/2017 09:42 PM, Cyril Hrubis wrote:
> Hi!
>> + 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 /
>
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
>
>> + 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
>> + 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.
>> + 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?
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
>
>> + fi
>> +
>> + ((maxkeysz -= 4))
>> + done
>> +
>> + tst_res TPASS "Bug not reproduced"
>> +}
>> +
>> +tst_run
>> --
>> 1.8.4.2
>>
>>
>>
>>
>> --
>> Mailing list info: https://lists.linux.it/listinfo/ltp
>
next prev parent reply other threads:[~2017-03-28 6:46 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 11:13 [LTP] [PATCH] commands/keyctl01: Add new regression test Guangwen Feng
2017-03-27 13:42 ` Cyril Hrubis
2017-03-28 6:46 ` Guangwen Feng [this message]
2017-03-28 8:34 ` Cyril Hrubis
2017-03-28 10:37 ` Guangwen Feng
2017-03-29 2:09 ` [LTP] [PATCH v2] " Guangwen Feng
2017-03-29 16:53 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=58DA06C2.6050703@cn.fujitsu.com \
--to=fenggw-fnst@cn.fujitsu.com \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox