1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

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,18 +8,18 @@ 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
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498" ETag: "21025-dc7-39462498"
Accept-Ranges: bytes Accept-Ranges: bytes
Content-Length: 6 Content-Length: 6
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
Funny-head: yesyes Funny-head: yesyes
-foo- -foo-
</data> </data>
</reply> </reply>
@ -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,13 +2,13 @@
# #
# 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
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
hello hello
</data> </data>
</reply> </reply>

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,13 +9,13 @@ 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
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
hello hello
</data> </data>
</reply> </reply>

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,18 +8,18 @@ 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
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498" ETag: "21025-dc7-39462498"
Accept-Ranges: bytes Accept-Ranges: bytes
Content-Length: 6 Content-Length: 6
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
Funny-head: yesyes Funny-head: yesyes
</data> </data>
</reply> </reply>

View File

@ -8,12 +8,12 @@ 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
Content-Length: 3 Content-Length: 3
OK OK
</data> </data>
</reply> </reply>

View File

@ -9,12 +9,12 @@ 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
Content-Length: 3 Content-Length: 3
OK OK
</data> </data>
</reply> </reply>

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,34 +9,34 @@ 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
Content-Length: 8 Content-Length: 8
content content
</data> </data>
<data1> <data1>
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
Content-Length: 9 Content-Length: 9
content2 content2
</data1> </data1>
<datacheck> <datacheck>
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
Content-Length: 8 Content-Length: 8
content content
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
Content-Length: 9 Content-Length: 9
content2 content2
</datacheck> </datacheck>
</reply> </reply>

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,23 +8,23 @@ 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"
Content-Length: 6 Content-Length: 6
Content-Type: text/html Content-Type: text/html
Funny-head: yesyes Funny-head: yesyes
hejsan hejsan
</data> </data>
<data1> <data1>
HTTP/1.1 200 Fine HTTP/1.1 200 Fine
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Content-Length: 13 Content-Length: 13
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
fine content fine content
</data1> </data1>

View File

@ -9,23 +9,23 @@ 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"
Content-Length: 6 Content-Length: 6
Content-Type: text/html Content-Type: text/html
Funny-head: yesyes Funny-head: yesyes
hejsan hejsan
</data> </data>
<data1> <data1>
HTTP/1.1 200 Fine HTTP/1.1 200 Fine
Date: Thu, 09 Nov 2010 14:49:00 GMT Date: Thu, 09 Nov 2010 14:49:00 GMT
Content-Length: 13 Content-Length: 13
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
fine content fine content
</data1> </data1>

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,12 +9,12 @@ 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
Content-Length: 3 Content-Length: 3
OK OK
</data> </data>
</reply> </reply>

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,13 +9,13 @@ 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
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
hello hello
</data> </data>
</reply> </reply>

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,18 +8,18 @@ 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
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498" ETag: "21025-dc7-39462498"
Accept-Ranges: bytes Accept-Ranges: bytes
Content-Length: 0 Content-Length: 0
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
Funny-head: yesyes Funny-head: yesyes
</data> </data>
</reply> </reply>
@ -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,18 +8,18 @@ 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
Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
ETag: "21025-dc7-39462498" ETag: "21025-dc7-39462498"
Accept-Ranges: bytes Accept-Ranges: bytes
Content-Length: 6 Content-Length: 6
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
Funny-head: yesyes Funny-head: yesyes
-foo- -foo-
</data> </data>
</reply> </reply>
@ -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

@ -11,31 +11,31 @@ multi
# Silly division of the first request is solely to appease the server which expects n_data_items == n_requests # Silly division of the first request is solely to appease the server which expects n_data_items == n_requests
<reply> <reply>
<data1> <data1>
HTTP/1.1 200 OK HTTP/1.1 200 OK
Server: test-server/fake Server: test-server/fake
Content-Length: 4 Content-Length: 4
584 584
</data1> </data1>
<data2> <data2>
HTTP/1.1 200 OK HTTP/1.1 200 OK
</data2> </data2>
<data3> <data3>
Server: test-server/fake Server: test-server/fake
</data3> </data3>
<data4> <data4>
Content-Length: 0 Content-Length: 0
HTTP/1.1 200 OK HTTP/1.1 200 OK
Server: test-server/fake Server: test-server/fake
Content-Length: 5 Content-Length: 5
585 585
HTTP/1.1 200 OK HTTP/1.1 200 OK
Server: test-server/fake Server: test-server/fake
Content-Length: 4 Content-Length: 4
586 586
</data4> </data4>
</reply> </reply>
@ -76,26 +76,26 @@ 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
584 584
HTTP/1.1 200 OK HTTP/1.1 200 OK
Server: test-server/fake Server: test-server/fake
Content-Length: 0 Content-Length: 0
HTTP/1.1 200 OK HTTP/1.1 200 OK
Server: test-server/fake Server: test-server/fake
Content-Length: 5 Content-Length: 5
585 585
HTTP/1.1 200 OK HTTP/1.1 200 OK
Server: test-server/fake Server: test-server/fake
Content-Length: 4 Content-Length: 4
586 586
</stdout> </stdout>
</verify> </verify>

View File

@ -12,31 +12,31 @@ 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
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
-foo- -foo-
</data> </data>
# since the request runs twice # since the request runs twice
<datacheck> <datacheck>
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
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
-foo- -foo-
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
Connection: close Connection: close
Content-Type: text/html Content-Type: text/html
-foo- -foo-
</datacheck> </datacheck>

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();
/* /*