From: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] commands/which: Added new testcase to test which(1).
Date: Fri, 4 Dec 2015 15:50:38 +0800 [thread overview]
Message-ID: <566145CE.8070004@cn.fujitsu.com> (raw)
In-Reply-To: <20151203133318.GE29110@rei.lan>
Hi!
Thanks for your review!
On 2015/12/03 21:33, Cyril Hrubis wrote:
> Hi!
>> +setup()
>> +{
>> + tst_require_root
>
> Do we really need root for the test?
>
It's not necessary indeed, I'll drop it.
>> + tst_check_cmds which
>> +
>> + tst_tmpdir
>> +
>> + TST_CLEANUP="cleanup"
>> +
>> + touch programname
>> + chmod +x programname
>> + PATH=$PATH:.
>> +
>> + mkdir bin
>> + touch bin/programname
>> + chmod +x bin/programname
>> + PATH=$PATH:./bin
>> +
>> + alias programname='programname -i'
>> +}
>> +
>> +cleanup()
>> +{
>> + tst_rmdir
>> +}
>> +
>> +which_verify()
>> +{
>> + local which_op=$1
>> + local prog_name=$2
>> +
>> + if [ -z "$which_op" ]; then
>> + grep -q `pwd`/"$prog_name" temp
>> + if [ $? -ne 0 ]; then
>> + return 1
>> + fi
>> + elif [ "$which_op" = "--all" ] || [ "$which_op" = "-a" ]; then
>> + grep -q `pwd`/"$prog_name" temp
>> + if [ $? -ne 0 ]; then
>> + return 1
>> + fi
>> + grep -q `pwd`/bin/"$prog_name" temp
>> + if [ $? -ne 0 ]; then
>> + return 1
>> + fi
>> + elif [ "$which_op" = "--read-alias" ] || [ "$which_op" = "-i" ]; then
>> + grep -q "programname='programname -i'" temp
>> + if [ $? -ne 0 ]; then
>> + return 1
>> + fi
>> + grep -q `pwd`/"$prog_name" temp
>> + if [ $? -ne 0 ]; then
>> + return 1
>> + fi
>> + elif [ "$which_op" = "--skip-alias" ]; then
>> + grep -q "programname='programname -i'" temp
>> + if [ $? -eq 0 ]; then
>> + return 1
>> + fi
>> + grep -q `pwd`/"$prog_name" temp
>> + if [ $? -ne 0 ]; then
>> + return 1
>> + fi
>> + fi
>
> Again, why don't we rather pass the expected paths as the parameters to
> the which_test function? For example:
>
> which_test "-a" "programname" "$PWD/programname" $PWD/bin/programname"
>
> Then we will do shift twice in the which_test() and loop over the rest
> of the $@ doing grep in the temp for each iteration.
>
Yeah, it sounds better, I'll rewrite this according to your suggestion.
Best Regards,
Guangwen Feng
next prev parent reply other threads:[~2015-12-04 7:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-26 11:55 [LTP] [PATCH] commands/which: Added new testcase to test which(1) Guangwen Feng
2015-12-03 13:33 ` Cyril Hrubis
2015-12-04 7:50 ` Guangwen Feng [this message]
2015-12-04 9:12 ` [LTP] [PATCH v2] " Guangwen Feng
2015-12-15 13:47 ` Cyril Hrubis
2015-12-16 7:01 ` [LTP] [PATCH v3] " Guangwen Feng
2016-01-05 15:27 ` 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=566145CE.8070004@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