public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v2] commands/which: Added new testcase to test which(1).
Date: Tue, 15 Dec 2015 14:47:34 +0100	[thread overview]
Message-ID: <20151215134733.GC26217@rei.lan> (raw)
In-Reply-To: <1449220333-14268-1-git-send-email-fenggw-fnst@cn.fujitsu.com>

Hi!
> +		grep -q "$1" temp
> +		if [ $? -ne 0 ]; then
> +			if [ "$which_op" = "--skip-alias" ] && \
> +				[ "$1" = "pname='pname -i'" ]; then
> +				shift
> +				continue
> +			fi

                              Hmm why don't we remove the
			      "pname='pname -i'" from the parameters?

			      If we silently ignore the failure it's the
			      same as if we haven't checked it in the
			      first place...

Also it would be good to be a bit more verbose here. I.e. do:

echo "'$1' not found in:
cat temp
echo

> +			return 1
> +		fi
> +		shift
> +	done
> +}
> +
> +which_test()
> +{
> +	local which_op=$1
> +	local prog_name=$2
> +
> +	local which_cmd="which $which_op $prog_name"
> +
> +	if [ "$which_op" = "--read-alias" ] || [ "$which_op" = "-i" ] || \
> +		[ "$which_op" = "--skip-alias" ]; then
> +		which_cmd="alias | $which_cmd"
> +	fi
> +
> +	eval ${which_cmd} >temp 2>&1
> +	if [ $? -ne 0 ]; then
> +		grep -q -E "unknown option|invalid option|Usage" temp
> +		if [ $? -eq 0 ]; then
> +			tst_resm TCONF "'${which_cmd}' not supported."
> +			return
> +		fi
> +
> +		tst_resm TFAIL "'${which_cmd}' failed."
> +		cat temp
> +		return
> +	fi
> +
> +	if [ -n "$prog_name" ]; then

I would rather do 'if [ $# -gt 2 ]; then' but that is very minor.

> +		shift 2
> +		which_verify "$which_op" "$@"
> +		if [ $? -ne 0 ]; then
> +			tst_resm TFAIL "'${which_cmd}' failed, not expected."
> +			return
> +		fi
> +	fi
> +
> +	tst_resm TPASS "'${which_cmd}' passed."
> +}

The rest looks good.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2015-12-15 13:47 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
2015-12-04  9:12     ` [LTP] [PATCH v2] " Guangwen Feng
2015-12-15 13:47       ` Cyril Hrubis [this message]
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=20151215134733.GC26217@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