diff options
author | Daniel Burrows <dburrows@debian.org> | 2009-08-19 07:41:38 -0700 |
---|---|---|
committer | Daniel Burrows <dburrows@debian.org> | 2009-08-19 07:41:38 -0700 |
commit | c2c01e5ece303416325640dac3a0bf843bedb704 (patch) | |
tree | 6545cb8ed260ed0df787f20c82f827cc31cfa6ea /tests/test_file_cache.cc | |
parent | 572ef12324eb6fec53876091e5db52f5e8036987 (diff) | |
download | aptitude-c2c01e5ece303416325640dac3a0bf843bedb704.tar.gz |
Fix the new test.
* The order in which entries were touched was wrong (I was touching
the entry that should have been least-recently-used last ... oops).
* Need to generate a new temporary file for each sub-test; otherwise
we end up re-opening the same cache that was used for the last test,
leading to trouble when we try to reset the test.
Diffstat (limited to 'tests/test_file_cache.cc')
-rw-r--r-- | tests/test_file_cache.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tests/test_file_cache.cc b/tests/test_file_cache.cc index b9afccc4..8c8c032c 100644 --- a/tests/test_file_cache.cc +++ b/tests/test_file_cache.cc @@ -260,7 +260,7 @@ BOOST_AUTO_TEST_CASE(fileCacheStoreDiskAndMemory) void runDropLeastRecentlyUsedTest(const temp::dir &td, - const boost::function<boost::shared_ptr<file_cache> ()> &cache_k) + const boost::function<boost::shared_ptr<file_cache> (std::string)> &cache_k) { // Check that we can control which of the three entries is dropped // when we add a fourth entry. @@ -268,14 +268,15 @@ void runDropLeastRecentlyUsedTest(const temp::dir &td, // Drop key3. { - boost::shared_ptr<file_cache> cache(cache_k()); + temp::name tn(td, "testFileCache"); + boost::shared_ptr<file_cache> cache(cache_k(tn.get_name())); fileCacheTestInfo testInfo; setupFileCacheTest(td, cache, testInfo); + CHECK_CACHED_VALUE(cache, testInfo.key3, testInfo.infileData3); CHECK_CACHED_VALUE(cache, testInfo.key1, testInfo.infileData1); CHECK_CACHED_VALUE(cache, testInfo.key2, testInfo.infileData2); - CHECK_CACHED_VALUE(cache, testInfo.key3, testInfo.infileData3); cache->putItem("key4", testInfo.infilename1.get_name()); @@ -289,14 +290,15 @@ void runDropLeastRecentlyUsedTest(const temp::dir &td, // Drop key2. { - boost::shared_ptr<file_cache> cache(cache_k()); + temp::name tn(td, "testFileCache"); + boost::shared_ptr<file_cache> cache(cache_k(tn.get_name())); fileCacheTestInfo testInfo; setupFileCacheTest(td, cache, testInfo); + CHECK_CACHED_VALUE(cache, testInfo.key2, testInfo.infileData2); CHECK_CACHED_VALUE(cache, testInfo.key1, testInfo.infileData1); CHECK_CACHED_VALUE(cache, testInfo.key3, testInfo.infileData3); - CHECK_CACHED_VALUE(cache, testInfo.key2, testInfo.infileData2); cache->putItem("key4", testInfo.infilename1.get_name()); @@ -310,14 +312,15 @@ void runDropLeastRecentlyUsedTest(const temp::dir &td, // Drop key1. { - boost::shared_ptr<file_cache> cache(cache_k()); + temp::name tn(td, "testFileCache"); + boost::shared_ptr<file_cache> cache(cache_k(tn.get_name())); fileCacheTestInfo testInfo; setupFileCacheTest(td, cache, testInfo); + CHECK_CACHED_VALUE(cache, testInfo.key1, testInfo.infileData1); CHECK_CACHED_VALUE(cache, testInfo.key3, testInfo.infileData3); CHECK_CACHED_VALUE(cache, testInfo.key2, testInfo.infileData2); - CHECK_CACHED_VALUE(cache, testInfo.key1, testInfo.infileData1); cache->putItem("key4", testInfo.infilename1.get_name()); @@ -334,5 +337,5 @@ BOOST_AUTO_TEST_CASE(fileCacheDropLeastRecentlyUsedDisk) temp::dir td("testFileCache"); temp::name tn(td, "testFileCache"); - runDropLeastRecentlyUsedTest(td, boost::lambda::bind(&file_cache::create, tn.get_name(), 0, 1000)); + runDropLeastRecentlyUsedTest(td, boost::lambda::bind(&file_cache::create, boost::lambda::_1, 0, 1000)); } |