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 700562 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.43 KB, created by
Martin Kyral
on 2013-02-21 14:07:13 UTC
(
hide
)
Description:
proposed patch
Filename:
MIME Type:
Creator:
Martin Kyral
Created:
2013-02-21 14:07:13 UTC
Size:
7.43 KB
patch
obsolete
>From 89ac58a9bb7af328ff066cd085c2881dd40e8979 Mon Sep 17 00:00:00 2001 >From: Martin Kyral <mkyral@redhat.com> >Date: Thu, 21 Feb 2013 15:02:49 +0100 >Subject: [PATCH] beakerlib: Added rlAssertRpm --all and rlAssertBinaryOrigin > >--- > src/rpms.sh | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++- > src/test/rpmsTest.sh | 65 ++++++++++++++++++++++++++++++++ > 2 files changed, 168 insertions(+), 1 deletion(-) > >diff --git a/src/rpms.sh b/src/rpms.sh >index 6819be5..4a0def3 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 >+ >+Check 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,97 @@ rlAssertNotRpm() { > __INTERNAL_RpmPresent assert_inverted $1 $2 $3 $4 > } > >+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >+# rlAssertBinaryOrigin >+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >+: <<'=cut' >+=pod >+ >+=head3 rlAssertNotRpm >+ >+Assertion making sure that given binary is owned by (one of) the given package(s). >+ >+ rlAssertBinaryOrigin binary package [package2 [...]] >+ rlAssertBinaryOrigin binary $PACKAGES >+ >+=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> >+ >+=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 >+ [ $# -eq 0 ] && { >+ status=100 >+ __INTERNAL_ConditionalAssert "Checking if binary $CMD belongs to rpm from: $PKGS" $status >+ return $status >+ } >+ >+ CMD=$1 >+ shift >+ >+ # if not given explicitlyi as param, take PKGS from $PACKAGES >+ local PKGS=$@ >+ [ $# -eq 0 ] && PKGS=$PACKAGES >+ >+ >+ local status=2 >+ which $CMD &>/dev/null && \ >+ { >+ status=1 >+ BINARY=$(ls -l $(which $CMD) | awk '{ print $NF }') >+ >+ # if the binary is a symlink to symlink in /etc/alternatives, we need to expand it to >+ # the real binary >+ echo $BINARY | grep 'alternatives' >/dev/null && \ >+ BINARY=$(ls -l $(echo $BINARY) | awk '{ print $NF }') >+ >+ # get the rpm owning the binary >+ BINARY_RPM=$(rpm -qf $BINARY) >+ >+ for rpm in $PKGS ; do >+ rpm -q $rpm &>/dev/null && \ >+ if [ $(rpm -q $rpm) = "$BINARY_RPM" ] ; then >+ status=0 >+ echo $BINARY_RPM >+ break >+ fi >+ done >+ } >+ [ $status -eq 2 ] && echo "$CMD: command not found" >+ >+ __INTERNAL_ConditionalAssert "Checking if binary $CMD belongs to rpm from: $PKGS" $status >+ return $status >+} > > # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > # AUTHORS >diff --git a/src/test/rpmsTest.sh b/src/test/rpmsTest.sh >index f183202..39c151c 100644 >--- a/src/test/rpmsTest.sh >+++ b/src/test/rpmsTest.sh >@@ -43,6 +43,34 @@ 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() { >@@ -95,6 +123,7 @@ test_rlCheckRpm() { > assertTrue "Checking log for $first_n" \ > "grep -q '$first_n' $OUTPUTFILE" > >+ > assertRun "rlCheckRpm" 100 "rlCheckRpm returns non-0 when run without parameters" > > : > $OUTPUTFILE >@@ -115,3 +144,39 @@ test_rlCheckRpm() { > test_rlRpmPresent(){ > assertTrue "rlrpmPresent is reported to be obsoleted" "rlRpmPresent abcdefg 2>&1 >&- |grep -q obsolete" > } >+ >+test_rlAssertBinaryOrigin(){ >+ : > $OUTPUTFILE >+ >+ #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-exisitng 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.2 >
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