From 9d91e898317fe19051d486fb76271a89603b5de8 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Fri, 30 Mar 2018 20:43:45 -0700 Subject: tests: Pick up testdata with LOCAL_TEST_DATA. Also push the testdata in AndroidTest.xml for `atest`. LOCAL_TEST_DATA was added in commit [1], which ships testdata next to native tests. With this CL, 1) manually sync-ing via `adb sync` and running tests with `adb shell` keep working. 2) both of 32- and 64-bit recovery_{unit,component}_test now work in APCT continuous tests. Note that 64-bit tests were failing previously in APCT, due to missing testdata. 3) `atest recovery_unit_test` works, as the testdata gets pushed to /data/local/tmp. [1] commit d07ba4e2a625a8f000d042c1953adb612bccbbe2 in https://android-review.googlesource.com/c/platform/build/+/312567. Bug: 77320514 Test: Build recovery_{unit,component,manual}_test. Setup the test via `adb sync data`. Run both of 32- and 64-bit versions on device. Test: Build and run recovery_host_test on host, for both of 32- and 64-bit versions. Test: `atest recovery_component_test` Change-Id: Ie54037726043a3a659a80030b83db1f8c1de318d --- tests/common/test_constants.h | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'tests/common') diff --git a/tests/common/test_constants.h b/tests/common/test_constants.h index 514818e0a..b6c27a754 100644 --- a/tests/common/test_constants.h +++ b/tests/common/test_constants.h @@ -17,10 +17,10 @@ #ifndef _OTA_TEST_CONSTANTS_H #define _OTA_TEST_CONSTANTS_H -#include - #include +#include + // Zip entries in ziptest_valid.zip. static const std::string kATxtContents("abcdefghabcdefgh\n"); static const std::string kBTxtContents("abcdefgh\n"); @@ -32,14 +32,9 @@ static const std::string kATxtSha1Sum("32c96a03dc8cd20097940f351bca6261ee5a1643" // echo -n -e "abcdefgh\n" | sha1sum static const std::string kBTxtSha1Sum("e414af7161c9554089f4106d6f1797ef14a73666"); -static std::string from_testdata_base(const std::string& fname) { -#ifdef __ANDROID__ - static std::string data_root = getenv("ANDROID_DATA"); -#else - static std::string data_root = std::string(getenv("ANDROID_PRODUCT_OUT")) + "/data"; -#endif - - return data_root + "/nativetest/recovery/testdata/" + fname; +[[maybe_unused]] static std::string from_testdata_base(const std::string& fname) { + static std::string exec_dir = android::base::GetExecutableDirectory(); + return exec_dir + "/testdata/" + fname; } #endif // _OTA_TEST_CONSTANTS_H -- cgit v1.2.3