diff options
author | vng <viktor.govako@gmail.com> | 2015-09-25 16:22:48 +0300 |
---|---|---|
committer | vng <viktor.govako@gmail.com> | 2015-09-25 17:17:52 +0300 |
commit | 25aaa05cefa9ecdd4ce6e7893786b4bf0eec5366 (patch) | |
tree | 1a988724f19463c79b18cbfa738bed7f5c7e26c8 /map/map_tests/mwm_set_test.cpp | |
parent | c56f4c20b946bf62831e917a695d4e6c7861fdd9 (diff) |
[mwm set] Handle file system exceptions when building feature offsets index.
Diffstat (limited to 'map/map_tests/mwm_set_test.cpp')
-rw-r--r-- | map/map_tests/mwm_set_test.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/map/map_tests/mwm_set_test.cpp b/map/map_tests/mwm_set_test.cpp new file mode 100644 index 0000000000..3ea80b0536 --- /dev/null +++ b/map/map_tests/mwm_set_test.cpp @@ -0,0 +1,49 @@ +#include "testing/testing.hpp" + +#include "indexer/index.hpp" + +#include "platform/local_country_file_utils.hpp" +#include "platform/platform.hpp" + +#ifndef OMIM_OS_WINDOWS +#include <sys/stat.h> +#endif + + +using namespace platform; +using namespace my; + +#ifndef OMIM_OS_WINDOWS +UNIT_TEST(MwmSet_FileSystemErrors) +{ + string const dir = GetPlatform().WritableDir(); + + CountryFile file("minsk-pass"); + LocalCountryFile localFile(dir, file, 0); + TEST(CountryIndexes::DeleteFromDisk(localFile), ()); + + LogLevel oldLevel = g_LogAbortLevel; + g_LogAbortLevel = LCRITICAL; + + // Remove writable permission. + int const readOnlyMode = S_IRUSR | S_IRGRP | S_IROTH | S_IXUSR | S_IXGRP | S_IXOTH; + TEST_EQUAL(chmod(dir.c_str(), readOnlyMode), 0, ()); + + Index index; + auto p = index.RegisterMap(localFile); + TEST_EQUAL(p.second, Index::RegResult::Success, ()); + + TEST(index.GetMwmIdByCountryFile(file) != Index::MwmId(), ()); + + TEST(!index.GetMwmHandleById(p.first).IsAlive(), ()); + + vector<shared_ptr<MwmInfo>> infos; + index.GetMwmsInfo(infos); + TEST(infos.empty(), ()); + + // Restore writable permission. + TEST_EQUAL(chmod(dir.c_str(), readOnlyMode | S_IWUSR), 0, ()); + + g_LogAbortLevel = oldLevel; +} +#endif |