-
Notifications
You must be signed in to change notification settings - Fork 177
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
Test the Unix binding #539
Milestone
Comments
@aantron I will work on Bigstrings. |
Merged
Now I will work on "sleeping and timeout". |
I continue with |
aantron
pushed a commit
that referenced
this issue
Mar 18, 2019
relates to #539 Signed-off-by: Anurag Soni <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NOTE: this will be much easier to work on after mirage/alcotest#177 and #701.
This is a big issue for lots of PRs. Some parts of it could be quite easy, but on the whole I'd say it is of medium difficulty.
Some care should be taken to run the tests properly sandboxed, i.e. files created in temporary directories, etc. For that, the test framework in
test/test.ml
will probably have to be extended with new helper functions. I'm not sure how to sandbox DNS and some of the other APIs. We should probably discuss that.Besides correct behavior, we need really thorough tests for various error conditions. The typical system call has man pages on multiple systems, listing the various ways the system call can fail. We want to trigger as many of those as possible. See section Help below for links to man pages.
The work
To make this manageable, I would break the work into chunks, based on the current order of functions in the various
.mli
files of the Unix binding. These aren't listed necessarily in the order they should be tested in. We generally want simple and obvious things tested first, and more complex things that depend on them tested later.There are a few tests already written, but I included all the functions in the category list, so make sure to check before choosing a category. I'll try to keep the check boxes up to date.
If you'd like to work on one of these items, please leave a comment, to avoid duplication of effort :)
Bigstrings. This is pure OCaml, and should be easy. (Test unix bytes #619, by @cedlemo)Sleeping and timeouts, probably best tested with the help of. (Test lwt unix sleeping and timeout functions #630, by @cedlemo)Unix.gettimeofday
Lwt_throttle
. I guess this is in the Unix binding because it is aware of real time.Lwt_timeout
.Unix
fd, but really thorough testing here would have to exercise the optional arguments, and so this might depend on testingread
orwrite
first.Lwt_unix.close
,Lwt_unix.abort
, andLwt_unix.state
.Lwt_preemptive
).Lwt_process
).Lwt_unix.unix_file_descr
to them, and checking for equality withUnix.stdout
, etc.Lwt_unix.openfile
. This is tricky, because there are many options to test, some of them are platform-specific, etc.Vector I/O. This was already done when vector I/O was added in writev – zero-copy gather output #291, but if you see more things to test, please test them :)fsync
.fstat
; and for large files.lockf
.Users. (Add tests for user id and group id #673, by @anuragsoni)Bigstring I/O. (Test lwt bytes second part #621, by @cedlemo)Memory mapping. (Test lwt bytes third part #628, by @cedlemo)Multicast. I believe we already have decent tests here, from Lwt_unix: add support for joining/leaving multicast groups #143.I've left
Lwt_io
for a separate issue.Help
Cheating off
Unix
Some of the easiest ways to test some bindings would be to do something with
Lwt_unix
(or other Lwt module), and check the result using stdlib'sUnix
.man pages
Here are some man page references:
MacIt seems Apple has archived their man pages and made them difficult to discover, so you have to do a web search for each system call.src/unix/windows_c/*
, and then look the API up in MSDN. A search is probably the easiest way.Skipping tests
Many Lwt APIs aren't implemented on Windows. Tests for them can be skipped like this:
lwt/test/unix/test_lwt_process.ml
Line 27 in 4f0dabc
Coverage analysis
Coverage analysis is enabled for the OCaml code of the Unix binding – run
make coverage
, then open_coverage/index.html
. This can help to see what still needs testing, though some of the code is visited unintentionally because other code depends on it. We don't have coverage analysis for C code at the moment. That could be its own PR, but maybe it's not necessary.Of course, high coverage doesn't imply thorough testing. Only low coverage implies insufficient testing.
cc @cedlemo
The text was updated successfully, but these errors were encountered: