[libvirt] [TCK][PATCH] Remove whitespace differences in network tmp files

The network/100-apply-verify-host.t test compares the results of various network commands (route, iptables, ebtables, etc...) against known, valid results. Depending on the versions of these tools, minor whitespace differences in command output can result in the failure of the test. This patch resolves the problem by removing trailing spaces and replacing three or more concurrent spaces with just two. These changes are only made to the temporary files involved with the tests. --- scripts/networks/networkApplyTest.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/networks/networkApplyTest.sh b/scripts/networks/networkApplyTest.sh index 3e93c0a..924130f 100644 --- a/scripts/networks/networkApplyTest.sh +++ b/scripts/networks/networkApplyTest.sh @@ -142,6 +142,11 @@ checkExpectedOutput() { break fi + # Remove trailing whitespace, replace multiple spaces with just two + for file in ${tmpfile} ${tmpfile2}; do + sed -i -e 's/ *$//' -e 's/ */ /g' $file + done + diff "${tmpfile}" "${tmpfile2}" >/dev/null if [ $? -ne 0 ]; then -- 1.8.4.5

On 03/24/2014 10:42 AM, Mike Latimer wrote:
The network/100-apply-verify-host.t test compares the results of various network commands (route, iptables, ebtables, etc...) against known, valid results. Depending on the versions of these tools, minor whitespace differences in command output can result in the failure of the test. This patch resolves the problem by removing trailing spaces and replacing three or more concurrent spaces with just two. These changes are only made to the temporary files involved with the tests.
--- scripts/networks/networkApplyTest.sh | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/scripts/networks/networkApplyTest.sh b/scripts/networks/networkApplyTest.sh index 3e93c0a..924130f 100644 --- a/scripts/networks/networkApplyTest.sh +++ b/scripts/networks/networkApplyTest.sh @@ -142,6 +142,11 @@ checkExpectedOutput() { break fi
+ # Remove trailing whitespace, replace multiple spaces with just two + for file in ${tmpfile} ${tmpfile2}; do + sed -i -e 's/ *$//' -e 's/ */ /g' $file
'sed -i' is not portable (it is a GNU-ism) - but it's not the first time we've assumed GNU tools in this testsuite so I can overlook it. Your code does not quite match your commit comment. The first -e says to remove trailing spaces; the second -e says to replace all runs of 1 or more space with 2 spaces. You MEANT to use 's/ */ /g' for the second expression. ACK with that fix, and pushed. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Monday, March 24, 2014 02:24:23 PM Eric Blake wrote:
'sed -i' is not portable (it is a GNU-ism) - but it's not the first time we've assumed GNU tools in this testsuite so I can overlook it.
Ok. I'll keep that in mind in the future. If you'd rather the -i not be used, it's easy enough to code around. Let me know if you want such a patch.
Your code does not quite match your commit comment. The first -e says to remove trailing spaces; the second -e says to replace all runs of 1 or more space with 2 spaces. You MEANT to use 's/ */ /g' for the second expression. ACK with that fix, and pushed.
Thanks for that fix as well. I did indeed mean to have three spaces before the *. :) -Mike
participants (2)
-
Eric Blake
-
Mike Latimer