Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 704988 Details for
Bug 910757
New function rlAssertBinaryOrigin
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
proposed patch
0001-beakerlib-Added-rlAssertRpm-all-and-rlAssertBinaryOr.patch (text/plain), 7.45 KB, created by
Martin Kyral
on 2013-03-04 13:42:36 UTC
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
Martin Kyral
Created:
2013-03-04 13:42:36 UTC
Size:
7.45 KB
patch
obsolete
>From a435bd61108fb83c6bd8c3ed31a254b82b1dc8bb Mon Sep 17 00:00:00 2001 >From: Martin Kyral <mkyral@redhat.com> >Date: Mon, 4 Mar 2013 14:38:53 +0100 >Subject: [PATCH] beakerlib: Added rlAssertRpm --all and rlAssertBinaryOrigin > >--- > src/rpms.sh | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++- > src/test/rpmsTest.sh | 65 +++++++++++++++++++++++++++++++- > 2 files changed, 166 insertions(+), 2 deletions(-) > >diff --git a/src/rpms.sh b/src/rpms.sh >index 6819be5..818f4f2 100644 >--- a/src/rpms.sh >+++ b/src/rpms.sh >@@ -147,6 +147,7 @@ rlRpmPresent() { > Assertion making sure that a package is installed. > > rlAssertRpm name [version] [release] [arch]> >+ rlAssertRpm --all > > =over > >@@ -166,6 +167,10 @@ Package release like C<55.fc9> > > Package architucture like C<i386> > >+=item --all >+ >+Assert all packages listed in the $PACKAGES $REQUIRES $COLLECTIONS env variables >+ > =back > > Returns 0 and asserts PASS if the specified package is installed. >@@ -173,7 +178,13 @@ Returns 0 and asserts PASS if the specified package is installed. > =cut > > rlAssertRpm() { >- __INTERNAL_RpmPresent assert $1 $2 $3 $4 >+ if [ "$1" = "--all" ] ; then >+ for package in $PACKAGES $REQUIRES $COLLECTIONS ; do >+ rlAssertRpm $package >+ done >+ else >+ __INTERNAL_RpmPresent assert $1 $2 $3 $4 >+ fi > } > > # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >@@ -228,6 +239,96 @@ rlAssertNotRpm() { > __INTERNAL_RpmPresent assert_inverted $1 $2 $3 $4 > } > >+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >+# rlAssertBinaryOrigin >+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >+: <<'=cut' >+=pod >+ >+=head3 rlAssertBinaryOrigin >+ >+Assertion making sure that given binary is owned by (one of) the given package(s). >+ >+ rlAssertBinaryOrigin binary package [package2 [...]] >+ PACKAGES=... rlAssertBinaryOrigin binary >+ >+=over >+ >+=item binary >+ >+Binary name like C<ksh> or C</bin/ksh> >+ >+=item package >+ >+Package name like C<ksh> >+ >+=item $PACKAGES (optional) >+ >+List of packages like C<ksh mksh>. The parameter is not mandatory. If missing, contents of env. variable >+$PACKAGES are taken into account. >+ >+=back >+ >+Returns 0 and asserts PASS if the specified binary belongs to (one of) the given package(s). >+Returns 1 and asserts FAIL if the specified binary does not belong to (any of) the given package(s). >+Returns 2 and asserts FAIL if the specified binary is not found. >+Returns 100 and asserts FAIL if invoked with no parameters >+ >+=head3 Example >+ >+Function C<rlAssertBinaryOrigin> is useful especially in prepare phase >+where it causes abort if a binary is missing or is owned by different package: >+ >+PACKAGES=mksh rlAssertBinaryOrigin ksh >+or >+rlAssertBinaryOrigin ksh mksh >+ >+Returns true if ksh is owned by the mksh package (in this case: /bin/ksh is a symlink pointing to /bin/mksh) >+ >+=cut >+ >+rlAssertBinaryOrigin() { >+ # without parameters, exit immediatelly >+ local status=0 >+ [ $# -eq 0 ] && { >+ status=100 >+ rlLogError "rlAssertBinaryOrigin called without parameters" >+ __INTERNAL_ConditionalAssert "Binary $CMD should belong to one rpm of: $PKGS" $status >+ return $status >+ } >+ >+ CMD=$1 >+ shift >+ >+ # if not given explicitly as param, take PKGS from $PACKAGES >+ local PKGS=$@ >+ [ $# -eq 0 ] && PKGS=$PACKAGES >+ >+ status=2 >+ FULL_CMD=$(which $CMD) &>/dev/null && \ >+ { >+ status=1 >+ # expand symlinks (if any) >+ local BINARY=$(readlink -f $FULL_CMD) >+ >+ # get the rpm owning the binary >+ local BINARY_RPM=$(rpm -qf $BINARY) >+ >+ for rpm in $PKGS ; do >+ local TESTED_RPM=$(rpm -q $rpm) &>/dev/null && \ >+ if [ "$TESTED_RPM" = "$BINARY_RPM" ] ; then >+ status=0 >+ echo $BINARY_RPM >+ break >+ fi >+ done >+ } >+ >+ [ $status -eq 2 ] && rlLogError "$CMD: command not found" >+ >+ __INTERNAL_ConditionalAssert "Binary $CMD should belong to one rpm of: $PKGS" $status >+ return $status >+} > > # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > # AUTHORS >diff --git a/src/test/rpmsTest.sh b/src/test/rpmsTest.sh >index f183202..20fbd6c 100644 >--- a/src/test/rpmsTest.sh >+++ b/src/test/rpmsTest.sh >@@ -43,6 +43,33 @@ test_rlAssertRpm() { > "rlAssertRpm $first_n $first_v $first_r ${first_a}xyz" > > assertGoodBad "rlAssertRpm ahsgqyrg" 0 1 >+ >+ : > $OUTPUTFILE >+ local PACKAGES=$( rpm -qa --qf "%{NAME} " | awk '{ print $1 " " $2 }' ) >+ local PACKAGES2=$PACKAGES >+ local COLLECTIONS=$( rpm -qa --qf "%{NAME} " | awk '{ print $3 " " $4 }' ) >+ local REQUIRES=$( rpm -qa --qf "%{NAME} " | awk '{ print $5 " " $6 }' ) >+ >+ assertTrue "Running rlAssertRpm --all with PACKAGES=$PACKAGES COLLECTIONS=$COLLECTIONS REQUIRES=$REQUIRES" \ >+ "rlAssertRpm --all >$OUTPUTFILE" >+ >+ for pkg in $PACKAGES $COLLECTIONS $REQUIRES ; do >+ assertTrue "Checking log for $pkg" \ >+ "grep -q '$pkg' $OUTPUTFILE" >+ done >+ >+ unset PACKAGES >+ assertTrue "Running rlAssertRpm --all with PACKAGES=$PACKAGES COLLECTIONS=$COLLECTIONS REQUIRES=$REQUIRES" \ >+ "rlAssertRpm --all >$OUTPUTFILE" >+ >+ for pkg in $PACKAGES $COLLECTIONS $REQUIRES ; do >+ assertTrue "Checking log for $pkg" \ >+ "grep -q '$pkg' $OUTPUTFILE" >+ done >+ for pkg in $PACKAGES2 ; do >+ assertFalse "Checking log for not containing $pkg" \ >+ "grep -q '$pkg' $OUTPUTFILE" >+ done > } > > test_rlAssertNotRpm() { >@@ -109,9 +136,45 @@ test_rlCheckRpm() { > assertTrue "Checking log for $first_n" "grep -q '$first_n' $OUTPUTFILE" > > assertGoodBad "rlCheckRpm ahsgqyrg" 0 0 >- > } > > test_rlRpmPresent(){ > assertTrue "rlrpmPresent is reported to be obsoleted" "rlRpmPresent abcdefg 2>&1 >&- |grep -q obsolete" > } >+ >+test_rlAssertBinaryOrigin(){ >+ #existing binary command >+ assertTrue "rlAssertBinaryOrigin returns 0 on existing command owned by the package (param)" \ >+ "rlAssertBinaryOrigin bash bash" >+ >+ #existing binary command >+ assertTrue "rlAssertBinaryOrigin returns 0 on existing command owned by the package (env)" \ >+ "PACKAGES='bash' rlAssertBinaryOrigin bash" >+ >+ #existing binary command in more packages >+ assertTrue "rlAssertBinaryOrigin returns 0 on existing command owned by one of the packages" \ >+ "rlAssertBinaryOrigin bash bash ksh pdksh" >+ >+ #existing binary full path >+ assertTrue "rlAssertBinaryOrigin returns 0 on existing full path command owned by the package" \ >+ "rlAssertBinaryOrigin /bin/bash bash" >+ >+ #exisiting alternative >+ local PKG=$(rpm -qf $( ls -l $( ls -l /usr/bin | grep alternatives | head -n1 | awk '{ print $NF }' ) | awk '{ print $NF }' )) >+ local BIN=$( ls -l /usr/bin | grep alternatives | head -n1 | awk '{ print $9 }' ) >+ assertTrue "rlAssertBinaryOrigin returns 0 on existing alternative command owned by the packages" \ >+ "rlAssertBinaryOrigin $BIN $PKG" >+ >+ #binary not in package >+ assertRun "rlAssertBinaryOrigin bash glibc" 1 \ >+ "rlAssertBinaryOrigin returns 1 on existing full path command owned by different package" >+ #non-existing package >+ assertRun "rlAssertBinaryOrigin bash rpm-not-found" 1 \ >+ "rlAssertBinaryOrigin returns 1 on non-existing package" >+ #non-existing binary >+ assertRun "rlAssertBinaryOrigin command-not-found bash" 2 \ >+ "rlAssertBinaryOrigin returns 2 on non-existing command" >+ #no params >+ assertRun "rlAssertBinaryOrigin" 100 \ >+ "rlAssertBinaryOrigin returns 100 when invoked without parameters" >+} >-- >1.8.1.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 910757
:
697868
|
699387
|
699498
|
699499
|
700562
|
702794
| 704988