From 66460ce1d979618851bace0635b438d2be3f116a Mon Sep 17 00:00:00 2001 From: "benchan@chromium.org" Date: Thu, 3 Apr 2014 16:50:06 +0000 Subject: [PATCH] Fix ElfCoreDumpTest.ValidCoreFile unit test. The ElfCoreDumpTest.ValidCoreFile unit test assumed that the number of NT_FPREGSET / NT_PRXFPREG notes in the core dump file equals to the number of threads of the crashed process. This assumption isn't always true as the kernel skips filling the NT_FPREGSET / NT_PRXFPREG note of a thread if the FPU state isn't available. The kernel indicates the availability of NT_FPREGSET / NT_PRXFPREG via the pr_fpvalid field of the NT_PRSTATUS note. This CL modifies the ElfCoreDumpTest.ValidCoreFile unit test to verify the number of NT_FPREGSET and NT_PRXFPREG notes based on the pr_fpvalid field of the NT_PRSTATUS notes. BUG=577 TEST=Run unit tests on x86 and x86_64 Linux platform. R=vapier@chromium.org Review URL: https://breakpad.appspot.com/1404002 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1303 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/common/linux/elf_core_dump_unittest.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/common/linux/elf_core_dump_unittest.cc b/src/common/linux/elf_core_dump_unittest.cc index 7c122aa6..4eae9680 100644 --- a/src/common/linux/elf_core_dump_unittest.cc +++ b/src/common/linux/elf_core_dump_unittest.cc @@ -176,6 +176,7 @@ TEST(ElfCoreDumpTest, ValidCoreFile) { size_t num_nt_prpsinfo = 0; size_t num_nt_prstatus = 0; + size_t num_pr_fpvalid = 0; #if defined(__i386__) || defined(__x86_64__) size_t num_nt_fpregset = 0; #endif @@ -207,6 +208,8 @@ TEST(ElfCoreDumpTest, ValidCoreFile) { EXPECT_EQ(kCrashSignal, status->pr_info.si_signo); } ++num_nt_prstatus; + if (status->pr_fpvalid) + ++num_pr_fpvalid; break; } #if defined(__i386__) || defined(__x86_64__) @@ -235,9 +238,9 @@ TEST(ElfCoreDumpTest, ValidCoreFile) { EXPECT_EQ(1U, num_nt_prpsinfo); EXPECT_EQ(kNumOfThreads, num_nt_prstatus); #if defined(__i386__) || defined(__x86_64__) - EXPECT_EQ(kNumOfThreads, num_nt_fpregset); + EXPECT_EQ(num_pr_fpvalid, num_nt_fpregset); #endif #if defined(__i386__) - EXPECT_EQ(kNumOfThreads, num_nt_prxfpreg); + EXPECT_EQ(num_pr_fpvalid, num_nt_prxfpreg); #endif }