Add a singleton CacheLocation to replace the hard coded locations
This class allows us to set the following locations dynamically: cache_temp_source, last_command_file, stash_directory_base. In the updater's main function, we reset the values of these variables to their default locations in /cache; while we can set them to temp files in unit tests or host simulation. Test: unit tests pass Change-Id: I528652650caa41373617ab055d41b1f1a4ec0f87
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "applypatch/applypatch.h"
|
||||
#include "applypatch/applypatch_modes.h"
|
||||
#include "common/test_constants.h"
|
||||
#include "otautil/cache_location.h"
|
||||
#include "otautil/print_sha1.h"
|
||||
|
||||
static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) {
|
||||
@@ -93,14 +94,14 @@ class ApplyPatchCacheTest : public ApplyPatchTest {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
ApplyPatchTest::SetUp();
|
||||
cache_temp_source = old_file;
|
||||
CacheLocation::location().set_cache_temp_source(old_file);
|
||||
}
|
||||
};
|
||||
|
||||
class ApplyPatchModesTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override {
|
||||
cache_temp_source = cache_source.path;
|
||||
CacheLocation::location().set_cache_temp_source(cache_source.path);
|
||||
}
|
||||
|
||||
TemporaryFile cache_source;
|
||||
|
||||
Reference in New Issue
Block a user