# -------------------------------------------------------------------------
TEST "Base case"
+ # Compile and send result to primary and secondary storage.
$CCACHE_COMPILE -c test.c
expect_stat direct_cache_hit 0
expect_stat cache_miss 1
fi
expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest
+ # Get result from primary storage.
$CCACHE_COMPILE -c test.c
expect_stat direct_cache_hit 1
expect_stat cache_miss 1
expect_stat files_in_cache 2
expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest
+ # Clear primary storage.
$CCACHE -C >/dev/null
expect_stat files_in_cache 0
expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest
+ # Get result from secondary storage, copying it to primary storage.
$CCACHE_COMPILE -c test.c
expect_stat direct_cache_hit 2
expect_stat cache_miss 1
expect_stat files_in_cache 2 # fetched from secondary
expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest
+ # Get result from primary storage again.
$CCACHE_COMPILE -c test.c
expect_stat direct_cache_hit 3
expect_stat cache_miss 1
expect_stat secondary_storage_miss 2 # result + manifest
expect_stat files_in_cache 2 # fetched from secondary
expect_file_count 3 '*' secondary # CACHEDIR.TAG + result + manifest
+
# -------------------------------------------------------------------------
TEST "Flat layout"
"No such file or directory");
}
-TEST_CASE(
- "Util::read_file, Util::write_file and Util::copy_file with binary files")
+TEST_CASE("Util::{read,write,copy}_file with binary files")
{
TestContext test_context;
- std::string origin_data;
- for (int i = 0; i < 512; i++) {
- origin_data.push_back(static_cast<char>((32 + i) % 256));
+ std::string data;
+ for (size_t i = 0; i < 512; ++i) {
+ data.push_back(static_cast<char>((32 + i) % 256));
}
- Util::write_file("test", origin_data, std::ios_base::binary);
- std::string data = Util::read_file("test");
- CHECK(data == origin_data);
+ Util::write_file("test", data);
+ CHECK(Util::read_file("test") == data);
Util::copy_file("test", "copy");
- data = Util::read_file("copy");
- CHECK(data == origin_data);
+ CHECK(Util::read_file("copy") == data);
}
TEST_CASE("Util::remove_extension")