mirror of
https://github.com/yuzu-emu/breakpad.git
synced 2024-11-24 06:55:48 +01:00
elf_core_dump_unittest: skip test if setrlimit will fail
Some systems have constrained rlimits for core files (the CrOS chroot is an example of this). Fail gracefully in this case, rather than breaking the user's tests. Bug: b:235999011 Change-Id: I5649b42d3e6fd9b4f9b11e1fd9d0d4a1083d300f Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3722724 Reviewed-by: Mark Mentovai <mark@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
parent
ad8a43f367
commit
a8e8a69591
@ -130,9 +130,13 @@ TEST(ElfCoreDumpTest, TestElfHeader) {
|
||||
TEST(ElfCoreDumpTest, ValidCoreFile) {
|
||||
CrashGenerator crash_generator;
|
||||
if (!crash_generator.HasDefaultCorePattern()) {
|
||||
fprintf(stderr, "ElfCoreDumpTest.ValidCoreFile test is skipped "
|
||||
"due to non-default core pattern");
|
||||
return;
|
||||
GTEST_SKIP() << "ElfCoreDumpTest.ValidCoreFile test is skipped "
|
||||
"due to non-default core pattern";
|
||||
}
|
||||
|
||||
if (!crash_generator.HasResourceLimitsAmenableToCrashCollection()) {
|
||||
GTEST_SKIP() << "ElfCoreDumpTest.ValidCoreFile test is skipped "
|
||||
"due to inadequate system resource limits";
|
||||
}
|
||||
|
||||
const unsigned kNumOfThreads = 3;
|
||||
|
@ -169,6 +169,15 @@ bool CrashGenerator::SetCoreFileSizeLimit(rlim_t limit) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CrashGenerator::HasResourceLimitsAmenableToCrashCollection() const {
|
||||
struct rlimit limits;
|
||||
if (getrlimit(RLIMIT_CORE, &limits) == -1) {
|
||||
perror("CrashGenerator: Failed to get core file size limit");
|
||||
return false;
|
||||
}
|
||||
return limits.rlim_max >= kCoreSizeLimit;
|
||||
}
|
||||
|
||||
bool CrashGenerator::CreateChildCrash(
|
||||
unsigned num_threads, unsigned crash_thread, int crash_signal,
|
||||
pid_t* child_pid) {
|
||||
|
@ -65,6 +65,10 @@ class CrashGenerator {
|
||||
// Returns the directory of a copy of proc files of the child process.
|
||||
string GetDirectoryOfProcFilesCopy() const;
|
||||
|
||||
// Returns whether current resource limits would prevent `CreateChildCrash`
|
||||
// from operating.
|
||||
bool HasResourceLimitsAmenableToCrashCollection() const;
|
||||
|
||||
// Creates a crash (and a core dump file) by creating a child process with
|
||||
// |num_threads| threads, and the terminating the child process by sending
|
||||
// a signal with number |crash_signal| to the |crash_thread|-th thread.
|
||||
|
Loading…
Reference in New Issue
Block a user