aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2007-06-11 23:44:54 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2007-06-11 23:44:54 +0000
commit3cd10f5ab6cda5c4a8db829dd38f25168edcfc4a (patch)
treef0c49eb250f5375414025a9e7022261e729ad905 /test
parent3074a8f56b5153f4477e662453102583d7b6f539 (diff)
downloadluasocket-3cd10f5ab6cda5c4a8db829dd38f25168edcfc4a.tar.gz
luasocket-3cd10f5ab6cda5c4a8db829dd38f25168edcfc4a.tar.bz2
luasocket-3cd10f5ab6cda5c4a8db829dd38f25168edcfc4a.zip
Crashy bug fixed in recvraw.
Also fixed returns on closed socket.
Diffstat (limited to 'test')
-rw-r--r--test/testclnt.lua61
-rw-r--r--test/testmesg.lua2
2 files changed, 61 insertions, 2 deletions
diff --git a/test/testclnt.lua b/test/testclnt.lua
index 304cfd3..2f4ffad 100644
--- a/test/testclnt.lua
+++ b/test/testclnt.lua
@@ -498,7 +498,63 @@ remote(string.format([[
498end 498end
499 499
500------------------------------------------------------------------------ 500------------------------------------------------------------------------
501 501function test_readafterclose()
502 local back, partial, err
503 local str = 'little string'
504 reconnect()
505 pass("trying repeated '*a' pattern")
506 remote (string.format ([[
507 data:send('%s')
508 data:close()
509 data = nil
510 ]], str))
511 back, err, partial = data:receive("*a")
512 assert(back == str, "unexpected data read")
513 back, err, partial = data:receive("*a")
514 assert(back == nil and err == "closed", "should have returned 'closed'")
515 print("ok")
516 reconnect()
517 pass("trying active close before '*a'")
518 remote (string.format ([[
519 data:close()
520 data = nil
521 ]]))
522 data:close()
523 back, err, partial = data:receive("*a")
524 assert(back == nil and err == "closed", "should have returned 'closed'")
525 print("ok")
526 reconnect()
527 pass("trying active close before '*l'")
528 remote (string.format ([[
529 data:close()
530 data = nil
531 ]]))
532 data:close()
533 back, err, partial = data:receive()
534 assert(back == nil and err == "closed", "should have returned 'closed'")
535 print("ok")
536 reconnect()
537 pass("trying active close before raw 1")
538 remote (string.format ([[
539 data:close()
540 data = nil
541 ]]))
542 data:close()
543 back, err, partial = data:receive(1)
544 assert(back == nil and err == "closed", "should have returned 'closed'")
545 print("ok")
546 reconnect()
547 pass("trying active close before raw 0")
548 remote (string.format ([[
549 data:close()
550 data = nil
551 ]]))
552 data:close()
553 back, err, partial = data:receive(0)
554 assert(back == nil and err == "closed", "should have returned 'closed'")
555 print("ok")
556os.exit()
557end
502 558
503test("method registration") 559test("method registration")
504test_methods(socket.tcp(), { 560test_methods(socket.tcp(), {
@@ -541,6 +597,9 @@ test_methods(socket.udp(), {
541 "settimeout" 597 "settimeout"
542}) 598})
543 599
600test("testing read after close")
601test_readafterclose()
602
544test("select function") 603test("select function")
545test_selectbugs() 604test_selectbugs()
546 605
diff --git a/test/testmesg.lua b/test/testmesg.lua
index 04305f4..580693b 100644
--- a/test/testmesg.lua
+++ b/test/testmesg.lua
@@ -62,7 +62,7 @@ source = smtp.message{
62 headers = { 62 headers = {
63 ["ConTenT-tYpE"] = 'image/png; name="luasocket.png"', 63 ["ConTenT-tYpE"] = 'image/png; name="luasocket.png"',
64 ["content-disposition"] = 'attachment; filename="luasocket.png"', 64 ["content-disposition"] = 'attachment; filename="luasocket.png"',
65 ["content-description"] = 'a beautiful image', 65 ["content-description"] = 'our logo',
66 ["content-transfer-encoding"] = "BASE64" 66 ["content-transfer-encoding"] = "BASE64"
67 }, 67 },
68 body = ltn12.source.chain( 68 body = ltn12.source.chain(