diff options
author | snappy.mirrorbot@gmail.com <snappy.mirrorbot@gmail.com@03e5f5b5-db94-4691-08a0-1a8bf15f6143> | 2011-03-24 19:13:57 +0000 |
---|---|---|
committer | snappy.mirrorbot@gmail.com <snappy.mirrorbot@gmail.com@03e5f5b5-db94-4691-08a0-1a8bf15f6143> | 2011-03-24 19:13:57 +0000 |
commit | 444a6c5f72d6f8d8f7213a5bcc08b26606eb9934 (patch) | |
tree | 682db37e110df68d1b17d661a391b73bbf406cdc /snappy_unittest.cc | |
parent | 2e182e9bb840737f9cd8817e859dc17a82f2c16b (diff) | |
download | snappy-git-444a6c5f72d6f8d8f7213a5bcc08b26606eb9934.tar.gz |
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: https://snappy.googlecode.com/svn/trunk@16 03e5f5b5-db94-4691-08a0-1a8bf15f6143
Diffstat (limited to 'snappy_unittest.cc')
-rw-r--r-- | snappy_unittest.cc | 13 |
1 files changed, 9 insertions, 4 deletions
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 <math.h> #include <stdlib.h> -#include <sys/mman.h> #include <algorithm> #include <string> @@ -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, }; |