[LLVMdev] [PATCH][Review request] MappedMemoryTest: Prevent tests from running if read flag is not set.
Akira Hatanaka
ahatanak at gmail.com
Tue Dec 4 13:33:08 PST 2012
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/20121204/67fd4245/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: memorytest.patch
Type: application/octet-stream
Size: 1054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121204/67fd4245/attachment.obj>
More information about the llvm-dev
mailing list