Package-specific test case and critical path test case project: drafts for review
Michal Jaegermann
michal at harddata.com
Thu Dec 23 04:37:49 UTC 2010
On Wed, Dec 22, 2010 at 07:53:22AM -0500, James Laska wrote:
> On Tue, 2010-12-21 at 18:32 -0700, Michal Jaegermann wrote:
> > On Tue, Dec 21, 2010 at 06:12:47PM -0500, James Laska wrote:
> > > Something to help testers find the right src.rpm name of the
> > > component under test?
> >
> > Something like that?
>
> Exactly, thanks for sharing. I've added some comments below for some
> common gotchas that always get me with bash scripts. Hope it's helpful.
>
> > #!/bin/bash
> >
> > me=$(basename $0)
> > usage () {
> > echo "Usage: $me <name>"
> > echo "where <name> is either path to a file or an rpm package name"
> > exit 1
> > }
> >
> > [ -z "$1" ] && usage
> >
> > arg="$1"
> > case $arg in
> > */*) file="-f" ;;
> > esac
>
> It might be a bit more error-proof to use, since the file argument could
> be in the current directory (no '/'):
Then you can pass ./<my_arg>. This is more or less what yum wants
to see when you ask "whatprovides".
> test -f %{arg} && file="-f" || file=""
And then you can have a file in the current directory with the same
name as an intended package. Chances are that both names indeed
agree but there is no guarantee. We can possibly retry if there
is no fit. Here is a modified scritpt:
#!/bin/bash
me=$(basename $0)
usage () {
echo "Usage: $me <name>"
echo "where <name> is either path to a file or an rpm package name"
exit 1
}
[ -z "$1" ] && usage
arg="$1"
while : ; do
case $arg in
*/*) file="-f" ; break ;;
*) # Check if we have a package with this name
rpm -q $arg >/dev/null 2>&1 && break
# No? Modify arg and try again
arg="./$arg"
;;
esac
done
# on multiarch we may get multiple package with the same n-v-r.
pkg=$(rpm -q $file --qf '%{sourcerpm}\n' $arg|head -1)
bname=${pkg%-*}
echo ${bname%-*}
echo ${pkg%.src.rpm}
exit
Another possibility would be to require some flag signalling that we
are passing a file name but I think that in practice you may often
want to give as an argument something like "$(which cat)". I think
that a possible retry will be the most convenient.
> If conditionally initializing the value of $file, you might want to
> provide a default value above.
There are no unitialized variables in shell. A default value for a
variable which was not yet asigned to is "". Yes, one can be
explicit but this is not required.
> As an extra data point, dmalcolm posted a somewhat
> script that opens up a bugzilla web page to assist in filing a bug
> against a component. I'm sure that could be adjusted to find the
> %{sourcerpm} name using the procedure you outlined.
>
> http://lists.fedoraproject.org/pipermail/test/2010-December/096079.html
I think so; but I will leave going into Python to somebody else. :-)
Michal
More information about the test
mailing list