commit fcac396517b8d227e602870060f43180d5715249
Author: Isuru Fernando <isuruf@gmail.com>
Date:   Sun Sep 23 13:44:46 2018 -0500

    Ignore CR in diff tests

diff --git a/config/hwloc_internal.m4 b/config/hwloc_internal.m4
index 24aee29a..3f60f2c4 100644
--- a/config/hwloc_internal.m4
+++ b/config/hwloc_internal.m4
@@ -316,6 +316,7 @@ EOF
 
     _HWLOC_CHECK_DIFF_U
     _HWLOC_CHECK_DIFF_W
+    _HWLOC_CHECK_DIFF_STRIP_TRAILING_CR
 
     AC_CHECK_HEADERS([time.h], [
       AC_CHECK_FUNCS([clock_gettime])
@@ -387,6 +388,7 @@ int foo(void) {
     AC_MSG_RESULT([$hwloc_have_cxx])
 
     _HWLOC_CHECK_DIFF_U
+    _HWLOC_CHECK_DIFF_STRIP_TRAILING_CR
 
     # Only generate these files if we're making the tests
     AC_CONFIG_FILES(
@@ -484,6 +486,19 @@ AC_DEFUN([_HWLOC_CHECK_DIFF_U], [
   AC_SUBST([HWLOC_DIFF_U])
 ])
 
+AC_DEFUN([_HWLOC_CHECK_DIFF_STRIP_TRAILING_CR], [
+  AC_MSG_CHECKING([whether diff accepts --strip-trailing-cr])
+  if diff --strip-trailing-cr /dev/null /dev/null 2> /dev/null
+  then
+    AC_MSG_RESULT([yes])
+    HWLOC_DIFF_STRIP_TRAILING_CR="--strip-trailing-cr"
+  else
+    AC_MSG_RESULT([no])
+    HWLOC_DIFF_STRIP_TRAILING_CR=""
+  fi
+  AC_SUBST([HWLOC_DIFF_STRIP_TRAILING_CR])
+])
+
 AC_DEFUN([_HWLOC_CHECK_DIFF_W], [
   AC_MSG_CHECKING([whether diff accepts -w])
   if diff -w /dev/null /dev/null 2> /dev/null
diff --git a/tests/hwloc/linux/allowed/test-topology.sh.in b/tests/hwloc/linux/allowed/test-topology.sh.in
index 4d67fc4d..f14e508a 100644
--- a/tests/hwloc/linux/allowed/test-topology.sh.in
+++ b/tests/hwloc/linux/allowed/test-topology.sh.in
@@ -73,7 +73,7 @@ test_topology ()
     else
 	if [ "$HWLOC_UPDATE_TEST_TOPOLOGY_OUTPUT" != 1 ]
 	then
-	    diff @HWLOC_DIFF_U@ -b "$expected_output" "$output"
+	    diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ -b "$expected_output" "$output"
 	    result=$?
 	else
 	    if ! diff "$expected_output" "$output" >/dev/null
diff --git a/tests/hwloc/linux/test-topology.sh.in b/tests/hwloc/linux/test-topology.sh.in
index cc094aa6..263152e3 100644
--- a/tests/hwloc/linux/test-topology.sh.in
+++ b/tests/hwloc/linux/test-topology.sh.in
@@ -65,7 +65,7 @@ test_topology ()
     else
 	if [ "$HWLOC_UPDATE_TEST_TOPOLOGY_OUTPUT" != 1 ]
 	then
-	    diff @HWLOC_DIFF_U@ -b "$expected_output" "$output"
+	    diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ -b "$expected_output" "$output"
 	    result=$?
 	else
 	    if ! diff "$expected_output" "$output" >/dev/null
diff --git a/tests/hwloc/x86/test-topology.sh.in b/tests/hwloc/x86/test-topology.sh.in
index bfad8afa..08610ecb 100644
--- a/tests/hwloc/x86/test-topology.sh.in
+++ b/tests/hwloc/x86/test-topology.sh.in
@@ -61,7 +61,7 @@ test_topology ()
     else
 	if [ "$HWLOC_UPDATE_TEST_TOPOLOGY_OUTPUT" != 1 ]
 	then
-	    diff -b @HWLOC_DIFF_U@ "$expected_output" "$output"
+	    diff -b @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ "$expected_output" "$output"
 	    result=$?
 	else
 	    if ! diff "$expected_output" "$output" >/dev/null
diff --git a/tests/hwloc/xml/test-topology.sh.in b/tests/hwloc/xml/test-topology.sh.in
index b87d295f..6bffedd0 100644
--- a/tests/hwloc/xml/test-topology.sh.in
+++ b/tests/hwloc/xml/test-topology.sh.in
@@ -85,7 +85,7 @@ do_run()
 
   if [ "$HWLOC_UPDATE_TEST_TOPOLOGY_OUTPUT" != 1 ]
   then
-    diff @HWLOC_DIFF_U@ @HWLOC_DIFF_W@ "$output" "$file"
+    diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ @HWLOC_DIFF_W@ "$output" "$file"
   else
     if ! diff "$output" "$file" >/dev/null
     then
@@ -110,7 +110,7 @@ do_run_with_output()
 
   if [ "$HWLOC_UPDATE_TEST_TOPOLOGY_OUTPUT" != 1 ]
   then
-    diff @HWLOC_DIFF_U@ @HWLOC_DIFF_W@ "$output" "$file"
+    diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ @HWLOC_DIFF_W@ "$output" "$file"
   else
     if ! diff "$output" "$file" >/dev/null
     then
diff --git a/utils/hwloc/test-hwloc-annotate.sh.in b/utils/hwloc/test-hwloc-annotate.sh.in
index eaf08933..8b03869f 100644
--- a/utils/hwloc/test-hwloc-annotate.sh.in
+++ b/utils/hwloc/test-hwloc-annotate.sh.in
@@ -68,5 +68,5 @@ pu:1
 EOF
 $annotate $file $file dummy distances $distances
 
-diff @HWLOC_DIFF_U@ $srcdir/test-hwloc-annotate.output "$file"
+diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ $srcdir/test-hwloc-annotate.output "$file"
 rm -rf "$tmp"
diff --git a/utils/hwloc/test-hwloc-calc.sh.in b/utils/hwloc/test-hwloc-calc.sh.in
index 3d604d90..da6482c7 100644
--- a/utils/hwloc/test-hwloc-calc.sh.in
+++ b/utils/hwloc/test-hwloc-calc.sh.in
@@ -103,5 +103,5 @@ node:0 node:3
 root
 EOF
 ) > "$file"
-diff @HWLOC_DIFF_U@ $srcdir/test-hwloc-calc.output "$file"
+diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ $srcdir/test-hwloc-calc.output "$file"
 rm -rf "$tmp"
diff --git a/utils/hwloc/test-hwloc-compress-dir.sh.in b/utils/hwloc/test-hwloc-compress-dir.sh.in
index b50fa79c..9ffe4538 100644
--- a/utils/hwloc/test-hwloc-compress-dir.sh.in
+++ b/utils/hwloc/test-hwloc-compress-dir.sh.in
@@ -46,10 +46,10 @@ set -e
 
 $compress "$tmp/test-hwloc-compress-dir.input" "$tmp/test-hwloc-compress-dir.newoutput"
 
-diff @HWLOC_DIFF_U@ -r "$tmp/test-hwloc-compress-dir.output" "$tmp/test-hwloc-compress-dir.newoutput"
+diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ -r "$tmp/test-hwloc-compress-dir.output" "$tmp/test-hwloc-compress-dir.newoutput"
 
 $compress -R "$tmp/test-hwloc-compress-dir.newoutput" "$tmp/test-hwloc-compress-dir.newoutput2"
 
-diff @HWLOC_DIFF_U@ -r "$tmp/test-hwloc-compress-dir.input" "$tmp/test-hwloc-compress-dir.newoutput2"
+diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ -r "$tmp/test-hwloc-compress-dir.input" "$tmp/test-hwloc-compress-dir.newoutput2"
 
 rm -rf "$tmp"
diff --git a/utils/hwloc/test-hwloc-diffpatch.sh.in b/utils/hwloc/test-hwloc-diffpatch.sh.in
index efc8daf6..b9e5e2df 100644
--- a/utils/hwloc/test-hwloc-diffpatch.sh.in
+++ b/utils/hwloc/test-hwloc-diffpatch.sh.in
@@ -52,8 +52,8 @@ cp $srcdir/test-hwloc-diffpatch.input1 .
 cat $diffoutput | $patch refname - $output1
 $patch -R $srcdir/test-hwloc-diffpatch.input2 $diffoutput $output2
 
-diff -u $srcdir/test-hwloc-diffpatch.input1 "$output2"
-diff -u $srcdir/test-hwloc-diffpatch.input2 "$output1"
+diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@  $srcdir/test-hwloc-diffpatch.input1 "$output2"
+diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@  $srcdir/test-hwloc-diffpatch.input2 "$output1"
 
 cd ..
 rm -rf "$tmp"
diff --git a/utils/hwloc/test-hwloc-distrib.sh.in b/utils/hwloc/test-hwloc-distrib.sh.in
index 67ffc1bb..6d7a6abc 100644
--- a/utils/hwloc/test-hwloc-distrib.sh.in
+++ b/utils/hwloc/test-hwloc-distrib.sh.in
@@ -69,5 +69,5 @@ set -e
   $distrib --if synthetic --input "2 2 2 2" --to core 9
   echo
 ) > "$file"
-diff @HWLOC_DIFF_U@ $srcdir/test-hwloc-distrib.output "$file"
+diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ $srcdir/test-hwloc-distrib.output "$file"
 rm -rf "$tmp"
diff --git a/utils/hwloc/test-hwloc-dump-hwdata/test-hwloc-dump-hwdata.sh.in b/utils/hwloc/test-hwloc-dump-hwdata/test-hwloc-dump-hwdata.sh.in
index 0654f6b8..621b1994 100644
--- a/utils/hwloc/test-hwloc-dump-hwdata/test-hwloc-dump-hwdata.sh.in
+++ b/utils/hwloc/test-hwloc-dump-hwdata/test-hwloc-dump-hwdata.sh.in
@@ -33,6 +33,6 @@ export HWLOC_FSROOT
 
 $hdhd -o $tmp/output
 
-diff @HWLOC_DIFF_U@ -r "$HWLOC_FSROOT/expected_output" "$tmp/output"
+diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ -r "$HWLOC_FSROOT/expected_output" "$tmp/output"
 
 rm -rf "$tmp"
diff --git a/utils/hwloc/test-hwloc-info.sh.in b/utils/hwloc/test-hwloc-info.sh.in
index 298f8cf8..f5fd7cc9 100644
--- a/utils/hwloc/test-hwloc-info.sh.in
+++ b/utils/hwloc/test-hwloc-info.sh.in
@@ -64,5 +64,5 @@ set -e
  > "$file"
 # filtered hwlocVersion since it often changes
 # filtered ProcessName since it may be hwloc-info or lt-hwloc-info
-diff @HWLOC_DIFF_U@ $srcdir/test-hwloc-info.output "$file"
+diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ $srcdir/test-hwloc-info.output "$file"
 rm -rf "$tmp"
diff --git a/utils/lstopo/test-lstopo.sh.in b/utils/lstopo/test-lstopo.sh.in
index deff4efc..be5c05a2 100644
--- a/utils/lstopo/test-lstopo.sh.in
+++ b/utils/lstopo/test-lstopo.sh.in
@@ -60,5 +60,5 @@ $ls
   $ls --export-xml-flags 1 -f $tmp/test.v1.xml
   $ls --input "pa:1 no:2 co:1 l2:2 2" $tmp/test.synthetic
 ) > "$file"
-diff @HWLOC_DIFF_U@ $srcdir/test-lstopo.output "$file"
+diff @HWLOC_DIFF_U@ @HWLOC_DIFF_STRIP_TRAILING_CR@ $srcdir/test-lstopo.output "$file"
 rm -rf "$tmp"
