public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Ulf Hermann <ulf.hermann@qt.io>
To: <elfutils-devel@sourceware.org>
Subject: [PATCH] Have diff ignore line ending differences when testing
Date: Thu, 04 May 2017 10:55:00 -0000	[thread overview]
Message-ID: <4541dccb-3392-c1cf-f939-16ddb84b1686@qt.io> (raw)

This accounts for the CR/LF problem we get when producing text files on
windows.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
 tests/ChangeLog             | 7 +++++++
 tests/run-addr2line-test.sh | 8 ++++----
 tests/run-readelf-test1.sh  | 2 +-
 tests/run-unstrip-n.sh      | 2 +-
 tests/test-subr.sh          | 2 +-
 5 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/tests/ChangeLog b/tests/ChangeLog
index b091ae0..5616c74 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,5 +1,12 @@
 2017-05-04  Ulf Hermann  <ulf.hermann@qt.io>
 
+	* run-addr2line-test.sh: Add --strip-trailing-cr option to diff.
+	* run-readelf-test1.sh: Likewise.
+	* run-unstrip-n.sh: Likewise.
+	* test-subr.sh: Likewise.
+
+2017-05-04  Ulf Hermann  <ulf.hermann@qt.io>
+
 	* alldts.c: Open files in O_BINARY.
 	* allfcts.c: Likewise.
 	* arextract.c: Likewise.
diff --git a/tests/run-addr2line-test.sh b/tests/run-addr2line-test.sh
index 1079c3e..0dae42d 100755
--- a/tests/run-addr2line-test.sh
+++ b/tests/run-addr2line-test.sh
@@ -56,7 +56,7 @@ EOF
 
 echo "# Everything from stdin (with newlines)."
 cat stdin.nl | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1
-cmp good.out stdin.nl.out || exit 1
+diff --strip-trailing-cr good.out stdin.nl.out || exit 1
 
 cat > foo.out <<\EOF
 foo
@@ -65,11 +65,11 @@ EOF
 
 echo "# stdin without newline address, just EOF."
 echo -n "0x08048468" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nonl.out || exit 1
-cmp foo.out stdin.nonl.out || exit 1
+diff --strip-trailing-cr foo.out stdin.nonl.out || exit 1
 
 echo "# stdin without newline symbol, just EOF."
 echo -n "foo" | testrun ${abs_top_builddir}/src/addr2line -f -e testfile > stdin.nl.out || exit 1
-cmp foo.out stdin.nonl.out || exit 1
+diff --strip-trailing-cr foo.out stdin.nonl.out || exit 1
 
 tempfiles good.addr.out
 
@@ -105,7 +105,7 @@ cat good.addr.out | testrun_compare ${abs_top_builddir}/src/addr2line -a -f -e t
 
 echo "# Everything from stdin (with newlines) with addresses."
 cat stdin.nl | testrun ${abs_top_builddir}/src/addr2line -a -f -e testfile > stdin.nl.out || exit 1
-cmp good.addr.out stdin.nl.out || exit 1
+diff --strip-trailing-cr good.addr.out stdin.nl.out || exit 1
 
 echo "# Pretty with functions and addresses."
 testrun_compare ${abs_top_builddir}/src/addr2line --pretty -a -f -e testfile 0x08048468 0x0804845c << EOF
diff --git a/tests/run-readelf-test1.sh b/tests/run-readelf-test1.sh
index 4725049..40b664f 100755
--- a/tests/run-readelf-test1.sh
+++ b/tests/run-readelf-test1.sh
@@ -28,7 +28,7 @@ tempfiles testfile.temp
 
 testrun ${abs_top_builddir}/src/readelf -r testfile3 > testfile.temp
 
-diff -u - testfile.temp <<EOF
+diff -u --strip-trailing-cr - testfile.temp <<EOF
 
 Relocation section [ 8] '.rel.got' for section [19] '.got' at offset 0x294 contains 1 entry:
   Offset      Type                 Value       Name
diff --git a/tests/run-unstrip-n.sh b/tests/run-unstrip-n.sh
index 37cbd60..f90f9d5 100755
--- a/tests/run-unstrip-n.sh
+++ b/tests/run-unstrip-n.sh
@@ -65,7 +65,7 @@ testrun_out $outfile ${abs_top_builddir}/src/unstrip -n -e test-core.exec --core
 outfile2=test-core.out2
 remove_files="$remove_files $outfile2"
 grep -v libc.so.6 $outfile | sort >$outfile2
-diff -u $outfile2 - <<EOF
+diff -u --strip-trailing-cr $outfile2 - <<EOF
 0x400000+0x202038 - test-core.exec - test-core.exec
 0x7f67f2aaf000+0x202000 - . - /home/jkratoch/redhat/elfutils-libregr/test-core-lib.so
 0x7fff1596c000+0x1000 a9cf37f53897b5468ee018655760be61b8633d3c@0x7fff1596c340 . - linux-vdso.so.1
diff --git a/tests/test-subr.sh b/tests/test-subr.sh
index a765db6..8bea18c 100644
--- a/tests/test-subr.sh
+++ b/tests/test-subr.sh
@@ -64,7 +64,7 @@ testrun_compare()
 {
   outfile="${1##*/}.out"
   testrun_out $outfile "$@"
-  diff -u $outfile -
+  diff -u --strip-trailing-cr $outfile -
   # diff's exit status will kill the script.
 }
 
-- 
2.1.4

                 reply	other threads:[~2017-05-04 10:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=4541dccb-3392-c1cf-f939-16ddb84b1686@qt.io \
    --to=ulf.hermann@qt.io \
    --cc=elfutils-devel@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).