Merge "tests: Set up testdata path for continuous native tests."

This commit is contained in:
Tao Bao 2016-11-03 18:15:07 +00:00 committed by Gerrit Code Review
commit 4011bb161a
4 changed files with 23 additions and 31 deletions

View file

@ -87,7 +87,8 @@ LOCAL_STATIC_LIBRARIES := \
testdata_files := $(call find-subdir-files, testdata/*) testdata_files := $(call find-subdir-files, testdata/*)
testdata_out_path := $(TARGET_OUT_DATA_NATIVE_TESTS)/recovery # The testdata files that will go to $OUT/data/nativetest/recovery.
testdata_out_path := $(TARGET_OUT_DATA)/nativetest/recovery
GEN := $(addprefix $(testdata_out_path)/, $(testdata_files)) GEN := $(addprefix $(testdata_out_path)/, $(testdata_files))
$(GEN): PRIVATE_PATH := $(LOCAL_PATH) $(GEN): PRIVATE_PATH := $(LOCAL_PATH)
$(GEN): PRIVATE_CUSTOM_TOOL = cp $< $@ $(GEN): PRIVATE_CUSTOM_TOOL = cp $< $@
@ -95,14 +96,16 @@ $(GEN): $(testdata_out_path)/% : $(LOCAL_PATH)/%
$(transform-generated-source) $(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN) LOCAL_GENERATED_SOURCES += $(GEN)
ifdef TARGET_2ND_ARCH # A copy of the testdata to be packed into continuous_native_tests.zip.
testdata_out_path_2nd_arch := $($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_DATA_NATIVE_TESTS)/recovery testdata_continuous_zip_prefix := \
GEN_2ND_ARCH := $(addprefix $(testdata_out_path_2nd_arch)/, $(testdata_files)) $(call intermediates-dir-for,PACKAGING,recovery_component_test)/DATA
$(GEN_2ND_ARCH): PRIVATE_PATH := $(LOCAL_PATH) testdata_continuous_zip_path := $(testdata_continuous_zip_prefix)/nativetest/recovery
$(GEN_2ND_ARCH): PRIVATE_CUSTOM_TOOL = cp $< $@ GEN := $(addprefix $(testdata_continuous_zip_path)/, $(testdata_files))
$(GEN_2ND_ARCH): $(testdata_out_path_2nd_arch)/% : $(LOCAL_PATH)/% $(GEN): PRIVATE_PATH := $(LOCAL_PATH)
$(GEN): PRIVATE_CUSTOM_TOOL = cp $< $@
$(GEN): $(testdata_continuous_zip_path)/% : $(LOCAL_PATH)/%
$(transform-generated-source) $(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN_2ND_ARCH) LOCAL_GENERATED_SOURCES += $(GEN)
endif # TARGET_2ND_ARCH LOCAL_PICKUP_FILES := $(testdata_continuous_zip_prefix)
include $(BUILD_NATIVE_TEST) include $(BUILD_NATIVE_TEST)

View file

@ -13,13 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
#ifndef _OTA_TEST_CONSTANTS_H #ifndef _OTA_TEST_CONSTANTS_H
#define _OTA_TEST_CONSTANTS_H #define _OTA_TEST_CONSTANTS_H
#if defined(__LP64__) #include <stdlib.h>
#define NATIVE_TEST_PATH "/nativetest64"
#else
#define NATIVE_TEST_PATH "/nativetest"
#endif
#endif static const char* data_root = getenv("ANDROID_DATA");
static std::string from_testdata_base(const std::string& fname) {
return std::string(data_root) + "/nativetest/recovery/testdata/" + fname;
}
#endif // _OTA_TEST_CONSTANTS_H

View file

@ -37,9 +37,6 @@
#include "common/test_constants.h" #include "common/test_constants.h"
#include "print_sha1.h" #include "print_sha1.h"
static const std::string DATA_PATH = getenv("ANDROID_DATA");
static const std::string TESTDATA_PATH = "/recovery/testdata";
static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) { static void sha1sum(const std::string& fname, std::string* sha1, size_t* fsize = nullptr) {
ASSERT_NE(nullptr, sha1); ASSERT_NE(nullptr, sha1);
@ -72,10 +69,6 @@ static bool file_cmp(const std::string& f1, const std::string& f2) {
return c1 == c2; return c1 == c2;
} }
static std::string from_testdata_base(const std::string& fname) {
return DATA_PATH + NATIVE_TEST_PATH + TESTDATA_PATH + "/" + fname;
}
class ApplyPatchTest : public ::testing::Test { class ApplyPatchTest : public ::testing::Test {
public: public:
static void SetUpTestCase() { static void SetUpTestCase() {

View file

@ -37,9 +37,6 @@
#include "ui.h" #include "ui.h"
#include "verifier.h" #include "verifier.h"
static const char* DATA_PATH = getenv("ANDROID_DATA");
static const char* TESTDATA_PATH = "/recovery/testdata/";
RecoveryUI* ui = NULL; RecoveryUI* ui = NULL;
class MockUI : public RecoveryUI { class MockUI : public RecoveryUI {
@ -92,17 +89,13 @@ class VerifierTest : public testing::TestWithParam<std::vector<std::string>> {
virtual void SetUp() { virtual void SetUp() {
std::vector<std::string> args = GetParam(); std::vector<std::string> args = GetParam();
std::string package = std::string package = from_testdata_base(args[0]);
android::base::StringPrintf("%s%s%s%s", DATA_PATH, NATIVE_TEST_PATH,
TESTDATA_PATH, args[0].c_str());
if (sysMapFile(package.c_str(), &memmap) != 0) { if (sysMapFile(package.c_str(), &memmap) != 0) {
FAIL() << "Failed to mmap " << package << ": " << strerror(errno) << "\n"; FAIL() << "Failed to mmap " << package << ": " << strerror(errno) << "\n";
} }
for (auto it = ++(args.cbegin()); it != args.cend(); ++it) { for (auto it = ++(args.cbegin()); it != args.cend(); ++it) {
std::string public_key_file = android::base::StringPrintf( std::string public_key_file = from_testdata_base("testkey_" + *it + ".txt");
"%s%s%stestkey_%s.txt", DATA_PATH, NATIVE_TEST_PATH,
TESTDATA_PATH, it->c_str());
ASSERT_TRUE(load_keys(public_key_file.c_str(), certs)); ASSERT_TRUE(load_keys(public_key_file.c_str(), certs));
} }
} }