aboutsummaryrefslogtreecommitdiff
path: root/test/utestclnt.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/utestclnt.lua')
-rw-r--r--test/utestclnt.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/utestclnt.lua b/test/utestclnt.lua
index 7f10643..395260c 100644
--- a/test/utestclnt.lua
+++ b/test/utestclnt.lua
@@ -511,6 +511,48 @@ remote(string.format([[
511end 511end
512 512
513------------------------------------------------------------------------ 513------------------------------------------------------------------------
514function test_maxsize()
515 -- A4: #prefix == maxsize raises (mirrors testclnt.lua group A)
516 reconnect()
517 pass("argument errors")
518 -- bounds the pre-implementation call (arg 4 silently dropped, so this
519 -- becomes a real blocking read on an idle socket) so a meaningful
520 -- failure doesn't hang the suite
521 data:settimeout(0.2)
522 local ok = pcall(data.receive, data, "*l", string.rep("x", 10), 10)
523 assert(not ok, "A4 failed: #prefix == maxsize should raise")
524 data:settimeout(-1)
525
526 -- B2/B3: *l boundary (mirrors testclnt.lua group B)
527 pass("*l boundary")
528 remote(string.format([[data:send(string.rep('a',%d) .. '\n')]], 100))
529 local d, e, p = data:receive("*l", nil, 100)
530 assert(d == string.rep("a", 100) and e == nil, "B2 failed")
531
532 remote(string.format([[data:send(string.rep('a',%d) .. '\n')]], 101))
533 d, e, p = data:receive("*l", nil, 100)
534 assert(d == nil and e == "oversized" and p == string.rep("a", 100), "B3 failed")
535 d, e = data:receive("*l", nil, 100)
536 assert(d == "a" and e == nil, "B3 failed: leftover byte")
537
538 -- C2: timeout exactly at the cap is oversized, not timeout (I1)
539 reconnect()
540 remote(string.format([[data:send(string.rep('a',%d))]], 100))
541 data:settimeout(0.5)
542 d, e, p = data:receive("*l", nil, 100)
543 assert(e == "oversized" and #p == 100,
544 "C2 failed: expected oversized, got " .. tostring(e))
545
546 -- E2: completion beats the cap (I2)
547 reconnect()
548 remote(string.format([[data:send(string.rep('a',%d)) data:close() data = nil]], 100))
549 d, e = data:receive("*a", nil, 100)
550 assert(d == string.rep("a", 100) and e == nil,
551 "E2 failed: completion should beat the cap")
552 pass("ok")
553end
554
555------------------------------------------------------------------------
514 556
515test("method registration") 557test("method registration")
516test_methods(socket.unix(), { 558test_methods(socket.unix(), {
@@ -641,4 +683,7 @@ test_blockingtimeoutreceive(800091, 2, 3)
641test_blockingtimeoutreceive(800091, 3, 2) 683test_blockingtimeoutreceive(800091, 3, 2)
642test_blockingtimeoutreceive(800091, 3, 1) 684test_blockingtimeoutreceive(800091, 3, 1)
643 685
686test("receive maxsize")
687test_maxsize()
688
644test(string.format("done in %.2fs", socket.gettime() - start)) 689test(string.format("done in %.2fs", socket.gettime() - start))