From 94cf8cb109cc68fe1e7b634509e8c4bfb46351b0 Mon Sep 17 00:00:00 2001 From: "snappy.mirrorbot@gmail.com" Date: Thu, 24 Mar 2011 19:13:57 +0000 Subject: Make the unit test work on systems without mmap(). This is required for, among others, Windows support. For Windows in specific, we could have used CreateFileMapping/MapViewOfFile, but this should at least get us a bit closer to compiling, and is of course also relevant for embedded systems with no MMU. (Part 2/2) R=csilvers DELTA=15 (12 added, 3 deleted, 0 changed) Revision created by MOE tool push_codebase. MOE_MIGRATION=1032 git-svn-id: http://snappy.googlecode.com/svn/trunk@16 03e5f5b5-db94-4691-08a0-1a8bf15f6143 --- snappy_unittest.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'snappy_unittest.cc') diff --git a/snappy_unittest.cc b/snappy_unittest.cc index f278633..23c6eec 100644 --- a/snappy_unittest.cc +++ b/snappy_unittest.cc @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -54,15 +53,14 @@ DEFINE_bool(write_uncompressed, false, namespace snappy { +#ifdef HAVE_FUNC_MMAP + // To test against code that reads beyond its input, this class copies a // string to a newly allocated group of pages, the last of which // is made unreadable via mprotect. Note that we need to allocate the // memory with mmap(), as POSIX allows mprotect() only on memory allocated // with mmap(), and some malloc/posix_memalign implementations expect to // be able to read previously allocated memory while doing heap allocations. -// -// TODO(user): Add support for running the unittest without the protection -// checks if the target system doesn't have mmap. class DataEndingAtUnreadablePage { public: explicit DataEndingAtUnreadablePage(const string& s) { @@ -100,6 +98,13 @@ class DataEndingAtUnreadablePage { size_t size_; }; +#else // HAVE_FUNC_MMAP + +// Fallback for systems without mmap. +typedef string DataEndingAtUnreadablePage; + +#endif + enum CompressorType { ZLIB, LZO, LIBLZF, QUICKLZ, FASTLZ, SNAPPY, }; -- cgit v1.2.1