From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] commands/keyctl01: Add new regression test
Date: Mon, 27 Mar 2017 15:42:32 +0200 [thread overview]
Message-ID: <20170327134232.GA21272@rei.lan> (raw)
In-Reply-To: <1489576439-15122-1-git-send-email-fenggw-fnst@cn.fujitsu.com>
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 /
> + 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.
> + 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?
> + 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
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2017-03-27 13:42 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 [this message]
2017-03-28 6:46 ` Guangwen Feng
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=20170327134232.GA21272@rei.lan \
--to=chrubis@suse.cz \
--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