[LLVMdev] [PATCH][Review request] MappedMemoryTest: Prevent tests from running if read flag is not set.

Kaylor, Andrew andrew.kaylor at intel.com
Wed Dec 5 14:24:43 PST 2012


Look good.

-Andy

From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Akira Hatanaka
Sent: Tuesday, December 04, 2012 1:33 PM
To: LLVM Developers Mailing List
Subject: [LLVMdev] [PATCH][Review request] MappedMemoryTest: Prevent tests from running if read flag is not set.

The attached patch prevents MappedMemoryTest.BasicWrite and MappedMemoryTest.MultipleWrite (both in unittests/Support/MemoryTest.cpp) from running if the correct protection flags for memory allocation are not set. Without this patch, the two tests fail when I run "make check-all" on a mips octeon board.

The problem with the current code is that it allocates a block of memory without setting the read flag. This results in a segfault at line 115 of MemoryTest.cpp where it reads the allocated block to check whether 1 has been written into the first word of the block. This patch fixes this, and checks that both read and write flags are set.


unittests/Support/MemoryTest.cpp (line 101)

TEST_P(MappedMemoryTest, BasicWrite) {
  // This test applies only to writeable combinations
  if (Flags && !(Flags & Memory::MF_WRITE))
    return;

  MemoryBlock M1 = Memory::allocateMappedMemory(sizeof(int), 0, Flags, EC);
  ...
  int *a = (int*)M1.base();
  *a = 1;
  EXPECT_EQ(1, *a); // This line segfaults.
  ...
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121205/a503d7e4/attachment.html>


More information about the llvm-dev mailing list