internal/gocore/test: increase rlimit to max in parent

In our CI system, RLIMIT_CORE's maximum value is not `unlimited`. So
`setrlimit(RLIMIT_CORE, {...RLIM_INFINITY})` fails. Instead set it to
the maximum and ensure that it's not 0. A core file, even if truncated,
should get created.

Additionally, move the rlimit increase to the parent instead of the
child. This makes it easier to add more test binaries without
duplicating code. To make this stick, wrap the spawn with
`(Un)LockOSThread`.

The new `run()` function returns a PID, which isn't necessary here, but
is useful in case `/proc/sys/kernel/core_pattern` contains format
modifiers like %p, as happens in our CI.

Change-Id: Ied3533e0910dde2df888e50ca88c607ef33afacc
Reviewed-on: https://go-review.googlesource.com/c/debug/+/619555
Auto-Submit: Nicolas Hillegeer <aktau@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 files changed
tree: bf43890a4c6c181608fcff8a03eb8fb977409b18
  1. cmd/
  2. dwtest/
  3. internal/
  4. codereview.cfg
  5. CONTRIBUTING.md
  6. go.mod
  7. go.sum
  8. LICENSE
  9. README.md
README.md

Go Debug

Go Reference

This repository holds utilities and libraries for debugging Go programs.

WARNING! Please expect breaking changes and unstable APIs. Most of them are currently are at an early, experimental stage.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html.

The main issue tracker for the debug repository is located at https://github.com/golang/go/issues. Prefix your issue with “x/debug:” in the subject line, so it is easy to find.