diff options
-rw-r--r-- | tests/Android.mk | 21 | ||||
-rw-r--r-- | tests/common/test_constants.h | 15 | ||||
-rw-r--r-- | tests/component/applypatch_test.cpp | 7 | ||||
-rw-r--r-- | tests/component/verifier_test.cpp | 11 |
4 files changed, 23 insertions, 31 deletions
diff --git a/tests/Android.mk b/tests/Android.mk index 461d6ef7..8f19992b 100644 --- a/tests/Android.mk +++ b/tests/Android.mk | |||
@@ -87,7 +87,8 @@ LOCAL_STATIC_LIBRARIES := \ | |||
87 | 87 | ||
88 | testdata_files := $(call find-subdir-files, testdata/*) | 88 | testdata_files := $(call find-subdir-files, testdata/*) |
89 | 89 | ||
90 | testdata_out_path := $(TARGET_OUT_DATA_NATIVE_TESTS)/recovery | 90 | # The testdata files that will go to $OUT/data/nativetest/recovery. |
91 | testdata_out_path := $(TARGET_OUT_DATA)/nativetest/recovery | ||
91 | GEN := $(addprefix $(testdata_out_path)/, $(testdata_files)) | 92 | GEN := $(addprefix $(testdata_out_path)/, $(testdata_files)) |
92 | $(GEN): PRIVATE_PATH := $(LOCAL_PATH) | 93 | $(GEN): PRIVATE_PATH := $(LOCAL_PATH) |
93 | $(GEN): PRIVATE_CUSTOM_TOOL = cp $< $@ | 94 | $(GEN): PRIVATE_CUSTOM_TOOL = cp $< $@ |
@@ -95,14 +96,16 @@ $(GEN): $(testdata_out_path)/% : $(LOCAL_PATH)/% | |||
95 | $(transform-generated-source) | 96 | $(transform-generated-source) |
96 | LOCAL_GENERATED_SOURCES += $(GEN) | 97 | LOCAL_GENERATED_SOURCES += $(GEN) |
97 | 98 | ||
98 | ifdef TARGET_2ND_ARCH | 99 | # A copy of the testdata to be packed into continuous_native_tests.zip. |
99 | testdata_out_path_2nd_arch := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/recovery | 100 | testdata_continuous_zip_prefix := \ |
100 | GEN_2ND_ARCH := $(addprefix $(testdata_out_path_2nd_arch)/, $(testdata_files)) | 101 | $(call intermediates-dir-for,PACKAGING,recovery_component_test)/DATA |
101 | $(GEN_2ND_ARCH): PRIVATE_PATH := $(LOCAL_PATH) | 102 | testdata_continuous_zip_path := $(testdata_continuous_zip_prefix)/nativetest/recovery |
102 | $(GEN_2ND_ARCH): PRIVATE_CUSTOM_TOOL = cp $< $@ | 103 | GEN := $(addprefix $(testdata_continuous_zip_path)/, $(testdata_files)) |
103 | $(GEN_2ND_ARCH): $(testdata_out_path_2nd_arch)/% : $(LOCAL_PATH)/% | 104 | $(GEN): PRIVATE_PATH := $(LOCAL_PATH) |
105 | $(GEN): PRIVATE_CUSTOM_TOOL = cp $< $@ | ||
106 | $(GEN): $(testdata_continuous_zip_path)/% : $(LOCAL_PATH)/% | ||
104 | $(transform-generated-source) | 107 | $(transform-generated-source) |
105 | LOCAL_GENERATED_SOURCES += $(GEN_2ND_ARCH) | 108 | LOCAL_GENERATED_SOURCES += $(GEN) |
106 | endif # TARGET_2ND_ARCH | 109 | LOCAL_PICKUP_FILES := $(testdata_continuous_zip_prefix) |
107 | 110 | ||
108 | include $(BUILD_NATIVE_TEST) | 111 | include $(BUILD_NATIVE_TEST) |
diff --git a/tests/common/test_constants.h b/tests/common/test_constants.h index 3490f680..97e74a3c 100644 --- a/tests/common/test_constants.h +++ b/tests/common/test_constants.h | |||
@@ -13,13 +13,16 @@ | |||
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | |||
16 | #ifndef _OTA_TEST_CONSTANTS_H | 17 | #ifndef _OTA_TEST_CONSTANTS_H |
17 | #define _OTA_TEST_CONSTANTS_H | 18 | #define _OTA_TEST_CONSTANTS_H |
18 | 19 | ||
19 | #if defined(__LP64__) | 20 | #include <stdlib.h> |
20 | #define NATIVE_TEST_PATH "/nativetest64" | 21 | |
21 | #else | 22 | static const char* data_root = getenv("ANDROID_DATA"); |
22 | #define NATIVE_TEST_PATH "/nativetest" | 23 | |
23 | #endif | 24 | static std::string from_testdata_base(const std::string& fname) { |
25 | return std::string(data_root) + "/nativetest/recovery/testdata/" + fname; | ||
26 | } | ||
24 | 27 | ||
25 | #endif | 28 | #endif // _OTA_TEST_CONSTANTS_H |
diff --git a/tests/component/applypatch_test.cpp b/tests/component/applypatch_test.cpp index f95ebed5..1a0b1911 100644 --- a/tests/component/applypatch_test.cpp +++ b/tests/component/applypatch_test.cpp | |||
@@ -37,9 +37,6 @@ | |||
37 | #include "common/test_constants.h" | 37 | #include "common/test_constants.h" |
38 | #include "print_sha1.h" | 38 | #include "print_sha1.h" |
39 | 39 | ||
40 | static const std::string DATA_PATH = getenv("ANDROID_DATA"); | ||
41 | static const std::string TESTDATA_PATH = "/recovery/testdata"; | ||
42 | |||
43 | static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) { | 40 | static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) { |
44 | ASSERT_NE(nullptr, sha1); | 41 | ASSERT_NE(nullptr, sha1); |
45 | 42 | ||
@@ -72,10 +69,6 @@ static bool file_cmp(const std::string& f1, const std::string& f2) { | |||
72 | return c1 == c2; | 69 | return c1 == c2; |
73 | } | 70 | } |
74 | 71 | ||
75 | static std::string from_testdata_base(const std::string& fname) { | ||
76 | return DATA_PATH + NATIVE_TEST_PATH + TESTDATA_PATH + "/" + fname; | ||
77 | } | ||
78 | |||
79 | class ApplyPatchTest : public ::testing::Test { | 72 | class ApplyPatchTest : public ::testing::Test { |
80 | public: | 73 | public: |
81 | static void SetUpTestCase() { | 74 | static void SetUpTestCase() { |
diff --git a/tests/component/verifier_test.cpp b/tests/component/verifier_test.cpp index 7f9a7140..60a78f5c 100644 --- a/tests/component/verifier_test.cpp +++ b/tests/component/verifier_test.cpp | |||
@@ -37,9 +37,6 @@ | |||
37 | #include "ui.h" | 37 | #include "ui.h" |
38 | #include "verifier.h" | 38 | #include "verifier.h" |
39 | 39 | ||
40 | static const char* DATA_PATH = getenv("ANDROID_DATA"); | ||
41 | static const char* TESTDATA_PATH = "/recovery/testdata/"; | ||
42 | |||
43 | RecoveryUI* ui = NULL; | 40 | RecoveryUI* ui = NULL; |
44 | 41 | ||
45 | class MockUI : public RecoveryUI { | 42 | class MockUI : public RecoveryUI { |
@@ -92,17 +89,13 @@ class VerifierTest : public testing::TestWithParam<std::vector<std::string>> { | |||
92 | 89 | ||
93 | virtual void SetUp() { | 90 | virtual void SetUp() { |
94 | std::vector<std::string> args = GetParam(); | 91 | std::vector<std::string> args = GetParam(); |
95 | std::string package = | 92 | std::string package = from_testdata_base(args[0]); |
96 | android::base::StringPrintf("%s%s%s%s", DATA_PATH, NATIVE_TEST_PATH, | ||
97 | TESTDATA_PATH, args[0].c_str()); | ||
98 | if (sysMapFile(package.c_str(), &memmap) != 0) { | 93 | if (sysMapFile(package.c_str(), &memmap) != 0) { |
99 | FAIL() << "Failed to mmap " << package << ": " << strerror(errno) << "\n"; | 94 | FAIL() << "Failed to mmap " << package << ": " << strerror(errno) << "\n"; |
100 | } | 95 | } |
101 | 96 | ||
102 | for (auto it = ++(args.cbegin()); it != args.cend(); ++it) { | 97 | for (auto it = ++(args.cbegin()); it != args.cend(); ++it) { |
103 | std::string public_key_file = android::base::StringPrintf( | 98 | std::string public_key_file = from_testdata_base("testkey_" + *it + ".txt"); |
104 | "%s%s%stestkey_%s.txt", DATA_PATH, NATIVE_TEST_PATH, | ||
105 | TESTDATA_PATH, it->c_str()); | ||
106 | ASSERT_TRUE(load_keys(public_key_file.c_str(), certs)); | 99 | ASSERT_TRUE(load_keys(public_key_file.c_str(), certs)); |
107 | } | 100 | } |
108 | } | 101 | } |