Commit b03be9a3 authored by Kenton Varda's avatar Kenton Varda

Fix Cygwin tests.

parent 3353ff72
......@@ -194,7 +194,7 @@ TEST(AsyncIo, TwoWayPipe) {
EXPECT_EQ("bar", result2);
}
#if !_WIN32
#if !_WIN32 && !__CYGWIN__
TEST(AsyncIo, CapabilityPipe) {
auto ioContext = setupAsyncIo();
......
......@@ -196,7 +196,7 @@ private:
bool isWine() { return false; }
#if __APPLE__
#if __APPLE__ || __CYGWIN__
#define HOLES_NOT_SUPPORTED 1
#endif
......@@ -324,7 +324,7 @@ KJ_TEST("DiskFile") {
file->write(12, StringPtr("corge").asBytes());
KJ_EXPECT(kj::str(mapping.slice(12, 17).asChars()) == "corge");
#if !_WIN32 // Windows doesn't allow the file size to change while mapped.
#if !_WIN32 && !__CYGWIN__ // Windows doesn't allow the file size to change while mapped.
// Can shrink.
file->truncate(6);
KJ_EXPECT(kj::str(mapping.slice(12, 17).asChars()) == kj::StringPtr("\0\0\0\0\0", 5));
......@@ -723,6 +723,7 @@ KJ_TEST("DiskDirectory createTemporary") {
KJ_EXPECT(dir->listNames() == nullptr);
}
#if !__CYGWIN__ // TODO(soon): Figure out why this doesn't work on Cygwin.
KJ_TEST("DiskDirectory replaceSubdir()") {
TempDir tempDir;
auto dir = tempDir.get();
......@@ -762,6 +763,7 @@ KJ_TEST("DiskDirectory replaceSubdir()") {
KJ_EXPECT(!dir->exists(Path({"foo", "bar"})));
KJ_EXPECT(dir->openFile(Path({"foo", "corge"}))->readAllText() == "bazqux");
}
#endif // !__CYGWIN__
KJ_TEST("DiskDirectory replace directory with file") {
TempDir tempDir;
......
......@@ -222,7 +222,12 @@ struct MmapRange {
};
static MmapRange getMmapRange(uint64_t offset, uint64_t size) {
// Rounds the given byte range up to page boundaries.
// Comes up with an offset and size to pass to mmap(), given an offset and size requested by
// the caller, and considering the fact that mappings must start at a page boundary.
//
// The offset is rounded down to the nearest page boundary, and the size is increased to
// compensate. Note that the endpoint of the mapping is *not* rounded up to a page boundary, as
// mmap() does not actually require this, and it causes trouble on some systems (notably Cygwin).
#ifndef _SC_PAGESIZE
#define _SC_PAGESIZE _SC_PAGE_SIZE
......@@ -232,10 +237,7 @@ static MmapRange getMmapRange(uint64_t offset, uint64_t size) {
uint64_t realOffset = offset & ~pageMask;
uint64_t end = offset + size;
uint64_t realEnd = (end + pageMask) & ~pageMask;
return { realOffset, realEnd - realOffset };
return { realOffset, offset + size - realOffset };
}
class MmapDisposer: public ArrayDisposer {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment