testsuite: use binary output mode for custom curl test tools

Do not try to convert line-endings to CRLF on Windows by setting stdout
to binary mode, just like the curl tool does if --ascii is not specified.

This should prevent corrupted stdout line-ending output like CRCRLF.

In order to make the previously naive text-aware tests work with
binary mode on Windows, text-mode is disabled for them if it is not
actually part of the test case and line-endings are corrected.
This commit is contained in:
Marc Hoersken
2014-02-01 00:58:58 +01:00
parent 69745aaa45
commit 75f00de55c
41 changed files with 232 additions and 216 deletions

View File

@@ -24,7 +24,7 @@ http://%HOSTIP:%HTTPPORT/path/1508
# Verify data after the test has been "shot" # Verify data after the test has been "shot"
<verify> <verify>
<file name="log/stdout1508" mode="text"> <file name="log/stdout1508">
We are done We are done
</file> </file>
</verify> </verify>

View File

@@ -9,7 +9,7 @@ multi
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
Adding handle 0 Adding handle 0
Handle 0 Completed with status 0 Handle 0 Completed with status 0
Adding handle 1 Adding handle 1

View File

@@ -9,7 +9,7 @@ multi
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
Adding handle 0 Adding handle 0
Handle 0 Completed with status 0 Handle 0 Completed with status 0
Adding handle 1 Adding handle 1

View File

@@ -9,7 +9,7 @@ multi
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
Adding handle 0 Adding handle 0
Handle 0 Completed with status 0 Handle 0 Completed with status 0
Adding handle 1 Adding handle 1

View File

@@ -9,7 +9,7 @@ multi
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
Adding handle 0 Adding handle 0
Handle 0 Completed with status 0 Handle 0 Completed with status 0
Adding handle 1 Adding handle 1

View File

@@ -8,7 +8,7 @@ HTTP GET
# #
# Server-side # Server-side
<reply name="1"> <reply name="1">
<data mode="text"> <data>
HTTP/1.1 200 OK HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake Server: test-server/fake
@@ -45,7 +45,7 @@ http://%HOSTIP:%HTTPPORT/500 log/ip500
# #
# Verify data after the test has been "shot" # Verify data after the test has been "shot"
<verify> <verify>
<file name="log/ip500" mode="text"> <file name="log/ip500">
IP: %HOSTIP IP: %HOSTIP
</file> </file>
<protocol> <protocol>

View File

@@ -7,7 +7,7 @@ FILE
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
foo foo
bar swsclose bar swsclose
bar bar

View File

@@ -72,7 +72,7 @@ http://%HOSTIP:%HTTPPORT/506
# Verify data after the test has been "shot" # Verify data after the test has been "shot"
<verify> <verify>
<stdout mode="text"> <stdout>
GLOBAL_INIT GLOBAL_INIT
SHARE_INIT SHARE_INIT
CURLSHOPT_LOCKFUNC CURLSHOPT_LOCKFUNC

View File

@@ -2,7 +2,7 @@
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 200 OK HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake swsclose Server: test-server/fake swsclose

View File

@@ -28,7 +28,7 @@ nothing
# #
# Verify data after the test has been "shot" # Verify data after the test has been "shot"
<verify> <verify>
<stdout mode="text"> <stdout>
seen custom_calloc() seen custom_calloc()
seen custom_malloc() seen custom_malloc()
seen custom_realloc() seen custom_realloc()

View File

@@ -9,7 +9,7 @@ HTTP POST
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 200 OK HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake swsclose Server: test-server/fake swsclose

View File

@@ -9,7 +9,7 @@ HTTP GET
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 200 OK swsclose HTTP/1.1 200 OK swsclose
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: yes Server: yes

View File

@@ -8,7 +8,7 @@ HTTP HEAD
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 200 OK HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake Server: test-server/fake

View File

@@ -8,7 +8,7 @@ HTTP POST
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 200 OK swsclose HTTP/1.1 200 OK swsclose
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake Server: test-server/fake

View File

@@ -9,7 +9,7 @@ HTTP POST
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 200 OK swsclose HTTP/1.1 200 OK swsclose
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake Server: test-server/fake

View File

@@ -25,7 +25,7 @@ nothing
# #
# Verify data after the test has been "shot" # Verify data after the test has been "shot"
<verify> <verify>
<stdout mode="text"> <stdout>
0: Sun, 06 Nov 1994 08:49:37 GMT => 784111777 0: Sun, 06 Nov 1994 08:49:37 GMT => 784111777
1: Sunday, 06-Nov-94 08:49:37 GMT => 784111777 1: Sunday, 06-Nov-94 08:49:37 GMT => 784111777
2: Sun Nov 6 08:49:37 1994 => 784111777 2: Sun Nov 6 08:49:37 1994 => 784111777

View File

@@ -9,7 +9,7 @@ HTTP GET
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 200 OK swsbounce HTTP/1.1 200 OK swsbounce
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake Server: test-server/fake

View File

@@ -53,7 +53,7 @@ Host: %HOSTIP:%HTTPPORT
Accept: */* Accept: */*
</protocol> </protocol>
<stdout mode="text"> <stdout>
hello hello
</stdout> </stdout>
</verify> </verify>

View File

@@ -57,7 +57,7 @@ Accept: */*
Proxy-Connection: Keep-Alive Proxy-Connection: Keep-Alive
</protocol> </protocol>
<stdout mode="text"> <stdout>
hello hello
</stdout> </stdout>
</verify> </verify>

View File

@@ -8,7 +8,7 @@ multi
</info> </info>
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 404 Badness HTTP/1.1 404 Badness
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
ETag: "21025-dc7-39462498" ETag: "21025-dc7-39462498"

View File

@@ -9,7 +9,7 @@ multi
</info> </info>
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 404 Badness HTTP/1.1 404 Badness
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
ETag: "21025-dc7-39462498" ETag: "21025-dc7-39462498"

View File

@@ -8,7 +8,7 @@ FTP
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
file contents file contents
</data> </data>

View File

@@ -28,7 +28,7 @@ curl_easy_escape
# There's no MTDM in the protocol here since this code doesn't ask for the # There's no MTDM in the protocol here since this code doesn't ask for the
# time/date of the file # time/date of the file
<verify> <verify>
<stdout mode="text"> <stdout>
%9C%26K%3DI%04%A1%01%E0%D8%7C%20%B7%EFS%29%FA%1DW%E1 %9C%26K%3DI%04%A1%01%E0%D8%7C%20%B7%EFS%29%FA%1DW%E1
</stdout> </stdout>
</verify> </verify>

View File

@@ -9,7 +9,7 @@ HTTP POST
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 200 OK swsclose HTTP/1.1 200 OK swsclose
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake Server: test-server/fake

Binary file not shown.

View File

@@ -58,7 +58,7 @@ Accept: */*
Proxy-Connection: Keep-Alive Proxy-Connection: Keep-Alive
</protocol> </protocol>
<stdout mode="text"> <stdout>
hello hello
</stdout> </stdout>
</verify> </verify>

View File

@@ -58,7 +58,7 @@ Accept: */*
Proxy-Connection: Keep-Alive Proxy-Connection: Keep-Alive
</protocol> </protocol>
<stdout mode="text"> <stdout>
hello hello
</stdout> </stdout>
</verify> </verify>

View File

@@ -9,7 +9,7 @@ HTTP POST
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 200 OK HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake swsclose Server: test-server/fake swsclose

View File

@@ -25,7 +25,7 @@ nothing
# #
# Verify data after the test has been "shot" # Verify data after the test has been "shot"
<verify> <verify>
<stdout mode="text"> <stdout>
All curl_mprintf() unsigned short tests OK! All curl_mprintf() unsigned short tests OK!
All curl_mprintf() signed short tests OK! All curl_mprintf() signed short tests OK!
All curl_mprintf() unsigned int tests OK! All curl_mprintf() unsigned int tests OK!

View File

@@ -34,7 +34,7 @@ nothing
# #
# Verify data after the test has been "shot" # Verify data after the test has been "shot"
<verify> <verify>
<file name="log/memdump" mode="text"> <file name="log/memdump">
MEM lib558.c: malloc() MEM lib558.c: malloc()
MEM lib558.c: free() MEM lib558.c: free()
MEM escape.c: malloc() MEM escape.c: malloc()

View File

@@ -59,7 +59,7 @@ Accept: */*
Proxy-Connection: Keep-Alive Proxy-Connection: Keep-Alive
</protocol> </protocol>
<stdout mode="text"> <stdout>
hello hello
</stdout> </stdout>
</verify> </verify>

View File

