Add a CHILD_REQUIRE macro similar to ATF_REQUIRE for use in child processes
of the main test process.
Details
- Reviewers
jhb ngie jmmv - Group Reviewers
Restricted Project - Commits
- rS284000: Add a CHILD_REQUIRE macro similar to ATF_REQUIRE for use in child processes
- Verified the updated test fails and outputs errors from child processes on stderr still on stable/10.
- Verified the updated test passes still on HEAD.
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
tests/sys/kern/ptrace_test.c | ||
---|---|---|
53–54 ↗ | (On Diff #5747) | __printflike would probably be a good idea here. |
58 ↗ | (On Diff #5747) | Might be a good idea to add... assert(cp != NULL) ..., or use something different from asprintf+write (I realize that this *shouldn't* happen, but to be on the safe side it'd be good to output the data as reliably as possible? |
tests/sys/kern/ptrace_test.c | ||
---|---|---|
53–54 ↗ | (On Diff #5747) | It explicitly does not accept a format string, only a raw string. |
58 ↗ | (On Diff #5747) | assert() uses fprintf(), so it's about as bad as using ATF_REQUIRE directly. If asprintf fails, then the result will be that the write() will silently fail with EFAULT, but the test will still fail. The user message will just be lost. You won't get a false positive from the test. Alternatively this could use a fixed-size buffer with open_memstream() or sbuf and output a possibly truncated message. |
tests/sys/kern/ptrace_test.c | ||
---|---|---|
58 ↗ | (On Diff #5747) | Maybe calling abort by itself would be a better idea...
All in all it's highly unlikely that this would occur, and if it does, we're in a really bad situation system-wide... |
- Add a CHILD_REQUIRE for use in children. (rebased)
- Use snprintf() into a fixed size buffer instead of asprintf().
tests/sys/kern/ptrace_test.c | ||
---|---|---|
58 ↗ | (On Diff #5747) | Actually, these messages are probably short anyway, so just using snprintf() into a fixed size buffer on the stack should work fine and be less fragile than asprintf(). In that case the failure result is a truncated message rather than a core. |