Tweak/Wontfix a few tests that we could care less about.
[chromium-blink-merge.git] / base / test / test_file_util_mac.cc
blob316b5c3d01aa9aec7c42d64bce64be95cd0b0969
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/test/test_file_util.h"
7 #include <sys/mman.h>
8 #include <errno.h>
9 #include "base/logging.h"
10 #include "base/file_util.h"
12 namespace file_util {
14 bool EvictFileFromSystemCache(const FilePath& file) {
15 // There aren't any really direct ways to purge a file from the UBC. From
16 // talking with Amit Singh, the safest is to mmap the file with MAP_FILE (the
17 // default) + MAP_SHARED, then do an msync to invalidate the memory. The next
18 // open should then have to load the file from disk.
20 file_util::MemoryMappedFile mapped_file;
21 if (!mapped_file.Initialize(file)) {
22 DLOG(WARNING) << "failed to memory map " << file.value();
23 return false;
26 if (msync(const_cast<uint8*>(mapped_file.data()), mapped_file.length(),
27 MS_INVALIDATE) != 0) {
28 DLOG(WARNING) << "failed to invalidate memory map of " << file.value()
29 << ", errno: " << errno;
30 return false;
33 return true;
36 } // namespace file_util