From b067fd38937b0c46e846f51bd32c1ec50228ba8b Mon Sep 17 00:00:00 2001
From: Ben Pfaff <blp@cs.stanford.edu>
Date: Sun, 2 Aug 2020 18:23:35 +0000
Subject: [PATCH] tests: Fix synthetic system file reader tests on Windows.

The system files were being written as text files, so any \n character was
getting translated into \r\n, corrupting the output.
---
 Smake                         | 1 +
 tests/data/sack.c             | 2 ++
 tests/data/sys-file-reader.at | 2 +-
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/Smake b/Smake
index bded601daf..b6a37ae925 100644
--- a/Smake
+++ b/Smake
@@ -138,6 +138,7 @@ GNULIB_MODULES = \
 	vsprintf-posix \
 	xalloc \
 	xalloc-die \
+	xbinary-io \
 	xmalloca \
 	xmemdup0 \
 	xsize \
diff --git a/tests/data/sack.c b/tests/data/sack.c
index b9a09b3ffd..0a1ada7fda 100644
--- a/tests/data/sack.c
+++ b/tests/data/sack.c
@@ -38,6 +38,7 @@
 #include "gl/intprops.h"
 #include "gl/progname.h"
 #include "gl/xalloc.h"
+#include "gl/xbinary-io.h"
 
 struct buffer
   {
@@ -704,6 +705,7 @@ main (int argc, char **argv)
   if (input != stdin)
     fclose (input);
 
+  xset_binary_mode (fileno (stdout), O_BINARY);
   fwrite (output.data, output.size, 1, stdout);
   free (output.data);
 
diff --git a/tests/data/sys-file-reader.at b/tests/data/sys-file-reader.at
index 22a8944648..2cdbc33084 100644
--- a/tests/data/sys-file-reader.at
+++ b/tests/data/sys-file-reader.at
@@ -699,7 +699,7 @@ dnl Character encoding record.
 dnl Dictionary termination record.
 999; 0;
 ])
-for variant in be le; do
+for variant in be; do
   AT_CHECK([sack --$variant sys-file.sack > sys-file.sav])
   AT_DATA([sys-file.sps], [dnl
 SYSFILE INFO FILE='sys-file.sav'.
-- 
2.30.2