Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1905)

Unified Diff: tests/syscalls/mem_test.cc

Issue 1264783002: Remove failure for bad mmap address hints. (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Dodging copyright presubmit warning Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/syscalls/mem_test.cc
diff --git a/tests/syscalls/mem_test.cc b/tests/syscalls/mem_test.cc
index 24a6420099d58342ca40abc2863998ca5cc100e5..79818d0de55b0cb8e29e2cedc47ace8cae95a25e 100644
--- a/tests/syscalls/mem_test.cc
+++ b/tests/syscalls/mem_test.cc
@@ -1,6 +1,8 @@
-// Copyright 2010 The Native Client Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can
-// be found in the LICENSE file.
+/*
+ * Copyright (c) 2015 The Native Client Authors. All rights reserved.
Mark Seaborn 2015/07/30 21:02:24 FWIW, current policy is to leave the copyright yea
Sean Klein 2015/07/30 21:49:16 Whoops. Changing it back to 2010.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
#include <errno.h>
#include <sys/mman.h>
@@ -54,6 +56,38 @@ int TestBadFiledesc() {
END_TEST();
}
+// Verify that mmap does not fail if a bad hint address is passed, but
+// |MMAP_FIXED| is not specified.
+int TestMmapBadHint() {
+ START_TEST("TestMmapBadHint");
+ void* bad_hint = (void *) 0x123;
+ void* mmap_ptr = mmap(bad_hint,
+ k64Kbytes,
+ PROT_READ,
+ MAP_PRIVATE | MAP_ANONYMOUS,
+ kAnonymousFiledesc,
+ 0);
+ EXPECT(MAP_FAILED != mmap_ptr);
+ EXPECT(mmap_ptr != bad_hint);
+ EXPECT(munmap(mmap_ptr, k64Kbytes) == 0);
+ END_TEST();
+}
+
+// Verify that mmap does fail if a bad hint address is passed and
+// |MMAP_FIXED| is specified.
+int TestMmapBadHintFixed() {
+ START_TEST("TestMmapBadHintFixed");
+ void* bad_hint = (void *) 0x123;
+ void* mmap_ptr = mmap(bad_hint,
+ k64Kbytes,
+ PROT_READ,
+ MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED,
+ kAnonymousFiledesc,
+ 0);
+ EXPECT(MAP_FAILED == mmap_ptr);
+ END_TEST();
+}
+
// Test mmap() and munmap(), since these often to go together. Tries to mmap
// a 64 Kb region of memory and then tests to make sure that the pages have all
// been 0-filled.
@@ -158,6 +192,8 @@ int main() {
int fail_count = 0;
fail_count += TestZeroLengthRegion();
fail_count += TestBadFiledesc();
+ fail_count += TestMmapBadHint();
+ fail_count += TestMmapBadHintFixed();
fail_count += TestMmapMunmap();
fail_count += TestMunmapText();
fail_count += TestMmapNULL();
« src/trusted/service_runtime/sys_memory.c ('K') | « src/trusted/service_runtime/sys_memory.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698