From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] commands/unshare: Add new testcase to test unshare(1)
Date: Thu, 30 Nov 2017 15:20:56 +0100 [thread overview]
Message-ID: <20171130142056.GF2924@rei> (raw)
In-Reply-To: <1509615297-2798-1-git-send-email-yangx.jy@cn.fujitsu.com>
Hi!
> + if [[ "${verify_cmd}" =~ 'id' ]]; then
> + if [ $(cat temp) -ne ${exp_result} ]; then
> + tst_res TFAIL "${unshare_cmd} got wrong uid/gid"
> + return
> + fi
> + fi
> +
> + if [[ "${verify_cmd}" =~ 'mount' ]]; then
> + if [ "${exp_result}" = "unmounted" ]; then
> + if ls test_B | grep -q 'A'; then
> + tst_res TFAIL "${unshare_cmd} got bind info"
> + umount test_B
> + return
> + fi
> + else
> + if ! ls test_B | grep -q 'A'; then
> + tst_res TFAIL "${unshare_cmd} did not get bind info"
> + return
> + fi
> + umount test_B
> + fi
> + fi
The double square operator is bash specific. The portable way who to
check for a start of a string is to use case as:
case "$verify_cmd" in
id*) echo starts with id;;
mount*) echo starts with mount;;
esac
And it may be a bit cleaner to put the checks into a separate functions
the indentation is getting out of the hand here.
> + tst_res TPASS "${unshare_cmd} succeeded as expected"
> +}
> +
> +do_test()
> +{
> + case $1 in
> + 1) unshare_test "--user" "id -u" "65534";;
> + 2) unshare_test "--user" "id -g" "65534";;
> + 3) unshare_test "--user --map-root-user" "id -u" "0";;
> + 4) unshare_test "--user --map-root-user" "id -g" "0";;
> + 5) unshare_test "--mount" "mount --bind test_A test_B" "unmounted";;
> + 6) unshare_test "--mount --propagation shared" \
> + "mount --bind test_A test_B" "mounted";;
> + 7) unshare_test "--user --map-root-user --mount" \
> + "mount --bind test_A test_B" "unmounted";;
> + 8) unshare_test "--user --map-root-user --mount --propagation shared" \
> + "mount --bind test_A test_B" "unmounted";;
> + esac
> +}
> +
> +tst_run
> --
> 1.8.3.1
>
>
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
next prev parent reply other threads:[~2017-11-30 14:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-02 9:34 [LTP] [PATCH] commands/unshare: Add new testcase to test unshare(1) Xiao Yang
2017-11-13 6:46 ` Xiao Yang
2017-11-30 14:20 ` Cyril Hrubis [this message]
2017-12-04 5:35 ` [LTP] [PATCH v2] " Xiao Yang
2017-12-04 14:17 ` 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=20171130142056.GF2924@rei \
--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