@@ -8,7 +8,7 @@ HTTP GET
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 200 OK HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake Server: test-server/fake
@@ -44,7 +44,7 @@ http://%HOSTIP:%HTTPPORT/566 log/ip566
# #
# Verify data after the test has been "shot" # Verify data after the test has been "shot"
<verify> <verify>
<file name="log/ip566" mode="text"> <file name="log/ip566">
CL: 0 CL: 0
</file> </file>
<protocol> <protocol>

View File

@@ -83,7 +83,7 @@ rtsp://%HOSTIP:%RTSPPORT/571 log/protofile.txt
</client> </client>
<verify> <verify>
<stdout mode="text"> <stdout>
RTP: message size 10, channel 1 RTP: message size 10, channel 1
RTP: message size 500, channel 0 RTP: message size 500, channel 0
RTP: message size 196, channel 0 RTP: message size 196, channel 0

View File

@@ -82,7 +82,7 @@ EPSV
RETR someothertext.txt RETR someothertext.txt
QUIT QUIT
</protocol> </protocol>
<stdout mode="text"> <stdout>
This file should have permissions 444 This file should have permissions 444
This file should have permissions 666 This file should have permissions 666
This file should have permissions 777 This file should have permissions 777

View File

@@ -100,7 +100,7 @@ EPSV
RETR someothertext.txt RETR someothertext.txt
QUIT QUIT
</protocol> </protocol>
<stdout mode="text"> <stdout>
This file should have permissions 444 This file should have permissions 444
This file should have permissions 666 This file should have permissions 666
This file should have permissions 777 This file should have permissions 777

View File

@@ -34,7 +34,7 @@ ftp://%HOSTIP:%FTPPORT/fully_simulated/UNIX/*
<errorcode> <errorcode>
0 0
</errorcode> </errorcode>
<stdout mode="text"> <stdout>
============================================================= =============================================================
Remains: 14 Remains: 14
Filename: . Filename: .

View File

@@ -8,7 +8,7 @@ HTTP POST
# #
# Server-side # Server-side
<reply name="1"> <reply name="1">
<data mode="text"> <data>
HTTP/1.1 200 OK HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Server: test-server/fake Server: test-server/fake
@@ -45,7 +45,7 @@ http://%HOSTIP:%HTTPPORT/500 log/ip578
# #
# Verify data after the test has been "shot" # Verify data after the test has been "shot"
<verify> <verify>
<file name="log/ip578" mode="text"> <file name="log/ip578">
PASSED, UL data matched data size PASSED, UL data matched data size
</file> </file>
</verify> </verify>

View File

@@ -72,7 +72,7 @@ http://%HOSTIP:%HTTPPORT/579 log/ip579
# #
# Verify data after the test has been "shot" # Verify data after the test has been "shot"
<verify> <verify>
<file name="log/ip579" mode="text"> <file name="log/ip579">
Progress callback called with UL 0 out of 0 Progress callback called with UL 0 out of 0
Progress callback called with UL 0 out of -1 Progress callback called with UL 0 out of -1
Progress callback called with UL 8 out of -1 Progress callback called with UL 8 out of -1

View File

@@ -76,7 +76,7 @@ Host: %HOSTIP:%HTTPPORT
Accept: */* Accept: */*
</protocol> </protocol>
<stdout mode="text"> <stdout>
HTTP/1.1 200 OK HTTP/1.1 200 OK
Server: test-server/fake Server: test-server/fake
Content-Length: 4 Content-Length: 4

View File

@@ -12,7 +12,7 @@ curl_easy_reset
# #
# Server-side # Server-side
<reply> <reply>
<data mode="text"> <data>
HTTP/1.1 200 OK HTTP/1.1 200 OK
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Content-Length: 6 Content-Length: 6

View File

@@ -22,7 +22,15 @@
#include "test.h" #include "test.h"
#ifdef HAVE_LOCALE_H #ifdef HAVE_LOCALE_H
#include <locale.h> /* for setlocale() */ # include <locale.h> /* for setlocale() */
#endif
#ifdef HAVE_IO_H
# include <io.h> /* for setmode() */
#endif
#ifdef HAVE_FCNTL_H
# include <fcntl.h> /* for setmode() */
#endif #endif
#ifdef CURLDEBUG #ifdef CURLDEBUG
@@ -98,6 +106,14 @@ int main(int argc, char **argv)
{ {
char *URL; char *URL;
#ifdef O_BINARY
# ifdef __HIGHC__
_setmode(stdout, O_BINARY);
# else
setmode(fileno(stdout), O_BINARY);
# endif
#endif
memory_tracking_init(); memory_tracking_init();
/* /*