-
Notifications
You must be signed in to change notification settings - Fork 3
tests/lapi: add io tests #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
b891b99
to
51b71db
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, Sergey!
Thanks for the patch!
Please consider my comments below.
local function TestOneInput(buf) | ||
local fdp = luzer.FuzzedDataProvider(buf) | ||
local str = fdp:consume_string(test_lib.MAX_STR_LEN) | ||
local lua_chunk = ("io.write([[%s]])"):format(str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If str
contains ]]
this string becomes invalid.
local function TestOneInput(buf) | ||
local fdp = luzer.FuzzedDataProvider(buf) | ||
local str = fdp:consume_string(test_lib.MAX_STR_LEN) | ||
local lua_chunk = ("io.write([[%s]])"):format(str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If str
contains ]]
this string becomes invalid.
local cur_pos = fh:seek() | ||
fh:seek("end") | ||
fh:seek("set", cur_pos) | ||
fh:read(mode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got the following return values for this read.
nil Bad file descriptor 9
|
||
local READ_MODE = { "*n", "*a", "*l" } | ||
|
||
local function TestOneInput(buf) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get the idea of the following test, please add the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is the following create IO object and make random operations with it (read, write, seek)
local function TestOneInput(buf) | ||
local fdp = luzer.FuzzedDataProvider(buf) | ||
local str = fdp:consume_string(test_lib.MAX_STR_LEN) | ||
local lua_cmd = ("%s -e '%s'"):format(test_lib.luabin(arg), str) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the expected behaviour if returned string str == "abc"
.
local fdp = luzer.FuzzedDataProvider(buf) | ||
local str = fdp:consume_string(test_lib.MAX_STR_LEN) | ||
local lua_cmd = ("%s -e '%s'"):format(test_lib.luabin(arg), str) | ||
local fh = io.popen(lua_cmd, "w") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use "w" mode if we read data from that program?
51b71db
to
b000c92
Compare
The functions below are not covered: `io.close()`, `io.flush()`, `io.input()`, `io.open()`, `io.output()`, `io.tmpfile()`, `io.type()`, `io.write()`, `file:close()`, `file:flush()`, `file:lines()`, `file:read()`, `file:seek()`, `file:setvbuf()`, `file:write()`.
b000c92
to
eb56c5e
Compare
The functions below are not covered:
io.close()
io.flush()
io.input()
io.open()
io.output()
io.tmpfile()
io.type()
io.write()
file:close()
file:flush()
file:lines()
file:read()
file:seek()
file:setvbuf()
file:write()