diff options
Diffstat (limited to 'testes')
| -rw-r--r-- | testes/files.lua | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/testes/files.lua b/testes/files.lua index 05fae49b..2c802047 100644 --- a/testes/files.lua +++ b/testes/files.lua | |||
| @@ -696,6 +696,37 @@ do | |||
| 696 | end | 696 | end |
| 697 | 697 | ||
| 698 | 698 | ||
| 699 | if T and T.nonblock then | ||
| 700 | print("testing failed write") | ||
| 701 | |||
| 702 | -- unable to write anything to /dev/full | ||
| 703 | local f = io.open("/dev/full", "w") | ||
| 704 | assert(f:setvbuf("no")) | ||
| 705 | local _, _, err, count = f:write("abcd") | ||
| 706 | assert(err > 0 and count == 0) | ||
| 707 | assert(f:close()) | ||
| 708 | |||
| 709 | -- receiver will read a "few" bytes (enough to empty a large buffer) | ||
| 710 | local receiver = [[ | ||
| 711 | lua -e 'assert(io.stdin:setvbuf("no")); assert(#io.read(1e4) == 1e4)' ]] | ||
| 712 | |||
| 713 | local f = io.popen(receiver, "w") | ||
| 714 | assert(f:setvbuf("no")) | ||
| 715 | T.nonblock(f) | ||
| 716 | |||
| 717 | -- able to write a few bytes | ||
| 718 | assert(f:write(string.rep("a", 1e2))) | ||
| 719 | |||
| 720 | -- Unable to write more bytes than the pipe buffer supports. | ||
| 721 | -- (In Linux, the pipe buffer size is 64K (2^16). Posix requires at | ||
| 722 | -- least 512 bytes.) | ||
| 723 | local _, _, err, count = f:write("abcd", string.rep("a", 2^17)) | ||
| 724 | assert(err > 0 and count >= 512 and count < 2^17) | ||
| 725 | |||
| 726 | assert(f:close()) | ||
| 727 | end | ||
| 728 | |||
| 729 | |||
| 699 | if not _soft then | 730 | if not _soft then |
| 700 | print("testing large files (> BUFSIZ)") | 731 | print("testing large files (> BUFSIZ)") |
| 701 | io.output(file) | 732 | io.output(file) |
