aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu2018-02-27 17:56:11 -0600
committerTianjie Xu2018-02-28 13:19:11 -0600
commit3bbb20f557790c015e44098098375eb6cc376a42 (patch)
tree9db0b6bd746646486aa990daecf8e3302c49b4c0 /tests/component/applypatch_test.cpp
parentac4818d6afe80cb71d19d34cd6c36fd9a04e7b6d (diff)
downloadplatform-bootable-recovery-3bbb20f557790c015e44098098375eb6cc376a42.tar.gz
platform-bootable-recovery-3bbb20f557790c015e44098098375eb6cc376a42.tar.xz
platform-bootable-recovery-3bbb20f557790c015e44098098375eb6cc376a42.zip
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
Diffstat (limited to 'tests/component/applypatch_test.cpp')
-rw-r--r--tests/component/applypatch_test.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/component/applypatch_test.cpp b/tests/component/applypatch_test.cpp
index 21c9a52d..b6d09255 100644
--- a/tests/component/applypatch_test.cpp
+++ b/tests/component/applypatch_test.cpp
@@ -35,6 +35,7 @@
35#include "applypatch/applypatch.h" 35#include "applypatch/applypatch.h"
36#include "applypatch/applypatch_modes.h" 36#include "applypatch/applypatch_modes.h"
37#include "common/test_constants.h" 37#include "common/test_constants.h"
38#include "otautil/cache_location.h"
38#include "otautil/print_sha1.h" 39#include "otautil/print_sha1.h"
39 40
40static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) { 41static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) {
@@ -93,14 +94,14 @@ class ApplyPatchCacheTest : public ApplyPatchTest {
93 protected: 94 protected:
94 void SetUp() override { 95 void SetUp() override {
95 ApplyPatchTest::SetUp(); 96 ApplyPatchTest::SetUp();
96 cache_temp_source = old_file; 97 CacheLocation::location().set_cache_temp_source(old_file);
97 } 98 }
98}; 99};
99 100
100class ApplyPatchModesTest : public ::testing::Test { 101class ApplyPatchModesTest : public ::testing::Test {
101 protected: 102 protected:
102 void SetUp() override { 103 void SetUp() override {
103 cache_temp_source = cache_source.path; 104 CacheLocation::location().set_cache_temp_source(cache_source.path);
104 } 105 }
105 106
106 TemporaryFile cache_source; 107 TemporaryFile cache_source;