Details
- Reviewers
markj ngie - Commits
- rG2fbb6e213ac2: closefrom_test: Convert to atf-c(3)
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
This seems ok to me. We are making some assumptions about the execution environment though; it might be good to somehow guarantee that there are no holes in the fd space when an ATF test starts.
| tests/sys/file/closefrom_test.c | ||
|---|---|---|
| 136 | I'm not really sure why this assertion must be true when the test is running in under a framework it doesn't control. This test also assumes that all fds up to 2 are open. | |
| tests/sys/file/closefrom_test.c | ||
|---|---|---|
| 136 | Yeah. That doesn't seem terribly wise... seems better to get the highest fd to start with, then work off that. | |
| tests/sys/file/closefrom_test.c | ||
|---|---|---|
| 82 | Here's a place we assume stderr is valid btw. Same in ptrace_test. | |
| 94 | Hmm, I copied this over from ptrace_test and it should probably be fixed there I guess. | |
| 136 | It is getting the highest fd before opening anything and working off of that. C and POSIX basically require 0/1/2 to be stdin/out/err and be open. That doesn't seem an unreasonable requirement that we are running in a valid POSIX environment? | |
| tests/sys/file/closefrom_test.c | ||
|---|---|---|
| 139 | Mark points out that this is probably the more interesting assumption as this is assuming that any extra file descriptors opened by the testing framework are "dense". This is probably true normally as you have to go out of your way a bit to get non-dense fds due to POSIX's requirements. I have tested this both standalone as well as under kyua test FWIW. | |
Possibly the child processes should all use _exit(), yes.
| tests/sys/file/closefrom_test.c | ||
|---|---|---|
| 213–217 | Shouldn't the strings be the empty strings? But also, I think this means I can perhaps avoid using CHILD_REQUIRE and just use ATF_REQUIRE directly in child processes? | |
| tests/sys/file/closefrom_test.c | ||
|---|---|---|
| 68–70 | I stopped using stderr here as when I inserted an intentionally false CHILD_REQUIRE I didn't actually get stderr output as closefrom() had closed stderr, so I ended up going back to using simple IPC via a shared page allocated before fork() to pass errors back to the parent. This does report errors nicely if a child requirement fails. | |
| 196 | I believe that atf_utils_fork() flushes streams (certainly stdout and stderr) internally, so using exit() should be fine. | |