Source release 18.5.0
This commit is contained in:
@@ -34,10 +34,8 @@ namespace {
|
||||
constexpr char kGlobalDumpFileName[] = "dumped_global_filesystem.dat";
|
||||
constexpr char kPerOriginDumpFileName[] = "dumped_per_origin_filesystem.dat";
|
||||
|
||||
using StorageMap = TestHost::Storage::StorageMap;
|
||||
|
||||
// Load a TestHost file system from the real file system.
|
||||
bool ReloadFileSystem(const char* file_name, StorageMap* map) {
|
||||
bool ReloadFileSystem(const char* file_name, TestHost::Storage* store) {
|
||||
std::ifstream input(file_name);
|
||||
if (input.fail()) {
|
||||
// This is OK for first pass, but an error for later passes.
|
||||
@@ -46,7 +44,7 @@ bool ReloadFileSystem(const char* file_name, StorageMap* map) {
|
||||
}
|
||||
std::string dumped_file_system((std::istreambuf_iterator<char>(input)),
|
||||
std::istreambuf_iterator<char>());
|
||||
if (!wvcdm::RebootTest::ParseDump(dumped_file_system, map)) {
|
||||
if (!store->LoadFromString(dumped_file_system)) {
|
||||
LOGE("Could not parse %s", file_name);
|
||||
return false;
|
||||
}
|
||||
@@ -54,31 +52,26 @@ bool ReloadFileSystem(const char* file_name, StorageMap* map) {
|
||||
}
|
||||
|
||||
bool ReloadFileSystems() {
|
||||
StorageMap global_map;
|
||||
StorageMap per_origin_map;
|
||||
if (!ReloadFileSystem(kGlobalDumpFileName, &global_map) ||
|
||||
!ReloadFileSystem(kPerOriginDumpFileName, &per_origin_map)) {
|
||||
return false;
|
||||
}
|
||||
g_host->global_storage().ResetFiles(global_map);
|
||||
g_host->per_origin_storage().ResetFiles(per_origin_map);
|
||||
return true;
|
||||
return ReloadFileSystem(kGlobalDumpFileName, &g_host->global_storage()) &&
|
||||
ReloadFileSystem(kPerOriginDumpFileName,
|
||||
&g_host->per_origin_storage());
|
||||
}
|
||||
|
||||
// Dump a TestHost file system to the real file system. If the dump file
|
||||
// cannot be written, this raises an exception and crashes the program. Since
|
||||
// we usually build with exceptions turned off, what this means is that the test
|
||||
// executable will halt if the file cannot be written.
|
||||
void DumpFileSystem(const char* file_name, const StorageMap& map) {
|
||||
std::string dump = wvcdm::RebootTest::DumpData(map);
|
||||
void DumpFileSystem(const char* file_name, const TestHost::Storage& store) {
|
||||
std::string dump;
|
||||
(void)store.SaveToString(&dump);
|
||||
std::ofstream output(file_name);
|
||||
output << dump;
|
||||
output.close();
|
||||
}
|
||||
|
||||
void DumpFileSystems() {
|
||||
DumpFileSystem(kGlobalDumpFileName, g_host->global_storage().files());
|
||||
DumpFileSystem(kPerOriginDumpFileName, g_host->per_origin_storage().files());
|
||||
DumpFileSystem(kGlobalDumpFileName, g_host->global_storage());
|
||||
DumpFileSystem(kPerOriginDumpFileName, g_host->per_origin_storage());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user