diff options
author | Fabian Keil <fk@fabiankeil.de> | 2021-02-09 14:04:32 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2022-01-10 15:54:54 +0100 |
commit | 736847611a40c01e7c290407e22e2f0f5f8efd6a (patch) | |
tree | 184518b9f0bbc09482a07494c6c6d68d7b912bdf /tests | |
parent | b6acbdeb6375c9552fd4b04d5ab38422ed25fbaf (diff) | |
download | curl-736847611a40c01e7c290407e22e2f0f5f8efd6a.tar.gz |
runtests.pl: support the nonewline attribute for the data part
Added to FILEFORMAT
Closes #8239
Diffstat (limited to 'tests')
-rw-r--r-- | tests/FILEFORMAT.md | 5 | ||||
-rwxr-xr-x | tests/runtests.pl | 7 | ||||
-rw-r--r-- | tests/server/getpart.c | 11 |
3 files changed, 21 insertions, 2 deletions
diff --git a/tests/FILEFORMAT.md b/tests/FILEFORMAT.md index 7ba1de2a6..c50d0fe59 100644 --- a/tests/FILEFORMAT.md +++ b/tests/FILEFORMAT.md @@ -188,7 +188,7 @@ When using curl built with Hyper, the keywords must include HTTP or HTTPS for 'hyper mode' to kick in and make line ending checks work for tests. ## `<reply>` -### `<data [nocheck="yes"] [sendzero="yes"] [base64="yes"] [hex="yes"]>` +### `<data [nocheck="yes"] [sendzero="yes"] [base64="yes"] [hex="yes"] [nonewline="yes"]>` data to be sent to the client on its request and later verified that it arrived safely. Set `nocheck="yes"` to prevent the test script from verifying @@ -214,6 +214,9 @@ much sense for other sections than "data"). `hex=yes` means that the data is a sequence of hex pairs. It will get decoded and used as "raw" data. +`nonewline=yes` means that the last byte (the trailing newline character) +should be cut off from the data before sending or comparing it. + For FTP file listings, the `<data>` section will be used *only* if you make sure that there has been a CWD done first to a directory named `test-[num]` where [num] is the test case number. Otherwise the ftp server can't know from diff --git a/tests/runtests.pl b/tests/runtests.pl index 232a8824b..bb1fae9be 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -3885,6 +3885,13 @@ sub singletest { else { # check against the data section @reply = getpart("reply", "data"); + if(@reply) { + my %hash = getpartattr("reply", "data"); + if($hash{'nonewline'}) { + # cut off the final newline from the final line of the data + chomp($reply[$#reply]); + } + } # get the mode attribute my $filemode=$replyattr{'mode'}; if($filemode && ($filemode eq "text") && $has_textaware) { diff --git a/tests/server/getpart.c b/tests/server/getpart.c index 68158530b..57b86c0ea 100644 --- a/tests/server/getpart.c +++ b/tests/server/getpart.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -323,6 +323,7 @@ int getpart(char **outbuf, size_t *outlen, size_t datalen; int in_wanted_part = 0; int base64 = 0; + int nonewline = 0; int error; enum { @@ -389,6 +390,8 @@ int getpart(char **outbuf, size_t *outlen, if(error) return error; } + if(nonewline) + (*outlen)--; break; } } @@ -406,6 +409,8 @@ int getpart(char **outbuf, size_t *outlen, if(error) return error; } + if(nonewline) + (*outlen)--; break; } } @@ -480,6 +485,10 @@ int getpart(char **outbuf, size_t *outlen, /* bit rough test, but "mostly" functional, */ /* treat wanted part data as base64 encoded */ base64 = 1; + if(strstr(patt, "nonewline=")) { + show(("* setting nonewline\n")); + nonewline = 1; + } } continue; } |