summaryrefslogtreecommitdiff
path: root/snappy_unittest.cc
diff options
context:
space:
mode:
authorsnappy.mirrorbot@gmail.com <snappy.mirrorbot@gmail.com@03e5f5b5-db94-4691-08a0-1a8bf15f6143>2011-03-24 19:13:57 +0000
committersnappy.mirrorbot@gmail.com <snappy.mirrorbot@gmail.com@03e5f5b5-db94-4691-08a0-1a8bf15f6143>2011-03-24 19:13:57 +0000
commit94cf8cb109cc68fe1e7b634509e8c4bfb46351b0 (patch)
tree682db37e110df68d1b17d661a391b73bbf406cdc /snappy_unittest.cc
parenta86c963d9fce9d95aa69e622c153cdcc4de09f70 (diff)
downloadsnappy-94cf8cb109cc68fe1e7b634509e8c4bfb46351b0.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: http://snappy.googlecode.com/svn/trunk@16 03e5f5b5-db94-4691-08a0-1a8bf15f6143
Diffstat (limited to 'snappy_unittest.cc')
-rw-r--r--snappy_unittest.cc13
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,
};