aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao2016-11-02 18:17:17 -0500
committerTao Bao2016-11-03 01:18:01 -0500
commit4102b281324eca22cd4ef0922a79949ec6cf846e (patch)
treedf496b1d676e1c2e265abbc5777ecba1eb3afddd
parent5696526ba4810e14a4a68d5951d37cae1e1028ec (diff)
downloadplatform-bootable-recovery-4102b281324eca22cd4ef0922a79949ec6cf846e.tar.gz
platform-bootable-recovery-4102b281324eca22cd4ef0922a79949ec6cf846e.tar.xz
platform-bootable-recovery-4102b281324eca22cd4ef0922a79949ec6cf846e.zip
tests: Set up testdata path for continuous native tests.
continuous_native_tests expects the testdata under DATA/ in continuous_native_tests.zip. This CL packs a copy of the testdata into continuous_native_tests.zip as DATA/nativetest/recovery/testdata (via LOCAL_PICKUP_FILES). This CL also removes the extra copy for nativetest64. Testdata will always stay at /data/nativetest/recovery/testdata, even for 64-bit version. Otherwise we will unnecessarily get four copies (two for data/ and another two for DATA/). Bug: 32123241 Test: mmma bootable/recovery && adb sync data. On bullhead, /data/nativetest/recovery_component_test/recovery_component_test works; /data/nativetest64/recovery_component_test/recovery_component_test works. Test: m continuous_native_test; DATA/nativetest/recovery/testdata exists. Change-Id: Ifefa0309de7af23c77654e8e450848ca2da218c2
-rw-r--r--tests/Android.mk21
-rw-r--r--tests/common/test_constants.h15
-rw-r--r--tests/component/applypatch_test.cpp7
-rw-r--r--tests/component/verifier_test.cpp11
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
88testdata_files := $(call find-subdir-files, testdata/*) 88testdata_files := $(call find-subdir-files, testdata/*)
89 89
90testdata_out_path := $(TARGET_OUT_DATA_NATIVE_TESTS)/recovery 90# The testdata files that will go to $OUT/data/nativetest/recovery.
91testdata_out_path := $(TARGET_OUT_DATA)/nativetest/recovery
91GEN := $(addprefix $(testdata_out_path)/, $(testdata_files)) 92GEN := $(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)
96LOCAL_GENERATED_SOURCES += $(GEN) 97LOCAL_GENERATED_SOURCES += $(GEN)
97 98
98ifdef TARGET_2ND_ARCH 99# A copy of the testdata to be packed into continuous_native_tests.zip.
99testdata_out_path_2nd_arch := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/recovery 100testdata_continuous_zip_prefix := \
100GEN_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) 102testdata_continuous_zip_path := $(testdata_continuous_zip_prefix)/nativetest/recovery
102$(GEN_2ND_ARCH): PRIVATE_CUSTOM_TOOL = cp $< $@ 103GEN := $(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)
105LOCAL_GENERATED_SOURCES += $(GEN_2ND_ARCH) 108LOCAL_GENERATED_SOURCES += $(GEN)
106endif # TARGET_2ND_ARCH 109LOCAL_PICKUP_FILES := $(testdata_continuous_zip_prefix)
107 110
108include $(BUILD_NATIVE_TEST) 111include $(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 22static const char* data_root = getenv("ANDROID_DATA");
22#define NATIVE_TEST_PATH "/nativetest" 23
23#endif 24static 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
40static const std::string DATA_PATH = getenv("ANDROID_DATA");
41static const std::string TESTDATA_PATH = "/recovery/testdata";
42
43static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) { 40static 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
75static std::string from_testdata_base(const std::string& fname) {
76 return DATA_PATH + NATIVE_TEST_PATH + TESTDATA_PATH + "/" + fname;
77}
78
79class ApplyPatchTest : public ::testing::Test { 72class 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
40static const char* DATA_PATH = getenv("ANDROID_DATA");
41static const char* TESTDATA_PATH = "/recovery/testdata/";
42
43RecoveryUI* ui = NULL; 40RecoveryUI* ui = NULL;
44 41
45class MockUI : public RecoveryUI { 42class 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 }