Page MenuHomeFreeBSD

Add a CHILD_REQUIRE for use in children.
ClosedPublic

Authored by jhb on May 28 2015, 3:07 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 26, 6:39 AM
Unknown Object (File)
Fri, Apr 26, 6:38 AM
Unknown Object (File)
Thu, Apr 11, 8:48 AM
Unknown Object (File)
Feb 6 2024, 10:39 PM
Unknown Object (File)
Jan 9 2024, 2:01 AM
Unknown Object (File)
Jan 7 2024, 2:54 PM
Unknown Object (File)
Nov 14 2023, 1:43 AM
Unknown Object (File)
Nov 6 2023, 7:28 AM
Subscribers

Details

Summary

Add a CHILD_REQUIRE macro similar to ATF_REQUIRE for use in child processes
of the main test process.

Test Plan
  • 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

jhb retitled this revision from to Add a CHILD_REQUIRE for use in children..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added a reviewer: ngie.
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?

ngie added reviewers: jmmv, Restricted Project.May 29 2015, 5:33 PM
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.

ngie edited edge metadata.
ngie added inline comments.
tests/sys/kern/ptrace_test.c
58 ↗(On Diff #5747)

Maybe calling abort by itself would be a better idea...

  • It would generate a corefile, which would contain the string that the program is trying to print out. I'm pretty sure it would get automatically reaped by kyua though (this is problematic I guess..); I opened this Issue: https://github.com/jmmv/kyua/issues/138 to track the item.
  • If kyua is configured properly, it would start gdb and dump the stack if/when the testcase crashes (which doesn't seem to be the case today? Not sure. configure.ac seems to imply that it will look for gdb and if found use it: https://github.com/jmmv/kyua/blob/master/configure.ac#L85 ).

All in all it's highly unlikely that this would occur, and if it does, we're in a really bad situation system-wide...

This revision is now accepted and ready to land.May 30 2015, 9:27 PM
jhb edited edge metadata.
  • Add a CHILD_REQUIRE for use in children. (rebased)
  • Use snprintf() into a fixed size buffer instead of asprintf().
This revision now requires review to proceed.Jun 4 2015, 8:47 PM
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.

jhb added a reviewer: jhb.
This revision is now accepted and ready to land.Jun 4 2015, 9:05 PM
This revision was automatically updated to reflect the committed changes.