diff options
| author | Caleb Maclennan <caleb@alerque.com> | 2022-03-19 17:42:53 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-19 17:42:53 +0300 |
| commit | a36818d3f3afd8758ec10991a5cb08ebdaca6329 (patch) | |
| tree | 445c27832ac4fb48a03c146fa7c797dc4880c099 /test | |
| parent | 6952262e6a1315b14935ddd0ea511c202c0154ba (diff) | |
| parent | 8390d07774a1ba1a597d809a1a2562d88ecce19d (diff) | |
| download | luasocket-a36818d3f3afd8758ec10991a5cb08ebdaca6329.tar.gz luasocket-a36818d3f3afd8758ec10991a5cb08ebdaca6329.tar.bz2 luasocket-a36818d3f3afd8758ec10991a5cb08ebdaca6329.zip | |
Merge pull request #354 from lunarmodules/linter
Diffstat (limited to 'test')
| -rw-r--r-- | test/ltn12test.lua | 24 | ||||
| -rw-r--r-- | test/mimetest.lua | 46 | ||||
| -rw-r--r-- | test/smtptest.lua | 20 | ||||
| -rw-r--r-- | test/test_socket_error.lua | 2 | ||||
| -rw-r--r-- | test/testmesg.lua | 14 | ||||
| -rw-r--r-- | test/testsupport.lua | 2 | ||||
| -rw-r--r-- | test/urltest.lua | 114 | ||||
| -rw-r--r-- | test/utestclnt.lua | 68 | ||||
| -rw-r--r-- | test/utestsrvr.lua | 2 |
9 files changed, 146 insertions, 146 deletions
diff --git a/test/ltn12test.lua b/test/ltn12test.lua index e7d368d..0cafbc9 100644 --- a/test/ltn12test.lua +++ b/test/ltn12test.lua | |||
| @@ -38,7 +38,7 @@ local function named(f, name) | |||
| 38 | end | 38 | end |
| 39 | 39 | ||
| 40 | -------------------------------- | 40 | -------------------------------- |
| 41 | local function split(size) | 41 | local function split(size) |
| 42 | local buffer = "" | 42 | local buffer = "" |
| 43 | local last_out = "" | 43 | local last_out = "" |
| 44 | local last_in = "" | 44 | local last_in = "" |
| @@ -50,12 +50,12 @@ local function split(size) | |||
| 50 | return last_out | 50 | return last_out |
| 51 | end | 51 | end |
| 52 | return function(chunk, done) | 52 | return function(chunk, done) |
| 53 | if done then | 53 | if done then |
| 54 | return not last_in and not last_out | 54 | return not last_in and not last_out |
| 55 | end | 55 | end |
| 56 | -- check if argument is consistent with state | 56 | -- check if argument is consistent with state |
| 57 | if not chunk then | 57 | if not chunk then |
| 58 | if last_in and last_in ~= "" and last_out ~= "" then | 58 | if last_in and last_in ~= "" and last_out ~= "" then |
| 59 | error("nil chunk following data chunk", 2) | 59 | error("nil chunk following data chunk", 2) |
| 60 | end | 60 | end |
| 61 | if not last_out then error("extra nil chunk", 2) end | 61 | if not last_out then error("extra nil chunk", 2) end |
| @@ -67,8 +67,8 @@ local function split(size) | |||
| 67 | return output(chunk) | 67 | return output(chunk) |
| 68 | else | 68 | else |
| 69 | if not last_in then error("data chunk following nil chunk", 2) end | 69 | if not last_in then error("data chunk following nil chunk", 2) end |
| 70 | if last_in ~= "" and last_out ~= "" then | 70 | if last_in ~= "" and last_out ~= "" then |
| 71 | error("data chunk following data chunk", 2) | 71 | error("data chunk following data chunk", 2) |
| 72 | end | 72 | end |
| 73 | buffer = chunk | 73 | buffer = chunk |
| 74 | return output(chunk) | 74 | return output(chunk) |
| @@ -85,7 +85,7 @@ local function format(chunk) | |||
| 85 | end | 85 | end |
| 86 | 86 | ||
| 87 | -------------------------------- | 87 | -------------------------------- |
| 88 | local function merge(size) | 88 | local function merge(size) |
| 89 | local buffer = "" | 89 | local buffer = "" |
| 90 | local last_out = "" | 90 | local last_out = "" |
| 91 | local last_in = "" | 91 | local last_in = "" |
| @@ -102,12 +102,12 @@ local function merge(size) | |||
| 102 | return last_out | 102 | return last_out |
| 103 | end | 103 | end |
| 104 | return function(chunk, done) | 104 | return function(chunk, done) |
| 105 | if done then | 105 | if done then |
| 106 | return not last_in and not last_out | 106 | return not last_in and not last_out |
| 107 | end | 107 | end |
| 108 | -- check if argument is consistent with state | 108 | -- check if argument is consistent with state |
| 109 | if not chunk then | 109 | if not chunk then |
| 110 | if last_in and last_in ~= "" and last_out ~= "" then | 110 | if last_in and last_in ~= "" and last_out ~= "" then |
| 111 | error("nil chunk following data chunk", 2) | 111 | error("nil chunk following data chunk", 2) |
| 112 | end | 112 | end |
| 113 | if not last_out then error("extra nil chunk", 2) end | 113 | if not last_out then error("extra nil chunk", 2) end |
| @@ -119,8 +119,8 @@ local function merge(size) | |||
| 119 | return output(chunk) | 119 | return output(chunk) |
| 120 | else | 120 | else |
| 121 | if not last_in then error("data chunk following nil chunk", 2) end | 121 | if not last_in then error("data chunk following nil chunk", 2) end |
| 122 | if last_in ~= "" and last_out ~= "" then | 122 | if last_in ~= "" and last_out ~= "" then |
| 123 | error("data chunk following data chunk", 2) | 123 | error("data chunk following data chunk", 2) |
| 124 | end | 124 | end |
| 125 | buffer = buffer .. chunk | 125 | buffer = buffer .. chunk |
| 126 | return output(chunk) | 126 | return output(chunk) |
diff --git a/test/mimetest.lua b/test/mimetest.lua index f5b3747..a3c89ac 100644 --- a/test/mimetest.lua +++ b/test/mimetest.lua | |||
| @@ -15,27 +15,27 @@ local eb64test = "b64test.bin2" | |||
| 15 | local db64test = "b64test.bin3" | 15 | local db64test = "b64test.bin3" |
| 16 | 16 | ||
| 17 | 17 | ||
| 18 | -- from Machado de Assis, "A Mão e a Rosa" | 18 | -- from Machado de Assis, "A M�o e a Rosa" |
| 19 | local mao = [[ | 19 | local mao = [[ |
| 20 | Cursavam estes dois moços a academia de S. Paulo, estando | 20 | Cursavam estes dois mo�os a academia de S. Paulo, estando |
| 21 | Luís Alves no quarto ano e Estêvão no terceiro. | 21 | Lu�s Alves no quarto ano e Est�v�o no terceiro. |
| 22 | Conheceram-se na academia, e ficaram amigos íntimos, tanto | 22 | Conheceram-se na academia, e ficaram amigos �ntimos, tanto |
| 23 | quanto podiam sê-lo dois espíritos diferentes, ou talvez por | 23 | quanto podiam s�-lo dois esp�ritos diferentes, ou talvez por |
| 24 | isso mesmo que o eram. Estêvão, dotado de extrema | 24 | isso mesmo que o eram. Est�v�o, dotado de extrema |
| 25 | sensibilidade, e não menor fraqueza de ânimo, afetuoso e | 25 | sensibilidade, e n�o menor fraqueza de �nimo, afetuoso e |
| 26 | bom, não daquela bondade varonil, que é apanágio de uma alma | 26 | bom, n�o daquela bondade varonil, que � apan�gio de uma alma |
| 27 | forte, mas dessa outra bondade mole e de cera, que vai à | 27 | forte, mas dessa outra bondade mole e de cera, que vai � |
| 28 | mercê de todas as circunstâncias, tinha, além de tudo isso, | 28 | merc� de todas as circunst�ncias, tinha, al�m de tudo isso, |
| 29 | o infortúnio de trazer ainda sobre o nariz os óculos | 29 | o infort�nio de trazer ainda sobre o nariz os �culos |
| 30 | cor-de-rosa de suas virginais ilusões. Luís Alves via bem | 30 | cor-de-rosa de suas virginais ilus�es. Lu�s Alves via bem |
| 31 | com os olhos da cara. Não era mau rapaz, mas tinha o seu | 31 | com os olhos da cara. N�o era mau rapaz, mas tinha o seu |
| 32 | grão de egoísmo, e se não era incapaz de afeições, sabia | 32 | gr�o de ego�smo, e se n�o era incapaz de afei��es, sabia |
| 33 | regê-las, moderá-las, e sobretudo guiá-las ao seu próprio | 33 | reg�-las, moder�-las, e sobretudo gui�-las ao seu pr�prio |
| 34 | interesse. Entre estes dois homens travara-se amizade | 34 | interesse. Entre estes dois homens travara-se amizade |
| 35 | íntima, nascida para um na simpatia, para outro no costume. | 35 | �ntima, nascida para um na simpatia, para outro no costume. |
| 36 | Eram eles os naturais confidentes um do outro, com a | 36 | Eram eles os naturais confidentes um do outro, com a |
| 37 | diferença que Luís Alves dava menos do que recebia, e, ainda | 37 | diferen�a que Lu�s Alves dava menos do que recebia, e, ainda |
| 38 | assim, nem tudo o que dava exprimia grande confiança. | 38 | assim, nem tudo o que dava exprimia grande confian�a. |
| 39 | ]] | 39 | ]] |
| 40 | 40 | ||
| 41 | local function random(handle, io_err) | 41 | local function random(handle, io_err) |
| @@ -44,8 +44,8 @@ local function random(handle, io_err) | |||
| 44 | if not handle then error("source is empty!", 2) end | 44 | if not handle then error("source is empty!", 2) end |
| 45 | local len = math.random(0, 1024) | 45 | local len = math.random(0, 1024) |
| 46 | local chunk = handle:read(len) | 46 | local chunk = handle:read(len) |
| 47 | if not chunk then | 47 | if not chunk then |
| 48 | handle:close() | 48 | handle:close() |
| 49 | handle = nil | 49 | handle = nil |
| 50 | end | 50 | end |
| 51 | return chunk | 51 | return chunk |
| @@ -62,7 +62,7 @@ local what = nil | |||
| 62 | local function transform(input, output, filter) | 62 | local function transform(input, output, filter) |
| 63 | local source = random(io.open(input, "rb")) | 63 | local source = random(io.open(input, "rb")) |
| 64 | local sink = ltn12.sink.file(io.open(output, "wb")) | 64 | local sink = ltn12.sink.file(io.open(output, "wb")) |
| 65 | if what then | 65 | if what then |
| 66 | sink = ltn12.sink.chain(filter, sink) | 66 | sink = ltn12.sink.chain(filter, sink) |
| 67 | else | 67 | else |
| 68 | source = ltn12.source.chain(source, filter) | 68 | source = ltn12.source.chain(source, filter) |
| @@ -147,7 +147,7 @@ local function create_qptest() | |||
| 147 | f:write(' ',string.char(32)) | 147 | f:write(' ',string.char(32)) |
| 148 | end | 148 | end |
| 149 | f:write("\r\n") | 149 | f:write("\r\n") |
| 150 | 150 | ||
| 151 | f:close() | 151 | f:close() |
| 152 | end | 152 | end |
| 153 | 153 | ||
| @@ -157,7 +157,7 @@ local function cleanup_qptest() | |||
| 157 | os.remove(dqptest) | 157 | os.remove(dqptest) |
| 158 | end | 158 | end |
| 159 | 159 | ||
| 160 | -- create test file | 160 | -- create test file |
| 161 | local function create_b64test() | 161 | local function create_b64test() |
| 162 | local f = assert(io.open(b64test, "wb")) | 162 | local f = assert(io.open(b64test, "wb")) |
| 163 | local t = {} | 163 | local t = {} |
diff --git a/test/smtptest.lua b/test/smtptest.lua index b5380ff..9d06054 100644 --- a/test/smtptest.lua +++ b/test/smtptest.lua | |||
| @@ -27,8 +27,8 @@ local total = function() | |||
| 27 | end | 27 | end |
| 28 | 28 | ||
| 29 | local similar = function(s1, s2) | 29 | local similar = function(s1, s2) |
| 30 | return | 30 | return |
| 31 | string.lower(string.gsub(s1, "%s", "")) == | 31 | string.lower(string.gsub(s1, "%s", "")) == |
| 32 | string.lower(string.gsub(s2, "%s", "")) | 32 | string.lower(string.gsub(s2, "%s", "")) |
| 33 | end | 33 | end |
| 34 | 34 | ||
| @@ -40,9 +40,9 @@ end | |||
| 40 | 40 | ||
| 41 | local readfile = function(name) | 41 | local readfile = function(name) |
| 42 | local f = io.open(name, "r") | 42 | local f = io.open(name, "r") |
| 43 | if not f then | 43 | if not f then |
| 44 | fail("unable to open file!") | 44 | fail("unable to open file!") |
| 45 | return nil | 45 | return nil |
| 46 | end | 46 | end |
| 47 | local s = f:read("*a") | 47 | local s = f:read("*a") |
| 48 | f:close() | 48 | f:close() |
| @@ -52,7 +52,7 @@ end | |||
| 52 | local empty = function() | 52 | local empty = function() |
| 53 | for i,v in ipairs(files) do | 53 | for i,v in ipairs(files) do |
| 54 | local f = io.open(v, "w") | 54 | local f = io.open(v, "w") |
| 55 | if not f then | 55 | if not f then |
| 56 | fail("unable to open file!") | 56 | fail("unable to open file!") |
| 57 | end | 57 | end |
| 58 | f:close() | 58 | f:close() |
| @@ -116,8 +116,8 @@ local wait = function(sentinel, n) | |||
| 116 | while 1 do | 116 | while 1 do |
| 117 | local mbox = parse(get()) | 117 | local mbox = parse(get()) |
| 118 | if n == #mbox then break end | 118 | if n == #mbox then break end |
| 119 | if socket.time() - sentinel.time > 50 then | 119 | if socket.time() - sentinel.time > 50 then |
| 120 | to = 1 | 120 | to = 1 |
| 121 | break | 121 | break |
| 122 | end | 122 | end |
| 123 | socket.sleep(1) | 123 | socket.sleep(1) |
| @@ -132,7 +132,7 @@ local stuffed_body = [[ | |||
| 132 | This message body needs to be | 132 | This message body needs to be |
| 133 | stuffed because it has a dot | 133 | stuffed because it has a dot |
| 134 | . | 134 | . |
| 135 | by itself on a line. | 135 | by itself on a line. |
| 136 | Otherwise the mailer would | 136 | Otherwise the mailer would |
| 137 | think that the dot | 137 | think that the dot |
| 138 | . | 138 | . |
| @@ -219,7 +219,7 @@ else print("ok") end | |||
| 219 | 219 | ||
| 220 | io.write("testing invalid from: ") | 220 | io.write("testing invalid from: ") |
| 221 | local ret, err = socket.smtp.mail{ | 221 | local ret, err = socket.smtp.mail{ |
| 222 | from = ' " " (( _ * ', | 222 | from = ' " " (( _ * ', |
| 223 | rcpt = rcpt, | 223 | rcpt = rcpt, |
| 224 | } | 224 | } |
| 225 | if ret or not err then fail("wrong error message") | 225 | if ret or not err then fail("wrong error message") |
| @@ -227,7 +227,7 @@ else print(err) end | |||
| 227 | 227 | ||
| 228 | io.write("testing no rcpt: ") | 228 | io.write("testing no rcpt: ") |
| 229 | local ret, err = socket.smtp.mail{ | 229 | local ret, err = socket.smtp.mail{ |
| 230 | from = from, | 230 | from = from, |
| 231 | } | 231 | } |
| 232 | if ret or not err then fail("wrong error message") | 232 | if ret or not err then fail("wrong error message") |
| 233 | else print(err) end | 233 | else print(err) end |
diff --git a/test/test_socket_error.lua b/test/test_socket_error.lua index bda6408..1b4b601 100644 --- a/test/test_socket_error.lua +++ b/test/test_socket_error.lua | |||
| @@ -19,7 +19,7 @@ for i = 1, 10 do | |||
| 19 | assert(ss == sock) | 19 | assert(ss == sock) |
| 20 | else | 20 | else |
| 21 | assert('timeout' == err, 'unexpected error :' .. tostring(err)) | 21 | assert('timeout' == err, 'unexpected error :' .. tostring(err)) |
| 22 | end | 22 | end |
| 23 | err = sock:getoption("error") -- i get 'connection refused' on WinXP | 23 | err = sock:getoption("error") -- i get 'connection refused' on WinXP |
| 24 | if err then | 24 | if err then |
| 25 | print("Passed! Error is '" .. err .. "'.") | 25 | print("Passed! Error is '" .. err .. "'.") |
diff --git a/test/testmesg.lua b/test/testmesg.lua index 135a008..8c086d5 100644 --- a/test/testmesg.lua +++ b/test/testmesg.lua | |||
| @@ -34,11 +34,11 @@ r, e = smtp.send{ | |||
| 34 | 34 | ||
| 35 | print(r, e) | 35 | print(r, e) |
| 36 | 36 | ||
| 37 | -- creates a source to send a message with two parts. The first part is | 37 | -- creates a source to send a message with two parts. The first part is |
| 38 | -- plain text, the second part is a PNG image, encoded as base64. | 38 | -- plain text, the second part is a PNG image, encoded as base64. |
| 39 | source = smtp.message{ | 39 | source = smtp.message{ |
| 40 | headers = { | 40 | headers = { |
| 41 | -- Remember that headers are *ignored* by smtp.send. | 41 | -- Remember that headers are *ignored* by smtp.send. |
| 42 | from = "Sicrano <sicrano@tecgraf.puc-rio.br>", | 42 | from = "Sicrano <sicrano@tecgraf.puc-rio.br>", |
| 43 | to = "Fulano <fulano@tecgraf.puc-rio.br>", | 43 | to = "Fulano <fulano@tecgraf.puc-rio.br>", |
| 44 | subject = "Here is a message with attachments" | 44 | subject = "Here is a message with attachments" |
| @@ -49,18 +49,18 @@ source = smtp.message{ | |||
| 49 | "Preamble might show up even in a MIME enabled client.", | 49 | "Preamble might show up even in a MIME enabled client.", |
| 50 | -- first part: No headers means plain text, us-ascii. | 50 | -- first part: No headers means plain text, us-ascii. |
| 51 | -- The mime.eol low-level filter normalizes end-of-line markers. | 51 | -- The mime.eol low-level filter normalizes end-of-line markers. |
| 52 | [1] = { | 52 | [1] = { |
| 53 | body = mime.eol(0, [[ | 53 | body = mime.eol(0, [[ |
| 54 | Lines in a message body should always end with CRLF. | 54 | Lines in a message body should always end with CRLF. |
| 55 | The smtp module will *NOT* perform translation. It will | 55 | The smtp module will *NOT* perform translation. It will |
| 56 | perform necessary stuffing, though. | 56 | perform necessary stuffing, though. |
| 57 | ]]) | 57 | ]]) |
| 58 | }, | 58 | }, |
| 59 | -- second part: Headers describe content the to be an image, | 59 | -- second part: Headers describe content the to be an image, |
| 60 | -- sent under the base64 transfer content encoding. | 60 | -- sent under the base64 transfer content encoding. |
| 61 | -- Notice that nothing happens until the message is sent. Small | 61 | -- Notice that nothing happens until the message is sent. Small |
| 62 | -- chunks are loaded into memory and translation happens on the fly. | 62 | -- chunks are loaded into memory and translation happens on the fly. |
| 63 | [2] = { | 63 | [2] = { |
| 64 | headers = { | 64 | headers = { |
| 65 | ["ConTenT-tYpE"] = 'image/png; name="luasocket.png"', | 65 | ["ConTenT-tYpE"] = 'image/png; name="luasocket.png"', |
| 66 | ["content-disposition"] = 'attachment; filename="luasocket.png"', | 66 | ["content-disposition"] = 'attachment; filename="luasocket.png"', |
diff --git a/test/testsupport.lua b/test/testsupport.lua index b986088..4360b6b 100644 --- a/test/testsupport.lua +++ b/test/testsupport.lua | |||
| @@ -7,7 +7,7 @@ function readfile(name) | |||
| 7 | end | 7 | end |
| 8 | 8 | ||
| 9 | function similar(s1, s2) | 9 | function similar(s1, s2) |
| 10 | return string.lower(string.gsub(s1 or "", "%s", "")) == | 10 | return string.lower(string.gsub(s1 or "", "%s", "")) == |
| 11 | string.lower(string.gsub(s2 or "", "%s", "")) | 11 | string.lower(string.gsub(s2 or "", "%s", "")) |
| 12 | end | 12 | end |
| 13 | 13 | ||
diff --git a/test/urltest.lua b/test/urltest.lua index ae8ba75..9a3c470 100644 --- a/test/urltest.lua +++ b/test/urltest.lua | |||
| @@ -60,8 +60,8 @@ end | |||
| 60 | 60 | ||
| 61 | local check_absolute_url = function(base, relative, absolute) | 61 | local check_absolute_url = function(base, relative, absolute) |
| 62 | local res = socket.url.absolute(base, relative) | 62 | local res = socket.url.absolute(base, relative) |
| 63 | if res ~= absolute then | 63 | if res ~= absolute then |
| 64 | io.write("absolute: In test for base='", base, "', rel='", relative, "' expected '", | 64 | io.write("absolute: In test for base='", base, "', rel='", relative, "' expected '", |
| 65 | absolute, "' but got '", res, "'\n") | 65 | absolute, "' but got '", res, "'\n") |
| 66 | os.exit() | 66 | os.exit() |
| 67 | end | 67 | end |
| @@ -73,7 +73,7 @@ local check_parse_url = function(gaba) | |||
| 73 | local parsed = socket.url.parse(url) | 73 | local parsed = socket.url.parse(url) |
| 74 | for i, v in pairs(gaba) do | 74 | for i, v in pairs(gaba) do |
| 75 | if v ~= parsed[i] then | 75 | if v ~= parsed[i] then |
| 76 | io.write("parse: In test for '", url, "' expected ", i, " = '", | 76 | io.write("parse: In test for '", url, "' expected ", i, " = '", |
| 77 | v, "' but got '", tostring(parsed[i]), "'\n") | 77 | v, "' but got '", tostring(parsed[i]), "'\n") |
| 78 | for i,v in pairs(parsed) do print(i,v) end | 78 | for i,v in pairs(parsed) do print(i,v) end |
| 79 | os.exit() | 79 | os.exit() |
| @@ -81,7 +81,7 @@ local check_parse_url = function(gaba) | |||
| 81 | end | 81 | end |
| 82 | for i, v in pairs(parsed) do | 82 | for i, v in pairs(parsed) do |
| 83 | if v ~= gaba[i] then | 83 | if v ~= gaba[i] then |
| 84 | io.write("parse: In test for '", url, "' expected ", i, " = '", | 84 | io.write("parse: In test for '", url, "' expected ", i, " = '", |
| 85 | tostring(gaba[i]), "' but got '", v, "'\n") | 85 | tostring(gaba[i]), "' but got '", v, "'\n") |
| 86 | for i,v in pairs(parsed) do print(i,v) end | 86 | for i,v in pairs(parsed) do print(i,v) end |
| 87 | os.exit() | 87 | os.exit() |
| @@ -92,8 +92,8 @@ end | |||
| 92 | print("testing URL parsing") | 92 | print("testing URL parsing") |
| 93 | check_parse_url{ | 93 | check_parse_url{ |
| 94 | url = "scheme://user:pass$%?#wd@host:port/path;params?query#fragment", | 94 | url = "scheme://user:pass$%?#wd@host:port/path;params?query#fragment", |
| 95 | scheme = "scheme", | 95 | scheme = "scheme", |
| 96 | authority = "user:pass$%?#wd@host:port", | 96 | authority = "user:pass$%?#wd@host:port", |
| 97 | host = "host", | 97 | host = "host", |
| 98 | port = "port", | 98 | port = "port", |
| 99 | userinfo = "user:pass$%?#wd", | 99 | userinfo = "user:pass$%?#wd", |
| @@ -106,8 +106,8 @@ check_parse_url{ | |||
| 106 | } | 106 | } |
| 107 | check_parse_url{ | 107 | check_parse_url{ |
| 108 | url = "scheme://user:pass?#wd@host:port/path;params?query#fragment", | 108 | url = "scheme://user:pass?#wd@host:port/path;params?query#fragment", |
| 109 | scheme = "scheme", | 109 | scheme = "scheme", |
| 110 | authority = "user:pass?#wd@host:port", | 110 | authority = "user:pass?#wd@host:port", |
| 111 | host = "host", | 111 | host = "host", |
| 112 | port = "port", | 112 | port = "port", |
| 113 | userinfo = "user:pass?#wd", | 113 | userinfo = "user:pass?#wd", |
| @@ -120,8 +120,8 @@ check_parse_url{ | |||
| 120 | } | 120 | } |
| 121 | check_parse_url{ | 121 | check_parse_url{ |
| 122 | url = "scheme://user:pass-wd@host:port/path;params?query#fragment", | 122 | url = "scheme://user:pass-wd@host:port/path;params?query#fragment", |
| 123 | scheme = "scheme", | 123 | scheme = "scheme", |
| 124 | authority = "user:pass-wd@host:port", | 124 | authority = "user:pass-wd@host:port", |
| 125 | host = "host", | 125 | host = "host", |
| 126 | port = "port", | 126 | port = "port", |
| 127 | userinfo = "user:pass-wd", | 127 | userinfo = "user:pass-wd", |
| @@ -134,8 +134,8 @@ check_parse_url{ | |||
| 134 | } | 134 | } |
| 135 | check_parse_url{ | 135 | check_parse_url{ |
| 136 | url = "scheme://user:pass#wd@host:port/path;params?query#fragment", | 136 | url = "scheme://user:pass#wd@host:port/path;params?query#fragment", |
| 137 | scheme = "scheme", | 137 | scheme = "scheme", |
| 138 | authority = "user:pass#wd@host:port", | 138 | authority = "user:pass#wd@host:port", |
| 139 | host = "host", | 139 | host = "host", |
| 140 | port = "port", | 140 | port = "port", |
| 141 | userinfo = "user:pass#wd", | 141 | userinfo = "user:pass#wd", |
| @@ -148,8 +148,8 @@ check_parse_url{ | |||
| 148 | } | 148 | } |
| 149 | check_parse_url{ | 149 | check_parse_url{ |
| 150 | url = "scheme://user:pass#wd@host:port/path;params?query", | 150 | url = "scheme://user:pass#wd@host:port/path;params?query", |
| 151 | scheme = "scheme", | 151 | scheme = "scheme", |
| 152 | authority = "user:pass#wd@host:port", | 152 | authority = "user:pass#wd@host:port", |
| 153 | host = "host", | 153 | host = "host", |
| 154 | port = "port", | 154 | port = "port", |
| 155 | userinfo = "user:pass#wd", | 155 | userinfo = "user:pass#wd", |
| @@ -161,8 +161,8 @@ check_parse_url{ | |||
| 161 | } | 161 | } |
| 162 | check_parse_url{ | 162 | check_parse_url{ |
| 163 | url = "scheme://userinfo@host:port/path;params?query#fragment", | 163 | url = "scheme://userinfo@host:port/path;params?query#fragment", |
| 164 | scheme = "scheme", | 164 | scheme = "scheme", |
| 165 | authority = "userinfo@host:port", | 165 | authority = "userinfo@host:port", |
| 166 | host = "host", | 166 | host = "host", |
| 167 | port = "port", | 167 | port = "port", |
| 168 | userinfo = "userinfo", | 168 | userinfo = "userinfo", |
| @@ -175,8 +175,8 @@ check_parse_url{ | |||
| 175 | 175 | ||
| 176 | check_parse_url{ | 176 | check_parse_url{ |
| 177 | url = "scheme://user:password@host:port/path;params?query#fragment", | 177 | url = "scheme://user:password@host:port/path;params?query#fragment", |
| 178 | scheme = "scheme", | 178 | scheme = "scheme", |
| 179 | authority = "user:password@host:port", | 179 | authority = "user:password@host:port", |
| 180 | host = "host", | 180 | host = "host", |
| 181 | port = "port", | 181 | port = "port", |
| 182 | userinfo = "user:password", | 182 | userinfo = "user:password", |
| @@ -190,8 +190,8 @@ check_parse_url{ | |||
| 190 | 190 | ||
| 191 | check_parse_url{ | 191 | check_parse_url{ |
| 192 | url = "scheme://userinfo@host:port/path;params?query#", | 192 | url = "scheme://userinfo@host:port/path;params?query#", |
| 193 | scheme = "scheme", | 193 | scheme = "scheme", |
| 194 | authority = "userinfo@host:port", | 194 | authority = "userinfo@host:port", |
| 195 | host = "host", | 195 | host = "host", |
| 196 | port = "port", | 196 | port = "port", |
| 197 | userinfo = "userinfo", | 197 | userinfo = "userinfo", |
| @@ -204,8 +204,8 @@ check_parse_url{ | |||
| 204 | 204 | ||
| 205 | check_parse_url{ | 205 | check_parse_url{ |
| 206 | url = "scheme://userinfo@host:port/path;params?#fragment", | 206 | url = "scheme://userinfo@host:port/path;params?#fragment", |
| 207 | scheme = "scheme", | 207 | scheme = "scheme", |
| 208 | authority = "userinfo@host:port", | 208 | authority = "userinfo@host:port", |
| 209 | host = "host", | 209 | host = "host", |
| 210 | port = "port", | 210 | port = "port", |
| 211 | userinfo = "userinfo", | 211 | userinfo = "userinfo", |
| @@ -218,8 +218,8 @@ check_parse_url{ | |||
| 218 | 218 | ||
| 219 | check_parse_url{ | 219 | check_parse_url{ |
| 220 | url = "scheme://userinfo@host:port/path;params#fragment", | 220 | url = "scheme://userinfo@host:port/path;params#fragment", |
| 221 | scheme = "scheme", | 221 | scheme = "scheme", |
| 222 | authority = "userinfo@host:port", | 222 | authority = "userinfo@host:port", |
| 223 | host = "host", | 223 | host = "host", |
| 224 | port = "port", | 224 | port = "port", |
| 225 | userinfo = "userinfo", | 225 | userinfo = "userinfo", |
| @@ -231,8 +231,8 @@ check_parse_url{ | |||
| 231 | 231 | ||
| 232 | check_parse_url{ | 232 | check_parse_url{ |
| 233 | url = "scheme://userinfo@host:port/path;?query#fragment", | 233 | url = "scheme://userinfo@host:port/path;?query#fragment", |
| 234 | scheme = "scheme", | 234 | scheme = "scheme", |
| 235 | authority = "userinfo@host:port", | 235 | authority = "userinfo@host:port", |
| 236 | host = "host", | 236 | host = "host", |
| 237 | port = "port", | 237 | port = "port", |
| 238 | userinfo = "userinfo", | 238 | userinfo = "userinfo", |
| @@ -245,8 +245,8 @@ check_parse_url{ | |||
| 245 | 245 | ||
| 246 | check_parse_url{ | 246 | check_parse_url{ |
| 247 | url = "scheme://userinfo@host:port/path?query#fragment", | 247 | url = "scheme://userinfo@host:port/path?query#fragment", |
| 248 | scheme = "scheme", | 248 | scheme = "scheme", |
| 249 | authority = "userinfo@host:port", | 249 | authority = "userinfo@host:port", |
| 250 | host = "host", | 250 | host = "host", |
| 251 | port = "port", | 251 | port = "port", |
| 252 | userinfo = "userinfo", | 252 | userinfo = "userinfo", |
| @@ -258,8 +258,8 @@ check_parse_url{ | |||
| 258 | 258 | ||
| 259 | check_parse_url{ | 259 | check_parse_url{ |
| 260 | url = "scheme://userinfo@host:port/;params?query#fragment", | 260 | url = "scheme://userinfo@host:port/;params?query#fragment", |
| 261 | scheme = "scheme", | 261 | scheme = "scheme", |
| 262 | authority = "userinfo@host:port", | 262 | authority = "userinfo@host:port", |
| 263 | host = "host", | 263 | host = "host", |
| 264 | port = "port", | 264 | port = "port", |
| 265 | userinfo = "userinfo", | 265 | userinfo = "userinfo", |
| @@ -272,8 +272,8 @@ check_parse_url{ | |||
| 272 | 272 | ||
| 273 | check_parse_url{ | 273 | check_parse_url{ |
| 274 | url = "scheme://userinfo@host:port", | 274 | url = "scheme://userinfo@host:port", |
| 275 | scheme = "scheme", | 275 | scheme = "scheme", |
| 276 | authority = "userinfo@host:port", | 276 | authority = "userinfo@host:port", |
| 277 | host = "host", | 277 | host = "host", |
| 278 | port = "port", | 278 | port = "port", |
| 279 | userinfo = "userinfo", | 279 | userinfo = "userinfo", |
| @@ -282,7 +282,7 @@ check_parse_url{ | |||
| 282 | 282 | ||
| 283 | check_parse_url{ | 283 | check_parse_url{ |
| 284 | url = "//userinfo@host:port/path;params?query#fragment", | 284 | url = "//userinfo@host:port/path;params?query#fragment", |
| 285 | authority = "userinfo@host:port", | 285 | authority = "userinfo@host:port", |
| 286 | host = "host", | 286 | host = "host", |
| 287 | port = "port", | 287 | port = "port", |
| 288 | userinfo = "userinfo", | 288 | userinfo = "userinfo", |
| @@ -295,7 +295,7 @@ check_parse_url{ | |||
| 295 | 295 | ||
| 296 | check_parse_url{ | 296 | check_parse_url{ |
| 297 | url = "//userinfo@host:port/path", | 297 | url = "//userinfo@host:port/path", |
| 298 | authority = "userinfo@host:port", | 298 | authority = "userinfo@host:port", |
| 299 | host = "host", | 299 | host = "host", |
| 300 | port = "port", | 300 | port = "port", |
| 301 | userinfo = "userinfo", | 301 | userinfo = "userinfo", |
| @@ -305,7 +305,7 @@ check_parse_url{ | |||
| 305 | 305 | ||
| 306 | check_parse_url{ | 306 | check_parse_url{ |
| 307 | url = "//userinfo@host/path", | 307 | url = "//userinfo@host/path", |
| 308 | authority = "userinfo@host", | 308 | authority = "userinfo@host", |
| 309 | host = "host", | 309 | host = "host", |
| 310 | userinfo = "userinfo", | 310 | userinfo = "userinfo", |
| 311 | user = "userinfo", | 311 | user = "userinfo", |
| @@ -314,7 +314,7 @@ check_parse_url{ | |||
| 314 | 314 | ||
| 315 | check_parse_url{ | 315 | check_parse_url{ |
| 316 | url = "//user:password@host/path", | 316 | url = "//user:password@host/path", |
| 317 | authority = "user:password@host", | 317 | authority = "user:password@host", |
| 318 | host = "host", | 318 | host = "host", |
| 319 | userinfo = "user:password", | 319 | userinfo = "user:password", |
| 320 | password = "password", | 320 | password = "password", |
| @@ -324,7 +324,7 @@ check_parse_url{ | |||
| 324 | 324 | ||
| 325 | check_parse_url{ | 325 | check_parse_url{ |
| 326 | url = "//user:@host/path", | 326 | url = "//user:@host/path", |
| 327 | authority = "user:@host", | 327 | authority = "user:@host", |
| 328 | host = "host", | 328 | host = "host", |
| 329 | userinfo = "user:", | 329 | userinfo = "user:", |
| 330 | password = "", | 330 | password = "", |
| @@ -334,7 +334,7 @@ check_parse_url{ | |||
| 334 | 334 | ||
| 335 | check_parse_url{ | 335 | check_parse_url{ |
| 336 | url = "//user@host:port/path", | 336 | url = "//user@host:port/path", |
| 337 | authority = "user@host:port", | 337 | authority = "user@host:port", |
| 338 | host = "host", | 338 | host = "host", |
| 339 | userinfo = "user", | 339 | userinfo = "user", |
| 340 | user = "user", | 340 | user = "user", |
| @@ -344,7 +344,7 @@ check_parse_url{ | |||
| 344 | 344 | ||
| 345 | check_parse_url{ | 345 | check_parse_url{ |
| 346 | url = "//host:port/path", | 346 | url = "//host:port/path", |
| 347 | authority = "host:port", | 347 | authority = "host:port", |
| 348 | port = "port", | 348 | port = "port", |
| 349 | host = "host", | 349 | host = "host", |
| 350 | path = "/path", | 350 | path = "/path", |
| @@ -352,14 +352,14 @@ check_parse_url{ | |||
| 352 | 352 | ||
| 353 | check_parse_url{ | 353 | check_parse_url{ |
| 354 | url = "//host/path", | 354 | url = "//host/path", |
| 355 | authority = "host", | 355 | authority = "host", |
| 356 | host = "host", | 356 | host = "host", |
| 357 | path = "/path", | 357 | path = "/path", |
| 358 | } | 358 | } |
| 359 | 359 | ||
| 360 | check_parse_url{ | 360 | check_parse_url{ |
| 361 | url = "//host", | 361 | url = "//host", |
| 362 | authority = "host", | 362 | authority = "host", |
| 363 | host = "host", | 363 | host = "host", |
| 364 | } | 364 | } |
| 365 | 365 | ||
| @@ -433,7 +433,7 @@ check_parse_url{ | |||
| 433 | 433 | ||
| 434 | check_parse_url{ | 434 | check_parse_url{ |
| 435 | url = "//userinfo@[::FFFF:129.144.52.38]:port/path;params?query#fragment", | 435 | url = "//userinfo@[::FFFF:129.144.52.38]:port/path;params?query#fragment", |
| 436 | authority = "userinfo@[::FFFF:129.144.52.38]:port", | 436 | authority = "userinfo@[::FFFF:129.144.52.38]:port", |
| 437 | host = "::FFFF:129.144.52.38", | 437 | host = "::FFFF:129.144.52.38", |
| 438 | port = "port", | 438 | port = "port", |
| 439 | userinfo = "userinfo", | 439 | userinfo = "userinfo", |
| @@ -447,7 +447,7 @@ check_parse_url{ | |||
| 447 | check_parse_url{ | 447 | check_parse_url{ |
| 448 | url = "scheme://user:password@[::192.9.5.5]:port/path;params?query#fragment", | 448 | url = "scheme://user:password@[::192.9.5.5]:port/path;params?query#fragment", |
| 449 | scheme = "scheme", | 449 | scheme = "scheme", |
| 450 | authority = "user:password@[::192.9.5.5]:port", | 450 | authority = "user:password@[::192.9.5.5]:port", |
| 451 | host = "::192.9.5.5", | 451 | host = "::192.9.5.5", |
| 452 | port = "port", | 452 | port = "port", |
| 453 | userinfo = "user:password", | 453 | userinfo = "user:password", |
| @@ -462,7 +462,7 @@ check_parse_url{ | |||
| 462 | print("testing URL building") | 462 | print("testing URL building") |
| 463 | check_build_url { | 463 | check_build_url { |
| 464 | url = "scheme://user:password@host:port/path;params?query#fragment", | 464 | url = "scheme://user:password@host:port/path;params?query#fragment", |
| 465 | scheme = "scheme", | 465 | scheme = "scheme", |
| 466 | host = "host", | 466 | host = "host", |
| 467 | port = "port", | 467 | port = "port", |
| 468 | user = "user", | 468 | user = "user", |
| @@ -499,7 +499,7 @@ check_build_url{ | |||
| 499 | 499 | ||
| 500 | check_build_url { | 500 | check_build_url { |
| 501 | url = "scheme://user:password@host/path;params?query#fragment", | 501 | url = "scheme://user:password@host/path;params?query#fragment", |
| 502 | scheme = "scheme", | 502 | scheme = "scheme", |
| 503 | host = "host", | 503 | host = "host", |
| 504 | user = "user", | 504 | user = "user", |
| 505 | password = "password", | 505 | password = "password", |
| @@ -511,7 +511,7 @@ check_build_url { | |||
| 511 | 511 | ||
| 512 | check_build_url { | 512 | check_build_url { |
| 513 | url = "scheme://user@host/path;params?query#fragment", | 513 | url = "scheme://user@host/path;params?query#fragment", |
| 514 | scheme = "scheme", | 514 | scheme = "scheme", |
| 515 | host = "host", | 515 | host = "host", |
| 516 | user = "user", | 516 | user = "user", |
| 517 | path = "/path", | 517 | path = "/path", |
| @@ -522,7 +522,7 @@ check_build_url { | |||
| 522 | 522 | ||
| 523 | check_build_url { | 523 | check_build_url { |
| 524 | url = "scheme://host/path;params?query#fragment", | 524 | url = "scheme://host/path;params?query#fragment", |
| 525 | scheme = "scheme", | 525 | scheme = "scheme", |
| 526 | host = "host", | 526 | host = "host", |
| 527 | path = "/path", | 527 | path = "/path", |
| 528 | params = "params", | 528 | params = "params", |
| @@ -532,7 +532,7 @@ check_build_url { | |||
| 532 | 532 | ||
| 533 | check_build_url { | 533 | check_build_url { |
| 534 | url = "scheme://host/path;params#fragment", | 534 | url = "scheme://host/path;params#fragment", |
| 535 | scheme = "scheme", | 535 | scheme = "scheme", |
| 536 | host = "host", | 536 | host = "host", |
| 537 | path = "/path", | 537 | path = "/path", |
| 538 | params = "params", | 538 | params = "params", |
| @@ -541,7 +541,7 @@ check_build_url { | |||
| 541 | 541 | ||
| 542 | check_build_url { | 542 | check_build_url { |
| 543 | url = "scheme://host/path#fragment", | 543 | url = "scheme://host/path#fragment", |
| 544 | scheme = "scheme", | 544 | scheme = "scheme", |
| 545 | host = "host", | 545 | host = "host", |
| 546 | path = "/path", | 546 | path = "/path", |
| 547 | fragment = "fragment" | 547 | fragment = "fragment" |
| @@ -549,7 +549,7 @@ check_build_url { | |||
| 549 | 549 | ||
| 550 | check_build_url { | 550 | check_build_url { |
| 551 | url = "scheme://host/path", | 551 | url = "scheme://host/path", |
| 552 | scheme = "scheme", | 552 | scheme = "scheme", |
| 553 | host = "host", | 553 | host = "host", |
| 554 | path = "/path", | 554 | path = "/path", |
| 555 | } | 555 | } |
| @@ -567,7 +567,7 @@ check_build_url { | |||
| 567 | 567 | ||
| 568 | check_build_url { | 568 | check_build_url { |
| 569 | url = "scheme://user:password@host:port/path;params?query#fragment", | 569 | url = "scheme://user:password@host:port/path;params?query#fragment", |
| 570 | scheme = "scheme", | 570 | scheme = "scheme", |
| 571 | host = "host", | 571 | host = "host", |
| 572 | port = "port", | 572 | port = "port", |
| 573 | user = "user", | 573 | user = "user", |
| @@ -581,7 +581,7 @@ check_build_url { | |||
| 581 | 581 | ||
| 582 | check_build_url { | 582 | check_build_url { |
| 583 | url = "scheme://user:password@host:port/path;params?query#fragment", | 583 | url = "scheme://user:password@host:port/path;params?query#fragment", |
| 584 | scheme = "scheme", | 584 | scheme = "scheme", |
| 585 | host = "host", | 585 | host = "host", |
| 586 | port = "port", | 586 | port = "port", |
| 587 | user = "user", | 587 | user = "user", |
| @@ -596,7 +596,7 @@ check_build_url { | |||
| 596 | 596 | ||
| 597 | check_build_url { | 597 | check_build_url { |
| 598 | url = "scheme://user:password@host:port/path;params?query#fragment", | 598 | url = "scheme://user:password@host:port/path;params?query#fragment", |
| 599 | scheme = "scheme", | 599 | scheme = "scheme", |
| 600 | host = "host", | 600 | host = "host", |
| 601 | port = "port", | 601 | port = "port", |
| 602 | userinfo = "user:password", | 602 | userinfo = "user:password", |
| @@ -609,7 +609,7 @@ check_build_url { | |||
| 609 | 609 | ||
| 610 | check_build_url { | 610 | check_build_url { |
| 611 | url = "scheme://user:password@host:port/path;params?query#fragment", | 611 | url = "scheme://user:password@host:port/path;params?query#fragment", |
| 612 | scheme = "scheme", | 612 | scheme = "scheme", |
| 613 | authority = "user:password@host:port", | 613 | authority = "user:password@host:port", |
| 614 | path = "/path", | 614 | path = "/path", |
| 615 | params = "params", | 615 | params = "params", |
| @@ -683,7 +683,7 @@ check_absolute_url("//a/b/c/d;p?q#f", "d/e/f", "//a/b/c/d/e/f") | |||
| 683 | check_absolute_url("/a/b/c/d;p?q#f", "d/e/f", "/a/b/c/d/e/f") | 683 | check_absolute_url("/a/b/c/d;p?q#f", "d/e/f", "/a/b/c/d/e/f") |
| 684 | check_absolute_url("a/b/c/d", "d/e/f", "a/b/c/d/e/f") | 684 | check_absolute_url("a/b/c/d", "d/e/f", "a/b/c/d/e/f") |
| 685 | check_absolute_url("a/b/c/d/../", "d/e/f", "a/b/c/d/e/f") | 685 | check_absolute_url("a/b/c/d/../", "d/e/f", "a/b/c/d/e/f") |
| 686 | check_absolute_url("http://velox.telemar.com.br", "/dashboard/index.html", | 686 | check_absolute_url("http://velox.telemar.com.br", "/dashboard/index.html", |
| 687 | "http://velox.telemar.com.br/dashboard/index.html") | 687 | "http://velox.telemar.com.br/dashboard/index.html") |
| 688 | check_absolute_url("http://example.com/", "../.badhost.com/", "http://example.com/.badhost.com/") | 688 | check_absolute_url("http://example.com/", "../.badhost.com/", "http://example.com/.badhost.com/") |
| 689 | check_absolute_url("http://example.com/", "...badhost.com/", "http://example.com/...badhost.com/") | 689 | check_absolute_url("http://example.com/", "...badhost.com/", "http://example.com/...badhost.com/") |
| @@ -700,11 +700,11 @@ check_absolute_url("http://example.com/a/b/c/d/", "../x/a/../y/z/../../../../q", | |||
| 700 | print("testing path parsing and composition") | 700 | print("testing path parsing and composition") |
| 701 | check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 }) | 701 | check_parse_path("/eu/tu/ele", { "eu", "tu", "ele"; is_absolute = 1 }) |
| 702 | check_parse_path("/eu/", { "eu"; is_absolute = 1, is_directory = 1 }) | 702 | check_parse_path("/eu/", { "eu"; is_absolute = 1, is_directory = 1 }) |
| 703 | check_parse_path("eu/tu/ele/nos/vos/eles/", | 703 | check_parse_path("eu/tu/ele/nos/vos/eles/", |
| 704 | { "eu", "tu", "ele", "nos", "vos", "eles"; is_directory = 1}) | 704 | { "eu", "tu", "ele", "nos", "vos", "eles"; is_directory = 1}) |
| 705 | check_parse_path("/", { is_absolute = 1, is_directory = 1}) | 705 | check_parse_path("/", { is_absolute = 1, is_directory = 1}) |
| 706 | check_parse_path("", { }) | 706 | check_parse_path("", { }) |
| 707 | check_parse_path("eu%01/%02tu/e%03l%04e/nos/vos%05/e%12les/", | 707 | check_parse_path("eu%01/%02tu/e%03l%04e/nos/vos%05/e%12les/", |
| 708 | { "eu\1", "\2tu", "e\3l\4e", "nos", "vos\5", "e\18les"; is_directory = 1}) | 708 | { "eu\1", "\2tu", "e\3l\4e", "nos", "vos\5", "e\18les"; is_directory = 1}) |
| 709 | check_parse_path("eu/tu", { "eu", "tu" }) | 709 | check_parse_path("eu/tu", { "eu", "tu" }) |
| 710 | 710 | ||
diff --git a/test/utestclnt.lua b/test/utestclnt.lua index 34a0718..7f10643 100644 --- a/test/utestclnt.lua +++ b/test/utestclnt.lua | |||
| @@ -54,30 +54,30 @@ function check_timeout(tm, sl, elapsed, err, opp, mode, alldone) | |||
| 54 | if not err then warn("must be buffered") | 54 | if not err then warn("must be buffered") |
| 55 | elseif err == "timeout" then pass("proper timeout") | 55 | elseif err == "timeout" then pass("proper timeout") |
| 56 | else fail("unexpected error '%s'", err) end | 56 | else fail("unexpected error '%s'", err) end |
| 57 | else | 57 | else |
| 58 | if err ~= "timeout" then fail("should have timed out") | 58 | if err ~= "timeout" then fail("should have timed out") |
| 59 | else pass("proper timeout") end | 59 | else pass("proper timeout") end |
| 60 | end | 60 | end |
| 61 | else | 61 | else |
| 62 | if mode == "total" then | 62 | if mode == "total" then |
| 63 | if elapsed > tm then | 63 | if elapsed > tm then |
| 64 | if err ~= "timeout" then fail("should have timed out") | 64 | if err ~= "timeout" then fail("should have timed out") |
| 65 | else pass("proper timeout") end | 65 | else pass("proper timeout") end |
| 66 | elseif elapsed < tm then | 66 | elseif elapsed < tm then |
| 67 | if err then fail(err) | 67 | if err then fail(err) |
| 68 | else pass("ok") end | 68 | else pass("ok") end |
| 69 | else | 69 | else |
| 70 | if alldone then | 70 | if alldone then |
| 71 | if err then fail("unexpected error '%s'", err) | 71 | if err then fail("unexpected error '%s'", err) |
| 72 | else pass("ok") end | 72 | else pass("ok") end |
| 73 | else | 73 | else |
| 74 | if err ~= "timeout" then fail(err) | 74 | if err ~= "timeout" then fail(err) |
| 75 | else pass("proper timeoutk") end | 75 | else pass("proper timeoutk") end |
| 76 | end | 76 | end |
| 77 | end | 77 | end |
| 78 | else | 78 | else |
| 79 | if err then fail(err) | 79 | if err then fail(err) |
| 80 | else pass("ok") end | 80 | else pass("ok") end |
| 81 | end | 81 | end |
| 82 | end | 82 | end |
| 83 | end | 83 | end |
| @@ -104,7 +104,7 @@ function reconnect() | |||
| 104 | print("done " .. i) | 104 | print("done " .. i) |
| 105 | ]] | 105 | ]] |
| 106 | data, err = uconnect(host, port) | 106 | data, err = uconnect(host, port) |
| 107 | if not data then fail(err) | 107 | if not data then fail(err) |
| 108 | else pass("connected!") end | 108 | else pass("connected!") end |
| 109 | end | 109 | end |
| 110 | 110 | ||
| @@ -116,8 +116,8 @@ else pass("connected!") end | |||
| 116 | ------------------------------------------------------------------------ | 116 | ------------------------------------------------------------------------ |
| 117 | function test_methods(sock, methods) | 117 | function test_methods(sock, methods) |
| 118 | for _, v in pairs(methods) do | 118 | for _, v in pairs(methods) do |
| 119 | if type(sock[v]) ~= "function" then | 119 | if type(sock[v]) ~= "function" then |
| 120 | fail(sock.class .. " method '" .. v .. "' not registered") | 120 | fail(sock.class .. " method '" .. v .. "' not registered") |
| 121 | end | 121 | end |
| 122 | end | 122 | end |
| 123 | pass(sock.class .. " methods are ok") | 123 | pass(sock.class .. " methods are ok") |
| @@ -132,7 +132,7 @@ function test_mixed(len) | |||
| 132 | local p3 = "raw " .. string.rep("z", inter) .. "bytes" | 132 | local p3 = "raw " .. string.rep("z", inter) .. "bytes" |
| 133 | local p4 = "end" .. string.rep("w", inter) .. "bytes" | 133 | local p4 = "end" .. string.rep("w", inter) .. "bytes" |
| 134 | local bp1, bp2, bp3, bp4 | 134 | local bp1, bp2, bp3, bp4 |
| 135 | remote (string.format("str = data:receive(%d)", | 135 | remote (string.format("str = data:receive(%d)", |
| 136 | string.len(p1)+string.len(p2)+string.len(p3)+string.len(p4))) | 136 | string.len(p1)+string.len(p2)+string.len(p3)+string.len(p4))) |
| 137 | sent, err = data:send(p1..p2..p3..p4) | 137 | sent, err = data:send(p1..p2..p3..p4) |
| 138 | if err then fail(err) end | 138 | if err then fail(err) end |
| @@ -172,7 +172,7 @@ function test_rawline(len) | |||
| 172 | reconnect() | 172 | reconnect() |
| 173 | local str, str10, back, err | 173 | local str, str10, back, err |
| 174 | str = string.rep(string.char(47), math.mod(len, 10)) | 174 | str = string.rep(string.char(47), math.mod(len, 10)) |
| 175 | str10 = string.rep(string.char(120,21,77,4,5,0,7,36,44,100), | 175 | str10 = string.rep(string.char(120,21,77,4,5,0,7,36,44,100), |
| 176 | math.floor(len/10)) | 176 | math.floor(len/10)) |
| 177 | str = str .. str10 | 177 | str = str .. str10 |
| 178 | remote "str = data:receive()" | 178 | remote "str = data:receive()" |
| @@ -221,7 +221,7 @@ function test_totaltimeoutreceive(len, tm, sl) | |||
| 221 | data:settimeout(tm, "total") | 221 | data:settimeout(tm, "total") |
| 222 | local t = socket.gettime() | 222 | local t = socket.gettime() |
| 223 | str, err, partial, elapsed = data:receive(2*len) | 223 | str, err, partial, elapsed = data:receive(2*len) |
| 224 | check_timeout(tm, sl, elapsed, err, "receive", "total", | 224 | check_timeout(tm, sl, elapsed, err, "receive", "total", |
| 225 | string.len(str or partial) == 2*len) | 225 | string.len(str or partial) == 2*len) |
| 226 | end | 226 | end |
| 227 | 227 | ||
| @@ -241,7 +241,7 @@ function test_totaltimeoutsend(len, tm, sl) | |||
| 241 | data:settimeout(tm, "total") | 241 | data:settimeout(tm, "total") |
| 242 | str = string.rep("a", 2*len) | 242 | str = string.rep("a", 2*len) |
| 243 | total, err, partial, elapsed = data:send(str) | 243 | total, err, partial, elapsed = data:send(str) |
| 244 | check_timeout(tm, sl, elapsed, err, "send", "total", | 244 | check_timeout(tm, sl, elapsed, err, "send", "total", |
| 245 | total == 2*len) | 245 | total == 2*len) |
| 246 | end | 246 | end |
| 247 | 247 | ||
| @@ -261,7 +261,7 @@ function test_blockingtimeoutreceive(len, tm, sl) | |||
| 261 | ]], 2*tm, len, sl, sl)) | 261 | ]], 2*tm, len, sl, sl)) |
| 262 | data:settimeout(tm) | 262 | data:settimeout(tm) |
| 263 | str, err, partial, elapsed = data:receive(2*len) | 263 | str, err, partial, elapsed = data:receive(2*len) |
| 264 | check_timeout(tm, sl, elapsed, err, "receive", "blocking", | 264 | check_timeout(tm, sl, elapsed, err, "receive", "blocking", |
| 265 | string.len(str or partial) == 2*len) | 265 | string.len(str or partial) == 2*len) |
| 266 | end | 266 | end |
| 267 | 267 | ||
| @@ -294,10 +294,10 @@ function empty_connect() | |||
| 294 | data = server:accept() | 294 | data = server:accept() |
| 295 | ]] | 295 | ]] |
| 296 | data, err = socket.connect("", port) | 296 | data, err = socket.connect("", port) |
| 297 | if not data then | 297 | if not data then |
| 298 | pass("ok") | 298 | pass("ok") |
| 299 | data = socket.connect(host, port) | 299 | data = socket.connect(host, port) |
| 300 | else | 300 | else |
| 301 | pass("gethostbyname returns localhost on empty string...") | 301 | pass("gethostbyname returns localhost on empty string...") |
| 302 | end | 302 | end |
| 303 | end | 303 | end |
| @@ -331,7 +331,7 @@ function test_closed() | |||
| 331 | data:close() | 331 | data:close() |
| 332 | data = nil | 332 | data = nil |
| 333 | ]], str)) | 333 | ]], str)) |
| 334 | -- try to get a line | 334 | -- try to get a line |
| 335 | back, err, partial = data:receive() | 335 | back, err, partial = data:receive() |
| 336 | if not err then fail("should have gotten 'closed'.") | 336 | if not err then fail("should have gotten 'closed'.") |
| 337 | elseif err ~= "closed" then fail("got '"..err.."' instead of 'closed'.") | 337 | elseif err ~= "closed" then fail("got '"..err.."' instead of 'closed'.") |
| @@ -344,25 +344,25 @@ function test_closed() | |||
| 344 | data = nil | 344 | data = nil |
| 345 | ]] | 345 | ]] |
| 346 | total, err, partial = data:send(string.rep("ugauga", 100000)) | 346 | total, err, partial = data:send(string.rep("ugauga", 100000)) |
| 347 | if not err then | 347 | if not err then |
| 348 | pass("failed: output buffer is at least %d bytes long!", total) | 348 | pass("failed: output buffer is at least %d bytes long!", total) |
| 349 | elseif err ~= "closed" then | 349 | elseif err ~= "closed" then |
| 350 | fail("got '"..err.."' instead of 'closed'.") | 350 | fail("got '"..err.."' instead of 'closed'.") |
| 351 | else | 351 | else |
| 352 | pass("graceful 'closed' received after %d bytes were sent", partial) | 352 | pass("graceful 'closed' received after %d bytes were sent", partial) |
| 353 | end | 353 | end |
| 354 | end | 354 | end |
| 355 | 355 | ||
| 356 | ------------------------------------------------------------------------ | 356 | ------------------------------------------------------------------------ |
| 357 | function test_selectbugs() | 357 | function test_selectbugs() |
| 358 | local r, s, e = socket.select(nil, nil, 0.1) | 358 | local r, s, e = socket.select(nil, nil, 0.1) |
| 359 | assert(type(r) == "table" and type(s) == "table" and | 359 | assert(type(r) == "table" and type(s) == "table" and |
| 360 | (e == "timeout" or e == "error")) | 360 | (e == "timeout" or e == "error")) |
| 361 | pass("both nil: ok") | 361 | pass("both nil: ok") |
| 362 | local udp = socket.udp() | 362 | local udp = socket.udp() |
| 363 | udp:close() | 363 | udp:close() |
| 364 | r, s, e = socket.select({ udp }, { udp }, 0.1) | 364 | r, s, e = socket.select({ udp }, { udp }, 0.1) |
| 365 | assert(type(r) == "table" and type(s) == "table" and | 365 | assert(type(r) == "table" and type(s) == "table" and |
| 366 | (e == "timeout" or e == "error")) | 366 | (e == "timeout" or e == "error")) |
| 367 | pass("closed sockets: ok") | 367 | pass("closed sockets: ok") |
| 368 | e = pcall(socket.select, "wrong", 1, 0.1) | 368 | e = pcall(socket.select, "wrong", 1, 0.1) |
| @@ -380,7 +380,7 @@ function accept_timeout() | |||
| 380 | local t = socket.gettime() | 380 | local t = socket.gettime() |
| 381 | s:settimeout(1) | 381 | s:settimeout(1) |
| 382 | local c, e = s:accept() | 382 | local c, e = s:accept() |
| 383 | assert(not c, "should not accept") | 383 | assert(not c, "should not accept") |
| 384 | assert(e == "timeout", string.format("wrong error message (%s)", e)) | 384 | assert(e == "timeout", string.format("wrong error message (%s)", e)) |
| 385 | t = socket.gettime() - t | 385 | t = socket.gettime() - t |
| 386 | assert(t < 2, string.format("took to long to give up (%gs)", t)) | 386 | assert(t < 2, string.format("took to long to give up (%gs)", t)) |
| @@ -398,9 +398,9 @@ function connect_timeout() | |||
| 398 | local t = socket.gettime() | 398 | local t = socket.gettime() |
| 399 | local r, e = c:connect("127.0.0.2", 80) | 399 | local r, e = c:connect("127.0.0.2", 80) |
| 400 | assert(not r, "should not connect") | 400 | assert(not r, "should not connect") |
| 401 | assert(socket.gettime() - t < 2, "took too long to give up.") | 401 | assert(socket.gettime() - t < 2, "took too long to give up.") |
| 402 | c:close() | 402 | c:close() |
| 403 | print("ok") | 403 | print("ok") |
| 404 | end | 404 | end |
| 405 | 405 | ||
| 406 | ------------------------------------------------------------------------ | 406 | ------------------------------------------------------------------------ |
| @@ -463,9 +463,9 @@ function getstats_test() | |||
| 463 | data:receive(c) | 463 | data:receive(c) |
| 464 | t = t + c | 464 | t = t + c |
| 465 | local r, s, a = data:getstats() | 465 | local r, s, a = data:getstats() |
| 466 | assert(r == t, "received count failed" .. tostring(r) | 466 | assert(r == t, "received count failed" .. tostring(r) |
| 467 | .. "/" .. tostring(t)) | 467 | .. "/" .. tostring(t)) |
| 468 | assert(s == t, "sent count failed" .. tostring(s) | 468 | assert(s == t, "sent count failed" .. tostring(s) |
| 469 | .. "/" .. tostring(t)) | 469 | .. "/" .. tostring(t)) |
| 470 | end | 470 | end |
| 471 | print("ok") | 471 | print("ok") |
| @@ -473,7 +473,7 @@ end | |||
| 473 | 473 | ||
| 474 | 474 | ||
| 475 | ------------------------------------------------------------------------ | 475 | ------------------------------------------------------------------------ |
| 476 | function test_nonblocking(size) | 476 | function test_nonblocking(size) |
| 477 | reconnect() | 477 | reconnect() |
| 478 | print("Testing " .. 2*size .. " bytes") | 478 | print("Testing " .. 2*size .. " bytes") |
| 479 | remote(string.format([[ | 479 | remote(string.format([[ |
diff --git a/test/utestsrvr.lua b/test/utestsrvr.lua index a96b570..b6e4246 100644 --- a/test/utestsrvr.lua +++ b/test/utestsrvr.lua | |||
| @@ -9,7 +9,7 @@ ack = "\n"; | |||
| 9 | while 1 do | 9 | while 1 do |
| 10 | print("server: waiting for client connection..."); | 10 | print("server: waiting for client connection..."); |
| 11 | control = assert(server:accept()); | 11 | control = assert(server:accept()); |
| 12 | while 1 do | 12 | while 1 do |
| 13 | command = assert(control:receive()); | 13 | command = assert(control:receive()); |
| 14 | assert(control:send(ack)); | 14 | assert(control:send(ack)); |
| 15 | ((loadstring or load)(command))(); | 15 | ((loadstring or load)(command))(); |
